@mtcute/node 0.1.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.
- package/LICENSE +8 -0
- package/README.md +19 -0
- package/cjs/index.d.ts +43 -0
- package/cjs/index.js +78 -0
- package/cjs/index.js.map +1 -0
- package/cjs/package.json +3 -0
- package/cjs/utils.d.ts +1 -0
- package/cjs/utils.js +18 -0
- package/cjs/utils.js.map +1 -0
- package/esm/index.d.ts +43 -0
- package/esm/index.js +63 -0
- package/esm/index.js.map +1 -0
- package/esm/utils.d.ts +1 -0
- package/esm/utils.js +2 -0
- package/esm/utils.js.map +1 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright 2023 Alina Sireneva
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @mtcute/node
|
|
2
|
+
|
|
3
|
+
📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_node.html)
|
|
4
|
+
|
|
5
|
+
All-in-one package for NodeJS. Includes support for native crypto addon
|
|
6
|
+
(must be installed separately, `@mtcute/crypto-node`), terminal I/O via
|
|
7
|
+
`readline` and comes with pre-installed HTML and Markdown parsers.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { NodeTelegramClient } from '@mtcute/node'
|
|
13
|
+
|
|
14
|
+
const tg = new NodeTelegramClient({
|
|
15
|
+
apiId: 12345,
|
|
16
|
+
apiHash: 'abcdef',
|
|
17
|
+
storage: 'my-account'
|
|
18
|
+
})
|
|
19
|
+
```
|
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TelegramClient, TelegramClientOptions } from '@mtcute/client';
|
|
2
|
+
import { SqliteStorage } from '@mtcute/sqlite';
|
|
3
|
+
export * from '@mtcute/client';
|
|
4
|
+
export * from '@mtcute/html-parser';
|
|
5
|
+
export * from '@mtcute/markdown-parser';
|
|
6
|
+
export { SqliteStorage };
|
|
7
|
+
export interface NodeTelegramClientOptions extends Omit<TelegramClientOptions, 'storage'> {
|
|
8
|
+
/**
|
|
9
|
+
* Storage to use.
|
|
10
|
+
*
|
|
11
|
+
* You can pass a file name as a simple string,
|
|
12
|
+
* which will be passed directly to `SqliteStorage`
|
|
13
|
+
*
|
|
14
|
+
* Defaults to SQLite storage in `client.session` file in
|
|
15
|
+
* current working directory
|
|
16
|
+
*/
|
|
17
|
+
storage?: TelegramClientOptions['storage'] | string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tiny wrapper over {@link TelegramClient} for usage inside Node JS.
|
|
21
|
+
*
|
|
22
|
+
* This automatically sets the parse modes, native
|
|
23
|
+
* crypto addon and defaults to SQLite session.
|
|
24
|
+
*
|
|
25
|
+
* Documentation for this class only contains the
|
|
26
|
+
* difference between {@link TelegramClient} and {@link NodeTelegramClient}.
|
|
27
|
+
* For the complete documentation, please refer to {@link TelegramClient}.
|
|
28
|
+
*/
|
|
29
|
+
export declare class NodeTelegramClient extends TelegramClient {
|
|
30
|
+
constructor(opts: NodeTelegramClientOptions);
|
|
31
|
+
private _rl?;
|
|
32
|
+
/**
|
|
33
|
+
* Tiny wrapper over Node `readline` package
|
|
34
|
+
* for simpler user input for `.run()` method.
|
|
35
|
+
*
|
|
36
|
+
* Associated `readline` interface is closed
|
|
37
|
+
* after `run()` returns, or with the client.
|
|
38
|
+
*
|
|
39
|
+
* @param text Text of the question
|
|
40
|
+
*/
|
|
41
|
+
input(text: string): Promise<string>;
|
|
42
|
+
close(): Promise<void>;
|
|
43
|
+
}
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.NodeTelegramClient = exports.SqliteStorage = void 0;
|
|
18
|
+
const readline_1 = require("readline");
|
|
19
|
+
const client_1 = require("@mtcute/client");
|
|
20
|
+
const sqlite_1 = require("@mtcute/sqlite");
|
|
21
|
+
Object.defineProperty(exports, "SqliteStorage", { enumerable: true, get: function () { return sqlite_1.SqliteStorage; } });
|
|
22
|
+
__exportStar(require("@mtcute/client"), exports);
|
|
23
|
+
__exportStar(require("@mtcute/html-parser"), exports);
|
|
24
|
+
__exportStar(require("@mtcute/markdown-parser"), exports);
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
let nativeCrypto;
|
|
27
|
+
try {
|
|
28
|
+
//
|
|
29
|
+
// eslint-disable-next-line
|
|
30
|
+
nativeCrypto = require('@mtcute/crypto-node').NodeNativeCryptoProvider;
|
|
31
|
+
}
|
|
32
|
+
catch (e) { }
|
|
33
|
+
/**
|
|
34
|
+
* Tiny wrapper over {@link TelegramClient} for usage inside Node JS.
|
|
35
|
+
*
|
|
36
|
+
* This automatically sets the parse modes, native
|
|
37
|
+
* crypto addon and defaults to SQLite session.
|
|
38
|
+
*
|
|
39
|
+
* Documentation for this class only contains the
|
|
40
|
+
* difference between {@link TelegramClient} and {@link NodeTelegramClient}.
|
|
41
|
+
* For the complete documentation, please refer to {@link TelegramClient}.
|
|
42
|
+
*/
|
|
43
|
+
class NodeTelegramClient extends client_1.TelegramClient {
|
|
44
|
+
constructor(opts) {
|
|
45
|
+
super({
|
|
46
|
+
// eslint-disable-next-line
|
|
47
|
+
crypto: nativeCrypto ? () => new nativeCrypto() : undefined,
|
|
48
|
+
...opts,
|
|
49
|
+
storage: typeof opts.storage === 'string' ?
|
|
50
|
+
new sqlite_1.SqliteStorage(opts.storage) :
|
|
51
|
+
opts.storage ?? new sqlite_1.SqliteStorage('client.session'),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Tiny wrapper over Node `readline` package
|
|
56
|
+
* for simpler user input for `.run()` method.
|
|
57
|
+
*
|
|
58
|
+
* Associated `readline` interface is closed
|
|
59
|
+
* after `run()` returns, or with the client.
|
|
60
|
+
*
|
|
61
|
+
* @param text Text of the question
|
|
62
|
+
*/
|
|
63
|
+
input(text) {
|
|
64
|
+
if (!this._rl) {
|
|
65
|
+
this._rl = (0, readline_1.createInterface)({
|
|
66
|
+
input: process.stdin,
|
|
67
|
+
output: process.stdout,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return new Promise((res) => this._rl?.question(text, res));
|
|
71
|
+
}
|
|
72
|
+
close() {
|
|
73
|
+
this._rl?.close();
|
|
74
|
+
return super.close();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.NodeTelegramClient = NodeTelegramClient;
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,uCAAoE;AAEpE,2CAAsE;AACtE,2CAA8C;AAKrC,8FALA,sBAAa,OAKA;AAHtB,iDAA8B;AAC9B,sDAAmC;AACnC,0DAAuC;AAGvC,8DAA8D;AAC9D,IAAI,YAAiB,CAAA;AAErB,IAAI;IACA,GAAG;IACH,2BAA2B;IAC3B,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC,wBAAwB,CAAA;CACzE;AAAC,OAAO,CAAC,EAAE,GAAE;AAed;;;;;;;;;GASG;AACH,MAAa,kBAAmB,SAAQ,uBAAc;IAClD,YAAY,IAA+B;QACvC,KAAK,CAAC;YACF,2BAA2B;YAC3B,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,SAAS;YAC3D,GAAG,IAAI;YACP,OAAO,EACH,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;gBAC9B,IAAI,sBAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBACjC,IAAI,CAAC,OAAO,IAAI,IAAI,sBAAa,CAAC,gBAAgB,CAAC;SAC9D,CAAC,CAAA;IACN,CAAC;IAID;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAY;QACd,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YACX,IAAI,CAAC,GAAG,GAAG,IAAA,0BAAe,EAAC;gBACvB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;aACzB,CAAC,CAAA;SACL;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,KAAK;QACD,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAA;QAEjB,OAAO,KAAK,CAAC,KAAK,EAAE,CAAA;IACxB,CAAC;CACJ;AAxCD,gDAwCC","sourcesContent":["import { createRequire } from 'module'\nimport { createInterface, Interface as RlInterface } from 'readline'\n\nimport { TelegramClient, TelegramClientOptions } from '@mtcute/client'\nimport { SqliteStorage } from '@mtcute/sqlite'\n\nexport * from '@mtcute/client'\nexport * from '@mtcute/html-parser'\nexport * from '@mtcute/markdown-parser'\nexport { SqliteStorage }\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet nativeCrypto: any\n\ntry {\n // \n // eslint-disable-next-line\n nativeCrypto = require('@mtcute/crypto-node').NodeNativeCryptoProvider\n} catch (e) {}\n\nexport interface NodeTelegramClientOptions extends Omit<TelegramClientOptions, 'storage'> {\n /**\n * Storage to use.\n *\n * You can pass a file name as a simple string,\n * which will be passed directly to `SqliteStorage`\n *\n * Defaults to SQLite storage in `client.session` file in\n * current working directory\n */\n storage?: TelegramClientOptions['storage'] | string\n}\n\n/**\n * Tiny wrapper over {@link TelegramClient} for usage inside Node JS.\n *\n * This automatically sets the parse modes, native\n * crypto addon and defaults to SQLite session.\n *\n * Documentation for this class only contains the\n * difference between {@link TelegramClient} and {@link NodeTelegramClient}.\n * For the complete documentation, please refer to {@link TelegramClient}.\n */\nexport class NodeTelegramClient extends TelegramClient {\n constructor(opts: NodeTelegramClientOptions) {\n super({\n // eslint-disable-next-line\n crypto: nativeCrypto ? () => new nativeCrypto() : undefined,\n ...opts,\n storage:\n typeof opts.storage === 'string' ?\n new SqliteStorage(opts.storage) :\n opts.storage ?? new SqliteStorage('client.session'),\n })\n }\n\n private _rl?: RlInterface\n\n /**\n * Tiny wrapper over Node `readline` package\n * for simpler user input for `.run()` method.\n *\n * Associated `readline` interface is closed\n * after `run()` returns, or with the client.\n *\n * @param text Text of the question\n */\n input(text: string): Promise<string> {\n if (!this._rl) {\n this._rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n }\n\n return new Promise((res) => this._rl?.question(text, res))\n }\n\n close(): Promise<void> {\n this._rl?.close()\n\n return super.close()\n }\n}\n"]}
|
package/cjs/package.json
ADDED
package/cjs/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mtcute/client/utils.js';
|
package/cjs/utils.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@mtcute/client/utils.js"), exports);
|
|
18
|
+
//# sourceMappingURL=utils.js.map
|
package/cjs/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC","sourcesContent":["export * from '@mtcute/client/utils.js'\n"]}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TelegramClient, TelegramClientOptions } from '@mtcute/client';
|
|
2
|
+
import { SqliteStorage } from '@mtcute/sqlite';
|
|
3
|
+
export * from '@mtcute/client';
|
|
4
|
+
export * from '@mtcute/html-parser';
|
|
5
|
+
export * from '@mtcute/markdown-parser';
|
|
6
|
+
export { SqliteStorage };
|
|
7
|
+
export interface NodeTelegramClientOptions extends Omit<TelegramClientOptions, 'storage'> {
|
|
8
|
+
/**
|
|
9
|
+
* Storage to use.
|
|
10
|
+
*
|
|
11
|
+
* You can pass a file name as a simple string,
|
|
12
|
+
* which will be passed directly to `SqliteStorage`
|
|
13
|
+
*
|
|
14
|
+
* Defaults to SQLite storage in `client.session` file in
|
|
15
|
+
* current working directory
|
|
16
|
+
*/
|
|
17
|
+
storage?: TelegramClientOptions['storage'] | string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tiny wrapper over {@link TelegramClient} for usage inside Node JS.
|
|
21
|
+
*
|
|
22
|
+
* This automatically sets the parse modes, native
|
|
23
|
+
* crypto addon and defaults to SQLite session.
|
|
24
|
+
*
|
|
25
|
+
* Documentation for this class only contains the
|
|
26
|
+
* difference between {@link TelegramClient} and {@link NodeTelegramClient}.
|
|
27
|
+
* For the complete documentation, please refer to {@link TelegramClient}.
|
|
28
|
+
*/
|
|
29
|
+
export declare class NodeTelegramClient extends TelegramClient {
|
|
30
|
+
constructor(opts: NodeTelegramClientOptions);
|
|
31
|
+
private _rl?;
|
|
32
|
+
/**
|
|
33
|
+
* Tiny wrapper over Node `readline` package
|
|
34
|
+
* for simpler user input for `.run()` method.
|
|
35
|
+
*
|
|
36
|
+
* Associated `readline` interface is closed
|
|
37
|
+
* after `run()` returns, or with the client.
|
|
38
|
+
*
|
|
39
|
+
* @param text Text of the question
|
|
40
|
+
*/
|
|
41
|
+
input(text: string): Promise<string>;
|
|
42
|
+
close(): Promise<void>;
|
|
43
|
+
}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { createInterface } from 'readline';
|
|
3
|
+
import { TelegramClient } from '@mtcute/client';
|
|
4
|
+
import { SqliteStorage } from '@mtcute/sqlite';
|
|
5
|
+
export * from '@mtcute/client';
|
|
6
|
+
export * from '@mtcute/html-parser';
|
|
7
|
+
export * from '@mtcute/markdown-parser';
|
|
8
|
+
export { SqliteStorage };
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
let nativeCrypto;
|
|
11
|
+
try {
|
|
12
|
+
// @only-if-esm
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
// @/only-if-esm
|
|
15
|
+
// eslint-disable-next-line
|
|
16
|
+
nativeCrypto = require('@mtcute/crypto-node').NodeNativeCryptoProvider;
|
|
17
|
+
}
|
|
18
|
+
catch (e) { }
|
|
19
|
+
/**
|
|
20
|
+
* Tiny wrapper over {@link TelegramClient} for usage inside Node JS.
|
|
21
|
+
*
|
|
22
|
+
* This automatically sets the parse modes, native
|
|
23
|
+
* crypto addon and defaults to SQLite session.
|
|
24
|
+
*
|
|
25
|
+
* Documentation for this class only contains the
|
|
26
|
+
* difference between {@link TelegramClient} and {@link NodeTelegramClient}.
|
|
27
|
+
* For the complete documentation, please refer to {@link TelegramClient}.
|
|
28
|
+
*/
|
|
29
|
+
export class NodeTelegramClient extends TelegramClient {
|
|
30
|
+
constructor(opts) {
|
|
31
|
+
super({
|
|
32
|
+
// eslint-disable-next-line
|
|
33
|
+
crypto: nativeCrypto ? () => new nativeCrypto() : undefined,
|
|
34
|
+
...opts,
|
|
35
|
+
storage: typeof opts.storage === 'string' ?
|
|
36
|
+
new SqliteStorage(opts.storage) :
|
|
37
|
+
opts.storage ?? new SqliteStorage('client.session'),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Tiny wrapper over Node `readline` package
|
|
42
|
+
* for simpler user input for `.run()` method.
|
|
43
|
+
*
|
|
44
|
+
* Associated `readline` interface is closed
|
|
45
|
+
* after `run()` returns, or with the client.
|
|
46
|
+
*
|
|
47
|
+
* @param text Text of the question
|
|
48
|
+
*/
|
|
49
|
+
input(text) {
|
|
50
|
+
if (!this._rl) {
|
|
51
|
+
this._rl = createInterface({
|
|
52
|
+
input: process.stdin,
|
|
53
|
+
output: process.stdout,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return new Promise((res) => this._rl?.question(text, res));
|
|
57
|
+
}
|
|
58
|
+
close() {
|
|
59
|
+
this._rl?.close();
|
|
60
|
+
return super.close();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,eAAe,EAA4B,MAAM,UAAU,CAAA;AAEpE,OAAO,EAAE,cAAc,EAAyB,MAAM,gBAAgB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,CAAA;AAExB,8DAA8D;AAC9D,IAAI,YAAiB,CAAA;AAErB,IAAI;IACA,eAAe;IACf,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC9C,gBAAgB;IAChB,2BAA2B;IAC3B,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC,wBAAwB,CAAA;CACzE;AAAC,OAAO,CAAC,EAAE,GAAE;AAed;;;;;;;;;GASG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IAClD,YAAY,IAA+B;QACvC,KAAK,CAAC;YACF,2BAA2B;YAC3B,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,SAAS;YAC3D,GAAG,IAAI;YACP,OAAO,EACH,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;gBAC9B,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBACjC,IAAI,CAAC,OAAO,IAAI,IAAI,aAAa,CAAC,gBAAgB,CAAC;SAC9D,CAAC,CAAA;IACN,CAAC;IAID;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAY;QACd,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YACX,IAAI,CAAC,GAAG,GAAG,eAAe,CAAC;gBACvB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;aACzB,CAAC,CAAA;SACL;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,KAAK;QACD,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAA;QAEjB,OAAO,KAAK,CAAC,KAAK,EAAE,CAAA;IACxB,CAAC;CACJ","sourcesContent":["import { createRequire } from 'module'\nimport { createInterface, Interface as RlInterface } from 'readline'\n\nimport { TelegramClient, TelegramClientOptions } from '@mtcute/client'\nimport { SqliteStorage } from '@mtcute/sqlite'\n\nexport * from '@mtcute/client'\nexport * from '@mtcute/html-parser'\nexport * from '@mtcute/markdown-parser'\nexport { SqliteStorage }\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet nativeCrypto: any\n\ntry {\n // @only-if-esm\n const require = createRequire(import.meta.url)\n // @/only-if-esm\n // eslint-disable-next-line\n nativeCrypto = require('@mtcute/crypto-node').NodeNativeCryptoProvider\n} catch (e) {}\n\nexport interface NodeTelegramClientOptions extends Omit<TelegramClientOptions, 'storage'> {\n /**\n * Storage to use.\n *\n * You can pass a file name as a simple string,\n * which will be passed directly to `SqliteStorage`\n *\n * Defaults to SQLite storage in `client.session` file in\n * current working directory\n */\n storage?: TelegramClientOptions['storage'] | string\n}\n\n/**\n * Tiny wrapper over {@link TelegramClient} for usage inside Node JS.\n *\n * This automatically sets the parse modes, native\n * crypto addon and defaults to SQLite session.\n *\n * Documentation for this class only contains the\n * difference between {@link TelegramClient} and {@link NodeTelegramClient}.\n * For the complete documentation, please refer to {@link TelegramClient}.\n */\nexport class NodeTelegramClient extends TelegramClient {\n constructor(opts: NodeTelegramClientOptions) {\n super({\n // eslint-disable-next-line\n crypto: nativeCrypto ? () => new nativeCrypto() : undefined,\n ...opts,\n storage:\n typeof opts.storage === 'string' ?\n new SqliteStorage(opts.storage) :\n opts.storage ?? new SqliteStorage('client.session'),\n })\n }\n\n private _rl?: RlInterface\n\n /**\n * Tiny wrapper over Node `readline` package\n * for simpler user input for `.run()` method.\n *\n * Associated `readline` interface is closed\n * after `run()` returns, or with the client.\n *\n * @param text Text of the question\n */\n input(text: string): Promise<string> {\n if (!this._rl) {\n this._rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n }\n\n return new Promise((res) => this._rl?.question(text, res))\n }\n\n close(): Promise<void> {\n this._rl?.close()\n\n return super.close()\n }\n}\n"]}
|
package/esm/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mtcute/client/utils.js';
|
package/esm/utils.js
ADDED
package/esm/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../utils.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA","sourcesContent":["export * from '@mtcute/client/utils.js'\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mtcute/node",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Meta-package for Node JS",
|
|
5
|
+
"author": "Alina Sireneva <alina@tei.su>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "cjs/index.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@mtcute/client": "^0.1.0",
|
|
12
|
+
"@mtcute/sqlite": "^0.1.0",
|
|
13
|
+
"@mtcute/markdown-parser": "^0.1.0",
|
|
14
|
+
"@mtcute/html-parser": "^0.1.0"
|
|
15
|
+
},
|
|
16
|
+
"module": "esm/index.js",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./esm/index.js",
|
|
20
|
+
"require": "./cjs/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./utils.js": {
|
|
23
|
+
"import": "./esm/utils.js",
|
|
24
|
+
"require": "./cjs/utils.js"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|