telegram-tghub-better-new 0.7.2 → 0.7.4

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/Version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.7.2";
1
+ export declare const version = "0.7.4";
package/Version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "0.7.2";
4
+ exports.version = "0.7.4";
@@ -56,7 +56,6 @@ const crypto = __importStar(require("crypto"));
56
56
  const string_template_1 = __importDefault(require("string-template"));
57
57
  const iso_lang_codes_1 = __importDefault(require("iso-lang-codes"));
58
58
  const libphonenumber_js_1 = require("libphonenumber-js");
59
- const convert_1 = require("@mtcute/convert");
60
59
  const __1 = require("../");
61
60
  const IGE_1 = require("../crypto/IGE");
62
61
  const model_js_1 = __importDefault(require("./model.js"));
@@ -172,8 +171,24 @@ const getInitConnection = (sessionInfo) => {
172
171
  return initRequest;
173
172
  };
174
173
  exports.getInitConnection = getInitConnection;
174
+ function serializeGramjsSession(session) {
175
+ const authKey = Buffer.from(session.authKey);
176
+ if (authKey.length !== 256) {
177
+ throw new Error("authKey must be 256 bytes long");
178
+ }
179
+ const ipEncoded = Buffer.from(session.ipAddress, "utf-8");
180
+ const u8 = Buffer.alloc(261 + ipEncoded.length);
181
+ let pos = 0;
182
+ pos = u8.writeUInt8(session.dcId, pos);
183
+ pos = u8.writeUInt16BE(ipEncoded.length, pos);
184
+ ipEncoded.copy(u8, pos);
185
+ pos += ipEncoded.length;
186
+ pos = u8.writeUInt16BE(session.port, pos);
187
+ authKey.copy(u8, pos);
188
+ return `1${u8.toString("base64")}`;
189
+ }
175
190
  const saveStringSession = (data) => {
176
- const stringSession = (0, convert_1.serializeGramjsSession)(lodash_1.default.assign({}, lodash_1.default.pick(data, ["dcId", "port", "ipAddress", "authKey"]), {
191
+ const stringSession = serializeGramjsSession(lodash_1.default.assign({}, lodash_1.default.pick(data, ["dcId", "port", "ipAddress", "authKey"]), {
177
192
  ipv6: false,
178
193
  }));
179
194
  return stringSession;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-tghub-better-new",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "NodeJS/Browser MTProto API Telegram client library,",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -68,9 +68,6 @@
68
68
  "store2": "^2.13.0",
69
69
  "ts-custom-error": "^3.2.0",
70
70
  "websocket": "^1.0.34",
71
- "@mtcute/convert": "0.27.8",
72
- "@mtcute/core": "0.27.8",
73
- "@mtcute/node": "0.27.8",
74
71
  "adm-zip": "0.5.12",
75
72
  "axios": "1.13.4",
76
73
  "better-sqlite3": "11.5.0",