@mtcute/convert 0.18.0 → 0.19.1

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.
Files changed (38) hide show
  1. package/convert/src/dcs.cjs +2 -2
  2. package/convert/src/gramjs/convert.cjs +2 -2
  3. package/convert/src/gramjs/parse.cjs +2 -2
  4. package/convert/src/gramjs/serialize.cjs +2 -2
  5. package/convert/src/mtkruto/convert.cjs +2 -2
  6. package/convert/src/mtkruto/parse.cjs +2 -2
  7. package/convert/src/mtkruto/serialize.cjs +2 -2
  8. package/convert/src/pyrogram/convert.cjs +2 -2
  9. package/convert/src/pyrogram/parse.cjs +2 -2
  10. package/convert/src/pyrogram/serialize.cjs +2 -2
  11. package/convert/src/tdesktop/convert.cjs +2 -2
  12. package/convert/src/tdesktop/qt-bundle.cjs +2 -2
  13. package/convert/src/tdesktop/qt-reader.cjs +2 -2
  14. package/convert/src/tdesktop/qt-writer.cjs +2 -2
  15. package/convert/src/tdesktop/tdata.cjs +16 -16
  16. package/convert/src/tdesktop/tdata.js +7 -7
  17. package/convert/src/telethon/convert.cjs +2 -2
  18. package/convert/src/telethon/parse.cjs +2 -2
  19. package/convert/src/telethon/serialize.cjs +2 -2
  20. package/convert/src/utils/crypto.cjs +2 -2
  21. package/convert/src/utils/fs.cjs +33 -0
  22. package/convert/src/utils/fs.js +28 -0
  23. package/convert/src/utils/rle.cjs +2 -2
  24. package/gramjs/store-session.d.cts +10 -0
  25. package/gramjs/store-session.d.ts +10 -0
  26. package/gramjs/store-session.test.d.cts +1 -0
  27. package/gramjs/store-session.test.d.ts +1 -0
  28. package/index.cjs +2 -2
  29. package/index.d.cts +1 -0
  30. package/index.d.ts +1 -0
  31. package/node/src/utils/crypto.cjs +2 -2
  32. package/node/src/utils.cjs +2 -2
  33. package/package.json +2 -2
  34. package/tdesktop/tdata.d.cts +1 -1
  35. package/tdesktop/tdata.d.ts +1 -1
  36. package/utils/fs.d.cts +3 -0
  37. package/utils/fs.d.ts +3 -0
  38. package/wasm/src/index.cjs +2 -2
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -22,17 +22,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  ));
23
23
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
24
24
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
25
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
26
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
25
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
26
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
27
27
  }
28
28
  "use strict";
29
29
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
30
- const posix = require("node:path/posix");
31
30
  const io = require("@fuman/io");
32
31
  const utils = require("@fuman/utils");
33
32
  const core = require("@mtcute/core");
34
33
  const utils_js = require("@mtcute/core/utils.js");
35
34
  const crypto = require("../utils/crypto.cjs");
35
+ const fs = require("../utils/fs.cjs");
36
36
  const qtReader = require("./qt-reader.cjs");
37
37
  const qtWriter = require("./qt-writer.cjs");
38
38
  const TDF_MAGIC = /* @__PURE__ */ utils.utf8.encoder.encode("TDF$");
@@ -50,25 +50,25 @@ function toFilePart(key) {
50
50
  return str;
51
51
  }
