@armatofik/tgsnake-core 1.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 (171) hide show
  1. package/COPYING +674 -0
  2. package/COPYING.lesser +165 -0
  3. package/README.md +88 -0
  4. package/lib/package.json +46 -0
  5. package/lib/src/Logger.d.ts +3 -0
  6. package/lib/src/Logger.js +9 -0
  7. package/lib/src/Queue.d.ts +19 -0
  8. package/lib/src/Queue.js +52 -0
  9. package/lib/src/Timeout.d.ts +9 -0
  10. package/lib/src/Timeout.js +44 -0
  11. package/lib/src/Version.node.d.ts +4 -0
  12. package/lib/src/Version.node.js +26 -0
  13. package/lib/src/client/Auth.d.ts +40 -0
  14. package/lib/src/client/Auth.js +317 -0
  15. package/lib/src/client/Client.d.ts +83 -0
  16. package/lib/src/client/Client.js +461 -0
  17. package/lib/src/client/Session.d.ts +9 -0
  18. package/lib/src/client/Session.js +132 -0
  19. package/lib/src/client/index.d.ts +3 -0
  20. package/lib/src/client/index.js +39 -0
  21. package/lib/src/connection/TCP/TCPAbridged.d.ts +9 -0
  22. package/lib/src/connection/TCP/TCPAbridged.js +47 -0
  23. package/lib/src/connection/TCP/TCPAbridgedO.d.ts +12 -0
  24. package/lib/src/connection/TCP/TCPAbridgedO.js +140 -0
  25. package/lib/src/connection/TCP/TCPFull.d.ts +10 -0
  26. package/lib/src/connection/TCP/TCPFull.js +43 -0
  27. package/lib/src/connection/TCP/TCPIntermediate.d.ts +9 -0
  28. package/lib/src/connection/TCP/TCPIntermediate.js +31 -0
  29. package/lib/src/connection/TCP/TCPIntermediateO.d.ts +12 -0
  30. package/lib/src/connection/TCP/TCPIntermediateO.js +123 -0
  31. package/lib/src/connection/TCP/TCPPaddedIntermediate.d.ts +9 -0
  32. package/lib/src/connection/TCP/TCPPaddedIntermediate.js +38 -0
  33. package/lib/src/connection/TCP/index.d.ts +7 -0
  34. package/lib/src/connection/TCP/index.js +17 -0
  35. package/lib/src/connection/TCP/tcp.d.ts +17 -0
  36. package/lib/src/connection/TCP/tcp.js +98 -0
  37. package/lib/src/connection/WebSocket.d.ts +21 -0
  38. package/lib/src/connection/WebSocket.js +279 -0
  39. package/lib/src/connection/connection.d.ts +53 -0
  40. package/lib/src/connection/connection.js +189 -0
  41. package/lib/src/connection/index.d.ts +4 -0
  42. package/lib/src/connection/index.js +41 -0
  43. package/lib/src/crypto/Aes.d.ts +10 -0
  44. package/lib/src/crypto/Aes.js +135 -0
  45. package/lib/src/crypto/Mtproto.d.ts +5 -0
  46. package/lib/src/crypto/Mtproto.js +123 -0
  47. package/lib/src/crypto/Password.d.ts +5 -0
  48. package/lib/src/crypto/Password.js +92 -0
  49. package/lib/src/crypto/Prime.d.ts +4 -0
  50. package/lib/src/crypto/Prime.js +64 -0
  51. package/lib/src/crypto/RSA.d.ts +7 -0
  52. package/lib/src/crypto/RSA.js +99 -0
  53. package/lib/src/crypto/SecretChat.d.ts +5 -0
  54. package/lib/src/crypto/SecretChat.js +136 -0
  55. package/lib/src/crypto/index.d.ts +6 -0
  56. package/lib/src/crypto/index.js +42 -0
  57. package/lib/src/errors/Base.d.ts +9 -0
  58. package/lib/src/errors/Base.js +50 -0
  59. package/lib/src/errors/Client.d.ts +21 -0
  60. package/lib/src/errors/Client.js +29 -0
  61. package/lib/src/errors/File.d.ts +13 -0
  62. package/lib/src/errors/File.js +30 -0
  63. package/lib/src/errors/RpcError.d.ts +22 -0
  64. package/lib/src/errors/RpcError.js +120 -0
  65. package/lib/src/errors/SecretChat.d.ts +13 -0
  66. package/lib/src/errors/SecretChat.js +30 -0
  67. package/lib/src/errors/WebSocket.d.ts +13 -0
  68. package/lib/src/errors/WebSocket.js +30 -0
  69. package/lib/src/errors/exceptions/All.d.ts +774 -0
  70. package/lib/src/errors/exceptions/All.js +778 -0
  71. package/lib/src/errors/exceptions/BadRequest400.d.ts +2345 -0
  72. package/lib/src/errors/exceptions/BadRequest400.js +2945 -0
  73. package/lib/src/errors/exceptions/Flood420.d.ts +37 -0
  74. package/lib/src/errors/exceptions/Flood420.js +49 -0
  75. package/lib/src/errors/exceptions/Forbidden403.d.ts +205 -0
  76. package/lib/src/errors/exceptions/Forbidden403.js +260 -0
  77. package/lib/src/errors/exceptions/InternalServerError500.d.ts +221 -0
  78. package/lib/src/errors/exceptions/InternalServerError500.js +280 -0
  79. package/lib/src/errors/exceptions/NotAcceptable406.d.ts +117 -0
  80. package/lib/src/errors/exceptions/NotAcceptable406.js +149 -0
  81. package/lib/src/errors/exceptions/NotFound404.d.ts +9 -0
  82. package/lib/src/errors/exceptions/NotFound404.js +14 -0
  83. package/lib/src/errors/exceptions/SeeOther303.d.ts +25 -0
  84. package/lib/src/errors/exceptions/SeeOther303.js +34 -0
  85. package/lib/src/errors/exceptions/ServiceUnavailable503.d.ts +17 -0
  86. package/lib/src/errors/exceptions/ServiceUnavailable503.js +24 -0
  87. package/lib/src/errors/exceptions/Unauthorized401.d.ts +41 -0
  88. package/lib/src/errors/exceptions/Unauthorized401.js +54 -0
  89. package/lib/src/errors/exceptions/index.d.ts +10 -0
  90. package/lib/src/errors/exceptions/index.js +48 -0
  91. package/lib/src/errors/index.d.ts +31 -0
  92. package/lib/src/errors/index.js +111 -0
  93. package/lib/src/file/Download.d.ts +11 -0
  94. package/lib/src/file/Download.js +118 -0
  95. package/lib/src/file/File.d.ts +20 -0
  96. package/lib/src/file/File.js +82 -0
  97. package/lib/src/file/Upload.d.ts +19 -0
  98. package/lib/src/file/Upload.js +250 -0
  99. package/lib/src/file/index.d.ts +3 -0
  100. package/lib/src/file/index.js +11 -0
  101. package/lib/src/helpers.d.ts +34 -0
  102. package/lib/src/helpers.js +358 -0
  103. package/lib/src/index.d.ts +16 -0
  104. package/lib/src/index.js +56 -0
  105. package/lib/src/platform.node.d.ts +36 -0
  106. package/lib/src/platform.node.js +109 -0
  107. package/lib/src/raw/All.d.ts +2400 -0
  108. package/lib/src/raw/All.js +2403 -0
  109. package/lib/src/raw/Raw.d.ts +29195 -0
  110. package/lib/src/raw/Raw.js +97277 -0
  111. package/lib/src/raw/core/BytesIO.d.ts +33 -0
  112. package/lib/src/raw/core/BytesIO.js +145 -0
  113. package/lib/src/raw/core/GzipPacked.d.ts +10 -0
  114. package/lib/src/raw/core/GzipPacked.js +60 -0
  115. package/lib/src/raw/core/Message.d.ts +13 -0
  116. package/lib/src/raw/core/Message.js +81 -0
  117. package/lib/src/raw/core/MsgContainer.d.ts +11 -0
  118. package/lib/src/raw/core/MsgContainer.js +69 -0
  119. package/lib/src/raw/core/TLObject.d.ts +19 -0
  120. package/lib/src/raw/core/TLObject.js +108 -0
  121. package/lib/src/raw/core/UpdateSecretChat.d.ts +40 -0
  122. package/lib/src/raw/core/UpdateSecretChat.js +88 -0
  123. package/lib/src/raw/core/index.d.ts +8 -0
  124. package/lib/src/raw/core/index.js +52 -0
  125. package/lib/src/raw/core/primitive/Bool.d.ts +20 -0
  126. package/lib/src/raw/core/primitive/Bool.js +41 -0
  127. package/lib/src/raw/core/primitive/Bytes.d.ts +7 -0
  128. package/lib/src/raw/core/primitive/Bytes.js +41 -0
  129. package/lib/src/raw/core/primitive/Double.d.ts +7 -0
  130. package/lib/src/raw/core/primitive/Double.js +24 -0
  131. package/lib/src/raw/core/primitive/Float.d.ts +7 -0
  132. package/lib/src/raw/core/primitive/Float.js +24 -0
  133. package/lib/src/raw/core/primitive/Int.d.ts +23 -0
  134. package/lib/src/raw/core/primitive/Int.js +122 -0
  135. package/lib/src/raw/core/primitive/String.d.ts +7 -0
  136. package/lib/src/raw/core/primitive/String.js +15 -0
  137. package/lib/src/raw/core/primitive/Vector.d.ts +9 -0
  138. package/lib/src/raw/core/primitive/Vector.js +50 -0
  139. package/lib/src/raw/core/primitive/index.d.ts +7 -0
  140. package/lib/src/raw/core/primitive/index.js +22 -0
  141. package/lib/src/raw/index.d.ts +3 -0
  142. package/lib/src/raw/index.js +17 -0
  143. package/lib/src/session/Auth.d.ts +15 -0
  144. package/lib/src/session/Auth.js +254 -0
  145. package/lib/src/session/Session.d.ts +58 -0
  146. package/lib/src/session/Session.js +571 -0
  147. package/lib/src/session/index.d.ts +7 -0
  148. package/lib/src/session/index.js +49 -0
  149. package/lib/src/session/internals/DataCenter.d.ts +42 -0
  150. package/lib/src/session/internals/DataCenter.js +80 -0
  151. package/lib/src/session/internals/MsgFactory.d.ts +3 -0
  152. package/lib/src/session/internals/MsgFactory.js +23 -0
  153. package/lib/src/session/internals/MsgId.d.ts +9 -0
  154. package/lib/src/session/internals/MsgId.js +24 -0
  155. package/lib/src/session/internals/SeqNo.d.ts +6 -0
  156. package/lib/src/session/internals/SeqNo.js +18 -0
  157. package/lib/src/session/secretChats/SecretChat.d.ts +29 -0
  158. package/lib/src/session/secretChats/SecretChat.js +527 -0
  159. package/lib/src/session/secretChats/index.d.ts +1 -0
  160. package/lib/src/session/secretChats/index.js +5 -0
  161. package/lib/src/storage/Abstract.d.ts +68 -0
  162. package/lib/src/storage/Abstract.js +6 -0
  163. package/lib/src/storage/SecretChat.d.ts +42 -0
  164. package/lib/src/storage/SecretChat.js +99 -0
  165. package/lib/src/storage/Session.d.ts +63 -0
  166. package/lib/src/storage/Session.js +245 -0
  167. package/lib/src/storage/StringSession.d.ts +4 -0
  168. package/lib/src/storage/StringSession.js +77 -0
  169. package/lib/src/storage/index.d.ts +4 -0
  170. package/lib/src/storage/index.js +12 -0
  171. package/package.json +46 -0
