@mtcute/convert 0.18.0-rc.5 → 0.18.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/dcs.d.cts +4 -0
- package/gramjs/__fixtures__/session.d.cts +1 -0
- package/gramjs/convert.d.cts +4 -0
- package/gramjs/convert.test.d.cts +1 -0
- package/gramjs/index.d.cts +4 -0
- package/gramjs/parse.d.cts +2 -0
- package/gramjs/parse.test.d.cts +1 -0
- package/gramjs/serialize.d.cts +2 -0
- package/gramjs/serialize.test.d.cts +1 -0
- package/gramjs/types.d.cts +7 -0
- package/index.d.cts +6 -0
- package/mtkruto/__fixtures__/session.d.cts +1 -0
- package/mtkruto/convert.d.cts +4 -0
- package/mtkruto/convert.test.d.cts +1 -0
- package/mtkruto/index.d.cts +4 -0
- package/mtkruto/parse.d.cts +2 -0
- package/mtkruto/parse.test.d.cts +1 -0
- package/mtkruto/serialize.d.cts +2 -0
- package/mtkruto/serialize.test.d.cts +1 -0
- package/mtkruto/types.d.cts +5 -0
- package/package.json +12 -12
- package/pyrogram/__fixtures__/session.d.cts +1 -0
- package/pyrogram/__fixtures__/session_old.d.cts +1 -0
- package/pyrogram/convert.d.cts +6 -0
- package/pyrogram/convert.test.d.cts +1 -0
- package/pyrogram/index.d.cts +4 -0
- package/pyrogram/parse.d.cts +2 -0
- package/pyrogram/parse.test.d.cts +1 -0
- package/pyrogram/serialize.d.cts +2 -0
- package/pyrogram/serialize.test.d.cts +1 -0
- package/pyrogram/types.d.cts +8 -0
- package/tdesktop/convert.d.cts +5 -0
- package/tdesktop/index.d.cts +5 -0
- package/tdesktop/qt-bundle.d.cts +3 -0
- package/tdesktop/qt-reader.d.cts +6 -0
- package/tdesktop/qt-writer.d.cts +6 -0
- package/tdesktop/tdata.d.cts +65 -0
- package/tdesktop/tdata.test.d.cts +1 -0
- package/tdesktop/types.d.cts +22 -0
- package/telethon/__fixtures__/session.d.cts +1 -0
- package/telethon/__fixtures__/session_v6.d.cts +1 -0
- package/telethon/convert.d.cts +4 -0
- package/telethon/convert.test.d.cts +1 -0
- package/telethon/index.d.cts +4 -0
- package/telethon/parse.d.cts +2 -0
- package/telethon/parse.test.d.cts +1 -0
- package/telethon/serialize.d.cts +2 -0
- package/telethon/serialize.test.d.cts +1 -0
- package/telethon/types.d.cts +7 -0
- package/types.d.cts +0 -0
- package/utils/crypto.d.cts +9 -0
- package/utils/fs.d.cts +11 -0
- package/utils/rle.d.cts +3 -0
package/dcs.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GRAMJS_SESSION = "1AgAOMTQ5LjE1NC4xNjcuNDABu60obcEYS8Yb/I7YlCwaLvW84dXCX2oGnBYG+zuMciJhHP99c8ZJvwxJgH8yU1QrqI+Gh0kK0JAuQucIpDfq/jJVLZ1ZRimq5yy1XbeEs65gtZA1+SUwZRXahh+NzGbPmOVUMCnCtRONo9GNvcx/QxSXRrh7T/K0YYN1iHsK1vJDk8/SUnthvTNmRycC+JLn4fMtctqP4Le2WPOH/deYbUF0BlwmR77M7fv1GZSInqCgWReaIl5nvn0IqA4mOCTkdOgcvwOiB2UmXwiyInxRuLdBIyLbBUDCuTlmL1m3FJqbuEpZEUJnoJf2YDFZ1wR6TfL0MUS1VwnjOcy3WIIFwwg=";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StringSessionData } from '@mtcute/core/utils.js';
|
|
2
|
+
import { TelethonSession } from '../telethon/types.js';
|
|
3
|
+
export declare function convertFromGramjsSession(session: TelethonSession | string): StringSessionData;
|
|
4
|
+
export declare function convertToGramjsSession(session: StringSessionData | string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MTKRUTO_SESSION = "BjItdGVzdAAB_gABAQABWEIKa07Ch-9zoA024mDOpsv20TW4YwuoRRROqSi41YQCbD3c4nKnz7BcFIu1mfn6f6Xm3OTVqoT0zib4p_AuZD9H-t8j5AagecRg-oSpQlmjoiUazKQSxnxWotGWf1mPNntAeOvDNa5t1NjXUxmqdB3e2AjYLF_E2jDESVgUuDBQUMBHIDc_xFBAlz6kVxCZ6iINJHbnyJ2F19tbEPFJvSM999RKaFj5lUUVs0qKNXEUmsFYUuIdPBzjWilY8Uvf9nYU_xXd9CUAAXS5_i4aaWlHoTIf3zn8ZEINhDIU1DMauh5vhSWt7F0fkxODjtou-7PdIunuDtqyQm4steuNJc8";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StringSessionData } from '@mtcute/core/utils.js';
|
|
2
|
+
import { MtkrutoSession } from './types.js';
|
|
3
|
+
export declare function convertFromMtkrutoSession(session: MtkrutoSession | string): StringSessionData;
|
|
4
|
+
export declare function convertToMtkrutoSession(session: StringSessionData | string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/convert",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.0
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"description": "Cross-library session conversion utilities",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://mtcute.dev",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/mtcute/mtcute.git"
|
|
11
|
-
},
|
|
12
|
-
"scripts": {},
|
|
13
7
|
"dependencies": {
|
|
14
|
-
"@mtcute/core": "0.18.0
|
|
15
|
-
"@fuman/utils": "0.0.
|
|
16
|
-
"@fuman/net": "0.0.
|
|
17
|
-
"@fuman/io": "0.0.
|
|
8
|
+
"@mtcute/core": "^0.18.0",
|
|
9
|
+
"@fuman/utils": "0.0.4",
|
|
10
|
+
"@fuman/net": "0.0.4",
|
|
11
|
+
"@fuman/io": "0.0.4"
|
|
18
12
|
},
|
|
19
13
|
"exports": {
|
|
20
14
|
".": {
|
|
@@ -29,5 +23,11 @@
|
|
|
29
23
|
}
|
|
30
24
|
},
|
|
31
25
|
"author": "alina sireneva <alina@tei.su>",
|
|
32
|
-
"sideEffects": false
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"homepage": "https://mtcute.dev",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/mtcute/mtcute.git"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {}
|
|
33
33
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PYROGRAM_TEST_SESSION = "AgAyyvcBTk6KssqikKPxEhxfXJpkoFIgQ_o8VpCk_4g0tcHe0rVCXx34AaDKvaNOlbkJOZ4jA3AI8iDYkI2opuifbM_7S2u9MMdnrjfg5jpfkXfI9-wF8DK_UBGIe1zk_Ibn0IHLRz-lkb-QqZNhh8O8Ggb8cieamatEYwLrkjkZR7JG53q76F0ktUd22L6_bUlp9p_qgXqBg8vZdkIIs9T1OiShw2X6TNO0lYqfJVaczMVQcT9Zt0FiyrAMpovFuT7-96OFKWcQ9gzrs_SHfz9HrQgBwvNSdkVziXTtxLJXsaNz3smGeyh-CEuEgdF3enIECnzftlvvUClLN_ylcPir1bi4_wAAAAEqEi1JAA";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PYROGRAM_TEST_SESSION_OLD = "AgEWdHMtuA1pC01YkNiHpL1bC0yBC3wzGZCwSRWKlA_a69RhePUN3M51NpnwSXrW3pZV9FS8WjAwUkA23uT_49t8c7Umw3ihhKD6-hTpZ5wXC2MuC0EsF0-Z6WshYhT3gmN6QhEt0jlXo5cW1BJ3MYmXtsTWNf_hJfd3_wF_ZFa58ntVV-3qd08wQRhiL_IxM7L5YazjPw0dg2z92CqRARku_oq5D29V6W6bo8T-SLzF_ujj5ZcAQL25mJtCcXfhhjp9atxcrqnKzEs05xyrehnlJZKoGmnX0mF2P_6wUHqZC9tcTBUV4AmFcbuy7m_4SYLnJ8MbftNs7aWHHNcB1R4fAAAAASoSLUkA";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StringSessionData } from '@mtcute/core/utils.js';
|
|
2
|
+
import { PyrogramSession } from './types.js';
|
|
3
|
+
export declare function convertFromPyrogramSession(session: PyrogramSession | string): StringSessionData;
|
|
4
|
+
export declare function convertToPyrogramSession(session: StringSessionData | string, params?: {
|
|
5
|
+
apiId?: number;
|
|
6
|
+
}): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MaybeArray } from '@fuman/utils';
|
|
2
|
+
import { TdataOptions, Tdata } from './tdata.js';
|
|
3
|
+
import { StringSessionData } from '@mtcute/core/utils.js';
|
|
4
|
+
export declare function convertFromTdata(tdata: Tdata | TdataOptions, accountIdx?: number): Promise<StringSessionData>;
|
|
5
|
+
export declare function convertToTdata(sessions: MaybeArray<StringSessionData | string>, tdata: Tdata | TdataOptions): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ISyncReadable } from '@fuman/io';
|
|
2
|
+
import { Long } from '@mtcute/core';
|
|
3
|
+
export declare function readQByteArray(readable: ISyncReadable): Uint8Array;
|
|
4
|
+
export declare function readLong(readable: ISyncReadable): Long;
|
|
5
|
+
export declare function readCharArray(readable: ISyncReadable): Uint8Array;
|
|
6
|
+
export declare function readQString(readable: ISyncReadable): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ISyncWritable } from '@fuman/io';
|
|
2
|
+
import { Long } from '@mtcute/core';
|
|
3
|
+
export declare function writeQByteArray(into: ISyncWritable, buf: Uint8Array): void;
|
|
4
|
+
export declare function writeLong(into: ISyncWritable, long: Long): void;
|
|
5
|
+
export declare function writeCharArray(into: ISyncWritable, buf: Uint8Array): void;
|
|
6
|
+
export declare function writeQString(into: ISyncWritable, str: string): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { INodeFsLike } from '../utils/fs.js';
|
|
2
|
+
import { InputTdKeyData, TdKeyData, TdMtpAuthorization } from './types.js';
|
|
3
|
+
import { IExtendedCryptoProvider } from '../utils/crypto.js';
|
|
4
|
+
export interface TdataOptions {
|
|
5
|
+
/** Full path to the tdata directory */
|
|
6
|
+
path: string;
|
|
7
|
+
/**
|
|
8
|
+
* File system to use for reading/writing.
|
|
9
|
+
*
|
|
10
|
+
* @default `import('node:fs/promises')`
|
|
11
|
+
*/
|
|
12
|
+
fs?: INodeFsLike;
|
|
13
|
+
/**
|
|
14
|
+
* Crypto functions to use for encryption/decryption.
|
|
15
|
+
*
|
|
16
|
+
* @default `node:crypto`-based implementation
|
|
17
|
+
*/
|
|
18
|
+
crypto?: IExtendedCryptoProvider;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to ignore TDF version mismatch.
|
|
21
|
+
* If set to `true`, the version will be ignored and the file will be read as is,
|
|
22
|
+
* however the probability of errors is higher.
|
|
23
|
+
*/
|
|
24
|
+
ignoreVersion?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the host machine has LE processor (default true, try changing in case of errors)
|
|
27
|
+
*/
|
|
28
|
+
le?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Value of -key cli parameter.
|
|
31
|
+
* Defaults to `data`
|
|
32
|
+
*/
|
|
33
|
+
dataKey?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Local passcode
|
|
36
|
+
*/
|
|
37
|
+
passcode?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare class Tdata {
|
|
40
|
+
#private;
|
|
41
|
+
readonly options: TdataOptions;
|
|
42
|
+
readonly fs: INodeFsLike;
|
|
43
|
+
readonly crypto: IExtendedCryptoProvider;
|
|
44
|
+
private constructor();
|
|
45
|
+
readonly keyData: TdKeyData;
|
|
46
|
+
static open(options: TdataOptions): Promise<Tdata>;
|
|
47
|
+
static create(options: TdataOptions & {
|
|
48
|
+
keyData: InputTdKeyData;
|
|
49
|
+
}): Promise<Tdata>;
|
|
50
|
+
getDataName(idx: number): string;
|
|
51
|
+
readFile(filename: string): Promise<[number, Uint8Array]>;
|
|
52
|
+
writeFile(filename: string, data: Uint8Array, mkdir?: boolean): Promise<void>;
|
|
53
|
+
createLocalKey(salt: Uint8Array, passcode?: string): Promise<Uint8Array>;
|
|
54
|
+
decryptLocal(encrypted: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
|
|
55
|
+
encryptLocal(data: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
|
|
56
|
+
readKeyData(): Promise<TdKeyData>;
|
|
57
|
+
writeKeyData(keyData: TdKeyData): Promise<void>;
|
|
58
|
+
computeDataNameKey(accountIdx: number): Promise<Uint8Array>;
|
|
59
|
+
computeDataNameKeyHex(accountIdx: number): Promise<string>;
|
|
60
|
+
readEncryptedFile(filename: string): Promise<[number, Uint8Array]>;
|
|
61
|
+
writeEncryptedFile(filename: string, data: Uint8Array, mkdir?: boolean): Promise<void>;
|
|
62
|
+
readMtpAuthorization(accountIdx?: number): Promise<TdMtpAuthorization>;
|
|
63
|
+
writeMtpAuthorization(auth: TdMtpAuthorization, accountIdx?: number): Promise<void>;
|
|
64
|
+
writeEmptyMapFile(accountIdx: number): Promise<void>;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Long } from '@mtcute/core';
|
|
2
|
+
export interface TdAuthKey {
|
|
3
|
+
dcId: number;
|
|
4
|
+
key: Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
export interface TdMtpAuthorization {
|
|
7
|
+
userId: Long;
|
|
8
|
+
mainDcId: number;
|
|
9
|
+
authKeys: TdAuthKey[];
|
|
10
|
+
authKeysToDestroy: TdAuthKey[];
|
|
11
|
+
}
|
|
12
|
+
export interface InputTdKeyData {
|
|
13
|
+
localKey?: Uint8Array;
|
|
14
|
+
version?: number;
|
|
15
|
+
count: number;
|
|
16
|
+
order: number[];
|
|
17
|
+
active: number;
|
|
18
|
+
}
|
|
19
|
+
export interface TdKeyData extends InputTdKeyData {
|
|
20
|
+
version: number;
|
|
21
|
+
localKey: Uint8Array;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TELETHON_TEST_SESSION = "1ApWapygAUChJS1_xwUK01Is4cOvQa1JKTn1POabdMUCfLmXNYFUyvG3v9Z_qbFNFp3zYP--3aVpTYI2DpB2Ib46p_bwSC0j1QEjvdQxJj26cVj8NfslrCkYrdV3glOhdczSq08kp31eqBGXMPhA7wy7DOcSLLAoy-Jf3Q_V_Q3y2a8_64ArFJe8PFfSqkdO56VQutajNLscFUtTQXUQFLJ7ft6vIl__UOc9tpQZEiFW7jWmID79WkfYLHFjuChTVKGMLDa8YcZj6z5Sq-pXPE9VbAbJ5L1JRqXOey3QGtZgJeIEww_WWD5nMMUfhLIydD2i7eDmVoUE5EIZPpsevJmjiGLw4vJk=";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TELETHON_TEST_SESSION_V6 = "1ASABCyjyPfABAAAAAAAAAA4Bu4pveAFWSE51_trKsrRQeMvGXMl8fI6NsGaWqdrXXeqyaXne9qNthqnrBmH56kHfOhFUCPSoVzNNrGgnQr67AYQbkhpP_Yml2EDd8epdc6Gywh4q2NBgYyW6VBT8UKg89-FebYTO6n47I1cJMGsSZ1ddxEOpIpHXsSmPdGBSTz6uaHbLYo0jnxd59PQn4H4dKb8FxuOQsUVa3vY_o79HMVMQRVT1IksUKFg5gAe5ZJ0yx6W4pMviVbC-TYZC0HInmv2fFMv-S3rQyg1C7qpU-Gbo1P6UZC4KZGmu2pMJooFNyfRbFgl3BI5Z-FNx9TKu4UFrF9G6Q0l8PjPXOZm4j-c=";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StringSessionData } from '@mtcute/core/utils.js';
|
|
2
|
+
import { TelethonSession } from './types.js';
|
|
3
|
+
export declare function convertFromTelethonSession(session: TelethonSession | string): StringSessionData;
|
|
4
|
+
export declare function convertToTelethonSession(session: StringSessionData | string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types.d.cts
ADDED
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MaybePromise } from '@fuman/utils';
|
|
2
|
+
import { ICryptoProvider } from '@mtcute/core/utils.js';
|
|
3
|
+
export interface IExtendedCryptoProvider extends ICryptoProvider {
|
|
4
|
+
createHash(algorithm: 'md5' | 'sha512'): MaybePromise<{
|
|
5
|
+
update(data: Uint8Array): MaybePromise<void>;
|
|
6
|
+
digest(): MaybePromise<Uint8Array>;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export declare function getDefaultCryptoProvider(): Promise<IExtendedCryptoProvider>;
|
package/utils/fs.d.cts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface INodeFsLike {
|
|
2
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
3
|
+
writeFile(path: string, data: Uint8Array): Promise<void>;
|
|
4
|
+
mkdir(path: string, options?: {
|
|
5
|
+
recursive?: boolean;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
stat(path: string): Promise<{
|
|
8
|
+
size: number;
|
|
9
|
+
lastModified: number;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
package/utils/rle.d.cts
ADDED