@mtcute/convert 0.19.4 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gramjs/convert.d.cts +2 -2
- package/gramjs/convert.d.ts +2 -2
- package/index.cjs +17 -17
- package/index.js +17 -17
- package/package.json +10 -2
- package/{convert/src/utils → utils}/crypto.cjs +3 -2
- package/{convert/src/utils → utils}/crypto.js +3 -2
- package/node/src/utils/crypto.cjs +0 -75
- package/node/src/utils/crypto.js +0 -69
- package/node/src/utils.cjs +0 -34
- package/node/src/utils.js +0 -7
- package/wasm/src/index.cjs +0 -64
- package/wasm/src/index.js +0 -59
- /package/{convert/src/dcs.cjs → dcs.cjs} +0 -0
- /package/{convert/src/dcs.js → dcs.js} +0 -0
- /package/{convert/src/gramjs → gramjs}/convert.cjs +0 -0
- /package/{convert/src/gramjs → gramjs}/convert.js +0 -0
- /package/{convert/src/gramjs → gramjs}/parse.cjs +0 -0
- /package/{convert/src/gramjs → gramjs}/parse.js +0 -0
- /package/{convert/src/gramjs → gramjs}/serialize.cjs +0 -0
- /package/{convert/src/gramjs → gramjs}/serialize.js +0 -0
- /package/{convert/src/gramjs → gramjs}/store-session.cjs +0 -0
- /package/{convert/src/gramjs → gramjs}/store-session.js +0 -0
- /package/{convert/src/mtkruto → mtkruto}/convert.cjs +0 -0
- /package/{convert/src/mtkruto → mtkruto}/convert.js +0 -0
- /package/{convert/src/mtkruto → mtkruto}/parse.cjs +0 -0
- /package/{convert/src/mtkruto → mtkruto}/parse.js +0 -0
- /package/{convert/src/mtkruto → mtkruto}/serialize.cjs +0 -0
- /package/{convert/src/mtkruto → mtkruto}/serialize.js +0 -0
- /package/{convert/src/pyrogram → pyrogram}/convert.cjs +0 -0
- /package/{convert/src/pyrogram → pyrogram}/convert.js +0 -0
- /package/{convert/src/pyrogram → pyrogram}/parse.cjs +0 -0
- /package/{convert/src/pyrogram → pyrogram}/parse.js +0 -0
- /package/{convert/src/pyrogram → pyrogram}/serialize.cjs +0 -0
- /package/{convert/src/pyrogram → pyrogram}/serialize.js +0 -0
- /package/{convert/src/tdesktop → tdesktop}/convert.cjs +0 -0
- /package/{convert/src/tdesktop → tdesktop}/convert.js +0 -0
- /package/{convert/src/tdesktop → tdesktop}/qt-bundle.cjs +0 -0
- /package/{convert/src/tdesktop → tdesktop}/qt-bundle.js +0 -0
- /package/{convert/src/tdesktop → tdesktop}/qt-reader.cjs +0 -0
- /package/{convert/src/tdesktop → tdesktop}/qt-reader.js +0 -0
- /package/{convert/src/tdesktop → tdesktop}/qt-writer.cjs +0 -0
- /package/{convert/src/tdesktop → tdesktop}/qt-writer.js +0 -0
- /package/{convert/src/tdesktop → tdesktop}/tdata.cjs +0 -0
- /package/{convert/src/tdesktop → tdesktop}/tdata.js +0 -0
- /package/{convert/src/telethon → telethon}/convert.cjs +0 -0
- /package/{convert/src/telethon → telethon}/convert.js +0 -0
- /package/{convert/src/telethon → telethon}/parse.cjs +0 -0
- /package/{convert/src/telethon → telethon}/parse.js +0 -0
- /package/{convert/src/telethon → telethon}/serialize.cjs +0 -0
- /package/{convert/src/telethon → telethon}/serialize.js +0 -0
- /package/{convert/src/utils → utils}/fs.cjs +0 -0
- /package/{convert/src/utils → utils}/fs.js +0 -0
- /package/{convert/src/utils → utils}/rle.cjs +0 -0
- /package/{convert/src/utils → utils}/rle.js +0 -0
package/gramjs/convert.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { StringSessionData } from '@mtcute/core/utils.js';
|
|
2
|
-
import {
|
|
3
|
-
export declare function convertFromGramjsSession(session:
|
|
2
|
+
import { GramjsSession } from './types.js';
|
|
3
|
+
export declare function convertFromGramjsSession(session: GramjsSession | string): StringSessionData;
|
|
4
4
|
export declare function convertToGramjsSession(session: StringSessionData | string): string;
|
package/gramjs/convert.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { StringSessionData } from '@mtcute/core/utils.js';
|
|
2
|
-
import {
|
|
3
|
-
export declare function convertFromGramjsSession(session:
|
|
2
|
+
import { GramjsSession } from './types.js';
|
|
3
|
+
export declare function convertFromGramjsSession(session: GramjsSession | string): StringSessionData;
|
|
4
4
|
export declare function convertToGramjsSession(session: StringSessionData | string): string;
|
package/index.cjs
CHANGED
|
@@ -5,23 +5,23 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
5
5
|
}
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
-
const dcs = require("./
|
|
9
|
-
const convert = require("./
|
|
10
|
-
const parse = require("./
|
|
11
|
-
const serialize = require("./
|
|
12
|
-
const storeSession = require("./
|
|
13
|
-
const convert$1 = require("./
|
|
14
|
-
const parse$1 = require("./
|
|
15
|
-
const serialize$1 = require("./
|
|
16
|
-
const convert$2 = require("./
|
|
17
|
-
const parse$2 = require("./
|
|
18
|
-
const serialize$2 = require("./
|
|
19
|
-
const convert$3 = require("./
|
|
20
|
-
const tdata = require("./
|
|
21
|
-
const qtBundle = require("./
|
|
22
|
-
const convert$4 = require("./
|
|
23
|
-
const parse$3 = require("./
|
|
24
|
-
const serialize$3 = require("./
|
|
8
|
+
const dcs = require("./dcs.cjs");
|
|
9
|
+
const convert = require("./gramjs/convert.cjs");
|
|
10
|
+
const parse = require("./gramjs/parse.cjs");
|
|
11
|
+
const serialize = require("./gramjs/serialize.cjs");
|
|
12
|
+
const storeSession = require("./gramjs/store-session.cjs");
|
|
13
|
+
const convert$1 = require("./mtkruto/convert.cjs");
|
|
14
|
+
const parse$1 = require("./mtkruto/parse.cjs");
|
|
15
|
+
const serialize$1 = require("./mtkruto/serialize.cjs");
|
|
16
|
+
const convert$2 = require("./pyrogram/convert.cjs");
|
|
17
|
+
const parse$2 = require("./pyrogram/parse.cjs");
|
|
18
|
+
const serialize$2 = require("./pyrogram/serialize.cjs");
|
|
19
|
+
const convert$3 = require("./tdesktop/convert.cjs");
|
|
20
|
+
const tdata = require("./tdesktop/tdata.cjs");
|
|
21
|
+
const qtBundle = require("./tdesktop/qt-bundle.cjs");
|
|
22
|
+
const convert$4 = require("./telethon/convert.cjs");
|
|
23
|
+
const parse$3 = require("./telethon/parse.cjs");
|
|
24
|
+
const serialize$3 = require("./telethon/serialize.cjs");
|
|
25
25
|
exports.DC_MAPPING_PROD = dcs.DC_MAPPING_PROD;
|
|
26
26
|
exports.DC_MAPPING_TEST = dcs.DC_MAPPING_TEST;
|
|
27
27
|
exports.isTestDc = dcs.isTestDc;
|
package/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { DC_MAPPING_PROD, DC_MAPPING_TEST, isTestDc } from "./
|
|
2
|
-
import { convertFromGramjsSession, convertToGramjsSession } from "./
|
|
3
|
-
import { parseGramjsSession } from "./
|
|
4
|
-
import { serializeGramjsSession } from "./
|
|
5
|
-
import { readGramjsStoreSession, writeGramjsStoreSession } from "./
|
|
6
|
-
import { convertFromMtkrutoSession, convertToMtkrutoSession } from "./
|
|
7
|
-
import { parseMtkrutoSession } from "./
|
|
8
|
-
import { serializeMtkrutoSession } from "./
|
|
9
|
-
import { convertFromPyrogramSession, convertToPyrogramSession } from "./
|
|
10
|
-
import { parsePyrogramSession } from "./
|
|
11
|
-
import { serializePyrogramSession } from "./
|
|
12
|
-
import { convertFromTdata, convertToTdata } from "./
|
|
13
|
-
import { Tdata } from "./
|
|
14
|
-
import * as qtBundle from "./
|
|
15
|
-
import { convertFromTelethonSession, convertToTelethonSession } from "./
|
|
16
|
-
import { parseTelethonSession } from "./
|
|
17
|
-
import { serializeTelethonSession } from "./
|
|
1
|
+
import { DC_MAPPING_PROD, DC_MAPPING_TEST, isTestDc } from "./dcs.js";
|
|
2
|
+
import { convertFromGramjsSession, convertToGramjsSession } from "./gramjs/convert.js";
|
|
3
|
+
import { parseGramjsSession } from "./gramjs/parse.js";
|
|
4
|
+
import { serializeGramjsSession } from "./gramjs/serialize.js";
|
|
5
|
+
import { readGramjsStoreSession, writeGramjsStoreSession } from "./gramjs/store-session.js";
|
|
6
|
+
import { convertFromMtkrutoSession, convertToMtkrutoSession } from "./mtkruto/convert.js";
|
|
7
|
+
import { parseMtkrutoSession } from "./mtkruto/parse.js";
|
|
8
|
+
import { serializeMtkrutoSession } from "./mtkruto/serialize.js";
|
|
9
|
+
import { convertFromPyrogramSession, convertToPyrogramSession } from "./pyrogram/convert.js";
|
|
10
|
+
import { parsePyrogramSession } from "./pyrogram/parse.js";
|
|
11
|
+
import { serializePyrogramSession } from "./pyrogram/serialize.js";
|
|
12
|
+
import { convertFromTdata, convertToTdata } from "./tdesktop/convert.js";
|
|
13
|
+
import { Tdata } from "./tdesktop/tdata.js";
|
|
14
|
+
import * as qtBundle from "./tdesktop/qt-bundle.js";
|
|
15
|
+
import { convertFromTelethonSession, convertToTelethonSession } from "./telethon/convert.js";
|
|
16
|
+
import { parseTelethonSession } from "./telethon/parse.js";
|
|
17
|
+
import { serializeTelethonSession } from "./telethon/serialize.js";
|
|
18
18
|
export {
|
|
19
19
|
DC_MAPPING_PROD,
|
|
20
20
|
DC_MAPPING_TEST,
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/convert",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.0",
|
|
5
5
|
"description": "Cross-library session conversion utilities",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mtcute/core": "^0.
|
|
8
|
+
"@mtcute/core": "^0.20.0",
|
|
9
9
|
"@fuman/utils": "0.0.4",
|
|
10
10
|
"@fuman/net": "0.0.9",
|
|
11
11
|
"@fuman/io": "0.0.8"
|
|
12
12
|
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@mtcute/node": "^0.20.0"
|
|
15
|
+
},
|
|
13
16
|
"exports": {
|
|
14
17
|
".": {
|
|
15
18
|
"import": {
|
|
@@ -24,6 +27,11 @@
|
|
|
24
27
|
},
|
|
25
28
|
"author": "alina sireneva <alina@tei.su>",
|
|
26
29
|
"sideEffects": false,
|
|
30
|
+
"peerDependenciesMeta": {
|
|
31
|
+
"@mtcute/node": {
|
|
32
|
+
"optional": true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
27
35
|
"homepage": "https://mtcute.dev",
|
|
28
36
|
"repository": {
|
|
29
37
|
"type": "git",
|
|
@@ -32,9 +32,10 @@ async function getDefaultCryptoProvider() {
|
|
|
32
32
|
/* @vite-ignore */
|
|
33
33
|
await import("node:crypto")
|
|
34
34
|
);
|
|
35
|
-
const
|
|
35
|
+
const nodeModule = "@mtcute/node/utils.js";
|
|
36
|
+
const { NodeCryptoProvider } = await import(
|
|
36
37
|
/* @vite-ignore */
|
|
37
|
-
|
|
38
|
+
nodeModule
|
|
38
39
|
);
|
|
39
40
|
return new class extends NodeCryptoProvider {
|
|
40
41
|
createHash(algorithm) {
|
|
@@ -3,9 +3,10 @@ async function getDefaultCryptoProvider() {
|
|
|
3
3
|
/* @vite-ignore */
|
|
4
4
|
await import("node:crypto")
|
|
5
5
|
);
|
|
6
|
-
const
|
|
6
|
+
const nodeModule = "@mtcute/node/utils.js";
|
|
7
|
+
const { NodeCryptoProvider } = await import(
|
|
7
8
|
/* @vite-ignore */
|
|
8
|
-
|
|
9
|
+
nodeModule
|
|
9
10
|
);
|
|
10
11
|
return new class extends NodeCryptoProvider {
|
|
11
12
|
createHash(algorithm) {
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
const node_crypto = require("node:crypto");
|
|
9
|
-
const promises = require("node:fs/promises");
|
|
10
|
-
const node_module = require("node:module");
|
|
11
|
-
const node_zlib = require("node:zlib");
|
|
12
|
-
const utils_js = require("@mtcute/core/utils.js");
|
|
13
|
-
const index = require("../../../wasm/src/index.cjs");
|
|
14
|
-
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
15
|
-
class BaseNodeCryptoProvider extends utils_js.BaseCryptoProvider {
|
|
16
|
-
createAesCtr(key, iv) {
|
|
17
|
-
const cipher = node_crypto.createCipheriv(`aes-${key.length * 8}-ctr`, key, iv);
|
|
18
|
-
const update = (data) => cipher.update(data);
|
|
19
|
-
return {
|
|
20
|
-
process: update
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
pbkdf2(password, salt, iterations, keylen = 64, algo = "sha512") {
|
|
24
|
-
return new Promise(
|
|
25
|
-
(resolve, reject) => node_crypto.pbkdf2(password, salt, iterations, keylen, algo, (err, buf) => err !== null ? reject(err) : resolve(buf))
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
sha1(data) {
|
|
29
|
-
return node_crypto.createHash("sha1").update(data).digest();
|
|
30
|
-
}
|
|
31
|
-
sha256(data) {
|
|
32
|
-
return node_crypto.createHash("sha256").update(data).digest();
|
|
33
|
-
}
|
|
34
|
-
hmacSha256(data, key) {
|
|
35
|
-
return node_crypto.createHmac("sha256", key).update(data).digest();
|
|
36
|
-
}
|
|
37
|
-
gzip(data, maxSize) {
|
|
38
|
-
try {
|
|
39
|
-
return node_zlib.deflateSync(data, {
|
|
40
|
-
maxOutputLength: maxSize
|
|
41
|
-
});
|
|
42
|
-
} catch (e) {
|
|
43
|
-
if (e.code === "ERR_BUFFER_TOO_LARGE") {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
throw e;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
gunzip(data) {
|
|
50
|
-
return node_zlib.gunzipSync(data);
|
|
51
|
-
}
|
|
52
|
-
randomFill(buf) {
|
|
53
|
-
node_crypto.randomFillSync(buf);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
class NodeCryptoProvider extends BaseNodeCryptoProvider {
|
|
57
|
-
async initialize() {
|
|
58
|
-
const require$1 = node_module.createRequire(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("node/src/utils/crypto.cjs", document.baseURI).href);
|
|
59
|
-
const wasmFile = require$1.resolve("@mtcute/wasm/mtcute.wasm");
|
|
60
|
-
const wasm = await promises.readFile(wasmFile);
|
|
61
|
-
index.initSync(wasm);
|
|
62
|
-
}
|
|
63
|
-
createAesIge(key, iv) {
|
|
64
|
-
return {
|
|
65
|
-
encrypt(data) {
|
|
66
|
-
return index.ige256Encrypt(data, key, iv);
|
|
67
|
-
},
|
|
68
|
-
decrypt(data) {
|
|
69
|
-
return index.ige256Decrypt(data, key, iv);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.BaseNodeCryptoProvider = BaseNodeCryptoProvider;
|
|
75
|
-
exports.NodeCryptoProvider = NodeCryptoProvider;
|
package/node/src/utils/crypto.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { createCipheriv, pbkdf2, createHash, createHmac, randomFillSync } from "node:crypto";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import { deflateSync, gunzipSync } from "node:zlib";
|
|
5
|
-
import { BaseCryptoProvider } from "@mtcute/core/utils.js";
|
|
6
|
-
import { initSync, ige256Decrypt, ige256Encrypt } from "../../../wasm/src/index.js";
|
|
7
|
-
class BaseNodeCryptoProvider extends BaseCryptoProvider {
|
|
8
|
-
createAesCtr(key, iv) {
|
|
9
|
-
const cipher = createCipheriv(`aes-${key.length * 8}-ctr`, key, iv);
|
|
10
|
-
const update = (data) => cipher.update(data);
|
|
11
|
-
return {
|
|
12
|
-
process: update
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
pbkdf2(password, salt, iterations, keylen = 64, algo = "sha512") {
|
|
16
|
-
return new Promise(
|
|
17
|
-
(resolve, reject) => pbkdf2(password, salt, iterations, keylen, algo, (err, buf) => err !== null ? reject(err) : resolve(buf))
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
sha1(data) {
|
|
21
|
-
return createHash("sha1").update(data).digest();
|
|
22
|
-
}
|
|
23
|
-
sha256(data) {
|
|
24
|
-
return createHash("sha256").update(data).digest();
|
|
25
|
-
}
|
|
26
|
-
hmacSha256(data, key) {
|
|
27
|
-
return createHmac("sha256", key).update(data).digest();
|
|
28
|
-
}
|
|
29
|
-
gzip(data, maxSize) {
|
|
30
|
-
try {
|
|
31
|
-
return deflateSync(data, {
|
|
32
|
-
maxOutputLength: maxSize
|
|
33
|
-
});
|
|
34
|
-
} catch (e) {
|
|
35
|
-
if (e.code === "ERR_BUFFER_TOO_LARGE") {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
throw e;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
gunzip(data) {
|
|
42
|
-
return gunzipSync(data);
|
|
43
|
-
}
|
|
44
|
-
randomFill(buf) {
|
|
45
|
-
randomFillSync(buf);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
class NodeCryptoProvider extends BaseNodeCryptoProvider {
|
|
49
|
-
async initialize() {
|
|
50
|
-
const require2 = createRequire(import.meta.url);
|
|
51
|
-
const wasmFile = require2.resolve("@mtcute/wasm/mtcute.wasm");
|
|
52
|
-
const wasm = await readFile(wasmFile);
|
|
53
|
-
initSync(wasm);
|
|
54
|
-
}
|
|
55
|
-
createAesIge(key, iv) {
|
|
56
|
-
return {
|
|
57
|
-
encrypt(data) {
|
|
58
|
-
return ige256Encrypt(data, key, iv);
|
|
59
|
-
},
|
|
60
|
-
decrypt(data) {
|
|
61
|
-
return ige256Decrypt(data, key, iv);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
BaseNodeCryptoProvider,
|
|
68
|
-
NodeCryptoProvider
|
|
69
|
-
};
|
package/node/src/utils.cjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
const crypto = require("./utils/crypto.cjs");
|
|
9
|
-
const utils_js = require("@mtcute/core/utils.js");
|
|
10
|
-
function _interopNamespaceDefault(e) {
|
|
11
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
12
|
-
if (e) {
|
|
13
|
-
for (const k in e) {
|
|
14
|
-
if (k !== "default") {
|
|
15
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: () => e[k]
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
n.default = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
const utils_js__namespace = /* @__PURE__ */ _interopNamespaceDefault(utils_js);
|
|
27
|
-
exports.BaseNodeCryptoProvider = crypto.BaseNodeCryptoProvider;
|
|
28
|
-
exports.NodeCryptoProvider = crypto.NodeCryptoProvider;
|
|
29
|
-
Object.keys(utils_js).forEach((k) => {
|
|
30
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: () => utils_js[k]
|
|
33
|
-
});
|
|
34
|
-
});
|
package/node/src/utils.js
DELETED
package/wasm/src/index.cjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
let wasm;
|
|
9
|
-
let sharedKeyPtr;
|
|
10
|
-
let sharedIvPtr;
|
|
11
|
-
let cachedUint8Memory = null;
|
|
12
|
-
function initCommon() {
|
|
13
|
-
wasm.libdeflate_alloc_compressor(6);
|
|
14
|
-
wasm.libdeflate_alloc_decompressor();
|
|
15
|
-
wasm.__get_shared_out();
|
|
16
|
-
sharedKeyPtr = wasm.__get_shared_key_buffer();
|
|
17
|
-
sharedIvPtr = wasm.__get_shared_iv_buffer();
|
|
18
|
-
}
|
|
19
|
-
function getUint8Memory() {
|
|
20
|
-
if (cachedUint8Memory === null || cachedUint8Memory.byteLength === 0) {
|
|
21
|
-
cachedUint8Memory = new Uint8Array(wasm.memory.buffer);
|
|
22
|
-
}
|
|
23
|
-
return cachedUint8Memory;
|
|
24
|
-
}
|
|
25
|
-
function initSync(module2) {
|
|
26
|
-
if (wasm !== void 0) return;
|
|
27
|
-
if (!(module2 instanceof WebAssembly.Instance)) {
|
|
28
|
-
if (!(module2 instanceof WebAssembly.Module)) {
|
|
29
|
-
module2 = new WebAssembly.Module(module2);
|
|
30
|
-
}
|
|
31
|
-
module2 = new WebAssembly.Instance(module2);
|
|
32
|
-
}
|
|
33
|
-
wasm = module2.exports;
|
|
34
|
-
initCommon();
|
|
35
|
-
}
|
|
36
|
-
function ige256Encrypt(data, key, iv) {
|
|
37
|
-
const ptr = wasm.__malloc(data.length + data.length);
|
|
38
|
-
const inputPtr = ptr;
|
|
39
|
-
const outputPtr = inputPtr + data.length;
|
|
40
|
-
const mem = getUint8Memory();
|
|
41
|
-
mem.set(data, inputPtr);
|
|
42
|
-
mem.set(key, sharedKeyPtr);
|
|
43
|
-
mem.set(iv, sharedIvPtr);
|
|
44
|
-
wasm.ige256_encrypt(inputPtr, data.length, outputPtr);
|
|
45
|
-
const result = mem.slice(outputPtr, outputPtr + data.length);
|
|
46
|
-
wasm.__free(ptr);
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
function ige256Decrypt(data, key, iv) {
|
|
50
|
-
const ptr = wasm.__malloc(data.length + data.length);
|
|
51
|
-
const inputPtr = ptr;
|
|
52
|
-
const outputPtr = inputPtr + data.length;
|
|
53
|
-
const mem = getUint8Memory();
|
|
54
|
-
mem.set(data, inputPtr);
|
|
55
|
-
mem.set(key, sharedKeyPtr);
|
|
56
|
-
mem.set(iv, sharedIvPtr);
|
|
57
|
-
wasm.ige256_decrypt(inputPtr, data.length, outputPtr);
|
|
58
|
-
const result = mem.slice(outputPtr, outputPtr + data.length);
|
|
59
|
-
wasm.__free(ptr);
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
exports.ige256Decrypt = ige256Decrypt;
|
|
63
|
-
exports.ige256Encrypt = ige256Encrypt;
|
|
64
|
-
exports.initSync = initSync;
|
package/wasm/src/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
let wasm;
|
|
2
|
-
let sharedKeyPtr;
|
|
3
|
-
let sharedIvPtr;
|
|
4
|
-
let cachedUint8Memory = null;
|
|
5
|
-
function initCommon() {
|
|
6
|
-
wasm.libdeflate_alloc_compressor(6);
|
|
7
|
-
wasm.libdeflate_alloc_decompressor();
|
|
8
|
-
wasm.__get_shared_out();
|
|
9
|
-
sharedKeyPtr = wasm.__get_shared_key_buffer();
|
|
10
|
-
sharedIvPtr = wasm.__get_shared_iv_buffer();
|
|
11
|
-
}
|
|
12
|
-
function getUint8Memory() {
|
|
13
|
-
if (cachedUint8Memory === null || cachedUint8Memory.byteLength === 0) {
|
|
14
|
-
cachedUint8Memory = new Uint8Array(wasm.memory.buffer);
|
|
15
|
-
}
|
|
16
|
-
return cachedUint8Memory;
|
|
17
|
-
}
|
|
18
|
-
function initSync(module) {
|
|
19
|
-
if (wasm !== void 0) return;
|
|
20
|
-
if (!(module instanceof WebAssembly.Instance)) {
|
|
21
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
22
|
-
module = new WebAssembly.Module(module);
|
|
23
|
-
}
|
|
24
|
-
module = new WebAssembly.Instance(module);
|
|
25
|
-
}
|
|
26
|
-
wasm = module.exports;
|
|
27
|
-
initCommon();
|
|
28
|
-
}
|
|
29
|
-
function ige256Encrypt(data, key, iv) {
|
|
30
|
-
const ptr = wasm.__malloc(data.length + data.length);
|
|
31
|
-
const inputPtr = ptr;
|
|
32
|
-
const outputPtr = inputPtr + data.length;
|
|
33
|
-
const mem = getUint8Memory();
|
|
34
|
-
mem.set(data, inputPtr);
|
|
35
|
-
mem.set(key, sharedKeyPtr);
|
|
36
|
-
mem.set(iv, sharedIvPtr);
|
|
37
|
-
wasm.ige256_encrypt(inputPtr, data.length, outputPtr);
|
|
38
|
-
const result = mem.slice(outputPtr, outputPtr + data.length);
|
|
39
|
-
wasm.__free(ptr);
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
function ige256Decrypt(data, key, iv) {
|
|
43
|
-
const ptr = wasm.__malloc(data.length + data.length);
|
|
44
|
-
const inputPtr = ptr;
|
|
45
|
-
const outputPtr = inputPtr + data.length;
|
|
46
|
-
const mem = getUint8Memory();
|
|
47
|
-
mem.set(data, inputPtr);
|
|
48
|
-
mem.set(key, sharedKeyPtr);
|
|
49
|
-
mem.set(iv, sharedIvPtr);
|
|
50
|
-
wasm.ige256_decrypt(inputPtr, data.length, outputPtr);
|
|
51
|
-
const result = mem.slice(outputPtr, outputPtr + data.length);
|
|
52
|
-
wasm.__free(ptr);
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
export {
|
|
56
|
-
ige256Decrypt,
|
|
57
|
-
ige256Encrypt,
|
|
58
|
-
initSync
|
|
59
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|