@@ -0,0 +1,358 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_USER_ID = exports.MAX_USER_ID_OLD = exports.MIN_CHAT_ID = exports.MAX_CHANNEL_ID = exports.MIN_CHANNEL_ID = exports.bigMath = void 0;
4
+ exports.bigintToBuffer = bigintToBuffer;
5
+ exports.includesBuffer = includesBuffer;
6
+ exports.sliceBuffer = sliceBuffer;
7
+ exports.makeCRCTable = makeCRCTable;
8
+ exports.crc32 = crc32;
9
+ exports.sleep = sleep;
10
+ exports.bufferToBigint = bufferToBigint;
11
+ exports.mod = mod;
12
+ exports.bigIntMod = bigIntMod;
13
+ exports.range = range;
14
+ exports.rangeBigint = rangeBigint;
15
+ exports.randint = randint;
16
+ exports.randBigint = randBigint;
17
+ exports.pow = pow;
18
+ exports.bigIntPow = bigIntPow;
19
+ exports.getChannelId = getChannelId;
20
+ exports.getPeerType = getPeerType;
21
+ exports.base64urlTobase64 = base64urlTobase64;
22
+ exports.generateRandomBigInt = generateRandomBigInt;
23
+ exports.normalizeSecretString = normalizeSecretString;
24
+ const platform_node_js_1 = require("./platform.node.js");
25
+ function bigintToBuffer(int, padding, litte = true, signed = false) {
26
+ const bigintLength = int.toString(2).length;
27
+ const bytes = Math.ceil(bigintLength / 8);
28
+ if (padding < bytes) {
29
+ throw new Error("Too big, Can't convert it to buffer with that padding.");
30
+ }
31
+ if (!signed && int < BigInt(0)) {
32
+ throw new Error('Too small, can convert it when unsigned.');
33
+ }
34
+ let isBellow = false;
35
+ if (int < BigInt(0)) {
36
+ isBellow = true;
37
+ int = int * BigInt(-1);
38
+ }
39
+ const hex = int.toString(16).padStart(padding * 2, '0');
40
+ let buffer = platform_node_js_1.Buffer.from(hex, 'hex');
41
+ if (litte)
42
+ buffer = buffer.reverse();
43
+ if (isBellow && signed) {
44
+ if (litte) {
45
+ let isReminder = false;
46
+ if (buffer[0])
47
+ buffer[0] -= 1;
48
+ for (let b = 0; b < platform_node_js_1.Buffer.byteLength(buffer); b++) {
49
+ if (!buffer[b]) {
50
+ isReminder = true;
51
+ continue;
52
+ }
53
+ if (isReminder) {
54
+ buffer[b] -= 1;
55
+ isReminder = false;
56
+ }
57
+ buffer[b] = 255 - buffer[b];
58
+ }
59
+ }
60
+ else {
61
+ buffer[platform_node_js_1.Buffer.byteLength(buffer) - 1] =
62
+ 256 - buffer[platform_node_js_1.Buffer.byteLength(buffer) - 1];
63
+ for (let b = 0; b < platform_node_js_1.Buffer.byteLength(buffer); b++) {
64
+ buffer[b] = 255 - buffer[b];
65
+ }
66
+ }
67
+ }
68
+ return buffer;
69
+ }
70
+ function includesBuffer(array, buffer) {
71
+ for (const buff of array) {
72
+ if (buff.equals(buffer)) {
73
+ return true;
74
+ }
75
+ }
76
+ return false;
77
+ }
78
+ function sliceBuffer(buffer, start, stop, step = 1) {
79
+ let slc = buffer.subarray(start, stop);
80
+ let res = slc;
81
+ if (step === 0) {
82
+ throw new Error('slice step cannot be zero.');
83
+ }
84
+ if (step < 0) {
85
+ slc = platform_node_js_1.Buffer.from(buffer.subarray(stop - step, start - step)).reverse();
86
+ res = slc;
87
+ step = -step;
88
+ }
89
+ if (step > 1) {
90
+ res = platform_node_js_1.Buffer.alloc(0);
91
+ let i = 0;
92
+ for (const buff of slc) {
93
+ i++;
94
+ if (i >= step) {
95
+ i = 0;
96
+ }
97
+ if (i === 1) {
98
+ res = platform_node_js_1.Buffer.concat([
99
+ res,
100
+ platform_node_js_1.Buffer.from([buff]),
101
+ ]);
102
+ }
103
+ }
104
+ }
105
+ return res;
106
+ }
107
+ function makeCRCTable() {
108
+ let c;
109
+ const crcTable = [];
110
+ for (let n = 0; n < 256; n++) {
111
+ c = n;
112
+ for (let k = 0; k < 8; k++) {
113
+ c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
114
+ }
115
+ crcTable[n] = c;
116
+ }
117
+ return crcTable;
118
+ }
119
+ function crc32(str) {
120
+ str = platform_node_js_1.Buffer.isBuffer(str) ? platform_node_js_1.Buffer.from(str) : str;
121
+ const crcTable = makeCRCTable();
122
+ const length = platform_node_js_1.Buffer.isBuffer(str) ? platform_node_js_1.Buffer.byteLength(str) : str.length;
123
+ let crc = -1;
124
+ for (let i = 0; i < length; i++) {
125
+ const bytes = Number(str[i]);
126
+ crc = (crc >>> 8) ^ crcTable[(crc ^ bytes) & 0xff];
127
+ }
128
+ return (crc ^ -1) >>> 0;
129
+ }
130
+ function sleep(ms) {
131
+ return new Promise((resolve) => {
132
+ setTimeout(resolve, ms);
133
+ });
134
+ }
135
+ function bufferToBigint(buffer, little = true, signed = false) {
136
+ const length = platform_node_js_1.Buffer.byteLength(buffer);
137
+ const value = little ? buffer.reverse().toString('hex') : buffer.toString('hex');
138
+ const _bigint = (0, platform_node_js_1.bigInt)(value, 16);
139
+ let bigint = BigInt(String(_bigint));
140
+ if (signed && Math.floor(bigint.toString(2).length / 8) >= length) {
141
+ bigint = bigint - bigIntPow(BigInt(2), BigInt(length * 8));
142
+ }
143
+ return BigInt(bigint);
144
+ }
145
+ function mod(n, m) {
146
+ return ((n % m) + m) % m;
147
+ }
148
+ function bigIntMod(n, m) {
149
+ return ((n % m) + m) % m;
150
+ }
151
+ function range(start, stop, step = 1) {
152
+ const temp = [];
153
+ const results = [];
154
+ if (step === 0) {
155
+ throw new Error('step cannot be zero');
156
+ }
157
+ if (step < 0) {
158
+ if (stop < 0) {
159
+ for (let i = start; i > stop; i--) {
160
+ temp.push(i);
161
+ }
162
+ step = -step;
163
+ if (step > 1) {
164
+ let i = 0;
165
+ for (let num of temp) {
166
+ i++;
167
+ if (i >= step) {
168
+ i = 0;
169
+ }
170
+ if (i === 1) {
171
+ results.push(num);
172
+ }
173
+ }
174
+ return results;
175
+ }
176
+ else {
177
+ return temp;
178
+ }
179
+ }
180
+ return results;
181
+ }
182
+ for (let i = start; i < stop; i++) {
183
+ temp.push(i);
184
+ }
185
+ if (step > 1) {
186
+ let i = 0;
187
+ for (let num of temp) {
188
+ i++;
189
+ if (i >= step) {
190
+ i = 0;
191
+ }
192
+ if (i === 1) {
193
+ results.push(num);
194
+ }
195
+ }
196
+ return results;
197
+ }
198
+ return temp;
199
+ }
200
+ function rangeBigint(start, stop, step = 1) {
201
+ const temp = [];
202
+ const results = [];
203
+ if (step === 0) {
204
+ throw new Error('step cannot be zero');
205
+ }
206
+ if (step < 0) {
207
+ if (stop < BigInt(0)) {
208
+ for (let i = start; i > stop; i--) {
209
+ temp.push(i);
210
+ }
211
+ step = -step;
212
+ if (step > 1) {
213
+ let i = 0;
214
+ for (const num of temp) {
215
+ i++;
216
+ if (i >= step) {
217
+ i = 0;
218
+ }
219
+ if (i === 1) {
220
+ results.push(num);
221
+ }
222
+ }
223
+ return results;
224
+ }
225
+ else {
226
+ return temp;
227
+ }
228
+ }
229
+ return results;
230
+ }
231
+ for (let i = start; i < stop; i++) {
232
+ temp.push(i);
233
+ }
234
+ if (step > 1) {
235
+ let i = 0;
236
+ for (const num of temp) {
237
+ i++;
238
+ if (i >= step) {
239
+ i = 0;
240
+ }
241
+ if (i === 1) {
242
+ results.push(num);
243
+ }
244
+ }
245
+ return results;
246
+ }
247
+ return temp;
248
+ }
249
+ function randint(min, max) {
250
+ return Math.floor(Math.random() * (max - min)) + min;
251
+ }
252
+ function randBigint(min, max) {
253
+ return platform_node_js_1.bigInt.randBetween(min, max).value;
254
+ }
255
+ function pow(x, y, z) {
256
+ let result = Math.pow(x, y);
257
+ if (z !== undefined) {
258
+ return mod(result, z);
259
+ }
260
+ return result;
261
+ }
262
+ function bigIntPow(x, y, z) {
263
+ if (z === undefined) {
264
+ return x ** y;
265
+ }
266
+ else {
267
+ let result = BigInt(1);
268
+ while (y > BigInt(0)) {
269
+ if (bigIntMod(y, BigInt(2)) === BigInt(1)) {
270
+ result = bigIntMod(result * x, z);
271
+ }
272
+ y = y >> BigInt(1);
273
+ x = bigIntMod(x * x, z);
274
+ }
275
+ return result;
276
+ }
277
+ }
278
+ const bigMath = {
279
+ abs(x) {
280
+ return x < BigInt(0) ? -x : x;
281
+ },
282
+ sign(x) {
283
+ if (x === BigInt(0))
284
+ return BigInt(0);
285
+ return x < BigInt(0) ? -BigInt(1) : BigInt(1);
286
+ },
287
+ pow(base, exponent) {
288
+ return base ** exponent;
289
+ },
290
+ min(value, ...values) {
291
+ for (const v of values)
292
+ if (v < value)
293
+ value = v;
294
+ return value;
295
+ },
296
+ max(value, ...values) {
297
+ for (const v of values)
298
+ if (v > value)
299
+ value = v;
300
+ return value;
301
+ },
302
+ };
303
+ exports.bigMath = bigMath;
304
+ exports.MIN_CHANNEL_ID = BigInt(-1002147483647);
305
+ exports.MAX_CHANNEL_ID = BigInt(-1000000000000);
306
+ exports.MIN_CHAT_ID = BigInt(-2147483647);
307
+ exports.MAX_USER_ID_OLD = BigInt(2147483647);
308
+ exports.MAX_USER_ID = BigInt(999999999999);
309
+ function getChannelId(id) {
310
+ return exports.MAX_CHANNEL_ID - id;
311
+ }
312
+ function getPeerType(id) {
313
+ if (id < BigInt(0)) {
314
+ if (exports.MIN_CHAT_ID <= id)
315
+ return 'chat';
316
+ if (exports.MIN_CHANNEL_ID <= id < exports.MAX_CHANNEL_ID)
317
+ return 'channel';
318
+ }
319
+ else if (BigInt(0) < id <= exports.MAX_USER_ID) {
320
+ return 'user';
321
+ }
322
+ else {
323
+ throw new Error(`PeerId Invalid: ${id}`);
324
+ }
325
+ }
326
+ function base64urlTobase64(text) {
327
+ const pad = text.length % 4;
328
+ if (pad === 1) {
329
+ throw new Error('Invalid base64url');
330
+ }
331
+ return (pad === 2 || pad === 3 ? text.padEnd(4 - pad, '=') : text)
332
+ .replace(/\-/g, '+')
333
+ .replace(/_/g, '/');
334
+ }
335
+ function generateRandomBigInt(lowBigInt, highBigInt) {
336
+ if (lowBigInt >= highBigInt) {
337
+ throw new Error('lowBigInt must be smaller than highBigInt');
338
+ }
339
+ const difference = highBigInt - lowBigInt;
340
+ const differenceLength = difference.toString().length;
341
+ let multiplier = '';
342
+ while (multiplier.length < differenceLength) {
343
+ multiplier += Math.random().toString().split('.')[1];
344
+ }
345
+ multiplier = multiplier.slice(0, differenceLength);
346
+ const divisor = '1' + '0'.repeat(differenceLength);
347
+ const randomDifference = (difference * BigInt(multiplier)) / BigInt(divisor);
348
+ return lowBigInt + randomDifference;
349
+ }
350
+ function normalizeSecretString(secret) {
351
+ if (secret.slice(0, 2) === 'dd' || secret.slice(0, 2) === 'ee') {
352
+ secret = secret.slice(2);
353
+ }
354
+ if (/^[0-9a-fA-F]+$/.test(secret)) {
355
+ return platform_node_js_1.Buffer.from(secret, 'hex');
356
+ }
357
+ return platform_node_js_1.Buffer.from(secret, 'base64').subarray(0, 16);
358
+ }
@@ -0,0 +1,16 @@
1
+ export { Client } from './client/Client.js';
2
+ export { Raw } from './raw/index.js';
3
+ export { Queue } from './Queue.js';
4
+ export { TCP } from './connection/connection.js';
5
+ export * as Clients from './client/index.js';
6
+ export * as Connections from './connection/index.js';
7
+ export * as Cryptos from './crypto/index.js';
8
+ export * as Errors from './errors/index.js';
9
+ export * as Files from './file/index.js';
10
+ export * as Raws from './raw/index.js';
11
+ export * as Sessions from './session/index.js';
12
+ export * as Storages from './storage/index.js';
13
+ export * as Versions from './Version.node.js';
14
+ export * as Helpers from './helpers.js';
15
+ export * as Timeouts from './Timeout.js';
16
+ export * as Loggers from './Logger.js';
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Loggers = exports.Timeouts = exports.Helpers = exports.Versions = exports.Storages = exports.Sessions = exports.Raws = exports.Files = exports.Errors = exports.Cryptos = exports.Connections = exports.Clients = exports.TCP = exports.Queue = exports.Raw = exports.Client = void 0;
37
+ var Client_js_1 = require("./client/Client.js");
38
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_js_1.Client; } });
39
+ var index_js_1 = require("./raw/index.js");
40
+ Object.defineProperty(exports, "Raw", { enumerable: true, get: function () { return index_js_1.Raw; } });
41
+ var Queue_js_1 = require("./Queue.js");
42
+ Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return Queue_js_1.Queue; } });
43
+ var connection_js_1 = require("./connection/connection.js");
44
+ Object.defineProperty(exports, "TCP", { enumerable: true, get: function () { return connection_js_1.TCP; } });
45
+ exports.Clients = __importStar(require("./client/index.js"));
46
+ exports.Connections = __importStar(require("./connection/index.js"));
47
+ exports.Cryptos = __importStar(require("./crypto/index.js"));
48
+ exports.Errors = __importStar(require("./errors/index.js"));
49
+ exports.Files = __importStar(require("./file/index.js"));
50
+ exports.Raws = __importStar(require("./raw/index.js"));
51
+ exports.Sessions = __importStar(require("./session/index.js"));
52
+ exports.Storages = __importStar(require("./storage/index.js"));
53
+ exports.Versions = __importStar(require("./Version.node.js"));
54
+ exports.Helpers = __importStar(require("./helpers.js"));
55
+ exports.Timeouts = __importStar(require("./Timeout.js"));
56
+ exports.Loggers = __importStar(require("./Logger.js"));
@@ -0,0 +1,36 @@
1
+ import * as crypto from 'crypto';
2
+ import * as net from 'net';
3
+ import * as os from 'os';
4
+ import * as path from 'path';
5
+ import process from 'process';
6
+ import { Buffer } from 'buffer';
7
+ export { inspect } from 'util';
8
+ export { gzipSync, gunzipSync } from 'zlib';
9
+ import bigInt from 'big-integer';
10
+ export { Logger } from '@tgsnake/log';
11
+ export { SocksClient } from 'socks';
12
+ export { Mutex, Semaphore } from 'async-mutex';
13
+ export { Readable, Writable, Duplex } from 'stream';
14
+ export declare const isDeno: boolean;
15
+ export declare const isBun: boolean;
16
+ export declare const isBrowser: boolean;
17
+ export declare const where: string;
18
+ export type BufferEncoding = 'utf-8' | 'utf8' | 'utf-16le' | 'utf16le' | 'latin1' | 'binary' | 'base64' | 'hex';
19
+ export declare namespace aesjs {
20
+ namespace ModeOfOperation {
21
+ class ecb {
22
+ constructor(..._args: Array<any>);
23
+ encrypt(..._args: Array<any>): Buffer;
24
+ decrypt(..._args: Array<any>): Buffer;
25
+ }
26
+ class ctr {
27
+ constructor(..._args: Array<any>);
28
+ encrypt(..._args: Array<any>): Buffer;
29
+ decrypt(..._args: Array<any>): Buffer;
30
+ }
31
+ }
32
+ class Counter {
33
+ constructor(..._args: Array<any>);
34
+ }
35
+ }
36
+ export { crypto, net, os, bigInt, path, process as sysprc, Buffer };
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Buffer = exports.sysprc = exports.path = exports.bigInt = exports.os = exports.net = exports.crypto = exports.aesjs = exports.where = exports.isBrowser = exports.isBun = exports.isDeno = exports.Duplex = exports.Writable = exports.Readable = exports.Semaphore = exports.Mutex = exports.SocksClient = exports.Logger = exports.gunzipSync = exports.gzipSync = exports.inspect = void 0;
40
+ const crypto = __importStar(require("crypto"));
41
+ exports.crypto = crypto;
42
+ const net = __importStar(require("net"));
43
+ exports.net = net;
44
+ const os = __importStar(require("os"));
45
+ exports.os = os;
46
+ const path = __importStar(require("path"));
47
+ exports.path = path;
48
+ const process_1 = __importDefault(require("process"));
49
+ exports.sysprc = process_1.default;
50
+ const buffer_1 = require("buffer");
51
+ Object.defineProperty(exports, "Buffer", { enumerable: true, get: function () { return buffer_1.Buffer; } });
52
+ var util_1 = require("util");
53
+ Object.defineProperty(exports, "inspect", { enumerable: true, get: function () { return util_1.inspect; } });
54
+ var zlib_1 = require("zlib");
55
+ Object.defineProperty(exports, "gzipSync", { enumerable: true, get: function () { return zlib_1.gzipSync; } });
56
+ Object.defineProperty(exports, "gunzipSync", { enumerable: true, get: function () { return zlib_1.gunzipSync; } });
57
+ const big_integer_1 = __importDefault(require("big-integer"));
58
+ exports.bigInt = big_integer_1.default;
59
+ var log_1 = require("@tgsnake/log");
60
+ Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return log_1.Logger; } });
61
+ var socks_1 = require("socks");
62
+ Object.defineProperty(exports, "SocksClient", { enumerable: true, get: function () { return socks_1.SocksClient; } });
63
+ var async_mutex_1 = require("async-mutex");
64
+ Object.defineProperty(exports, "Mutex", { enumerable: true, get: function () { return async_mutex_1.Mutex; } });
65
+ Object.defineProperty(exports, "Semaphore", { enumerable: true, get: function () { return async_mutex_1.Semaphore; } });
66
+ var stream_1 = require("stream");
67
+ Object.defineProperty(exports, "Readable", { enumerable: true, get: function () { return stream_1.Readable; } });
68
+ Object.defineProperty(exports, "Writable", { enumerable: true, get: function () { return stream_1.Writable; } });
69
+ Object.defineProperty(exports, "Duplex", { enumerable: true, get: function () { return stream_1.Duplex; } });
70
+ exports.isDeno = 'Deno' in globalThis;
71
+ exports.isBun = 'Bun' in globalThis;
72
+ exports.isBrowser = !exports.isDeno && !exports.isBun && typeof window !== 'undefined';
73
+ exports.where = exports.isDeno ? 'Deno' : exports.isBun ? 'Bun' : exports.isBrowser ? 'Browser' : 'Node';
74
+ var aesjs;
75
+ (function (aesjs) {
76
+ let ModeOfOperation;
77
+ (function (ModeOfOperation) {
78
+ class ecb {
79
+ constructor(..._args) {
80
+ throw new Error('not implemented');
81
+ }
82
+ encrypt(..._args) {
83
+ return buffer_1.Buffer.alloc(0);
84
+ }
85
+ decrypt(..._args) {
86
+ return buffer_1.Buffer.alloc(0);
87
+ }
88
+ }
89
+ ModeOfOperation.ecb = ecb;
90
+ class ctr {
91
+ constructor(..._args) {
92
+ throw new Error('not implemented');
93
+ }
94
+ encrypt(..._args) {
95
+ return buffer_1.Buffer.alloc(0);
96
+ }
97
+ decrypt(..._args) {
98
+ return buffer_1.Buffer.alloc(0);
99
+ }
100
+ }
101
+ ModeOfOperation.ctr = ctr;
102
+ })(ModeOfOperation = aesjs.ModeOfOperation || (aesjs.ModeOfOperation = {}));
103
+ class Counter {
104
+ constructor(..._args) {
105
+ throw new Error('not implemented');
106
+ }
107
+ }
108
+ aesjs.Counter = Counter;
109
+ })(aesjs || (exports.aesjs = aesjs = {}));