@mtcute/node 0.16.7 → 0.16.13

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 (124) hide show
  1. package/chunks/cjs/BpvQ752Q.js +33 -0
  2. package/chunks/cjs/D7i-4e0W.js +74 -0
  3. package/chunks/cjs/HP2yqAk_.js +79 -0
  4. package/chunks/cjs/package.json +3 -0
  5. package/chunks/es/CKso6cAV.js +75 -0
  6. package/chunks/es/CnOjjhdK.js +29 -0
  7. package/chunks/es/HZgHrOPU.js +69 -0
  8. package/{cjs/client.d.ts → client.d.ts} +3 -4
  9. package/{cjs/common-internals-node → common-internals-node}/platform.d.ts +1 -1
  10. package/index.cjs +449 -0
  11. package/index.d.ts +8 -1
  12. package/index.js +410 -1
  13. package/{cjs/methods → methods}/download-file.d.ts +1 -1
  14. package/{esm/methods → methods}/download-node-stream.d.ts +2 -2
  15. package/methods.cjs +17 -0
  16. package/methods.d.ts +3 -1
  17. package/methods.js +6 -1
  18. package/package.json +49 -33
  19. package/{esm/sqlite → sqlite}/driver.d.ts +2 -3
  20. package/{esm/sqlite → sqlite}/index.d.ts +1 -1
  21. package/sqlite/sqlite.test.d.ts +1 -0
  22. package/{cjs/utils → utils}/crypto.d.ts +1 -2
  23. package/utils/crypto.test.d.ts +1 -0
  24. package/{cjs/utils → utils}/normalize-file.d.ts +1 -1
  25. package/utils/stream-utils.test.d.ts +1 -0
  26. package/{cjs/utils → utils}/tcp.d.ts +4 -5
  27. package/utils/tcp.test.d.ts +1 -0
  28. package/utils.cjs +20 -0
  29. package/utils.d.ts +3 -1
  30. package/utils.js +9 -1
  31. package/{cjs/worker.d.ts → worker.d.ts} +1 -2
  32. package/cjs/client.js +0 -112
  33. package/cjs/client.js.map +0 -1
  34. package/cjs/common-internals-node/exit-hook.js +0 -45
  35. package/cjs/common-internals-node/exit-hook.js.map +0 -1
  36. package/cjs/common-internals-node/logging.js +0 -34
  37. package/cjs/common-internals-node/logging.js.map +0 -1
  38. package/cjs/common-internals-node/platform.js +0 -85
  39. package/cjs/common-internals-node/platform.js.map +0 -1
  40. package/cjs/index.js +0 -31
  41. package/cjs/index.js.map +0 -1
  42. package/cjs/methods/download-file.js +0 -33
  43. package/cjs/methods/download-file.js.map +0 -1
  44. package/cjs/methods/download-node-stream.d.ts +0 -8
  45. package/cjs/methods/download-node-stream.js +0 -14
  46. package/cjs/methods/download-node-stream.js.map +0 -1
  47. package/cjs/methods.js +0 -29
  48. package/cjs/methods.js.map +0 -1
  49. package/cjs/package.json +0 -3
  50. package/cjs/sqlite/driver.d.ts +0 -26
  51. package/cjs/sqlite/driver.js +0 -29
  52. package/cjs/sqlite/driver.js.map +0 -1
  53. package/cjs/sqlite/index.d.ts +0 -8
  54. package/cjs/sqlite/index.js +0 -18
  55. package/cjs/sqlite/index.js.map +0 -1
  56. package/cjs/utils/crypto.js +0 -71
  57. package/cjs/utils/crypto.js.map +0 -1
  58. package/cjs/utils/normalize-file.js +0 -30
  59. package/cjs/utils/normalize-file.js.map +0 -1
  60. package/cjs/utils/stream-utils.js +0 -76
  61. package/cjs/utils/stream-utils.js.map +0 -1
  62. package/cjs/utils/tcp.js +0 -126
  63. package/cjs/utils/tcp.js.map +0 -1
  64. package/cjs/utils/version.js +0 -21
  65. package/cjs/utils/version.js.map +0 -1
  66. package/cjs/utils.js +0 -26
  67. package/cjs/utils.js.map +0 -1
  68. package/cjs/worker.js +0 -48
  69. package/cjs/worker.js.map +0 -1
  70. package/esm/client.d.ts +0 -48
  71. package/esm/client.js +0 -107
  72. package/esm/client.js.map +0 -1
  73. package/esm/common-internals-node/exit-hook.d.ts +0 -1
  74. package/esm/common-internals-node/exit-hook.js +0 -42
  75. package/esm/common-internals-node/exit-hook.js.map +0 -1
  76. package/esm/common-internals-node/logging.d.ts +0 -2
  77. package/esm/common-internals-node/logging.js +0 -31
  78. package/esm/common-internals-node/logging.js.map +0 -1
  79. package/esm/common-internals-node/platform.d.ts +0 -18
  80. package/esm/common-internals-node/platform.js +0 -58
  81. package/esm/common-internals-node/platform.js.map +0 -1
  82. package/esm/index.d.ts +0 -8
  83. package/esm/index.js +0 -9
  84. package/esm/index.js.map +0 -1
  85. package/esm/methods/download-file.d.ts +0 -9
  86. package/esm/methods/download-file.js +0 -30
  87. package/esm/methods/download-file.js.map +0 -1
  88. package/esm/methods/download-node-stream.js +0 -11
  89. package/esm/methods/download-node-stream.js.map +0 -1
  90. package/esm/methods.d.ts +0 -3
  91. package/esm/methods.js +0 -4
  92. package/esm/methods.js.map +0 -1
  93. package/esm/sqlite/driver.js +0 -22
  94. package/esm/sqlite/driver.js.map +0 -1
  95. package/esm/sqlite/index.js +0 -13
  96. package/esm/sqlite/index.js.map +0 -1
  97. package/esm/utils/crypto.d.ts +0 -16
  98. package/esm/utils/crypto.js +0 -69
  99. package/esm/utils/crypto.js.map +0 -1
  100. package/esm/utils/normalize-file.d.ts +0 -6
  101. package/esm/utils/normalize-file.js +0 -27
  102. package/esm/utils/normalize-file.js.map +0 -1
  103. package/esm/utils/stream-utils.d.ts +0 -3
  104. package/esm/utils/stream-utils.js +0 -72
  105. package/esm/utils/stream-utils.js.map +0 -1
  106. package/esm/utils/tcp.d.ts +0 -30
  107. package/esm/utils/tcp.js +0 -118
  108. package/esm/utils/tcp.js.map +0 -1
  109. package/esm/utils/version.d.ts +0 -3
  110. package/esm/utils/version.js +0 -17
  111. package/esm/utils/version.js.map +0 -1
  112. package/esm/utils.d.ts +0 -3
  113. package/esm/utils.js +0 -4
  114. package/esm/utils.js.map +0 -1
  115. package/esm/worker.d.ts +0 -11
  116. package/esm/worker.js +0 -43
  117. package/esm/worker.js.map +0 -1
  118. /package/{cjs/common-internals-node → common-internals-node}/exit-hook.d.ts +0 -0
  119. /package/{cjs/common-internals-node → common-internals-node}/logging.d.ts +0 -0
  120. /package/{cjs/index.d.ts → index.d.cts} +0 -0
  121. /package/{cjs/methods.d.ts → methods.d.cts} +0 -0
  122. /package/{cjs/utils → utils}/stream-utils.d.ts +0 -0
  123. /package/{cjs/utils → utils}/version.d.ts +0 -0
  124. /package/{cjs/utils.d.ts → utils.d.cts} +0 -0
@@ -1 +0,0 @@
1
- export declare function beforeExit(fn: () => void): () => void;
@@ -1,42 +0,0 @@
1
- // roughly based on https://github.com/sindresorhus/exit-hook/blob/main/index.js, MIT license
2
- let installed = false;
3
- let handled = false;
4
- const callbacks = new Set();
5
- const myHandlers = new Map();
6
- function register(shouldManuallyExit, signal, event) {
7
- function eventHandler() {
8
- if (handled) {
9
- return;
10
- }
11
- handled = true;
12
- for (const callback of callbacks) {
13
- callback();
14
- }
15
- for (const [event, handler] of myHandlers) {
16
- process.off(event, handler);
17
- }
18
- if (shouldManuallyExit) {
19
- // send the signal again and let node handle it
20
- process.kill(process.pid, signal);
21
- }
22
- }
23
- process.on(event, eventHandler);
24
- myHandlers.set(event, eventHandler);
25
- }
26
- export function beforeExit(fn) {
27
- // unsupported platform
28
- if (typeof process === 'undefined')
29
- return () => { };
30
- if (!installed) {
31
- installed = true;
32
- register(true, 0, 'beforeExit');
33
- register(true, 2, 'SIGINT');
34
- register(true, 15, 'SIGTERM');
35
- register(false, 15, 'exit');
36
- }
37
- callbacks.add(fn);
38
- return () => {
39
- callbacks.delete(fn);
40
- };
41
- }
42
- //# sourceMappingURL=exit-hook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exit-hook.js","sourceRoot":"","sources":["../../../src/common-internals-node/exit-hook.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAE7F,IAAI,SAAS,GAAG,KAAK,CAAA;AACrB,IAAI,OAAO,GAAG,KAAK,CAAA;AAEnB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AAEvC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAsB,CAAA;AAEhD,SAAS,QAAQ,CAAC,kBAA2B,EAAE,MAAc,EAAE,KAAa;IACxE,SAAS,YAAY;QACjB,IAAI,OAAO,EAAE,CAAC;YACV,OAAM;QACV,CAAC;QAED,OAAO,GAAG,IAAI,CAAA;QAEd,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YAC/B,QAAQ,EAAE,CAAA;QACd,CAAC;QAED,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,UAAU,EAAE,CAAC;YACxC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC/B,CAAC;QAED,IAAI,kBAAkB,EAAE,CAAC;YACrB,+CAA+C;YAC/C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACrC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IAC/B,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAc;IACrC,uBAAuB;IACvB,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IAEnD,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,SAAS,GAAG,IAAI,CAAA;QAEhB,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,CAAA;QAC/B,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAA;QAC3B,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;QAC7B,QAAQ,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEjB,OAAO,GAAG,EAAE;QACR,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACxB,CAAC,CAAA;AACL,CAAC","sourcesContent":["// roughly based on https://github.com/sindresorhus/exit-hook/blob/main/index.js, MIT license\n\nlet installed = false\nlet handled = false\n\nconst callbacks = new Set<() => void>()\n\nconst myHandlers = new Map<string, () => void>()\n\nfunction register(shouldManuallyExit: boolean, signal: number, event: string) {\n function eventHandler() {\n if (handled) {\n return\n }\n\n handled = true\n\n for (const callback of callbacks) {\n callback()\n }\n\n for (const [event, handler] of myHandlers) {\n process.off(event, handler)\n }\n\n if (shouldManuallyExit) {\n // send the signal again and let node handle it\n process.kill(process.pid, signal)\n }\n }\n\n process.on(event, eventHandler)\n myHandlers.set(event, eventHandler)\n}\n\nexport function beforeExit(fn: () => void): () => void {\n // unsupported platform\n if (typeof process === 'undefined') return () => {}\n\n if (!installed) {\n installed = true\n\n register(true, 0, 'beforeExit')\n register(true, 2, 'SIGINT')\n register(true, 15, 'SIGTERM')\n register(false, 15, 'exit')\n }\n\n callbacks.add(fn)\n\n return () => {\n callbacks.delete(fn)\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- /** @internal */
2
- export declare const defaultLoggingHandler: (color: number, level: number, tag: string, fmt: string, args: unknown[]) => void;
@@ -1,31 +0,0 @@
1
- const isTty = typeof process === 'object' && Boolean(process.stdout?.isTTY);
2
- const BASE_FORMAT = isTty ? '%s [%s] [%s%s\x1B[0m] ' : '%s [%s] [%s] ';
3
- const LEVEL_NAMES = isTty
4
- ? [
5
- '', // OFF
6
- '\x1B[31mERR\x1B[0m',
7
- '\x1B[33mWRN\x1B[0m',
8
- '\x1B[34mINF\x1B[0m',
9
- '\x1B[36mDBG\x1B[0m',
10
- '\x1B[35mVRB\x1B[0m',
11
- ]
12
- : [
13
- '', // OFF
14
- 'ERR',
15
- 'WRN',
16
- 'INF',
17
- 'DBG',
18
- 'VRB',
19
- ];
20
- const TAG_COLORS = [6, 2, 3, 4, 5, 1].map(i => `\x1B[3${i};1m`);
21
- /** @internal */
22
- export const defaultLoggingHandler = isTty
23
- ? (color, level, tag, fmt, args) => {
24
- // eslint-disable-next-line no-console
25
- console.log(BASE_FORMAT + fmt, new Date().toISOString(), LEVEL_NAMES[level], TAG_COLORS[color], tag, ...args);
26
- }
27
- : (color, level, tag, fmt, args) => {
28
- // eslint-disable-next-line no-console
29
- console.log(BASE_FORMAT + fmt, new Date().toISOString(), LEVEL_NAMES[level], tag, ...args);
30
- };
31
- //# sourceMappingURL=logging.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../src/common-internals-node/logging.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAE3E,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,eAAe,CAAA;AACtE,MAAM,WAAW,GAAG,KAAK;IACrB,CAAC,CAAC;QACE,EAAE,EAAE,MAAM;QACV,oBAAoB;QACpB,oBAAoB;QACpB,oBAAoB;QACpB,oBAAoB;QACpB,oBAAoB;KACvB;IACD,CAAC,CAAC;QACE,EAAE,EAAE,MAAM;QACV,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;KACR,CAAA;AACL,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAE/D,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAMtB,KAAK;IACb,CAAC,CAAC,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,IAAe,EAAQ,EAAE;QAChF,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;IACjH,CAAC;IACD,CAAC,CAAC,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,IAAe,EAAQ,EAAE;QAChF,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;IAC9F,CAAC,CAAA","sourcesContent":["const isTty = typeof process === 'object' && Boolean(process.stdout?.isTTY)\n\nconst BASE_FORMAT = isTty ? '%s [%s] [%s%s\\x1B[0m] ' : '%s [%s] [%s] '\nconst LEVEL_NAMES = isTty\n ? [\n '', // OFF\n '\\x1B[31mERR\\x1B[0m',\n '\\x1B[33mWRN\\x1B[0m',\n '\\x1B[34mINF\\x1B[0m',\n '\\x1B[36mDBG\\x1B[0m',\n '\\x1B[35mVRB\\x1B[0m',\n ]\n : [\n '', // OFF\n 'ERR',\n 'WRN',\n 'INF',\n 'DBG',\n 'VRB',\n ]\nconst TAG_COLORS = [6, 2, 3, 4, 5, 1].map(i => `\\x1B[3${i};1m`)\n\n/** @internal */\nexport const defaultLoggingHandler: (\n color: number,\n level: number,\n tag: string,\n fmt: string,\n args: unknown[]\n) => void = isTty\n ? (color: number, level: number, tag: string, fmt: string, args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console.log(BASE_FORMAT + fmt, new Date().toISOString(), LEVEL_NAMES[level], TAG_COLORS[color], tag, ...args)\n }\n : (color: number, level: number, tag: string, fmt: string, args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console.log(BASE_FORMAT + fmt, new Date().toISOString(), LEVEL_NAMES[level], tag, ...args)\n }\n"]}
@@ -1,18 +0,0 @@
1
- import type { ICorePlatform } from '@mtcute/core/platform.js';
2
- import { normalizeFile } from '../utils/normalize-file.js';
3
- import { beforeExit } from './exit-hook.js';
4
- import { defaultLoggingHandler } from './logging.js';
5
- export declare class NodePlatform implements ICorePlatform {
6
- log: typeof defaultLoggingHandler;
7
- beforeExit: typeof beforeExit;
8
- normalizeFile: typeof normalizeFile;
9
- getDeviceModel(): string;
10
- getDefaultLogLevel(): number | null;
11
- utf8ByteLength(str: string): number;
12
- utf8Encode(str: string): Uint8Array;
13
- utf8Decode(buf: Uint8Array): string;
14
- hexEncode(buf: Uint8Array): string;
15
- hexDecode(str: string): Uint8Array;
16
- base64Encode(buf: Uint8Array, url?: boolean): string;
17
- base64Decode(string: string, url?: boolean): Uint8Array;
18
- }
@@ -1,58 +0,0 @@
1
- import * as os from 'node:os';
2
- import { normalizeFile } from '../utils/normalize-file.js';
3
- import { beforeExit } from './exit-hook.js';
4
- import { defaultLoggingHandler } from './logging.js';
5
- const BUFFER_BASE64_URL_AVAILABLE = typeof Buffer.isEncoding === 'function' && Buffer.isEncoding('base64url');
6
- const toBuffer = (buf) => Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
7
- export class NodePlatform {
8
- getDeviceModel() {
9
- return `Node.js/${process.version} (${os.type()} ${os.arch()})`;
10
- }
11
- getDefaultLogLevel() {
12
- const envLogLevel = Number.parseInt(process.env.MTCUTE_LOG_LEVEL ?? '');
13
- if (!Number.isNaN(envLogLevel)) {
14
- return envLogLevel;
15
- }
16
- return null;
17
- }
18
- // ITlPlatform
19
- utf8ByteLength(str) {
20
- return Buffer.byteLength(str, 'utf8');
21
- }
22
- utf8Encode(str) {
23
- return Buffer.from(str, 'utf8');
24
- }
25
- utf8Decode(buf) {
26
- return toBuffer(buf).toString('utf8');
27
- }
28
- hexEncode(buf) {
29
- return toBuffer(buf).toString('hex');
30
- }
31
- hexDecode(str) {
32
- return Buffer.from(str, 'hex');
33
- }
34
- base64Encode(buf, url = false) {
35
- const nodeBuffer = toBuffer(buf);
36
- if (url && BUFFER_BASE64_URL_AVAILABLE)
37
- return nodeBuffer.toString('base64url');
38
- const str = nodeBuffer.toString('base64');
39
- if (url)
40
- return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
41
- return str;
42
- }
43
- base64Decode(string, url = false) {
44
- if (url && BUFFER_BASE64_URL_AVAILABLE) {
45
- return Buffer.from(string, 'base64url');
46
- }
47
- if (url) {
48
- string = string.replace(/-/g, '+').replace(/_/g, '/');
49
- while (string.length % 4)
50
- string += '=';
51
- }
52
- return Buffer.from(string, 'base64');
53
- }
54
- }
55
- NodePlatform.prototype.log = defaultLoggingHandler;
56
- NodePlatform.prototype.beforeExit = beforeExit;
57
- NodePlatform.prototype.normalizeFile = normalizeFile;
58
- //# sourceMappingURL=platform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../../src/common-internals-node/platform.ts"],"names":[],"mappings":"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","sourcesContent":["import * as os from 'node:os'\n\nimport type { ICorePlatform } from '@mtcute/core/platform.js'\n\nimport { normalizeFile } from '../utils/normalize-file.js'\n\nimport { beforeExit } from './exit-hook.js'\nimport { defaultLoggingHandler } from './logging.js'\n\nconst BUFFER_BASE64_URL_AVAILABLE = typeof Buffer.isEncoding === 'function' && Buffer.isEncoding('base64url')\n\nconst toBuffer = (buf: Uint8Array): Buffer => Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n\nexport class NodePlatform implements ICorePlatform {\n // ICorePlatform\n declare log: typeof defaultLoggingHandler\n declare beforeExit: typeof beforeExit\n declare normalizeFile: typeof normalizeFile\n\n getDeviceModel(): string {\n return `Node.js/${process.version} (${os.type()} ${os.arch()})`\n }\n\n getDefaultLogLevel(): number | null {\n const envLogLevel = Number.parseInt(process.env.MTCUTE_LOG_LEVEL ?? '')\n\n if (!Number.isNaN(envLogLevel)) {\n return envLogLevel\n }\n\n return null\n }\n\n // ITlPlatform\n utf8ByteLength(str: string): number {\n return Buffer.byteLength(str, 'utf8')\n }\n\n utf8Encode(str: string): Uint8Array {\n return Buffer.from(str, 'utf8')\n }\n\n utf8Decode(buf: Uint8Array): string {\n return toBuffer(buf).toString('utf8')\n }\n\n hexEncode(buf: Uint8Array): string {\n return toBuffer(buf).toString('hex')\n }\n\n hexDecode(str: string): Uint8Array {\n return Buffer.from(str, 'hex')\n }\n\n base64Encode(buf: Uint8Array, url = false): string {\n const nodeBuffer = toBuffer(buf)\n\n if (url && BUFFER_BASE64_URL_AVAILABLE) return nodeBuffer.toString('base64url')\n\n const str = nodeBuffer.toString('base64')\n if (url) return str.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '')\n\n return str\n }\n\n base64Decode(string: string, url = false): Uint8Array {\n if (url && BUFFER_BASE64_URL_AVAILABLE) {\n return Buffer.from(string, 'base64url')\n }\n\n if (url) {\n string = string.replace(/-/g, '+').replace(/_/g, '/')\n while (string.length % 4) string += '='\n }\n\n return Buffer.from(string, 'base64')\n }\n}\n\nNodePlatform.prototype.log = defaultLoggingHandler\nNodePlatform.prototype.beforeExit = beforeExit\nNodePlatform.prototype.normalizeFile = normalizeFile\n"]}
package/esm/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export * from './client.js';
2
- export * from './common-internals-node/platform.js';
3
- export * from './sqlite/index.js';
4
- export * from './utils/tcp.js';
5
- export * from './worker.js';
6
- export * from '@mtcute/core';
7
- export * from '@mtcute/html-parser';
8
- export * from '@mtcute/markdown-parser';
package/esm/index.js DELETED
@@ -1,9 +0,0 @@
1
- export * from './client.js';
2
- export * from './common-internals-node/platform.js';
3
- export * from './sqlite/index.js';
4
- export * from './utils/tcp.js';
5
- export * from './worker.js';
6
- export * from '@mtcute/core';
7
- export * from '@mtcute/html-parser';
8
- export * from '@mtcute/markdown-parser';
9
- //# sourceMappingURL=index.js.map
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,qCAAqC,CAAA;AACnD,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA","sourcesContent":["export * from './client.js'\nexport * from './common-internals-node/platform.js'\nexport * from './sqlite/index.js'\nexport * from './utils/tcp.js'\nexport * from './worker.js'\nexport * from '@mtcute/core'\nexport * from '@mtcute/html-parser'\nexport * from '@mtcute/markdown-parser'\n"]}
@@ -1,9 +0,0 @@
1
- import type { FileDownloadLocation, FileDownloadParameters, ITelegramClient } from '@mtcute/core';
2
- /**
3
- * Download a remote file to a local file (only for NodeJS).
4
- * Promise will resolve once the download is complete.
5
- *
6
- * @param filename Local file name to which the remote file will be downloaded
7
- * @param params File download parameters
8
- */
9
- export declare function downloadToFile(client: ITelegramClient, filename: string, location: FileDownloadLocation, params?: FileDownloadParameters): Promise<void>;
@@ -1,30 +0,0 @@
1
- import { createWriteStream, rmSync } from 'node:fs';
2
- import { writeFile } from 'node:fs/promises';
3
- import { FileLocation } from '@mtcute/core';
4
- import { downloadAsIterable } from '@mtcute/core/methods.js';
5
- /**
6
- * Download a remote file to a local file (only for NodeJS).
7
- * Promise will resolve once the download is complete.
8
- *
9
- * @param filename Local file name to which the remote file will be downloaded
10
- * @param params File download parameters
11
- */
12
- export async function downloadToFile(client, filename, location, params) {
13
- if (location instanceof FileLocation && ArrayBuffer.isView(location.location)) {
14
- // early return for inline files
15
- await writeFile(filename, location.location);
16
- }
17
- const output = createWriteStream(filename);
18
- if (params?.abortSignal) {
19
- params.abortSignal.addEventListener('abort', () => {
20
- client.log.debug('aborting file download %s - cleaning up', filename);
21
- output.destroy();
22
- rmSync(filename);
23
- });
24
- }
25
- for await (const chunk of downloadAsIterable(client, location, params)) {
26
- output.write(chunk);
27
- }
28
- output.end();
29
- }
30
- //# sourceMappingURL=download-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"download-file.js","sourceRoot":"","sources":["../../../src/methods/download-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,MAAuB,EACvB,QAAgB,EAChB,QAA8B,EAC9B,MAA+B;IAE/B,IAAI,QAAQ,YAAY,YAAY,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,gCAAgC;QAChC,MAAM,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAChD,CAAC;IAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAA;IAE1C,IAAI,MAAM,EAAE,WAAW,EAAE,CAAC;QACtB,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC9C,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,yCAAyC,EAAE,QAAQ,CAAC,CAAA;YACrE,MAAM,CAAC,OAAO,EAAE,CAAA;YAChB,MAAM,CAAC,QAAQ,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;IACN,CAAC;IAED,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;QACrE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC;IAED,MAAM,CAAC,GAAG,EAAE,CAAA;AAChB,CAAC","sourcesContent":["import { createWriteStream, rmSync } from 'node:fs'\nimport { writeFile } from 'node:fs/promises'\n\nimport type { FileDownloadLocation, FileDownloadParameters, ITelegramClient } from '@mtcute/core'\nimport { FileLocation } from '@mtcute/core'\nimport { downloadAsIterable } from '@mtcute/core/methods.js'\n\n/**\n * Download a remote file to a local file (only for NodeJS).\n * Promise will resolve once the download is complete.\n *\n * @param filename Local file name to which the remote file will be downloaded\n * @param params File download parameters\n */\nexport async function downloadToFile(\n client: ITelegramClient,\n filename: string,\n location: FileDownloadLocation,\n params?: FileDownloadParameters,\n): Promise<void> {\n if (location instanceof FileLocation && ArrayBuffer.isView(location.location)) {\n // early return for inline files\n await writeFile(filename, location.location)\n }\n\n const output = createWriteStream(filename)\n\n if (params?.abortSignal) {\n params.abortSignal.addEventListener('abort', () => {\n client.log.debug('aborting file download %s - cleaning up', filename)\n output.destroy()\n rmSync(filename)\n })\n }\n\n for await (const chunk of downloadAsIterable(client, location, params)) {\n output.write(chunk)\n }\n\n output.end()\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { downloadAsStream } from '@mtcute/core/methods.js';
2
- import { webStreamToNode } from '../utils/stream-utils.js';
3
- /**
4
- * Download a remote file as a Node.js Readable stream.
5
- *
6
- * @param params File download parameters
7
- */
8
- export function downloadAsNodeStream(client, location, params) {
9
- return webStreamToNode(downloadAsStream(client, location, params));
10
- }
11
- //# sourceMappingURL=download-node-stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"download-node-stream.js","sourceRoot":"","sources":["../../../src/methods/download-node-stream.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAChC,MAAuB,EACvB,QAA8B,EAC9B,MAA+B;IAE/B,OAAO,eAAe,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import type { Readable } from 'node:stream'\n\nimport type { FileDownloadLocation, FileDownloadParameters, ITelegramClient } from '@mtcute/core'\nimport { downloadAsStream } from '@mtcute/core/methods.js'\n\nimport { webStreamToNode } from '../utils/stream-utils.js'\n\n/**\n * Download a remote file as a Node.js Readable stream.\n *\n * @param params File download parameters\n */\nexport function downloadAsNodeStream(\n client: ITelegramClient,\n location: FileDownloadLocation,\n params?: FileDownloadParameters,\n): Readable {\n return webStreamToNode(downloadAsStream(client, location, params))\n}\n"]}
package/esm/methods.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { downloadToFile } from './methods/download-file.js';
2
- export { downloadAsNodeStream } from './methods/download-node-stream.js';
3
- export * from '@mtcute/core/methods.js';
package/esm/methods.js DELETED
@@ -1,4 +0,0 @@
1
- export { downloadToFile } from './methods/download-file.js';
2
- export { downloadAsNodeStream } from './methods/download-node-stream.js';
3
- export * from '@mtcute/core/methods.js';
4
- //# sourceMappingURL=methods.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,cAAc,yBAAyB,CAAA","sourcesContent":["export { downloadToFile } from './methods/download-file.js'\nexport { downloadAsNodeStream } from './methods/download-node-stream.js'\nexport * from '@mtcute/core/methods.js'\n"]}
@@ -1,22 +0,0 @@
1
- import sqlite3 from 'better-sqlite3';
2
- import { BaseSqliteStorageDriver } from '@mtcute/core';
3
- export class SqliteStorageDriver extends BaseSqliteStorageDriver {
4
- filename;
5
- params;
6
- constructor(filename = ':memory:', params) {
7
- super();
8
- this.filename = filename;
9
- this.params = params;
10
- }
11
- _createDatabase() {
12
- const db = sqlite3(this.filename, {
13
- ...this.params?.options,
14
- verbose: this._log.mgr.level >= 5 ? this._log.verbose : undefined,
15
- });
16
- if (!this.params?.disableWal) {
17
- db.pragma('journal_mode = WAL');
18
- }
19
- return db;
20
- }
21
- }
22
- //# sourceMappingURL=driver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"driver.js","sourceRoot":"","sources":["../../../src/sqlite/driver.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,gBAAgB,CAAA;AAEpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAqBtD,MAAM,OAAO,mBAAoB,SAAQ,uBAAuB;IAE/C;IACA;IAFb,YACa,WAAW,UAAU,EACrB,MAA+C;QAExD,KAAK,EAAE,CAAA;QAHE,aAAQ,GAAR,QAAQ,CAAa;QACrB,WAAM,GAAN,MAAM,CAAyC;IAG5D,CAAC;IAED,eAAe;QACX,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC9B,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO;YACvB,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,IAAI,CAAC,OAA8B,CAAC,CAAC,CAAC,SAAS;SAC5F,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;YAC3B,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;QACnC,CAAC;QAED,OAAO,EAAqB,CAAA;IAChC,CAAC;CACJ","sourcesContent":["import type { Options } from 'better-sqlite3'\nimport sqlite3 from 'better-sqlite3'\nimport type { ISqliteDatabase } from '@mtcute/core'\nimport { BaseSqliteStorageDriver } from '@mtcute/core'\n\nexport interface SqliteStorageDriverOptions {\n /**\n * By default, WAL mode is enabled, which\n * significantly improves performance.\n * [Learn more](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/performance.md)\n *\n * However, you might encounter some issues,\n * and if you do, you can disable WAL by passing `true`\n *\n * @default false\n */\n disableWal?: boolean\n\n /**\n * Additional options to pass to `better-sqlite3`\n */\n options?: Options\n}\n\nexport class SqliteStorageDriver extends BaseSqliteStorageDriver {\n constructor(\n readonly filename = ':memory:',\n readonly params?: SqliteStorageDriverOptions | undefined,\n ) {\n super()\n }\n\n _createDatabase(): ISqliteDatabase {\n const db = sqlite3(this.filename, {\n ...this.params?.options,\n verbose: this._log.mgr.level >= 5 ? (this._log.verbose as Options['verbose']) : undefined,\n })\n\n if (!this.params?.disableWal) {\n db.pragma('journal_mode = WAL')\n }\n\n return db as ISqliteDatabase\n }\n}\n"]}
@@ -1,13 +0,0 @@
1
- import { BaseSqliteStorage } from '@mtcute/core';
2
- import { SqliteStorageDriver } from './driver.js';
3
- export { SqliteStorageDriver } from './driver.js';
4
- export class SqliteStorage extends BaseSqliteStorage {
5
- filename;
6
- params;
7
- constructor(filename = ':memory:', params) {
8
- super(new SqliteStorageDriver(filename, params));
9
- this.filename = filename;
10
- this.params = params;
11
- }
12
- }
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sqlite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAGhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAEnC;IACA;IAFb,YACa,WAAW,UAAU,EACrB,MAA+C;QAExD,KAAK,CAAC,IAAI,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;QAHvC,aAAQ,GAAR,QAAQ,CAAa;QACrB,WAAM,GAAN,MAAM,CAAyC;IAG5D,CAAC;CACJ","sourcesContent":["import { BaseSqliteStorage } from '@mtcute/core'\n\nimport type { SqliteStorageDriverOptions } from './driver.js'\nimport { SqliteStorageDriver } from './driver.js'\n\nexport { SqliteStorageDriver } from './driver.js'\n\nexport class SqliteStorage extends BaseSqliteStorage {\n constructor(\n readonly filename = ':memory:',\n readonly params?: SqliteStorageDriverOptions | undefined,\n ) {\n super(new SqliteStorageDriver(filename, params))\n }\n}\n"]}
@@ -1,16 +0,0 @@
1
- import type { IAesCtr, ICryptoProvider, IEncryptionScheme } from '@mtcute/core/utils.js';
2
- import { BaseCryptoProvider } from '@mtcute/core/utils.js';
3
- export declare abstract class BaseNodeCryptoProvider extends BaseCryptoProvider {
4
- createAesCtr(key: Uint8Array, iv: Uint8Array): IAesCtr;
5
- pbkdf2(password: Uint8Array, salt: Uint8Array, iterations: number, keylen?: number, algo?: string): Promise<Uint8Array>;
6
- sha1(data: Uint8Array): Uint8Array;
7
- sha256(data: Uint8Array): Uint8Array;
8
- hmacSha256(data: Uint8Array, key: Uint8Array): Uint8Array;
9
- gzip(data: Uint8Array, maxSize: number): Uint8Array | null;
10
- gunzip(data: Uint8Array): Uint8Array;
11
- randomFill(buf: Uint8Array): void;
12
- }
13
- export declare class NodeCryptoProvider extends BaseNodeCryptoProvider implements ICryptoProvider {
14
- initialize(): Promise<void>;
15
- createAesIge(key: Uint8Array, iv: Uint8Array): IEncryptionScheme;
16
- }
@@ -1,69 +0,0 @@
1
- import { createCipheriv, createHash, createHmac, pbkdf2, randomFillSync } from 'node:crypto';
2
- import { readFile } from 'node:fs/promises';
3
- import { createRequire } from 'node:module';
4
- import { deflateSync, gunzipSync } from 'node:zlib';
5
- import { BaseCryptoProvider } from '@mtcute/core/utils.js';
6
- import { ige256Decrypt, ige256Encrypt, initSync } from '@mtcute/wasm';
7
- export class BaseNodeCryptoProvider extends BaseCryptoProvider {
8
- createAesCtr(key, iv) {
9
- const cipher = createCipheriv(`aes-${key.length * 8}-ctr`, key, iv);
10
- const update = (data) => cipher.update(data);
11
- return {
12
- process: update,
13
- };
14
- }
15
- pbkdf2(password, salt, iterations, keylen = 64, algo = 'sha512') {
16
- return new Promise((resolve, reject) => pbkdf2(password, salt, iterations, keylen, algo, (err, buf) => err !== null ? reject(err) : resolve(buf)));
17
- }
18
- sha1(data) {
19
- return createHash('sha1').update(data).digest();
20
- }
21
- sha256(data) {
22
- return createHash('sha256').update(data).digest();
23
- }
24
- hmacSha256(data, key) {
25
- return createHmac('sha256', key).update(data).digest();
26
- }
27
- gzip(data, maxSize) {
28
- try {
29
- // telegram accepts both zlib and gzip, but zlib is faster and has less overhead, so we use it here
30
- return deflateSync(data, {
31
- maxOutputLength: maxSize,
32
- });
33
- // hot path, avoid additional runtime checks
34
- }
35
- catch (e) {
36
- if (e.code === 'ERR_BUFFER_TOO_LARGE') {
37
- return null;
38
- }
39
- throw e;
40
- }
41
- }
42
- gunzip(data) {
43
- return gunzipSync(data);
44
- }
45
- randomFill(buf) {
46
- randomFillSync(buf);
47
- }
48
- }
49
- export class NodeCryptoProvider extends BaseNodeCryptoProvider {
50
- async initialize() {
51
- // @only-if-esm
52
- const require = createRequire(import.meta.url);
53
- // @/only-if-esm
54
- const wasmFile = require.resolve('@mtcute/wasm/mtcute.wasm');
55
- const wasm = await readFile(wasmFile);
56
- initSync(wasm);
57
- }
58
- createAesIge(key, iv) {
59
- return {
60
- encrypt(data) {
61
- return ige256Encrypt(data, key, iv);
62
- },
63
- decrypt(data) {
64
- return ige256Decrypt(data, key, iv);
65
- },
66
- };
67
- }
68
- }
69
- //# sourceMappingURL=crypto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/utils/crypto.ts"],"names":[],"mappings":"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","sourcesContent":["import { createCipheriv, createHash, createHmac, pbkdf2, randomFillSync } from 'node:crypto'\nimport { readFile } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { deflateSync, gunzipSync } from 'node:zlib'\n\nimport type { IAesCtr, ICryptoProvider, IEncryptionScheme } from '@mtcute/core/utils.js'\nimport { BaseCryptoProvider } from '@mtcute/core/utils.js'\nimport { ige256Decrypt, ige256Encrypt, initSync } from '@mtcute/wasm'\n\nexport abstract class BaseNodeCryptoProvider extends BaseCryptoProvider {\n createAesCtr(key: Uint8Array, iv: Uint8Array): IAesCtr {\n const cipher = createCipheriv(`aes-${key.length * 8}-ctr`, key, iv)\n\n const update = (data: Uint8Array) => cipher.update(data)\n\n return {\n process: update,\n }\n }\n\n pbkdf2(\n password: Uint8Array,\n salt: Uint8Array,\n iterations: number,\n keylen = 64,\n algo = 'sha512',\n ): Promise<Uint8Array> {\n return new Promise((resolve, reject) =>\n pbkdf2(password, salt, iterations, keylen, algo, (err: Error | null, buf: Uint8Array) =>\n err !== null ? reject(err) : resolve(buf)),\n )\n }\n\n sha1(data: Uint8Array): Uint8Array {\n return createHash('sha1').update(data).digest()\n }\n\n sha256(data: Uint8Array): Uint8Array {\n return createHash('sha256').update(data).digest()\n }\n\n hmacSha256(data: Uint8Array, key: Uint8Array): Uint8Array {\n return createHmac('sha256', key).update(data).digest()\n }\n\n gzip(data: Uint8Array, maxSize: number): Uint8Array | null {\n try {\n // telegram accepts both zlib and gzip, but zlib is faster and has less overhead, so we use it here\n return deflateSync(data, {\n maxOutputLength: maxSize,\n })\n // hot path, avoid additional runtime checks\n } catch (e: any) {\n if (e.code === 'ERR_BUFFER_TOO_LARGE') {\n return null\n }\n\n throw e\n }\n }\n\n gunzip(data: Uint8Array): Uint8Array {\n return gunzipSync(data)\n }\n\n randomFill(buf: Uint8Array): void {\n randomFillSync(buf)\n }\n}\n\nexport class NodeCryptoProvider extends BaseNodeCryptoProvider implements ICryptoProvider {\n async initialize(): Promise<void> {\n // @only-if-esm\n const require = createRequire(import.meta.url)\n // @/only-if-esm\n const wasmFile = require.resolve('@mtcute/wasm/mtcute.wasm')\n const wasm = await readFile(wasmFile)\n initSync(wasm)\n }\n\n createAesIge(key: Uint8Array, iv: Uint8Array): IEncryptionScheme {\n return {\n encrypt(data: Uint8Array): Uint8Array {\n return ige256Encrypt(data, key, iv)\n },\n decrypt(data: Uint8Array): Uint8Array {\n return ige256Decrypt(data, key, iv)\n },\n }\n }\n}\n"]}
@@ -1,6 +0,0 @@
1
- import type { UploadFileLike } from '@mtcute/core';
2
- export declare function normalizeFile(file: UploadFileLike): Promise<{
3
- file: UploadFileLike;
4
- fileName?: string | undefined;
5
- fileSize?: number;
6
- } | null>;
@@ -1,27 +0,0 @@
1
- import { ReadStream, createReadStream } from 'node:fs';
2
- import { stat } from 'node:fs/promises';
3
- import { basename } from 'node:path';
4
- import { Readable } from 'node:stream';
5
- import { nodeStreamToWeb } from './stream-utils.js';
6
- export async function normalizeFile(file) {
7
- if (typeof file === 'string') {
8
- file = createReadStream(file);
9
- }
10
- if (file instanceof ReadStream) {
11
- const fileName = basename(file.path.toString());
12
- const fileSize = await stat(file.path.toString()).then(stat => stat.size);
13
- return {
14
- file: nodeStreamToWeb(file),
15
- fileName,
16
- fileSize,
17
- };
18
- }
19
- if (file instanceof Readable) {
20
- return {
21
- file: nodeStreamToWeb(file),
22
- };
23
- }
24
- // string -> ReadStream, thus already handled
25
- return null;
26
- }
27
- //# sourceMappingURL=normalize-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-file.js","sourceRoot":"","sources":["../../../src/utils/normalize-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAItC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAoB;IAKpD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;IACjC,CAAC;IAED,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC/C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEzE,OAAO;YACH,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;YAC3B,QAAQ;YACR,QAAQ;SACX,CAAA;IACL,CAAC;IAED,IAAI,IAAI,YAAY,QAAQ,EAAE,CAAC;QAC3B,OAAO;YACH,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;SAC9B,CAAA;IACL,CAAC;IAED,6CAA6C;IAC7C,OAAO,IAAI,CAAA;AACf,CAAC","sourcesContent":["import { ReadStream, createReadStream } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { basename } from 'node:path'\nimport { Readable } from 'node:stream'\n\nimport type { UploadFileLike } from '@mtcute/core'\n\nimport { nodeStreamToWeb } from './stream-utils.js'\n\nexport async function normalizeFile(file: UploadFileLike): Promise<{\n file: UploadFileLike\n fileName?: string | undefined\n fileSize?: number\n} | null> {\n if (typeof file === 'string') {\n file = createReadStream(file)\n }\n\n if (file instanceof ReadStream) {\n const fileName = basename(file.path.toString())\n const fileSize = await stat(file.path.toString()).then(stat => stat.size)\n\n return {\n file: nodeStreamToWeb(file),\n fileName,\n fileSize,\n }\n }\n\n if (file instanceof Readable) {\n return {\n file: nodeStreamToWeb(file),\n }\n }\n\n // string -> ReadStream, thus already handled\n return null\n}\n"]}
@@ -1,3 +0,0 @@
1
- import { Readable } from 'node:stream';
2
- export declare function nodeStreamToWeb(stream: Readable): ReadableStream<Uint8Array>;
3
- export declare function webStreamToNode(stream: ReadableStream<Uint8Array>): Readable;
@@ -1,72 +0,0 @@
1
- import { Readable } from 'node:stream';
2
- import { isNodeVersionAfter } from './version.js';
3
- export function nodeStreamToWeb(stream) {
4
- if (typeof Readable.toWeb === 'function') {
5
- return Readable.toWeb(stream);
6
- }
7
- // otherwise, use a silly little adapter
8
- stream.pause();
9
- return new ReadableStream({
10
- start(c) {
11
- stream.on('data', (chunk) => {
12
- c.enqueue(chunk);
13
- });
14
- stream.on('end', () => {
15
- c.close();
16
- });
17
- stream.on('error', (err) => {
18
- c.error(err);
19
- });
20
- },
21
- pull() {
22
- stream.resume();
23
- },
24
- });
25
- }
26
- export function webStreamToNode(stream) {
27
- if (typeof Readable.fromWeb === 'function'
28
- && isNodeVersionAfter(18, 13, 0) // https://github.com/nodejs/node/issues/42694
29
- ) {
30
- // @ts-expect-error node typings are wrong lmao
31
- return Readable.fromWeb(stream);
32
- }
33
- const reader = stream.getReader();
34
- let ended = false;
35
- const readable = new Readable({
36
- async read() {
37
- try {
38
- const { done, value } = await reader.read();
39
- if (done) {
40
- this.push(null);
41
- }
42
- else {
43
- this.push(Buffer.from(value.buffer, value.byteOffset, value.byteLength));
44
- }
45
- }
46
- catch (err) {
47
- this.destroy(err);
48
- }
49
- },
50
- destroy(error, cb) {
51
- if (!ended) {
52
- void reader
53
- .cancel(error)
54
- .catch(() => { })
55
- .then(() => {
56
- cb(error);
57
- });
58
- return;
59
- }
60
- cb(error);
61
- },
62
- });
63
- reader.closed
64
- .then(() => {
65
- ended = true;
66
- })
67
- .catch((err) => {
68
- readable.destroy(err);
69
- });
70
- return readable;
71
- }
72
- //# sourceMappingURL=stream-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-utils.js","sourceRoot":"","sources":["../../../src/utils/stream-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,UAAU,eAAe,CAAC,MAAgB;IAC5C,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QACvC,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,CAA0C,CAAA;IAC1E,CAAC;IAED,wCAAwC;IAExC,MAAM,CAAC,KAAK,EAAE,CAAA;IAEd,OAAO,IAAI,cAAc,CAAC;QACtB,KAAK,CAAC,CAAC;YACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBACxB,CAAC,CAAC,OAAO,CAAC,KAAmB,CAAC,CAAA;YAClC,CAAC,CAAC,CAAA;YACF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBAClB,CAAC,CAAC,KAAK,EAAE,CAAA;YACb,CAAC,CAAC,CAAA;YACF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACvB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAChB,CAAC,CAAC,CAAA;QACN,CAAC;QACD,IAAI;YACA,MAAM,CAAC,MAAM,EAAE,CAAA;QACnB,CAAC;KACJ,CAAC,CAAA;AACN,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAkC;IAC9D,IACI,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU;WACnC,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,8CAA8C;MACjF,CAAC;QACC,+CAA+C;QAC/C,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACnC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;IACjC,IAAI,KAAK,GAAG,KAAK,CAAA;IAEjB,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC;QAC1B,KAAK,CAAC,IAAI;YACN,IAAI,CAAC;gBACD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;gBAE3C,IAAI,IAAI,EAAE,CAAC;oBACP,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACnB,CAAC;qBAAM,CAAC;oBACJ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA;gBAC5E,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,IAAI,CAAC,OAAO,CAAC,GAAY,CAAC,CAAA;YAC9B,CAAC;QACL,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,EAAE;YACb,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,KAAK,MAAM;qBACN,MAAM,CAAC,KAAK,CAAC;qBACb,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;qBACf,IAAI,CAAC,GAAG,EAAE;oBACP,EAAE,CAAC,KAAK,CAAC,CAAA;gBACb,CAAC,CAAC,CAAA;gBAEN,OAAM;YACV,CAAC;YAED,EAAE,CAAC,KAAK,CAAC,CAAA;QACb,CAAC;KACJ,CAAC,CAAA;IAEF,MAAM,CAAC,MAAM;SACR,IAAI,CAAC,GAAG,EAAE;QACP,KAAK,GAAG,IAAI,CAAA;IAChB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,QAAQ,CAAC,OAAO,CAAC,GAAY,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEN,OAAO,QAAQ,CAAA;AACnB,CAAC","sourcesContent":["import { Readable } from 'node:stream'\n\nimport { isNodeVersionAfter } from './version.js'\n\nexport function nodeStreamToWeb(stream: Readable): ReadableStream<Uint8Array> {\n if (typeof Readable.toWeb === 'function') {\n return Readable.toWeb(stream) as unknown as ReadableStream<Uint8Array>\n }\n\n // otherwise, use a silly little adapter\n\n stream.pause()\n\n return new ReadableStream({\n start(c) {\n stream.on('data', (chunk) => {\n c.enqueue(chunk as Uint8Array)\n })\n stream.on('end', () => {\n c.close()\n })\n stream.on('error', (err) => {\n c.error(err)\n })\n },\n pull() {\n stream.resume()\n },\n })\n}\n\nexport function webStreamToNode(stream: ReadableStream<Uint8Array>): Readable {\n if (\n typeof Readable.fromWeb === 'function'\n && isNodeVersionAfter(18, 13, 0) // https://github.com/nodejs/node/issues/42694\n ) {\n // @ts-expect-error node typings are wrong lmao\n return Readable.fromWeb(stream)\n }\n\n const reader = stream.getReader()\n let ended = false\n\n const readable = new Readable({\n async read() {\n try {\n const { done, value } = await reader.read()\n\n if (done) {\n this.push(null)\n } else {\n this.push(Buffer.from(value.buffer, value.byteOffset, value.byteLength))\n }\n } catch (err) {\n this.destroy(err as Error)\n }\n },\n destroy(error, cb) {\n if (!ended) {\n void reader\n .cancel(error)\n .catch(() => {})\n .then(() => {\n cb(error)\n })\n\n return\n }\n\n cb(error)\n },\n })\n\n reader.closed\n .then(() => {\n ended = true\n })\n .catch((err) => {\n readable.destroy(err as Error)\n })\n\n return readable\n}\n"]}
@@ -1,30 +0,0 @@
1
- import EventEmitter from 'node:events';
2
- import type { Socket } from 'node:net';
3
- import type { IPacketCodec, ITelegramTransport } from '@mtcute/core';
4
- import { IntermediatePacketCodec, TransportState } from '@mtcute/core';
5
- import type { BasicDcOption, ICryptoProvider, Logger } from '@mtcute/core/utils.js';
6
- /**
7
- * Base for TCP transports.
8
- * Subclasses must provide packet codec in `_packetCodec` property
9
- */
10
- export declare abstract class BaseTcpTransport extends EventEmitter implements ITelegramTransport {
11
- protected _currentDc: BasicDcOption | null;
12
- protected _state: TransportState;
13
- protected _socket: Socket | null;
14
- abstract _packetCodec: IPacketCodec;
15
- protected _crypto: ICryptoProvider;
16
- protected log: Logger;
17
- packetCodecInitialized: boolean;
18
- private _updateLogPrefix;
19
- setup(crypto: ICryptoProvider, log: Logger): void;
20
- state(): TransportState;
21
- currentDc(): BasicDcOption | null;
22
- connect(dc: BasicDcOption, testMode: boolean): void;
23
- close(): void;
24
- handleError(error: Error): void;
25
- handleConnect(): void;
26
- send(bytes: Uint8Array): Promise<void>;
27
- }
28
- export declare class TcpTransport extends BaseTcpTransport {
29
- _packetCodec: IntermediatePacketCodec;
30
- }