@mtcute/convert 0.16.7 → 0.16.9
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/{cjs/dcs.d.ts → dcs.d.ts} +1 -1
- package/gramjs/__fixtures__/session.d.ts +1 -0
- package/{esm/gramjs → gramjs}/convert.d.ts +2 -2
- package/{cjs/gramjs → gramjs}/parse.d.ts +1 -1
- package/{cjs/gramjs → gramjs}/serialize.d.ts +1 -1
- package/gramjs/serialize.test.d.ts +1 -0
- package/index.cjs +493 -0
- package/index.d.ts +5 -1
- package/index.js +488 -1
- package/mtkruto/__fixtures__/session.d.ts +1 -0
- package/{cjs/mtkruto → mtkruto}/convert.d.ts +2 -2
- package/mtkruto/convert.test.d.ts +1 -0
- package/{esm/mtkruto → mtkruto}/parse.d.ts +1 -1
- package/mtkruto/parse.test.d.ts +1 -0
- package/{cjs/mtkruto → mtkruto}/serialize.d.ts +1 -1
- package/mtkruto/serialize.test.d.ts +1 -0
- package/package.json +27 -23
- package/pyrogram/__fixtures__/session.d.ts +1 -0
- package/pyrogram/__fixtures__/session_old.d.ts +1 -0
- package/{esm/pyrogram → pyrogram}/convert.d.ts +2 -2
- package/pyrogram/convert.test.d.ts +1 -0
- package/{esm/pyrogram → pyrogram}/parse.d.ts +1 -1
- package/pyrogram/parse.test.d.ts +1 -0
- package/{esm/pyrogram → pyrogram}/serialize.d.ts +1 -1
- package/pyrogram/serialize.test.d.ts +1 -0
- package/telethon/__fixtures__/session.d.ts +1 -0
- package/telethon/__fixtures__/session_v6.d.ts +1 -0
- package/{esm/telethon → telethon}/convert.d.ts +2 -2
- package/telethon/convert.test.d.ts +1 -0
- package/{esm/telethon → telethon}/parse.d.ts +1 -1
- package/telethon/parse.test.d.ts +1 -0
- package/{esm/telethon → telethon}/serialize.d.ts +1 -1
- package/telethon/serialize.test.d.ts +1 -0
- package/types.d.ts +0 -0
- package/cjs/dcs.js +0 -113
- package/cjs/dcs.js.map +0 -1
- package/cjs/gramjs/convert.d.ts +0 -4
- package/cjs/gramjs/convert.js +0 -27
- package/cjs/gramjs/convert.js.map +0 -1
- package/cjs/gramjs/index.js +0 -21
- package/cjs/gramjs/index.js.map +0 -1
- package/cjs/gramjs/parse.js +0 -30
- package/cjs/gramjs/parse.js.map +0 -1
- package/cjs/gramjs/serialize.js +0 -23
- package/cjs/gramjs/serialize.js.map +0 -1
- package/cjs/gramjs/types.js +0 -3
- package/cjs/gramjs/types.js.map +0 -1
- package/cjs/index.js +0 -28
- package/cjs/index.js.map +0 -1
- package/cjs/mtkruto/convert.js +0 -30
- package/cjs/mtkruto/convert.js.map +0 -1
- package/cjs/mtkruto/index.js +0 -21
- package/cjs/mtkruto/index.js.map +0 -1
- package/cjs/mtkruto/parse.d.ts +0 -2
- package/cjs/mtkruto/parse.js +0 -27
- package/cjs/mtkruto/parse.js.map +0 -1
- package/cjs/mtkruto/serialize.js +0 -14
- package/cjs/mtkruto/serialize.js.map +0 -1
- package/cjs/mtkruto/types.js +0 -3
- package/cjs/mtkruto/types.js.map +0 -1
- package/cjs/package.json +0 -3
- package/cjs/pyrogram/convert.d.ts +0 -6
- package/cjs/pyrogram/convert.js +0 -39
- package/cjs/pyrogram/convert.js.map +0 -1
- package/cjs/pyrogram/index.js +0 -21
- package/cjs/pyrogram/index.js.map +0 -1
- package/cjs/pyrogram/parse.d.ts +0 -2
- package/cjs/pyrogram/parse.js +0 -55
- package/cjs/pyrogram/parse.js.map +0 -1
- package/cjs/pyrogram/serialize.d.ts +0 -2
- package/cjs/pyrogram/serialize.js +0 -39
- package/cjs/pyrogram/serialize.js.map +0 -1
- package/cjs/pyrogram/types.js +0 -3
- package/cjs/pyrogram/types.js.map +0 -1
- package/cjs/telethon/convert.d.ts +0 -4
- package/cjs/telethon/convert.js +0 -43
- package/cjs/telethon/convert.js.map +0 -1
- package/cjs/telethon/index.js +0 -21
- package/cjs/telethon/index.js.map +0 -1
- package/cjs/telethon/parse.d.ts +0 -2
- package/cjs/telethon/parse.js +0 -32
- package/cjs/telethon/parse.js.map +0 -1
- package/cjs/telethon/serialize.d.ts +0 -2
- package/cjs/telethon/serialize.js +0 -33
- package/cjs/telethon/serialize.js.map +0 -1
- package/cjs/telethon/types.js +0 -3
- package/cjs/telethon/types.js.map +0 -1
- package/cjs/types.js +0 -3
- package/cjs/types.js.map +0 -1
- package/cjs/utils/ip.js +0 -44
- package/cjs/utils/ip.js.map +0 -1
- package/cjs/utils/rle.js +0 -54
- package/cjs/utils/rle.js.map +0 -1
- package/esm/dcs.d.ts +0 -4
- package/esm/dcs.js +0 -109
- package/esm/dcs.js.map +0 -1
- package/esm/gramjs/convert.js +0 -23
- package/esm/gramjs/convert.js.map +0 -1
- package/esm/gramjs/index.d.ts +0 -4
- package/esm/gramjs/index.js +0 -5
- package/esm/gramjs/index.js.map +0 -1
- package/esm/gramjs/parse.d.ts +0 -2
- package/esm/gramjs/parse.js +0 -27
- package/esm/gramjs/parse.js.map +0 -1
- package/esm/gramjs/serialize.d.ts +0 -2
- package/esm/gramjs/serialize.js +0 -20
- package/esm/gramjs/serialize.js.map +0 -1
- package/esm/gramjs/types.d.ts +0 -7
- package/esm/gramjs/types.js +0 -2
- package/esm/gramjs/types.js.map +0 -1
- package/esm/index.d.ts +0 -5
- package/esm/index.js +0 -6
- package/esm/index.js.map +0 -1
- package/esm/mtkruto/convert.d.ts +0 -4
- package/esm/mtkruto/convert.js +0 -26
- package/esm/mtkruto/convert.js.map +0 -1
- package/esm/mtkruto/index.d.ts +0 -4
- package/esm/mtkruto/index.js +0 -5
- package/esm/mtkruto/index.js.map +0 -1
- package/esm/mtkruto/parse.js +0 -24
- package/esm/mtkruto/parse.js.map +0 -1
- package/esm/mtkruto/serialize.d.ts +0 -2
- package/esm/mtkruto/serialize.js +0 -11
- package/esm/mtkruto/serialize.js.map +0 -1
- package/esm/mtkruto/types.d.ts +0 -5
- package/esm/mtkruto/types.js +0 -2
- package/esm/mtkruto/types.js.map +0 -1
- package/esm/pyrogram/convert.js +0 -35
- package/esm/pyrogram/convert.js.map +0 -1
- package/esm/pyrogram/index.d.ts +0 -4
- package/esm/pyrogram/index.js +0 -5
- package/esm/pyrogram/index.js.map +0 -1
- package/esm/pyrogram/parse.js +0 -52
- package/esm/pyrogram/parse.js.map +0 -1
- package/esm/pyrogram/serialize.js +0 -36
- package/esm/pyrogram/serialize.js.map +0 -1
- package/esm/pyrogram/types.d.ts +0 -8
- package/esm/pyrogram/types.js +0 -2
- package/esm/pyrogram/types.js.map +0 -1
- package/esm/telethon/convert.js +0 -39
- package/esm/telethon/convert.js.map +0 -1
- package/esm/telethon/index.d.ts +0 -4
- package/esm/telethon/index.js +0 -5
- package/esm/telethon/index.js.map +0 -1
- package/esm/telethon/parse.js +0 -29
- package/esm/telethon/parse.js.map +0 -1
- package/esm/telethon/serialize.js +0 -30
- package/esm/telethon/serialize.js.map +0 -1
- package/esm/telethon/types.d.ts +0 -7
- package/esm/telethon/types.js +0 -2
- package/esm/telethon/types.js.map +0 -1
- package/esm/types.js +0 -2
- package/esm/types.js.map +0 -1
- package/esm/utils/ip.d.ts +0 -3
- package/esm/utils/ip.js +0 -39
- package/esm/utils/ip.js.map +0 -1
- package/esm/utils/rle.d.ts +0 -3
- package/esm/utils/rle.js +0 -49
- package/esm/utils/rle.js.map +0 -1
- /package/{cjs/types.d.ts → gramjs/convert.test.d.ts} +0 -0
- /package/{cjs/gramjs → gramjs}/index.d.ts +0 -0
- /package/{esm/types.d.ts → gramjs/parse.test.d.ts} +0 -0
- /package/{cjs/gramjs → gramjs}/types.d.ts +0 -0
- /package/{cjs/index.d.ts → index.d.cts} +0 -0
- /package/{cjs/mtkruto → mtkruto}/index.d.ts +0 -0
- /package/{cjs/mtkruto → mtkruto}/types.d.ts +0 -0
- /package/{cjs/pyrogram → pyrogram}/index.d.ts +0 -0
- /package/{cjs/pyrogram → pyrogram}/types.d.ts +0 -0
- /package/{cjs/telethon → telethon}/index.d.ts +0 -0
- /package/{cjs/telethon → telethon}/types.d.ts +0 -0
- /package/{cjs/utils → utils}/ip.d.ts +0 -0
- /package/{cjs/utils → utils}/rle.d.ts +0 -0
package/cjs/dcs.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DC_MAPPING_TEST = exports.DC_MAPPING_PROD = void 0;
|
|
4
|
-
exports.isTestDc = isTestDc;
|
|
5
|
-
// some libraries only store the DCs in the source code, so we need to map them to the correct DCs
|
|
6
|
-
// this may not be very accurate, but it's better than nothing
|
|
7
|
-
// we *could* always map those to the primary dc (the client should handle that gracefully),
|
|
8
|
-
// but imo it's better to be as accurate as possible
|
|
9
|
-
// we'll also only map to ipv4 since that's more portable
|
|
10
|
-
exports.DC_MAPPING_PROD = {
|
|
11
|
-
1: {
|
|
12
|
-
main: {
|
|
13
|
-
id: 1,
|
|
14
|
-
ipAddress: '149.154.175.56',
|
|
15
|
-
port: 443,
|
|
16
|
-
},
|
|
17
|
-
media: {
|
|
18
|
-
id: 1,
|
|
19
|
-
ipAddress: '149.154.175.211',
|
|
20
|
-
port: 443,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
2: {
|
|
24
|
-
main: {
|
|
25
|
-
id: 2,
|
|
26
|
-
ipAddress: '149.154.167.41',
|
|
27
|
-
port: 443,
|
|
28
|
-
},
|
|
29
|
-
media: {
|
|
30
|
-
id: 2,
|
|
31
|
-
ipAddress: '149.154.167.35',
|
|
32
|
-
port: 443,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
3: {
|
|
36
|
-
main: {
|
|
37
|
-
id: 3,
|
|
38
|
-
ipAddress: '149.154.175.100',
|
|
39
|
-
port: 443,
|
|
40
|
-
},
|
|
41
|
-
media: {
|
|
42
|
-
id: 3,
|
|
43
|
-
ipAddress: '149.154.175.100',
|
|
44
|
-
port: 443,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
4: {
|
|
48
|
-
main: {
|
|
49
|
-
id: 4,
|
|
50
|
-
ipAddress: '149.154.167.91',
|
|
51
|
-
port: 443,
|
|
52
|
-
},
|
|
53
|
-
media: {
|
|
54
|
-
id: 4,
|
|
55
|
-
ipAddress: '149.154.167.255',
|
|
56
|
-
port: 443,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
5: {
|
|
60
|
-
main: {
|
|
61
|
-
id: 5,
|
|
62
|
-
ipAddress: '91.108.56.179',
|
|
63
|
-
port: 443,
|
|
64
|
-
},
|
|
65
|
-
media: {
|
|
66
|
-
id: 5,
|
|
67
|
-
ipAddress: '149.154.171.255',
|
|
68
|
-
port: 443,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
exports.DC_MAPPING_TEST = {
|
|
73
|
-
1: {
|
|
74
|
-
main: {
|
|
75
|
-
id: 1,
|
|
76
|
-
ipAddress: '149.154.175.10',
|
|
77
|
-
port: 80,
|
|
78
|
-
},
|
|
79
|
-
media: {
|
|
80
|
-
id: 1,
|
|
81
|
-
ipAddress: '149.154.175.10',
|
|
82
|
-
port: 80,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
2: {
|
|
86
|
-
main: {
|
|
87
|
-
id: 2,
|
|
88
|
-
ipAddress: '149.154.167.40',
|
|
89
|
-
port: 443,
|
|
90
|
-
},
|
|
91
|
-
media: {
|
|
92
|
-
id: 2,
|
|
93
|
-
ipAddress: '149.154.167.40',
|
|
94
|
-
port: 443,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
3: {
|
|
98
|
-
main: {
|
|
99
|
-
id: 3,
|
|
100
|
-
ipAddress: '149.154.175.117',
|
|
101
|
-
port: 443,
|
|
102
|
-
},
|
|
103
|
-
media: {
|
|
104
|
-
id: 3,
|
|
105
|
-
ipAddress: '149.154.175.117',
|
|
106
|
-
port: 443,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
function isTestDc(ip) {
|
|
111
|
-
return Object.values(exports.DC_MAPPING_TEST).some(dc => dc.main.ipAddress === ip || dc.media.ipAddress === ip);
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=dcs.js.map
|
package/cjs/dcs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dcs.js","sourceRoot":"","sources":["../../src/dcs.ts"],"names":[],"mappings":";;;AA8GA,4BAEC;AA9GD,kGAAkG;AAClG,8DAA8D;AAC9D,4FAA4F;AAC5F,oDAAoD;AACpD,yDAAyD;AAE5C,QAAA,eAAe,GAA8B;IACtD,CAAC,EAAE;QACC,IAAI,EAAE;YACF,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,GAAG;SACZ;QACD,KAAK,EAAE;YACH,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,iBAAiB;YAC5B,IAAI,EAAE,GAAG;SACZ;KACJ;IACD,CAAC,EAAE;QACC,IAAI,EAAE;YACF,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,GAAG;SACZ;QACD,KAAK,EAAE;YACH,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,GAAG;SACZ;KACJ;IACD,CAAC,EAAE;QACC,IAAI,EAAE;YACF,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,iBAAiB;YAC5B,IAAI,EAAE,GAAG;SACZ;QACD,KAAK,EAAE;YACH,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,iBAAiB;YAC5B,IAAI,EAAE,GAAG;SACZ;KACJ;IACD,CAAC,EAAE;QACC,IAAI,EAAE;YACF,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,GAAG;SACZ;QACD,KAAK,EAAE;YACH,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,iBAAiB;YAC5B,IAAI,EAAE,GAAG;SACZ;KACJ;IACD,CAAC,EAAE;QACC,IAAI,EAAE;YACF,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,eAAe;YAC1B,IAAI,EAAE,GAAG;SACZ;QACD,KAAK,EAAE;YACH,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,iBAAiB;YAC5B,IAAI,EAAE,GAAG;SACZ;KACJ;CACJ,CAAA;AAEY,QAAA,eAAe,GAA8B;IACtD,CAAC,EAAE;QACC,IAAI,EAAE;YACF,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,EAAE;SACX;QACD,KAAK,EAAE;YACH,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,EAAE;SACX;KACJ;IACD,CAAC,EAAE;QACC,IAAI,EAAE;YACF,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,GAAG;SACZ;QACD,KAAK,EAAE;YACH,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,GAAG;SACZ;KACJ;IACD,CAAC,EAAE;QACC,IAAI,EAAE;YACF,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,iBAAiB;YAC5B,IAAI,EAAE,GAAG;SACZ;QACD,KAAK,EAAE;YACH,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,iBAAiB;YAC5B,IAAI,EAAE,GAAG;SACZ;KACJ;CACJ,CAAA;AAED,SAAgB,QAAQ,CAAC,EAAU;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,uBAAe,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,EAAE,CAAC,CAAA;AAC3G,CAAC","sourcesContent":["import type { DcOptions } from '@mtcute/core/utils.js'\n\n// some libraries only store the DCs in the source code, so we need to map them to the correct DCs\n// this may not be very accurate, but it's better than nothing\n// we *could* always map those to the primary dc (the client should handle that gracefully),\n// but imo it's better to be as accurate as possible\n// we'll also only map to ipv4 since that's more portable\n\nexport const DC_MAPPING_PROD: Record<number, DcOptions> = {\n 1: {\n main: {\n id: 1,\n ipAddress: '149.154.175.56',\n port: 443,\n },\n media: {\n id: 1,\n ipAddress: '149.154.175.211',\n port: 443,\n },\n },\n 2: {\n main: {\n id: 2,\n ipAddress: '149.154.167.41',\n port: 443,\n },\n media: {\n id: 2,\n ipAddress: '149.154.167.35',\n port: 443,\n },\n },\n 3: {\n main: {\n id: 3,\n ipAddress: '149.154.175.100',\n port: 443,\n },\n media: {\n id: 3,\n ipAddress: '149.154.175.100',\n port: 443,\n },\n },\n 4: {\n main: {\n id: 4,\n ipAddress: '149.154.167.91',\n port: 443,\n },\n media: {\n id: 4,\n ipAddress: '149.154.167.255',\n port: 443,\n },\n },\n 5: {\n main: {\n id: 5,\n ipAddress: '91.108.56.179',\n port: 443,\n },\n media: {\n id: 5,\n ipAddress: '149.154.171.255',\n port: 443,\n },\n },\n}\n\nexport const DC_MAPPING_TEST: Record<number, DcOptions> = {\n 1: {\n main: {\n id: 1,\n ipAddress: '149.154.175.10',\n port: 80,\n },\n media: {\n id: 1,\n ipAddress: '149.154.175.10',\n port: 80,\n },\n },\n 2: {\n main: {\n id: 2,\n ipAddress: '149.154.167.40',\n port: 443,\n },\n media: {\n id: 2,\n ipAddress: '149.154.167.40',\n port: 443,\n },\n },\n 3: {\n main: {\n id: 3,\n ipAddress: '149.154.175.117',\n port: 443,\n },\n media: {\n id: 3,\n ipAddress: '149.154.175.117',\n port: 443,\n },\n },\n}\n\nexport function isTestDc(ip: string): boolean {\n return Object.values(DC_MAPPING_TEST).some(dc => dc.main.ipAddress === ip || dc.media.ipAddress === ip)\n}\n"]}
|
package/cjs/gramjs/convert.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { StringSessionData } from '@mtcute/core/utils.js';
|
|
2
|
-
import type { TelethonSession } from '../telethon/types.js';
|
|
3
|
-
export declare function convertFromGramjsSession(session: TelethonSession | string): StringSessionData;
|
|
4
|
-
export declare function convertToGramjsSession(session: StringSessionData | string): string;
|
package/cjs/gramjs/convert.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertFromGramjsSession = convertFromGramjsSession;
|
|
4
|
-
exports.convertToGramjsSession = convertToGramjsSession;
|
|
5
|
-
const utils_js_1 = require("@mtcute/core/utils.js");
|
|
6
|
-
const convert_js_1 = require("../telethon/convert.js");
|
|
7
|
-
const parse_js_1 = require("./parse.js");
|
|
8
|
-
const serialize_js_1 = require("./serialize.js");
|
|
9
|
-
function convertFromGramjsSession(session) {
|
|
10
|
-
if (typeof session === 'string') {
|
|
11
|
-
session = (0, parse_js_1.parseGramjsSession)(session);
|
|
12
|
-
}
|
|
13
|
-
return (0, convert_js_1.convertFromTelethonSession)(session);
|
|
14
|
-
}
|
|
15
|
-
function convertToGramjsSession(session) {
|
|
16
|
-
if (typeof session === 'string') {
|
|
17
|
-
session = (0, utils_js_1.readStringSession)(session);
|
|
18
|
-
}
|
|
19
|
-
return (0, serialize_js_1.serializeGramjsSession)({
|
|
20
|
-
dcId: session.primaryDcs.main.id,
|
|
21
|
-
ipAddress: session.primaryDcs.main.ipAddress,
|
|
22
|
-
port: session.primaryDcs.main.port,
|
|
23
|
-
ipv6: session.primaryDcs.main.ipv6 ?? false,
|
|
24
|
-
authKey: session.authKey,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/gramjs/convert.ts"],"names":[],"mappings":";;AASA,4DAMC;AAED,wDAYC;AA5BD,oDAAyD;AAEzD,uDAAmE;AAGnE,yCAA+C;AAC/C,iDAAuD;AAEvD,SAAgB,wBAAwB,CAAC,OAAiC;IACtE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAA,6BAAkB,EAAC,OAAO,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,IAAA,uCAA0B,EAAC,OAAO,CAAC,CAAA;AAC9C,CAAC;AAED,SAAgB,sBAAsB,CAAC,OAAmC;IACtE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAA,4BAAiB,EAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,IAAA,qCAAsB,EAAC;QAC1B,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAChC,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS;QAC5C,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI;QAClC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK;QAC3C,OAAO,EAAE,OAAO,CAAC,OAAO;KAC3B,CAAC,CAAA;AACN,CAAC","sourcesContent":["import type { StringSessionData } from '@mtcute/core/utils.js'\nimport { readStringSession } from '@mtcute/core/utils.js'\n\nimport { convertFromTelethonSession } from '../telethon/convert.js'\nimport type { TelethonSession } from '../telethon/types.js'\n\nimport { parseGramjsSession } from './parse.js'\nimport { serializeGramjsSession } from './serialize.js'\n\nexport function convertFromGramjsSession(session: TelethonSession | string): StringSessionData {\n if (typeof session === 'string') {\n session = parseGramjsSession(session)\n }\n\n return convertFromTelethonSession(session)\n}\n\nexport function convertToGramjsSession(session: StringSessionData | string): string {\n if (typeof session === 'string') {\n session = readStringSession(session)\n }\n\n return serializeGramjsSession({\n dcId: session.primaryDcs.main.id,\n ipAddress: session.primaryDcs.main.ipAddress,\n port: session.primaryDcs.main.port,\n ipv6: session.primaryDcs.main.ipv6 ?? false,\n authKey: session.authKey,\n })\n}\n"]}
|
package/cjs/gramjs/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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("./convert.js"), exports);
|
|
18
|
-
__exportStar(require("./parse.js"), exports);
|
|
19
|
-
__exportStar(require("./serialize.js"), exports);
|
|
20
|
-
__exportStar(require("./types.js"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/gramjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/gramjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,6CAA0B;AAC1B,iDAA8B;AAC9B,6CAA0B","sourcesContent":["export * from './convert.js'\nexport * from './parse.js'\nexport * from './serialize.js'\nexport * from './types.js'\n"]}
|
package/cjs/gramjs/parse.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseGramjsSession = parseGramjsSession;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
const platform_js_1 = require("@mtcute/core/platform.js");
|
|
6
|
-
const utils_js_1 = require("@mtcute/core/utils.js");
|
|
7
|
-
function parseGramjsSession(session) {
|
|
8
|
-
if (session[0] !== '1') {
|
|
9
|
-
// version
|
|
10
|
-
throw new core_1.MtArgumentError(`Invalid session string (version = ${session[0]})`);
|
|
11
|
-
}
|
|
12
|
-
session = session.slice(1);
|
|
13
|
-
const data = (0, platform_js_1.getPlatform)().base64Decode(session);
|
|
14
|
-
const dv = (0, utils_js_1.dataViewFromBuffer)(data);
|
|
15
|
-
const dcId = dv.getUint8(0);
|
|
16
|
-
const ipSize = dv.getUint16(1);
|
|
17
|
-
let pos = 3 + ipSize;
|
|
18
|
-
const ip = (0, platform_js_1.getPlatform)().utf8Decode(data.subarray(3, pos));
|
|
19
|
-
const port = dv.getUint16(pos);
|
|
20
|
-
pos += 2;
|
|
21
|
-
const authKey = data.subarray(pos, pos + 256);
|
|
22
|
-
return {
|
|
23
|
-
dcId,
|
|
24
|
-
ipAddress: ip,
|
|
25
|
-
ipv6: ip.includes(':'), // dumb check but gramjs does this
|
|
26
|
-
port,
|
|
27
|
-
authKey,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=parse.js.map
|
package/cjs/gramjs/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/gramjs/parse.ts"],"names":[],"mappings":";;AAMA,gDA4BC;AAlCD,uCAA8C;AAC9C,0DAAsD;AACtD,oDAA0D;AAI1D,SAAgB,kBAAkB,CAAC,OAAe;IAC9C,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACrB,UAAU;QACV,MAAM,IAAI,sBAAe,CAAC,qCAAqC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACjF,CAAC;IAED,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAE1B,MAAM,IAAI,GAAG,IAAA,yBAAW,GAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;IAChD,MAAM,EAAE,GAAG,IAAA,6BAAkB,EAAC,IAAI,CAAC,CAAA;IAEnC,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAE3B,MAAM,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAC9B,IAAI,GAAG,GAAG,CAAC,GAAG,MAAM,CAAA;IAEpB,MAAM,EAAE,GAAG,IAAA,yBAAW,GAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;IAC1D,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,GAAG,IAAI,CAAC,CAAA;IACR,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,CAAA;IAE7C,OAAO;QACH,IAAI;QACJ,SAAS,EAAE,EAAE;QACb,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,kCAAkC;QAC1D,IAAI;QACJ,OAAO;KACV,CAAA;AACL,CAAC","sourcesContent":["import { MtArgumentError } from '@mtcute/core'\nimport { getPlatform } from '@mtcute/core/platform.js'\nimport { dataViewFromBuffer } from '@mtcute/core/utils.js'\n\nimport type { TelethonSession } from '../telethon/types.js'\n\nexport function parseGramjsSession(session: string): TelethonSession {\n if (session[0] !== '1') {\n // version\n throw new MtArgumentError(`Invalid session string (version = ${session[0]})`)\n }\n\n session = session.slice(1)\n\n const data = getPlatform().base64Decode(session)\n const dv = dataViewFromBuffer(data)\n\n const dcId = dv.getUint8(0)\n\n const ipSize = dv.getUint16(1)\n let pos = 3 + ipSize\n\n const ip = getPlatform().utf8Decode(data.subarray(3, pos))\n const port = dv.getUint16(pos)\n pos += 2\n const authKey = data.subarray(pos, pos + 256)\n\n return {\n dcId,\n ipAddress: ip,\n ipv6: ip.includes(':'), // dumb check but gramjs does this\n port,\n authKey,\n }\n}\n"]}
|
package/cjs/gramjs/serialize.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeGramjsSession = serializeGramjsSession;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
const platform_js_1 = require("@mtcute/core/platform.js");
|
|
6
|
-
const utils_js_1 = require("@mtcute/core/utils.js");
|
|
7
|
-
function serializeGramjsSession(session) {
|
|
8
|
-
if (session.authKey.length !== 256) {
|
|
9
|
-
throw new core_1.MtArgumentError('authKey must be 256 bytes long');
|
|
10
|
-
}
|
|
11
|
-
const ipEncoded = (0, platform_js_1.getPlatform)().utf8Encode(session.ipAddress);
|
|
12
|
-
const u8 = new Uint8Array(261 + ipEncoded.length);
|
|
13
|
-
const dv = (0, utils_js_1.dataViewFromBuffer)(u8);
|
|
14
|
-
dv.setUint8(0, session.dcId);
|
|
15
|
-
dv.setUint16(1, ipEncoded.length);
|
|
16
|
-
u8.set(ipEncoded, 3);
|
|
17
|
-
let pos = 3 + ipEncoded.length;
|
|
18
|
-
dv.setUint16(pos, session.port);
|
|
19
|
-
pos += 2;
|
|
20
|
-
u8.set(session.authKey, pos);
|
|
21
|
-
return `1${(0, platform_js_1.getPlatform)().base64Encode(u8)}`;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=serialize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/gramjs/serialize.ts"],"names":[],"mappings":";;AAMA,wDAqBC;AA3BD,uCAA8C;AAC9C,0DAAsD;AACtD,oDAA0D;AAI1D,SAAgB,sBAAsB,CAAC,OAAwB;IAC3D,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACjC,MAAM,IAAI,sBAAe,CAAC,gCAAgC,CAAC,CAAA;IAC/D,CAAC;IAED,MAAM,SAAS,GAAG,IAAA,yBAAW,GAAE,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAE7D,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;IACjD,MAAM,EAAE,GAAG,IAAA,6BAAkB,EAAC,EAAE,CAAC,CAAA;IAEjC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IACjC,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;IAEpB,IAAI,GAAG,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAA;IAE9B,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,GAAG,IAAI,CAAC,CAAA;IACR,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAE5B,OAAO,IAAI,IAAA,yBAAW,GAAE,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAA;AAC/C,CAAC","sourcesContent":["import { MtArgumentError } from '@mtcute/core'\nimport { getPlatform } from '@mtcute/core/platform.js'\nimport { dataViewFromBuffer } from '@mtcute/core/utils.js'\n\nimport type { TelethonSession } from '../telethon/types.js'\n\nexport function serializeGramjsSession(session: TelethonSession) {\n if (session.authKey.length !== 256) {\n throw new MtArgumentError('authKey must be 256 bytes long')\n }\n\n const ipEncoded = getPlatform().utf8Encode(session.ipAddress)\n\n const u8 = new Uint8Array(261 + ipEncoded.length)\n const dv = dataViewFromBuffer(u8)\n\n dv.setUint8(0, session.dcId)\n dv.setUint16(1, ipEncoded.length)\n u8.set(ipEncoded, 3)\n\n let pos = 3 + ipEncoded.length\n\n dv.setUint16(pos, session.port)\n pos += 2\n u8.set(session.authKey, pos)\n\n return `1${getPlatform().base64Encode(u8)}`\n}\n"]}
|
package/cjs/gramjs/types.js
DELETED
package/cjs/gramjs/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/gramjs/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface GramjsSession {\n dcId: number\n ipAddress: string\n ipv6: boolean\n port: number\n authKey: Uint8Array\n}\n"]}
|
package/cjs/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
if (typeof globalThis !== 'undefined' && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
3
|
-
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true
|
|
4
|
-
console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed soon. Please consider switching to ESM, it's "+(new Date()).getFullYear()+" already.")
|
|
5
|
-
console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c")
|
|
6
|
-
}
|
|
7
|
-
"use strict";
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./dcs.js"), exports);
|
|
24
|
-
__exportStar(require("./gramjs/index.js"), exports);
|
|
25
|
-
__exportStar(require("./mtkruto/index.js"), exports);
|
|
26
|
-
__exportStar(require("./pyrogram/index.js"), exports);
|
|
27
|
-
__exportStar(require("./telethon/index.js"), exports);
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,oDAAiC;AACjC,qDAAkC;AAClC,sDAAmC;AACnC,sDAAmC","sourcesContent":["export * from './dcs.js'\nexport * from './gramjs/index.js'\nexport * from './mtkruto/index.js'\nexport * from './pyrogram/index.js'\nexport * from './telethon/index.js'\n"]}
|
package/cjs/mtkruto/convert.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertFromMtkrutoSession = convertFromMtkrutoSession;
|
|
4
|
-
exports.convertToMtkrutoSession = convertToMtkrutoSession;
|
|
5
|
-
const utils_js_1 = require("@mtcute/core/utils.js");
|
|
6
|
-
const dcs_js_1 = require("../dcs.js");
|
|
7
|
-
const parse_js_1 = require("./parse.js");
|
|
8
|
-
const serialize_js_1 = require("./serialize.js");
|
|
9
|
-
function convertFromMtkrutoSession(session) {
|
|
10
|
-
if (typeof session === 'string') {
|
|
11
|
-
session = (0, parse_js_1.parseMtkrutoSession)(session);
|
|
12
|
-
}
|
|
13
|
-
return {
|
|
14
|
-
version: 3,
|
|
15
|
-
testMode: session.isTest,
|
|
16
|
-
primaryDcs: (session.isTest ? dcs_js_1.DC_MAPPING_TEST : dcs_js_1.DC_MAPPING_PROD)[session.dcId],
|
|
17
|
-
authKey: session.authKey,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function convertToMtkrutoSession(session) {
|
|
21
|
-
if (typeof session === 'string') {
|
|
22
|
-
session = (0, utils_js_1.readStringSession)(session);
|
|
23
|
-
}
|
|
24
|
-
return (0, serialize_js_1.serializeMtkrutoSession)({
|
|
25
|
-
dcId: session.primaryDcs.main.id,
|
|
26
|
-
isTest: session.testMode,
|
|
27
|
-
authKey: session.authKey,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/mtkruto/convert.ts"],"names":[],"mappings":";;AASA,8DAWC;AAED,0DAUC;AA/BD,oDAAyD;AAEzD,sCAA4D;AAE5D,yCAAgD;AAChD,iDAAwD;AAGxD,SAAgB,yBAAyB,CAAC,OAAgC;IACtE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAA,8BAAmB,EAAC,OAAO,CAAC,CAAA;IAC1C,CAAC;IAED,OAAO;QACH,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,OAAO,CAAC,MAAM;QACxB,UAAU,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,wBAAe,CAAC,CAAC,CAAC,wBAAe,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9E,OAAO,EAAE,OAAO,CAAC,OAAO;KAC3B,CAAA;AACL,CAAC;AAED,SAAgB,uBAAuB,CAAC,OAAmC;IACvE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAA,4BAAiB,EAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,IAAA,sCAAuB,EAAC;QAC3B,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAChC,MAAM,EAAE,OAAO,CAAC,QAAQ;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;KAC3B,CAAC,CAAA;AACN,CAAC","sourcesContent":["import type { StringSessionData } from '@mtcute/core/utils.js'\nimport { readStringSession } from '@mtcute/core/utils.js'\n\nimport { DC_MAPPING_PROD, DC_MAPPING_TEST } from '../dcs.js'\n\nimport { parseMtkrutoSession } from './parse.js'\nimport { serializeMtkrutoSession } from './serialize.js'\nimport type { MtkrutoSession } from './types.js'\n\nexport function convertFromMtkrutoSession(session: MtkrutoSession | string): StringSessionData {\n if (typeof session === 'string') {\n session = parseMtkrutoSession(session)\n }\n\n return {\n version: 3,\n testMode: session.isTest,\n primaryDcs: (session.isTest ? DC_MAPPING_TEST : DC_MAPPING_PROD)[session.dcId],\n authKey: session.authKey,\n }\n}\n\nexport function convertToMtkrutoSession(session: StringSessionData | string): string {\n if (typeof session === 'string') {\n session = readStringSession(session)\n }\n\n return serializeMtkrutoSession({\n dcId: session.primaryDcs.main.id,\n isTest: session.testMode,\n authKey: session.authKey,\n })\n}\n"]}
|
package/cjs/mtkruto/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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("./convert.js"), exports);
|
|
18
|
-
__exportStar(require("./parse.js"), exports);
|
|
19
|
-
__exportStar(require("./serialize.js"), exports);
|
|
20
|
-
__exportStar(require("./types.js"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/mtkruto/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mtkruto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,6CAA0B;AAC1B,iDAA8B;AAC9B,6CAA0B","sourcesContent":["export * from './convert.js'\nexport * from './parse.js'\nexport * from './serialize.js'\nexport * from './types.js'\n"]}
|
package/cjs/mtkruto/parse.d.ts
DELETED
package/cjs/mtkruto/parse.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseMtkrutoSession = parseMtkrutoSession;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
const platform_js_1 = require("@mtcute/core/platform.js");
|
|
6
|
-
const utils_js_1 = require("@mtcute/core/utils.js");
|
|
7
|
-
const rle_js_1 = require("../utils/rle.js");
|
|
8
|
-
function parseMtkrutoSession(session) {
|
|
9
|
-
const data = (0, rle_js_1.telegramRleDecode)((0, platform_js_1.getPlatform)().base64Decode(session, true));
|
|
10
|
-
const reader = utils_js_1.TlBinaryReader.manual(data);
|
|
11
|
-
let dcIdStr = reader.string();
|
|
12
|
-
const authKey = reader.bytes();
|
|
13
|
-
const isTest = dcIdStr.endsWith('-test');
|
|
14
|
-
if (isTest) {
|
|
15
|
-
dcIdStr = dcIdStr.slice(0, -5);
|
|
16
|
-
}
|
|
17
|
-
const dcId = Number(dcIdStr);
|
|
18
|
-
if (Number.isNaN(dcId)) {
|
|
19
|
-
throw new core_1.MtArgumentError(`Invalid DC ID: ${dcIdStr}`);
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
dcId,
|
|
23
|
-
isTest,
|
|
24
|
-
authKey,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=parse.js.map
|
package/cjs/mtkruto/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/mtkruto/parse.ts"],"names":[],"mappings":";;AAQA,kDAuBC;AA/BD,uCAA8C;AAC9C,0DAAsD;AACtD,oDAAsD;AAEtD,4CAAmD;AAInD,SAAgB,mBAAmB,CAAC,OAAe;IAC/C,MAAM,IAAI,GAAG,IAAA,0BAAiB,EAAC,IAAA,yBAAW,GAAE,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;IACzE,MAAM,MAAM,GAAG,yBAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAE1C,IAAI,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAA;IAC7B,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,CAAA;IAE9B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IAExC,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAClC,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IAE5B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,sBAAe,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,OAAO;QACH,IAAI;QACJ,MAAM;QACN,OAAO;KACV,CAAA;AACL,CAAC","sourcesContent":["import { MtArgumentError } from '@mtcute/core'\nimport { getPlatform } from '@mtcute/core/platform.js'\nimport { TlBinaryReader } from '@mtcute/core/utils.js'\n\nimport { telegramRleDecode } from '../utils/rle.js'\n\nimport type { MtkrutoSession } from './types.js'\n\nexport function parseMtkrutoSession(session: string): MtkrutoSession {\n const data = telegramRleDecode(getPlatform().base64Decode(session, true))\n const reader = TlBinaryReader.manual(data)\n\n let dcIdStr = reader.string()\n const authKey = reader.bytes()\n\n const isTest = dcIdStr.endsWith('-test')\n\n if (isTest) {\n dcIdStr = dcIdStr.slice(0, -5)\n }\n const dcId = Number(dcIdStr)\n\n if (Number.isNaN(dcId)) {\n throw new MtArgumentError(`Invalid DC ID: ${dcIdStr}`)\n }\n\n return {\n dcId,\n isTest,\n authKey,\n }\n}\n"]}
|
package/cjs/mtkruto/serialize.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeMtkrutoSession = serializeMtkrutoSession;
|
|
4
|
-
const platform_js_1 = require("@mtcute/core/platform.js");
|
|
5
|
-
const utils_js_1 = require("@mtcute/core/utils.js");
|
|
6
|
-
const rle_js_1 = require("../utils/rle.js");
|
|
7
|
-
function serializeMtkrutoSession(session) {
|
|
8
|
-
const dcIdStr = `${session.dcId}${session.isTest ? '-test' : ''}`;
|
|
9
|
-
const writer = utils_js_1.TlBinaryWriter.manual(session.authKey.length + dcIdStr.length + 8);
|
|
10
|
-
writer.string(dcIdStr);
|
|
11
|
-
writer.bytes(session.authKey);
|
|
12
|
-
return (0, platform_js_1.getPlatform)().base64Encode((0, rle_js_1.telegramRleEncode)(writer.result()), true);
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=serialize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/mtkruto/serialize.ts"],"names":[],"mappings":";;AAOA,0DASC;AAhBD,0DAAsD;AACtD,oDAAsD;AAEtD,4CAAmD;AAInD,SAAgB,uBAAuB,CAAC,OAAuB;IAC3D,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAEjE,MAAM,MAAM,GAAG,yBAAc,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAEjF,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACtB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAE7B,OAAO,IAAA,yBAAW,GAAE,CAAC,YAAY,CAAC,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["import { getPlatform } from '@mtcute/core/platform.js'\nimport { TlBinaryWriter } from '@mtcute/core/utils.js'\n\nimport { telegramRleEncode } from '../utils/rle.js'\n\nimport type { MtkrutoSession } from './types.js'\n\nexport function serializeMtkrutoSession(session: MtkrutoSession): string {\n const dcIdStr = `${session.dcId}${session.isTest ? '-test' : ''}`\n\n const writer = TlBinaryWriter.manual(session.authKey.length + dcIdStr.length + 8)\n\n writer.string(dcIdStr)\n writer.bytes(session.authKey)\n\n return getPlatform().base64Encode(telegramRleEncode(writer.result()), true)\n}\n"]}
|
package/cjs/mtkruto/types.js
DELETED
package/cjs/mtkruto/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/mtkruto/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface MtkrutoSession {\n dcId: number\n isTest: boolean\n authKey: Uint8Array\n}\n"]}
|
package/cjs/package.json
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { StringSessionData } from '@mtcute/core/utils.js';
|
|
2
|
-
import type { 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;
|
package/cjs/pyrogram/convert.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertFromPyrogramSession = convertFromPyrogramSession;
|
|
4
|
-
exports.convertToPyrogramSession = convertToPyrogramSession;
|
|
5
|
-
const utils_js_1 = require("@mtcute/core/utils.js");
|
|
6
|
-
const dcs_js_1 = require("../dcs.js");
|
|
7
|
-
const parse_js_1 = require("./parse.js");
|
|
8
|
-
const serialize_js_1 = require("./serialize.js");
|
|
9
|
-
function convertFromPyrogramSession(session) {
|
|
10
|
-
if (typeof session === 'string') {
|
|
11
|
-
session = (0, parse_js_1.parsePyrogramSession)(session);
|
|
12
|
-
}
|
|
13
|
-
return {
|
|
14
|
-
version: 3,
|
|
15
|
-
testMode: session.isTest,
|
|
16
|
-
primaryDcs: (session.isTest ? dcs_js_1.DC_MAPPING_TEST : dcs_js_1.DC_MAPPING_PROD)[session.dcId],
|
|
17
|
-
authKey: session.authKey,
|
|
18
|
-
self: {
|
|
19
|
-
userId: session.userId,
|
|
20
|
-
isBot: session.isBot,
|
|
21
|
-
isPremium: false,
|
|
22
|
-
usernames: [],
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function convertToPyrogramSession(session, params) {
|
|
27
|
-
if (typeof session === 'string') {
|
|
28
|
-
session = (0, utils_js_1.readStringSession)(session);
|
|
29
|
-
}
|
|
30
|
-
return (0, serialize_js_1.serializePyrogramSession)({
|
|
31
|
-
apiId: params?.apiId,
|
|
32
|
-
isBot: session.self?.isBot ?? false,
|
|
33
|
-
isTest: session.testMode,
|
|
34
|
-
userId: session.self?.userId ?? 0,
|
|
35
|
-
dcId: session.primaryDcs.main.id,
|
|
36
|
-
authKey: session.authKey,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/pyrogram/convert.ts"],"names":[],"mappings":";;AASA,gEAiBC;AAED,4DAkBC;AA7CD,oDAAyD;AAEzD,sCAA4D;AAE5D,yCAAiD;AACjD,iDAAyD;AAGzD,SAAgB,0BAA0B,CAAC,OAAiC;IACxE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAA,+BAAoB,EAAC,OAAO,CAAC,CAAA;IAC3C,CAAC;IAED,OAAO;QACH,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,OAAO,CAAC,MAAM;QACxB,UAAU,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,wBAAe,CAAC,CAAC,CAAC,wBAAe,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9E,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,EAAE;SAChB;KACJ,CAAA;AACL,CAAC;AAED,SAAgB,wBAAwB,CACpC,OAAmC,EACnC,MAEC;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAA,4BAAiB,EAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,IAAA,uCAAwB,EAAC;QAC5B,KAAK,EAAE,MAAM,EAAE,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,IAAI,KAAK;QACnC,MAAM,EAAE,OAAO,CAAC,QAAQ;QACxB,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;QACjC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAChC,OAAO,EAAE,OAAO,CAAC,OAAO;KAC3B,CAAC,CAAA;AACN,CAAC","sourcesContent":["import type { StringSessionData } from '@mtcute/core/utils.js'\nimport { readStringSession } from '@mtcute/core/utils.js'\n\nimport { DC_MAPPING_PROD, DC_MAPPING_TEST } from '../dcs.js'\n\nimport { parsePyrogramSession } from './parse.js'\nimport { serializePyrogramSession } from './serialize.js'\nimport type { PyrogramSession } from './types.js'\n\nexport function convertFromPyrogramSession(session: PyrogramSession | string): StringSessionData {\n if (typeof session === 'string') {\n session = parsePyrogramSession(session)\n }\n\n return {\n version: 3,\n testMode: session.isTest,\n primaryDcs: (session.isTest ? DC_MAPPING_TEST : DC_MAPPING_PROD)[session.dcId],\n authKey: session.authKey,\n self: {\n userId: session.userId,\n isBot: session.isBot,\n isPremium: false,\n usernames: [],\n },\n }\n}\n\nexport function convertToPyrogramSession(\n session: StringSessionData | string,\n params?: {\n apiId?: number\n },\n): string {\n if (typeof session === 'string') {\n session = readStringSession(session)\n }\n\n return serializePyrogramSession({\n apiId: params?.apiId,\n isBot: session.self?.isBot ?? false,\n isTest: session.testMode,\n userId: session.self?.userId ?? 0,\n dcId: session.primaryDcs.main.id,\n authKey: session.authKey,\n })\n}\n"]}
|
package/cjs/pyrogram/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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("./convert.js"), exports);
|
|
18
|
-
__exportStar(require("./parse.js"), exports);
|
|
19
|
-
__exportStar(require("./serialize.js"), exports);
|
|
20
|
-
__exportStar(require("./types.js"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pyrogram/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,6CAA0B;AAC1B,iDAA8B;AAC9B,6CAA0B","sourcesContent":["export * from './convert.js'\nexport * from './parse.js'\nexport * from './serialize.js'\nexport * from './types.js'\n"]}
|
package/cjs/pyrogram/parse.d.ts
DELETED
package/cjs/pyrogram/parse.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// source: https://github.com/pyrogram/pyrogram/blob/master/pyrogram/storage/storage.py
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.parsePyrogramSession = parsePyrogramSession;
|
|
5
|
-
const core_1 = require("@mtcute/core");
|
|
6
|
-
const platform_js_1 = require("@mtcute/core/platform.js");
|
|
7
|
-
const utils_js_1 = require("@mtcute/core/utils.js");
|
|
8
|
-
const SESSION_STRING_SIZE = 351;
|
|
9
|
-
const SESSION_STRING_SIZE_64 = 356;
|
|
10
|
-
function parsePyrogramSession(session) {
|
|
11
|
-
const data = (0, platform_js_1.getPlatform)().base64Decode(session, true);
|
|
12
|
-
const dv = (0, utils_js_1.dataViewFromBuffer)(data);
|
|
13
|
-
if (session.length === SESSION_STRING_SIZE || session.length === SESSION_STRING_SIZE_64) {
|
|
14
|
-
// old format
|
|
15
|
-
// const OLD_SESSION_STRING_FORMAT = '>B?256sI?'
|
|
16
|
-
// const OLD_SESSION_STRING_FORMAT_64 = '>B?256sQ?'
|
|
17
|
-
const dcId = dv.getUint8(0);
|
|
18
|
-
const isTest = dv.getUint8(1) !== 0;
|
|
19
|
-
const authKey = data.subarray(2, 258);
|
|
20
|
-
let userId;
|
|
21
|
-
if (data.length === SESSION_STRING_SIZE) {
|
|
22
|
-
userId = dv.getUint32(258);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
const high = dv.getUint32(258);
|
|
26
|
-
const low = dv.getUint32(262);
|
|
27
|
-
userId = core_1.Long.fromBits(low, high).toNumber();
|
|
28
|
-
}
|
|
29
|
-
const isBot = dv.getUint8(data.length - 1) !== 0;
|
|
30
|
-
return {
|
|
31
|
-
dcId,
|
|
32
|
-
isTest,
|
|
33
|
-
authKey,
|
|
34
|
-
userId,
|
|
35
|
-
isBot,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
// new format
|
|
39
|
-
// const SESSION_STRING_FORMAT = '>BI?256sQ?'
|
|
40
|
-
const dcId = dv.getUint8(0);
|
|
41
|
-
const apiId = dv.getUint32(1);
|
|
42
|
-
const isTest = dv.getUint8(5) !== 0;
|
|
43
|
-
const authKey = data.subarray(6, 262);
|
|
44
|
-
const userId = (0, utils_js_1.longFromBuffer)(data.subarray(262, 270), true, false).toNumber();
|
|
45
|
-
const isBot = dv.getUint8(270) !== 0;
|
|
46
|
-
return {
|
|
47
|
-
dcId,
|
|
48
|
-
apiId,
|
|
49
|
-
isTest,
|
|
50
|
-
authKey,
|
|
51
|
-
userId,
|
|
52
|
-
isBot,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=parse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/pyrogram/parse.ts"],"names":[],"mappings":";AAAA,uFAAuF;;AAWvF,oDAkDC;AA3DD,uCAAmC;AACnC,0DAAsD;AACtD,oDAA0E;AAI1E,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAC/B,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAElC,SAAgB,oBAAoB,CAAC,OAAe;IAChD,MAAM,IAAI,GAAG,IAAA,yBAAW,GAAE,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IACtD,MAAM,EAAE,GAAG,IAAA,6BAAkB,EAAC,IAAI,CAAC,CAAA;IAEnC,IAAI,OAAO,CAAC,MAAM,KAAK,mBAAmB,IAAI,OAAO,CAAC,MAAM,KAAK,sBAAsB,EAAE,CAAC;QACtF,aAAa;QACb,gDAAgD;QAChD,mDAAmD;QACnD,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;QAC3B,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;QAErC,IAAI,MAAM,CAAA;QAEV,IAAI,IAAI,CAAC,MAAM,KAAK,mBAAmB,EAAE,CAAC;YACtC,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QAC9B,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;YAC9B,MAAM,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;YAC7B,MAAM,GAAG,WAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;QAChD,CAAC;QAED,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAA;QAEhD,OAAO;YACH,IAAI;YACJ,MAAM;YACN,OAAO;YACP,MAAM;YACN,KAAK;SACR,CAAA;IACL,CAAC;IAED,aAAa;IACb,6CAA6C;IAC7C,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC3B,MAAM,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAC7B,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACrC,MAAM,MAAM,GAAG,IAAA,yBAAc,EAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC9E,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAEpC,OAAO;QACH,IAAI;QACJ,KAAK;QACL,MAAM;QACN,OAAO;QACP,MAAM;QACN,KAAK;KACR,CAAA;AACL,CAAC","sourcesContent":["// source: https://github.com/pyrogram/pyrogram/blob/master/pyrogram/storage/storage.py\n\nimport { Long } from '@mtcute/core'\nimport { getPlatform } from '@mtcute/core/platform.js'\nimport { dataViewFromBuffer, longFromBuffer } from '@mtcute/core/utils.js'\n\nimport type { PyrogramSession } from './types.js'\n\nconst SESSION_STRING_SIZE = 351\nconst SESSION_STRING_SIZE_64 = 356\n\nexport function parsePyrogramSession(session: string): PyrogramSession {\n const data = getPlatform().base64Decode(session, true)\n const dv = dataViewFromBuffer(data)\n\n if (session.length === SESSION_STRING_SIZE || session.length === SESSION_STRING_SIZE_64) {\n // old format\n // const OLD_SESSION_STRING_FORMAT = '>B?256sI?'\n // const OLD_SESSION_STRING_FORMAT_64 = '>B?256sQ?'\n const dcId = dv.getUint8(0)\n const isTest = dv.getUint8(1) !== 0\n const authKey = data.subarray(2, 258)\n\n let userId\n\n if (data.length === SESSION_STRING_SIZE) {\n userId = dv.getUint32(258)\n } else {\n const high = dv.getUint32(258)\n const low = dv.getUint32(262)\n userId = Long.fromBits(low, high).toNumber()\n }\n\n const isBot = dv.getUint8(data.length - 1) !== 0\n\n return {\n dcId,\n isTest,\n authKey,\n userId,\n isBot,\n }\n }\n\n // new format\n // const SESSION_STRING_FORMAT = '>BI?256sQ?'\n const dcId = dv.getUint8(0)\n const apiId = dv.getUint32(1)\n const isTest = dv.getUint8(5) !== 0\n const authKey = data.subarray(6, 262)\n const userId = longFromBuffer(data.subarray(262, 270), true, false).toNumber()\n const isBot = dv.getUint8(270) !== 0\n\n return {\n dcId,\n apiId,\n isTest,\n authKey,\n userId,\n isBot,\n }\n}\n"]}
|