52
52
  class Tdata {
53
- constructor(options, fs, crypto2) {
53
+ constructor(options, fs2, crypto2) {
54
54
  this.options = options;
55
- this.fs = fs;
55
+ this.fs = fs2;
56
56
  this.crypto = crypto2;
57
57
  }
58
58
  keyData;
59
59
  static async open(options) {
60
- const fs = options.fs ?? await import("node:fs/promises");
60
+ const fs2 = options.fs ?? await import("node:fs/promises");
61
61
  const crypto$1 = options.crypto ?? await crypto.getDefaultCryptoProvider();
62
62
  await crypto$1.initialize?.();
63
- const tdata = new Tdata(options, fs, crypto$1);
63
+ const tdata = new Tdata(options, fs2, crypto$1);
64
64
  tdata.keyData = await tdata.readKeyData();
65
65
  return tdata;
66
66
  }
67
67
  static async create(options) {
68
- const fs = options.fs ?? await import("node:fs/promises");
68
+ const fs2 = options.fs ?? await import("node:fs/promises");
69
69
  const crypto$1 = options.crypto ?? await crypto.getDefaultCryptoProvider();
70
70
  await crypto$1.initialize?.();
71
- const tdata = new Tdata(options, fs, crypto$1);
71
+ const tdata = new Tdata(options, fs2, crypto$1);
72
72
  const keyData = {
73
73
  ...options.keyData,
74
74
  localKey: options.keyData.localKey ?? crypto$1.randomBytes(256),
@@ -99,13 +99,13 @@ class Tdata {
99
99
  async readFile(filename) {
100
100
  const order = [];
101
101
  const modern = `${filename}s`;
102
- if (await this.fs.stat(posix.join(this.options.path, modern))) {
102
+ if (await this.fs.stat(fs.joinPaths(this.options.path, modern))) {
103
103
  order.push(modern);
104
104
  } else {
105
105
  const try0 = `${filename}0`;
106
106
  const try1 = `${filename}1`;
107
- const try0s = await this.fs.stat(posix.join(this.options.path, try0));
108
- const try1s = await this.fs.stat(posix.join(this.options.path, try1));
107
+ const try0s = await this.fs.stat(fs.joinPaths(this.options.path, try0));
108
+ const try1s = await this.fs.stat(fs.joinPaths(this.options.path, try1));
109
109
  if (try0s) {
110
110
  order.push(try0);
111
111
  if (try1s) {
@@ -120,7 +120,7 @@ class Tdata {
120
120
  }
121
121
  let lastError = "file not found";
122
122
  for (const file of order) {
123
- const data = await this.fs.readFile(posix.join(this.options.path, file));
123
+ const data = await this.fs.readFile(fs.joinPaths(this.options.path, file));
124
124
  const magic = data.subarray(0, 4);
125
125
  if (!utils.typed.equal(magic, TDF_MAGIC)) {
126
126
  lastError = "invalid magic";
@@ -149,7 +149,7 @@ class Tdata {
149
149
  throw new Error(`failed to read ${filename}, last error: ${lastError}`);
150
150
  }
151
151
  async writeFile(filename, data, mkdir = false) {
152
- filename = posix.join(this.options.path, `${filename}s`);
152
+ filename = fs.joinPaths(this.options.path, `${filename}s`);
153
153
  const version = this.#writeInt32(utils.u8.alloc(4), TDF_VERSION);
154
154
  const dataSize = this.#writeInt32(utils.u8.alloc(4), data.length);
155
155
  const md5 = await this.crypto.createHash("md5");
@@ -158,7 +158,7 @@ class Tdata {
158
158
  await md5.update(version);
159
159
  await md5.update(TDF_MAGIC);
160
160
  if (mkdir) {
161
- await this.fs.mkdir(posix.dirname(filename), { recursive: true });
161
+ await this.fs.mkdir(fs.dirname(filename), { recursive: true });
162
162
  }
163
163
  await this.fs.writeFile(
164
164
  filename,
@@ -350,7 +350,7 @@ class Tdata {
350
350
  qtWriter.writeQByteArray(writer, utils.u8.empty);
351
351
  qtWriter.writeQByteArray(writer, await this.encryptLocal(utils.u8.empty, this.keyData.localKey));
352
352
  await this.writeFile(
353
- posix.join(await this.computeDataNameKeyHex(accountIdx), "map"),
353
+ fs.joinPaths(await this.computeDataNameKeyHex(accountIdx), "map"),
354
354
  writer.result(),
355
355
  true
356
356
  );
@@ -1,9 +1,9 @@
1
- import { join, dirname } from "node:path/posix";
2
1
  import { read, write, Bytes } from "@fuman/io";
3
2
  import { typed, utf8, u8 } from "@fuman/utils";
4
3
  import { MtUnsupportedError, Long } from "@mtcute/core";
5
4
  import { createAesIgeForMessageOld } from "@mtcute/core/utils.js";
6
5
  import { getDefaultCryptoProvider } from "../utils/crypto.js";
6
+ import { joinPaths, dirname } from "../utils/fs.js";
7
7
  import { readQByteArray, readLong } from "./qt-reader.js";
8
8
  import { writeQByteArray, writeLong } from "./qt-writer.js";
9
9
  const TDF_MAGIC = /* @__PURE__ */ utf8.encoder.encode("TDF$");
@@ -70,13 +70,13 @@ class Tdata {
70
70
  async readFile(filename) {
71
71
  const order = [];
72
72
  const modern = `${filename}s`;
73
- if (await this.fs.stat(join(this.options.path, modern))) {
73
+ if (await this.fs.stat(joinPaths(this.options.path, modern))) {
74
74
  order.push(modern);
75
75
  } else {
76
76
  const try0 = `${filename}0`;
77
77
  const try1 = `${filename}1`;
78
- const try0s = await this.fs.stat(join(this.options.path, try0));
79
- const try1s = await this.fs.stat(join(this.options.path, try1));
78
+ const try0s = await this.fs.stat(joinPaths(this.options.path, try0));
79
+ const try1s = await this.fs.stat(joinPaths(this.options.path, try1));
80
80
  if (try0s) {
81
81
  order.push(try0);
82
82
  if (try1s) {
@@ -91,7 +91,7 @@ class Tdata {
91
91
  }
92
92
  let lastError = "file not found";
93
93
  for (const file of order) {
94
- const data = await this.fs.readFile(join(this.options.path, file));
94
+ const data = await this.fs.readFile(joinPaths(this.options.path, file));
95
95
  const magic = data.subarray(0, 4);
96
96
  if (!typed.equal(magic, TDF_MAGIC)) {
97
97
  lastError = "invalid magic";
@@ -120,7 +120,7 @@ class Tdata {
120
120
  throw new Error(`failed to read ${filename}, last error: ${lastError}`);
121
121
  }
122
122
  async writeFile(filename, data, mkdir = false) {
123
- filename = join(this.options.path, `${filename}s`);
123
+ filename = joinPaths(this.options.path, `${filename}s`);
124
124
  const version = this.#writeInt32(u8.alloc(4), TDF_VERSION);
125
125
  const dataSize = this.#writeInt32(u8.alloc(4), data.length);
126
126
  const md5 = await this.crypto.createHash("md5");
@@ -321,7 +321,7 @@ class Tdata {
321
321
  writeQByteArray(writer, u8.empty);
322
322
  writeQByteArray(writer, await this.encryptLocal(u8.empty, this.keyData.localKey));
323
323
  await this.writeFile(
324
- join(await this.computeDataNameKeyHex(accountIdx), "map"),
324
+ joinPaths(await this.computeDataNameKeyHex(accountIdx), "map"),
325
325
  writer.result(),
326
326
  true
327
327
  );
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -22,8 +22,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  ));
23
23
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
24
24
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
25
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
26
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
25
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
26
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
27
27
  }
28
28
  "use strict";
29
29
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -0,0 +1,33 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ function dirname(path) {
9
+ return path.replace(/[/\\][^/\\]*$/, "");
10
+ }
11
+ function joinPaths(...paths) {
12
+ const parts = [];
13
+ let guessedSep;
14
+ for (const path of paths) {
15
+ if (!guessedSep) {
16
+ guessedSep = path.match(/[/\\]/)?.[0];
17
+ }
18
+ for (const segment of path.split(/[/\\]/)) {
19
+ if (segment === ".") continue;
20
+ if (segment === ".." && parts.length !== 0) {
21
+ parts.pop();
22
+ continue;
23
+ }
24
+ if (segment === "" && parts.length !== 0) {
25
+ continue;
26
+ }
27
+ parts.push(segment);
28
+ }
29
+ }
30
+ return parts.join(guessedSep ?? "/");
31
+ }
32
+ exports.dirname = dirname;
33
+ exports.joinPaths = joinPaths;
@@ -0,0 +1,28 @@
1
+ function dirname(path) {
2
+ return path.replace(/[/\\][^/\\]*$/, "");
3
+ }
4
+ function joinPaths(...paths) {
5
+ const parts = [];
6
+ let guessedSep;
7
+ for (const path of paths) {
8
+ if (!guessedSep) {
9
+ guessedSep = path.match(/[/\\]/)?.[0];
10
+ }
11
+ for (const segment of path.split(/[/\\]/)) {
12
+ if (segment === ".") continue;
13
+ if (segment === ".." && parts.length !== 0) {
14
+ parts.pop();
15
+ continue;
16
+ }
17
+ if (segment === "" && parts.length !== 0) {
18
+ continue;
19
+ }
20
+ parts.push(segment);
21
+ }
22
+ }
23
+ return parts.join(guessedSep ?? "/");
24
+ }
25
+ export {
26
+ dirname,
27
+ joinPaths
28
+ };
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -0,0 +1,10 @@
1
+ import { GramjsSession } from './types.js';
2
+ import { INodeFsLike } from '../utils/fs.js';
3
+ export declare function readGramjsStoreSession(path: string, params?: {
4
+ /** filesystem implementation to use (defaults to `node:fs/promises`) */
5
+ fs?: INodeFsLike;
6
+ }): Promise<GramjsSession>;
7
+ export declare function writeGramjsStoreSession(path: string, session: GramjsSession, params?: {
8
+ /** filesystem implementation to use (defaults to `node:fs/promises`) */
9
+ fs?: INodeFsLike;
10
+ }): Promise<void>;
@@ -0,0 +1,10 @@
1
+ import { GramjsSession } from './types.js';
2
+ import { INodeFsLike } from '../utils/fs.js';
3
+ export declare function readGramjsStoreSession(path: string, params?: {
4
+ /** filesystem implementation to use (defaults to `node:fs/promises`) */
5
+ fs?: INodeFsLike;
6
+ }): Promise<GramjsSession>;
7
+ export declare function writeGramjsStoreSession(path: string, session: GramjsSession, params?: {
8
+ /** filesystem implementation to use (defaults to `node:fs/promises`) */
9
+ fs?: INodeFsLike;
10
+ }): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
package/index.d.cts CHANGED
@@ -4,3 +4,4 @@ export * from './mtkruto/index.js';
4
4
  export * from './pyrogram/index.js';
5
5
  export * from './tdesktop/index.js';
6
6
  export * from './telethon/index.js';
7
+ export type { INodeFsLike } from './utils/fs.js';
package/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './mtkruto/index.js';
4
4
  export * from './pyrogram/index.js';
5
5
  export * from './tdesktop/index.js';
6
6
  export * from './telethon/index.js';
7
+ export type { INodeFsLike } from './utils/fs.js';
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@mtcute/convert",
3
3
  "type": "module",
4
- "version": "0.18.0",
4
+ "version": "0.19.1",
5
5
  "description": "Cross-library session conversion utilities",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@mtcute/core": "^0.18.0",
8
+ "@mtcute/core": "^0.19.1",
9
9
  "@fuman/utils": "0.0.4",
10
10
  "@fuman/net": "0.0.4",
11
11
  "@fuman/io": "0.0.4"
@@ -1,6 +1,6 @@
1
- import { INodeFsLike } from '../utils/fs.js';
2
1
  import { InputTdKeyData, TdKeyData, TdMtpAuthorization } from './types.js';
3
2
  import { IExtendedCryptoProvider } from '../utils/crypto.js';
3
+ import { INodeFsLike } from '../utils/fs.js';
4
4
  export interface TdataOptions {
5
5
  /** Full path to the tdata directory */
6
6
  path: string;
@@ -1,6 +1,6 @@
1
- import { INodeFsLike } from '../utils/fs.js';
2
1
  import { InputTdKeyData, TdKeyData, TdMtpAuthorization } from './types.js';
3
2
  import { IExtendedCryptoProvider } from '../utils/crypto.js';
3
+ import { INodeFsLike } from '../utils/fs.js';
4
4
  export interface TdataOptions {
5
5
  /** Full path to the tdata directory */
6
6
  path: string;
package/utils/fs.d.cts CHANGED
@@ -9,3 +9,6 @@ export interface INodeFsLike {
9
9
  lastModified: number;
10
10
  }>;
11
11
  }
12
+ export declare function dirname(path: string): string;
13
+ export declare function basename(path: string): string;
14
+ export declare function joinPaths(...paths: string[]): string;
package/utils/fs.d.ts CHANGED
@@ -9,3 +9,6 @@ export interface INodeFsLike {
9
9
  lastModified: number;
10
10
  }>;
11
11
  }
12
+ export declare function dirname(path: string): string;
13
+ export declare function basename(path: string): string;
14
+ export declare function joinPaths(...paths: string[]): string;
@@ -1,7 +1,7 @@
1
1
  if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
2
  globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[mtcute-workspace] CommonJS support is deprecated and will be removed in 0.20.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[mtcute-workspace] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
3
+ console.warn("[@mtcute/convert] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/convert] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });