@mtcute/convert 0.16.0 → 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/README.md +1 -1
- package/gramjs/__fixtures__/session.d.ts +1 -0
- 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/mtkruto/convert.test.d.ts +1 -0
- package/mtkruto/parse.test.d.ts +1 -0
- 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/pyrogram/convert.test.d.ts +1 -0
- package/pyrogram/parse.test.d.ts +1 -0
- 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/telethon/convert.test.d.ts +1 -0
- package/telethon/parse.test.d.ts +1 -0
- 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.js +0 -28
- 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 -31
- package/cjs/gramjs/parse.js.map +0 -1
- package/cjs/gramjs/serialize.js +0 -24
- 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 -31
- 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.js +0 -28
- package/cjs/mtkruto/parse.js.map +0 -1
- package/cjs/mtkruto/serialize.js +0 -15
- 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.js +0 -40
- 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.js +0 -56
- package/cjs/pyrogram/parse.js.map +0 -1
- package/cjs/pyrogram/serialize.js +0 -40
- 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.js +0 -44
- 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.js +0 -33
- package/cjs/telethon/parse.js.map +0 -1
- package/cjs/telethon/serialize.js +0 -34
- 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 -45
- package/cjs/utils/ip.js.map +0 -1
- package/cjs/utils/rle.js +0 -55
- 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.d.ts +0 -4
- 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.d.ts +0 -2
- 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.d.ts +0 -6
- 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.d.ts +0 -2
- package/esm/pyrogram/parse.js +0 -52
- package/esm/pyrogram/parse.js.map +0 -1
- package/esm/pyrogram/serialize.d.ts +0 -2
- 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.d.ts +0 -4
- 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.d.ts +0 -2
- package/esm/telethon/parse.js +0 -29
- package/esm/telethon/parse.js.map +0 -1
- package/esm/telethon/serialize.d.ts +0 -2
- 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/dcs.d.ts → dcs.d.ts} +0 -0
- /package/{cjs/gramjs → gramjs}/convert.d.ts +0 -0
- /package/{cjs/types.d.ts → gramjs/convert.test.d.ts} +0 -0
- /package/{cjs/gramjs → gramjs}/index.d.ts +0 -0
- /package/{cjs/gramjs → gramjs}/parse.d.ts +0 -0
- /package/{esm/types.d.ts → gramjs/parse.test.d.ts} +0 -0
- /package/{cjs/gramjs → gramjs}/serialize.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}/convert.d.ts +0 -0
- /package/{cjs/mtkruto → mtkruto}/index.d.ts +0 -0
- /package/{cjs/mtkruto → mtkruto}/parse.d.ts +0 -0
- /package/{cjs/mtkruto → mtkruto}/serialize.d.ts +0 -0
- /package/{cjs/mtkruto → mtkruto}/types.d.ts +0 -0
- /package/{cjs/pyrogram → pyrogram}/convert.d.ts +0 -0
- /package/{cjs/pyrogram → pyrogram}/index.d.ts +0 -0
- /package/{cjs/pyrogram → pyrogram}/parse.d.ts +0 -0
- /package/{cjs/pyrogram → pyrogram}/serialize.d.ts +0 -0
- /package/{cjs/pyrogram → pyrogram}/types.d.ts +0 -0
- /package/{cjs/telethon → telethon}/convert.d.ts +0 -0
- /package/{cjs/telethon → telethon}/index.d.ts +0 -0
- /package/{cjs/telethon → telethon}/parse.d.ts +0 -0
- /package/{cjs/telethon → telethon}/serialize.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/telethon/parse.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseTelethonSession = void 0;
|
|
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 ip_js_1 = require("../utils/ip.js");
|
|
8
|
-
function parseTelethonSession(session) {
|
|
9
|
-
if (session[0] !== '1') {
|
|
10
|
-
// version
|
|
11
|
-
throw new core_1.MtArgumentError(`Invalid session string (version = ${session[0]})`);
|
|
12
|
-
}
|
|
13
|
-
session = session.slice(1);
|
|
14
|
-
const data = (0, platform_js_1.getPlatform)().base64Decode(session, true);
|
|
15
|
-
const dv = (0, utils_js_1.dataViewFromBuffer)(data);
|
|
16
|
-
const dcId = dv.getUint8(0);
|
|
17
|
-
const ipSize = session.length === 352 ? 4 : 16;
|
|
18
|
-
let pos = 1 + ipSize;
|
|
19
|
-
const ipBytes = data.subarray(1, pos);
|
|
20
|
-
const port = dv.getUint16(pos);
|
|
21
|
-
pos += 2;
|
|
22
|
-
const authKey = data.subarray(pos, pos + 256);
|
|
23
|
-
const ip = (0, ip_js_1.parseIpFromBytes)(ipBytes);
|
|
24
|
-
return {
|
|
25
|
-
dcId,
|
|
26
|
-
ipAddress: ip,
|
|
27
|
-
ipv6: ipSize === 16,
|
|
28
|
-
port,
|
|
29
|
-
authKey,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.parseTelethonSession = parseTelethonSession;
|
|
33
|
-
//# sourceMappingURL=parse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["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Error } from '@mtcute/core'\nimport { getPlatform } from '@mtcute/core/platform.js'\nimport { dataViewFromBuffer } from '@mtcute/core/utils.js'\n\nimport { parseIpFromBytes } from '../utils/ip.js'\nimport { TelethonSession } from './types.js'\n\nexport function parseTelethonSession(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, true)\n const dv = dataViewFromBuffer(data)\n\n const dcId = dv.getUint8(0)\n\n const ipSize = session.length === 352 ? 4 : 16\n let pos = 1 + ipSize\n\n const ipBytes = data.subarray(1, pos)\n const port = dv.getUint16(pos)\n pos += 2\n const authKey = data.subarray(pos, pos + 256)\n\n const ip = parseIpFromBytes(ipBytes)\n\n return {\n dcId,\n ipAddress: ip,\n ipv6: ipSize === 16,\n port,\n authKey,\n }\n}\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeTelethonSession = void 0;
|
|
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 ip_js_1 = require("../utils/ip.js");
|
|
8
|
-
function serializeTelethonSession(session) {
|
|
9
|
-
if (session.authKey.length !== 256) {
|
|
10
|
-
throw new core_1.MtArgumentError('authKey must be 256 bytes long');
|
|
11
|
-
}
|
|
12
|
-
const ipSize = session.ipv6 ? 16 : 4;
|
|
13
|
-
const u8 = new Uint8Array(259 + ipSize);
|
|
14
|
-
const dv = (0, utils_js_1.dataViewFromBuffer)(u8);
|
|
15
|
-
dv.setUint8(0, session.dcId);
|
|
16
|
-
let pos;
|
|
17
|
-
if (session.ipv6) {
|
|
18
|
-
(0, ip_js_1.serializeIpv6ToBytes)(session.ipAddress, u8.subarray(1, 17));
|
|
19
|
-
pos = 17;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
(0, ip_js_1.serializeIpv4ToBytes)(session.ipAddress, u8.subarray(1, 5));
|
|
23
|
-
pos = 5;
|
|
24
|
-
}
|
|
25
|
-
dv.setUint16(pos, session.port);
|
|
26
|
-
pos += 2;
|
|
27
|
-
u8.set(session.authKey, pos);
|
|
28
|
-
let b64 = (0, platform_js_1.getPlatform)().base64Encode(u8, true);
|
|
29
|
-
while (b64.length % 4 !== 0)
|
|
30
|
-
b64 += '='; // for some reason telethon uses padding
|
|
31
|
-
return '1' + b64;
|
|
32
|
-
}
|
|
33
|
-
exports.serializeTelethonSession = serializeTelethonSession;
|
|
34
|
-
//# sourceMappingURL=serialize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/telethon/serialize.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAC9C,0DAAsD;AACtD,oDAA0D;AAE1D,0CAA2E;AAG3E,SAAgB,wBAAwB,CAAC,OAAwB;IAC7D,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACjC,MAAM,IAAI,sBAAe,CAAC,gCAAgC,CAAC,CAAA;IAC/D,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACpC,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,GAAG,GAAG,MAAM,CAAC,CAAA;IACvC,MAAM,EAAE,GAAG,IAAA,6BAAkB,EAAC,EAAE,CAAC,CAAA;IAEjC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5B,IAAI,GAAG,CAAA;IAEP,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,IAAA,4BAAoB,EAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QAC3D,GAAG,GAAG,EAAE,CAAA;IACZ,CAAC;SAAM,CAAC;QACJ,IAAA,4BAAoB,EAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAC1D,GAAG,GAAG,CAAC,CAAA;IACX,CAAC;IAED,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,IAAI,GAAG,GAAG,IAAA,yBAAW,GAAE,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAC9C,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;QAAE,GAAG,IAAI,GAAG,CAAA,CAAC,wCAAwC;IAEhF,OAAO,GAAG,GAAG,GAAG,CAAA;AACpB,CAAC;AA7BD,4DA6BC","sourcesContent":["import { MtArgumentError } from '@mtcute/core'\nimport { getPlatform } from '@mtcute/core/platform.js'\nimport { dataViewFromBuffer } from '@mtcute/core/utils.js'\n\nimport { serializeIpv4ToBytes, serializeIpv6ToBytes } from '../utils/ip.js'\nimport { TelethonSession } from './types.js'\n\nexport function serializeTelethonSession(session: TelethonSession) {\n if (session.authKey.length !== 256) {\n throw new MtArgumentError('authKey must be 256 bytes long')\n }\n\n const ipSize = session.ipv6 ? 16 : 4\n const u8 = new Uint8Array(259 + ipSize)\n const dv = dataViewFromBuffer(u8)\n\n dv.setUint8(0, session.dcId)\n\n let pos\n\n if (session.ipv6) {\n serializeIpv6ToBytes(session.ipAddress, u8.subarray(1, 17))\n pos = 17\n } else {\n serializeIpv4ToBytes(session.ipAddress, u8.subarray(1, 5))\n pos = 5\n }\n\n dv.setUint16(pos, session.port)\n pos += 2\n u8.set(session.authKey, pos)\n\n let b64 = getPlatform().base64Encode(u8, true)\n while (b64.length % 4 !== 0) b64 += '=' // for some reason telethon uses padding\n\n return '1' + b64\n}\n"]}
|
package/cjs/telethon/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/telethon/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface TelethonSession {\n dcId: number\n ipAddress: string\n ipv6: boolean\n port: number\n authKey: Uint8Array\n}\n"]}
|
package/cjs/types.js
DELETED
package/cjs/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
package/cjs/utils/ip.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeIpv6ToBytes = exports.serializeIpv4ToBytes = exports.parseIpFromBytes = void 0;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
function parseIpFromBytes(data) {
|
|
6
|
-
if (data.length === 4) {
|
|
7
|
-
return `${data[0]}.${data[1]}.${data[2]}.${data[3]}`;
|
|
8
|
-
}
|
|
9
|
-
if (data.length === 16) {
|
|
10
|
-
let res = '';
|
|
11
|
-
for (let i = 0; i < 16; i += 2) {
|
|
12
|
-
res += data[i].toString(16).padStart(2, '0');
|
|
13
|
-
res += data[i + 1].toString(16).padStart(2, '0');
|
|
14
|
-
if (i < 14)
|
|
15
|
-
res += ':';
|
|
16
|
-
}
|
|
17
|
-
return res;
|
|
18
|
-
}
|
|
19
|
-
throw new core_1.MtArgumentError('Invalid IP address length');
|
|
20
|
-
}
|
|
21
|
-
exports.parseIpFromBytes = parseIpFromBytes;
|
|
22
|
-
function serializeIpv4ToBytes(ip, buf) {
|
|
23
|
-
const parts = ip.split('.');
|
|
24
|
-
if (parts.length !== 4) {
|
|
25
|
-
throw new core_1.MtArgumentError('Invalid IPv4 address');
|
|
26
|
-
}
|
|
27
|
-
buf[0] = Number(parts[0]);
|
|
28
|
-
buf[1] = Number(parts[1]);
|
|
29
|
-
buf[2] = Number(parts[2]);
|
|
30
|
-
buf[3] = Number(parts[3]);
|
|
31
|
-
}
|
|
32
|
-
exports.serializeIpv4ToBytes = serializeIpv4ToBytes;
|
|
33
|
-
function serializeIpv6ToBytes(ip, buf) {
|
|
34
|
-
const parts = ip.split(':');
|
|
35
|
-
if (parts.length !== 8) {
|
|
36
|
-
throw new core_1.MtArgumentError('Invalid IPv6 address');
|
|
37
|
-
}
|
|
38
|
-
for (let i = 0; i < 8; i++) {
|
|
39
|
-
const val = parseInt(parts[i], 16);
|
|
40
|
-
buf[i * 2] = val >> 8;
|
|
41
|
-
buf[i * 2 + 1] = val & 0xff;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.serializeIpv6ToBytes = serializeIpv6ToBytes;
|
|
45
|
-
//# sourceMappingURL=ip.js.map
|
package/cjs/utils/ip.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ip.js","sourceRoot":"","sources":["../../../src/utils/ip.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAE9C,SAAgB,gBAAgB,CAAC,IAAgB;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IACxD,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACrB,IAAI,GAAG,GAAG,EAAE,CAAA;QAEZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,GAAG,I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,CAAC,CAAA;IACrD,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAClC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAA;QACrB,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAA;IAC/B,CAAC;AACL,CAAC;AAZD,oDAYC","sourcesContent":["import { MtArgumentError } from '@mtcute/core'\n\nexport function parseIpFromBytes(data: Uint8Array): string {\n if (data.length === 4) {\n return `${data[0]}.${data[1]}.${data[2]}.${data[3]}`\n }\n\n if (data.length === 16) {\n let res = ''\n\n for (let i = 0; i < 16; i += 2) {\n res += data[i].toString(16).padStart(2, '0')\n res += data[i + 1].toString(16).padStart(2, '0')\n if (i < 14) res += ':'\n }\n\n return res\n }\n\n throw new MtArgumentError('Invalid IP address length')\n}\n\nexport function serializeIpv4ToBytes(ip: string, buf: Uint8Array) {\n const parts = ip.split('.')\n\n if (parts.length !== 4) {\n throw new MtArgumentError('Invalid IPv4 address')\n }\n\n buf[0] = Number(parts[0])\n buf[1] = Number(parts[1])\n buf[2] = Number(parts[2])\n buf[3] = Number(parts[3])\n}\n\nexport function serializeIpv6ToBytes(ip: string, buf: Uint8Array) {\n const parts = ip.split(':')\n\n if (parts.length !== 8) {\n throw new MtArgumentError('Invalid IPv6 address')\n }\n\n for (let i = 0; i < 8; i++) {\n const val = parseInt(parts[i], 16)\n buf[i * 2] = val >> 8\n buf[i * 2 + 1] = val & 0xff\n }\n}\n"]}
|
package/cjs/utils/rle.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// tdlib's RLE only encodes consecutive \x00
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.assertNever = exports.telegramRleDecode = exports.telegramRleEncode = void 0;
|
|
5
|
-
function telegramRleEncode(buf) {
|
|
6
|
-
const len = buf.length;
|
|
7
|
-
const ret = [];
|
|
8
|
-
let count = 0;
|
|
9
|
-
for (let i = 0; i < len; i++) {
|
|
10
|
-
const cur = buf[i];
|
|
11
|
-
if (cur === 0) {
|
|
12
|
-
count += 1;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
if (count > 0) {
|
|
16
|
-
ret.push(0, count);
|
|
17
|
-
count = 0;
|
|
18
|
-
}
|
|
19
|
-
ret.push(cur);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (count > 0) {
|
|
23
|
-
ret.push(0, count);
|
|
24
|
-
}
|
|
25
|
-
return new Uint8Array(ret);
|
|
26
|
-
}
|
|
27
|
-
exports.telegramRleEncode = telegramRleEncode;
|
|
28
|
-
function telegramRleDecode(buf) {
|
|
29
|
-
const len = buf.length;
|
|
30
|
-
const ret = [];
|
|
31
|
-
let prev = -1;
|
|
32
|
-
for (let i = 0; i < len; i++) {
|
|
33
|
-
const cur = buf[i];
|
|
34
|
-
if (prev === 0) {
|
|
35
|
-
for (let j = 0; j < cur; j++) {
|
|
36
|
-
ret.push(prev);
|
|
37
|
-
}
|
|
38
|
-
prev = -1;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
if (prev !== -1)
|
|
42
|
-
ret.push(prev);
|
|
43
|
-
prev = cur;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (prev !== -1)
|
|
47
|
-
ret.push(prev);
|
|
48
|
-
return new Uint8Array(ret);
|
|
49
|
-
}
|
|
50
|
-
exports.telegramRleDecode = telegramRleDecode;
|
|
51
|
-
function assertNever(_) {
|
|
52
|
-
throw new Error('unreachable');
|
|
53
|
-
}
|
|
54
|
-
exports.assertNever = assertNever;
|
|
55
|
-
//# sourceMappingURL=rle.js.map
|
package/cjs/utils/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AAA;QAElB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAClB,CAAC;YACD,IAAI,GAAG,CAAC,CAAC,CAAA;QACb,CAAC;aAAM,CAAC;YACJ,IAAI,IAAI,KAAK,CAAC,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC/B,IAAI,GAAG,GAAG,CAAA;QACd,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,CAAC,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAE/B,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAA;AAC9B,CAAC;AAtBD,8CAsBC;AAED,SAAgB,WAAW,CAAC,CAAQ;IAChC,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;AAClC,CAAC;AAFD,kCAEC","sourcesContent":["// tdlib's RLE only encodes consecutive \\x00\n\nexport function telegramRleEncode(buf: Uint8Array): Uint8Array {\n const len = buf.length\n const ret: number[] = []\n let count = 0\n\n for (let i = 0; i < len; i++) {\n const cur = buf[i]\n\n if (cur === 0) {\n count += 1\n } else {\n if (count > 0) {\n ret.push(0, count)\n count = 0\n }\n\n ret.push(cur)\n }\n }\n\n if (count > 0) {\n ret.push(0, count)\n }\n\n return new Uint8Array(ret)\n}\n\nexport function telegramRleDecode(buf: Uint8Array): Uint8Array {\n const len = buf.length\n const ret: number[] = []\n let prev = -1\n\n for (let i = 0; i < len; i++) {\n const cur = buf[i]\n\n if (prev === 0) {\n for (let j = 0; j < cur; j++) {\n ret.push(prev)\n }\n prev = -1\n } else {\n if (prev !== -1) ret.push(prev)\n prev = cur\n }\n }\n\n if (prev !== -1) ret.push(prev)\n\n return new Uint8Array(ret)\n}\n\nexport function assertNever(_: never): never {\n throw new Error('unreachable')\n}\n"]}
|
package/esm/dcs.d.ts
DELETED
package/esm/dcs.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// some libraries only store the DCs in the source code, so we need to map them to the correct DCs
|
|
2
|
-
// this may not be very accurate, but it's better than nothing
|
|
3
|
-
// we *could* always map those to the primary dc (the client should handle that gracefully),
|
|
4
|
-
// but imo it's better to be as accurate as possible
|
|
5
|
-
// we'll also only map to ipv4 since that's more portable
|
|
6
|
-
export const DC_MAPPING_PROD = {
|
|
7
|
-
'1': {
|
|
8
|
-
main: {
|
|
9
|
-
id: 1,
|
|
10
|
-
ipAddress: '149.154.175.56',
|
|
11
|
-
port: 443,
|
|
12
|
-
},
|
|
13
|
-
media: {
|
|
14
|
-
id: 1,
|
|
15
|
-
ipAddress: '149.154.175.211',
|
|
16
|
-
port: 443,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
'2': {
|
|
20
|
-
main: {
|
|
21
|
-
id: 2,
|
|
22
|
-
ipAddress: '149.154.167.41',
|
|
23
|
-
port: 443,
|
|
24
|
-
},
|
|
25
|
-
media: {
|
|
26
|
-
id: 2,
|
|
27
|
-
ipAddress: '149.154.167.35',
|
|
28
|
-
port: 443,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
'3': {
|
|
32
|
-
main: {
|
|
33
|
-
id: 3,
|
|
34
|
-
ipAddress: '149.154.175.100',
|
|
35
|
-
port: 443,
|
|
36
|
-
},
|
|
37
|
-
media: {
|
|
38
|
-
id: 3,
|
|
39
|
-
ipAddress: '149.154.175.100',
|
|
40
|
-
port: 443,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
'4': {
|
|
44
|
-
main: {
|
|
45
|
-
id: 4,
|
|
46
|
-
ipAddress: '149.154.167.91',
|
|
47
|
-
port: 443,
|
|
48
|
-
},
|
|
49
|
-
media: {
|
|
50
|
-
id: 4,
|
|
51
|
-
ipAddress: '149.154.167.255',
|
|
52
|
-
port: 443,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
'5': {
|
|
56
|
-
main: {
|
|
57
|
-
id: 5,
|
|
58
|
-
ipAddress: '91.108.56.179',
|
|
59
|
-
port: 443,
|
|
60
|
-
},
|
|
61
|
-
media: {
|
|
62
|
-
id: 5,
|
|
63
|
-
ipAddress: '149.154.171.255',
|
|
64
|
-
port: 443,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
export const DC_MAPPING_TEST = {
|
|
69
|
-
'1': {
|
|
70
|
-
main: {
|
|
71
|
-
id: 1,
|
|
72
|
-
ipAddress: '149.154.175.10',
|
|
73
|
-
port: 80,
|
|
74
|
-
},
|
|
75
|
-
media: {
|
|
76
|
-
id: 1,
|
|
77
|
-
ipAddress: '149.154.175.10',
|
|
78
|
-
port: 80,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
'2': {
|
|
82
|
-
main: {
|
|
83
|
-
id: 2,
|
|
84
|
-
ipAddress: '149.154.167.40',
|
|
85
|
-
port: 443,
|
|
86
|
-
},
|
|
87
|
-
media: {
|
|
88
|
-
id: 2,
|
|
89
|
-
ipAddress: '149.154.167.40',
|
|
90
|
-
port: 443,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
'3': {
|
|
94
|
-
main: {
|
|
95
|
-
id: 3,
|
|
96
|
-
ipAddress: '149.154.175.117',
|
|
97
|
-
port: 443,
|
|
98
|
-
},
|
|
99
|
-
media: {
|
|
100
|
-
id: 3,
|
|
101
|
-
ipAddress: '149.154.175.117',
|
|
102
|
-
port: 443,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
export function isTestDc(ip) {
|
|
107
|
-
return Object.values(DC_MAPPING_TEST).some((dc) => dc.main.ipAddress === ip || dc.media.ipAddress === ip);
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=dcs.js.map
|
package/esm/dcs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|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IAAI,EAAE,GAAG;SACZ;KACJ;CACJ,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAA8B;IACtD,GAAG,EAAE;QACD,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,GAAG,EAAE;QACD,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,GAAG,EAAE;QACD,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,MAAM,UAAU,QAAQ,CAAC,EAAU;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,EAAE,CAAC,CAAA;AAC7G,CAAC","sourcesContent":["import { 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/esm/gramjs/convert.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
package/esm/gramjs/convert.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { readStringSession } from '@mtcute/core/utils.js';
|
|
2
|
-
import { convertFromTelethonSession } from '../telethon/convert.js';
|
|
3
|
-
import { parseGramjsSession } from './parse.js';
|
|
4
|
-
import { serializeGramjsSession } from './serialize.js';
|
|
5
|
-
export function convertFromGramjsSession(session) {
|
|
6
|
-
if (typeof session === 'string') {
|
|
7
|
-
session = parseGramjsSession(session);
|
|
8
|
-
}
|
|
9
|
-
return convertFromTelethonSession(session);
|
|
10
|
-
}
|
|
11
|
-
export function convertToGramjsSession(session) {
|
|
12
|
-
if (typeof session === 'string') {
|
|
13
|
-
session = readStringSession(session);
|
|
14
|
-
}
|
|
15
|
-
return serializeGramjsSession({
|
|
16
|
-
dcId: session.primaryDcs.main.id,
|
|
17
|
-
ipAddress: session.primaryDcs.main.ipAddress,
|
|
18
|
-
port: session.primaryDcs.main.port,
|
|
19
|
-
ipv6: session.primaryDcs.main.ipv6 ?? false,
|
|
20
|
-
authKey: session.authKey,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/gramjs/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,uBAAuB,CAAA;AAE5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,MAAM,UAAU,wBAAwB,CAAC,OAAiC;IACtE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAmC;IACtE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,sBAAsB,CAAC;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 { readStringSession, StringSessionData } from '@mtcute/core/utils.js'\n\nimport { convertFromTelethonSession } from '../telethon/convert.js'\nimport { TelethonSession } from '../telethon/types.js'\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/esm/gramjs/index.d.ts
DELETED
package/esm/gramjs/index.js
DELETED
package/esm/gramjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/gramjs/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA","sourcesContent":["export * from './convert.js'\nexport * from './parse.js'\nexport * from './serialize.js'\nexport * from './types.js'\n"]}
|
package/esm/gramjs/parse.d.ts
DELETED
package/esm/gramjs/parse.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MtArgumentError } from '@mtcute/core';
|
|
2
|
-
import { getPlatform } from '@mtcute/core/platform.js';
|
|
3
|
-
import { dataViewFromBuffer } from '@mtcute/core/utils.js';
|
|
4
|
-
export function parseGramjsSession(session) {
|
|
5
|
-
if (session[0] !== '1') {
|
|
6
|
-
// version
|
|
7
|
-
throw new MtArgumentError(`Invalid session string (version = ${session[0]})`);
|
|
8
|
-
}
|
|
9
|
-
session = session.slice(1);
|
|
10
|
-
const data = getPlatform().base64Decode(session);
|
|
11
|
-
const dv = dataViewFromBuffer(data);
|
|
12
|
-
const dcId = dv.getUint8(0);
|
|
13
|
-
const ipSize = dv.getUint16(1);
|
|
14
|
-
let pos = 3 + ipSize;
|
|
15
|
-
const ip = getPlatform().utf8Decode(data.subarray(3, pos));
|
|
16
|
-
const port = dv.getUint16(pos);
|
|
17
|
-
pos += 2;
|
|
18
|
-
const authKey = data.subarray(pos, pos + 256);
|
|
19
|
-
return {
|
|
20
|
-
dcId,
|
|
21
|
-
ipAddress: ip,
|
|
22
|
-
ipv6: ip.includes(':'), // dumb check but gramjs does this
|
|
23
|
-
port,
|
|
24
|
-
authKey,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=parse.js.map
|
package/esm/gramjs/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/gramjs/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAI1D,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAC9C,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACrB,UAAU;QACV,MAAM,IAAI,eAAe,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,WAAW,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;IAChD,MAAM,EAAE,GAAG,kBAAkB,CAAC,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,WAAW,EAAE,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 { 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/esm/gramjs/serialize.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { MtArgumentError } from '@mtcute/core';
|
|
2
|
-
import { getPlatform } from '@mtcute/core/platform.js';
|
|
3
|
-
import { dataViewFromBuffer } from '@mtcute/core/utils.js';
|
|
4
|
-
export function serializeGramjsSession(session) {
|
|
5
|
-
if (session.authKey.length !== 256) {
|
|
6
|
-
throw new MtArgumentError('authKey must be 256 bytes long');
|
|
7
|
-
}
|
|
8
|
-
const ipEncoded = getPlatform().utf8Encode(session.ipAddress);
|
|
9
|
-
const u8 = new Uint8Array(261 + ipEncoded.length);
|
|
10
|
-
const dv = dataViewFromBuffer(u8);
|
|
11
|
-
dv.setUint8(0, session.dcId);
|
|
12
|
-
dv.setUint16(1, ipEncoded.length);
|
|
13
|
-
u8.set(ipEncoded, 3);
|
|
14
|
-
let pos = 3 + ipEncoded.length;
|
|
15
|
-
dv.setUint16(pos, session.port);
|
|
16
|
-
pos += 2;
|
|
17
|
-
u8.set(session.authKey, pos);
|
|
18
|
-
return '1' + getPlatform().base64Encode(u8);
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=serialize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/gramjs/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAI1D,MAAM,UAAU,sBAAsB,CAAC,OAAwB;IAC3D,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACjC,MAAM,IAAI,eAAe,CAAC,gCAAgC,CAAC,CAAA;IAC/D,CAAC;IAED,MAAM,SAAS,GAAG,WAAW,EAAE,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,kBAAkB,CAAC,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,GAAG,GAAG,WAAW,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,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 { 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/esm/gramjs/types.d.ts
DELETED
package/esm/gramjs/types.js
DELETED
package/esm/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/esm/index.d.ts
DELETED
package/esm/index.js
DELETED
package/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA","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/esm/mtkruto/convert.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
package/esm/mtkruto/convert.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { readStringSession } from '@mtcute/core/utils.js';
|
|
2
|
-
import { DC_MAPPING_PROD, DC_MAPPING_TEST } from '../dcs.js';
|
|
3
|
-
import { parseMtkrutoSession } from './parse.js';
|
|
4
|
-
import { serializeMtkrutoSession } from './serialize.js';
|
|
5
|
-
export function convertFromMtkrutoSession(session) {
|
|
6
|
-
if (typeof session === 'string') {
|
|
7
|
-
session = parseMtkrutoSession(session);
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
version: 3,
|
|
11
|
-
testMode: session.isTest,
|
|
12
|
-
primaryDcs: (session.isTest ? DC_MAPPING_TEST : DC_MAPPING_PROD)[session.dcId],
|
|
13
|
-
authKey: session.authKey,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export function convertToMtkrutoSession(session) {
|
|
17
|
-
if (typeof session === 'string') {
|
|
18
|
-
session = readStringSession(session);
|
|
19
|
-
}
|
|
20
|
-
return serializeMtkrutoSession({
|
|
21
|
-
dcId: session.primaryDcs.main.id,
|
|
22
|
-
isTest: session.testMode,
|
|
23
|
-
authKey: session.authKey,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/mtkruto/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,uBAAuB,CAAA;AAE5E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAGxD,MAAM,UAAU,yBAAyB,CAAC,OAAgC;IACtE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,mBAAmB,CAAC,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,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9E,OAAO,EAAE,OAAO,CAAC,OAAO;KAC3B,CAAA;AACL,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAmC;IACvE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,uBAAuB,CAAC;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 { readStringSession, StringSessionData } from '@mtcute/core/utils.js'\n\nimport { DC_MAPPING_PROD, DC_MAPPING_TEST } from '../dcs.js'\nimport { parseMtkrutoSession } from './parse.js'\nimport { serializeMtkrutoSession } from './serialize.js'\nimport { 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/esm/mtkruto/index.d.ts
DELETED
package/esm/mtkruto/index.js
DELETED
package/esm/mtkruto/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mtkruto/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA","sourcesContent":["export * from './convert.js'\nexport * from './parse.js'\nexport * from './serialize.js'\nexport * from './types.js'\n"]}
|
package/esm/mtkruto/parse.d.ts
DELETED
package/esm/mtkruto/parse.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MtArgumentError } from '@mtcute/core';
|
|
2
|
-
import { getPlatform } from '@mtcute/core/platform.js';
|
|
3
|
-
import { TlBinaryReader } from '@mtcute/core/utils.js';
|
|
4
|
-
import { telegramRleDecode } from '../utils/rle.js';
|
|
5
|
-
export function parseMtkrutoSession(session) {
|
|
6
|
-
const data = telegramRleDecode(getPlatform().base64Decode(session, true));
|
|
7
|
-
const reader = TlBinaryReader.manual(data);
|
|
8
|
-
let dcIdStr = reader.string();
|
|
9
|
-
const authKey = reader.bytes();
|
|
10
|
-
const isTest = dcIdStr.endsWith('-test');
|
|
11
|
-
if (isTest) {
|
|
12
|
-
dcIdStr = dcIdStr.slice(0, -5);
|
|
13
|
-
}
|
|
14
|
-
const dcId = Number(dcIdStr);
|
|
15
|
-
if (isNaN(dcId)) {
|
|
16
|
-
throw new MtArgumentError(`Invalid DC ID: ${dcIdStr}`);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
dcId,
|
|
20
|
-
isTest,
|
|
21
|
-
authKey,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=parse.js.map
|
package/esm/mtkruto/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/mtkruto/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAGnD,MAAM,UAAU,mBAAmB,CAAC,OAAe;IAC/C,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;IACzE,MAAM,MAAM,GAAG,cAAc,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,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,eAAe,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'\nimport { 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 (isNaN(dcId)) {\n throw new MtArgumentError(`Invalid DC ID: ${dcIdStr}`)\n }\n\n return {\n dcId,\n isTest,\n authKey,\n }\n}\n"]}
|
package/esm/mtkruto/serialize.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getPlatform } from '@mtcute/core/platform.js';
|
|
2
|
-
import { TlBinaryWriter } from '@mtcute/core/utils.js';
|
|
3
|
-
import { telegramRleEncode } from '../utils/rle.js';
|
|
4
|
-
export function serializeMtkrutoSession(session) {
|
|
5
|
-
const dcIdStr = `${session.dcId}${session.isTest ? '-test' : ''}`;
|
|
6
|
-
const writer = TlBinaryWriter.manual(session.authKey.length + dcIdStr.length + 8);
|
|
7
|
-
writer.string(dcIdStr);
|
|
8
|
-
writer.bytes(session.authKey);
|
|
9
|
-
return getPlatform().base64Encode(telegramRleEncode(writer.result()), true);
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=serialize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/mtkruto/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAGnD,MAAM,UAAU,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,cAAc,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,WAAW,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,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'\nimport { 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"]}
|