@lynovratech/baileys 1.0.8 → 1.0.10
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/lib/cjs/Utils/chat-utils.js +1 -1
- package/lib/cjs/Utils/crypto.js +1 -1
- package/lib/cjs/Utils/lt-hash.js +1 -1
- package/lib/esm/Utils/chat-utils.js +1 -1
- package/lib/esm/Utils/crypto.js +1 -1
- package/lib/esm/Utils/lt-hash.js +1 -1
- package/lib/vendor/whatsapp-rust-bridge-cjs.cjs +29 -0
- package/package.json +1 -1
- package/scripts/fix-rust-bridge-import.cjs +35 -13
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processSyncAction = exports.chatModificationToAppPatch = exports.decodePatches = exports.decodeSyncdSnapshot = exports.downloadExternalPatch = exports.downloadExternalBlob = exports.extractSyncdPatches = exports.decodeSyncdPatch = exports.decodeSyncdMutations = exports.encodeSyncdPatch = exports.newLTHashState = void 0;
|
|
4
4
|
const boom_1 = require("@hapi/boom");
|
|
5
|
-
const whatsapp_rust_bridge_1 = require("
|
|
5
|
+
const whatsapp_rust_bridge_1 = require("../../vendor/whatsapp-rust-bridge-cjs.cjs");
|
|
6
6
|
const index_js_1 = require("../../WAProto/index.js");
|
|
7
7
|
const LabelAssociation_1 = require("../Types/LabelAssociation");
|
|
8
8
|
const WABinary_1 = require("../WABinary");
|
package/lib/cjs/Utils/crypto.js
CHANGED
|
@@ -48,7 +48,7 @@ exports.derivePairingCodeKey = derivePairingCodeKey;
|
|
|
48
48
|
const crypto_1 = require("crypto");
|
|
49
49
|
const curve = __importStar(require("libsignal/src/curve"));
|
|
50
50
|
const Defaults_1 = require("../Defaults");
|
|
51
|
-
var whatsapp_rust_bridge_1 = require("
|
|
51
|
+
var whatsapp_rust_bridge_1 = require("../../vendor/whatsapp-rust-bridge-cjs.cjs");
|
|
52
52
|
Object.defineProperty(exports, "md5", { enumerable: true, get: function () { return whatsapp_rust_bridge_1.md5; } });
|
|
53
53
|
Object.defineProperty(exports, "hkdf", { enumerable: true, get: function () { return whatsapp_rust_bridge_1.hkdf; } });
|
|
54
54
|
// insure browser & node compatibility
|
package/lib/cjs/Utils/lt-hash.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LT_HASH_ANTI_TAMPERING = void 0;
|
|
4
|
-
const whatsapp_rust_bridge_1 = require("
|
|
4
|
+
const whatsapp_rust_bridge_1 = require("../../vendor/whatsapp-rust-bridge-cjs.cjs");
|
|
5
5
|
/**
|
|
6
6
|
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
7
7
|
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
|
-
import { expandAppStateKeys } from "
|
|
2
|
+
import { expandAppStateKeys } from "../../vendor/whatsapp-rust-bridge.js";
|
|
3
3
|
import { proto } from '../../WAProto/index.js';
|
|
4
4
|
import { LabelAssociationType } from '../Types/LabelAssociation.js';
|
|
5
5
|
import { getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidNormalizedUser } from '../WABinary/index.js';
|
package/lib/esm/Utils/crypto.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes } from 'crypto';
|
|
2
2
|
import * as curve from 'libsignal/src/curve.js';
|
|
3
3
|
import { KEY_BUNDLE_TYPE } from '../Defaults/index.js';
|
|
4
|
-
export { md5, hkdf } from "
|
|
4
|
+
export { md5, hkdf } from "../../vendor/whatsapp-rust-bridge.js";
|
|
5
5
|
// insure browser & node compatibility
|
|
6
6
|
const { subtle } = globalThis.crypto;
|
|
7
7
|
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
package/lib/esm/Utils/lt-hash.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LTHashAntiTampering } from "
|
|
1
|
+
import { LTHashAntiTampering } from "../../vendor/whatsapp-rust-bridge.js";
|
|
2
2
|
/**
|
|
3
3
|
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
4
4
|
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
let _mod = null;
|
|
4
|
+
|
|
5
|
+
async function _load() {
|
|
6
|
+
if (!_mod) {
|
|
7
|
+
_mod = await import('./whatsapp-rust-bridge.js');
|
|
8
|
+
}
|
|
9
|
+
return _mod;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
async expandAppStateKeys(...args) {
|
|
14
|
+
const m = await _load();
|
|
15
|
+
return m.expandAppStateKeys(...args);
|
|
16
|
+
},
|
|
17
|
+
async md5(...args) {
|
|
18
|
+
const m = await _load();
|
|
19
|
+
return m.md5(...args);
|
|
20
|
+
},
|
|
21
|
+
async hkdf(...args) {
|
|
22
|
+
const m = await _load();
|
|
23
|
+
return m.hkdf(...args);
|
|
24
|
+
},
|
|
25
|
+
async LTHashAntiTampering(...args) {
|
|
26
|
+
const m = await _load();
|
|
27
|
+
return m.LTHashAntiTampering(...args);
|
|
28
|
+
}
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
function getDepth(filePath, baseDir) {
|
|
5
|
-
const rel = path.relative(baseDir, path.dirname(filePath));
|
|
6
|
-
return rel === '' ? 0 : rel.split(path.sep).length;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
4
|
function fixDir(dir, baseDir) {
|
|
10
5
|
const files = fs.readdirSync(dir);
|
|
11
6
|
for(const file of files) {
|
|
@@ -15,21 +10,48 @@ function fixDir(dir, baseDir) {
|
|
|
15
10
|
fixDir(full, baseDir);
|
|
16
11
|
} else if(file.endsWith('.js')) {
|
|
17
12
|
let c = fs.readFileSync(full, 'utf8');
|
|
18
|
-
if(c.includes(
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
if(c.includes('whatsapp-rust-bridge')) {
|
|
14
|
+
const relToVendor = path.relative(
|
|
15
|
+
path.dirname(full),
|
|
16
|
+
path.join(baseDir, '..', 'vendor', 'whatsapp-rust-bridge-cjs.cjs')
|
|
17
|
+
).replace(/\\/g, '/');
|
|
18
|
+
c = c.replace(/require\(["'].*?whatsapp-rust-bridge.*?["']\)/g, `require("${relToVendor}")`);
|
|
19
|
+
c = c.replace(/from ["'].*?whatsapp-rust-bridge.*?["']/g, `from "${relToVendor}"`);
|
|
23
20
|
fs.writeFileSync(full, c);
|
|
24
|
-
console.log('Fixed:', full);
|
|
21
|
+
console.log('Fixed:', full, '->', relToVendor);
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
|
|
27
|
+
// CJS pakai wrapper .cjs
|
|
30
28
|
const cjsDir = path.resolve(__dirname, '../lib/cjs');
|
|
29
|
+
fixDir(cjsDir, cjsDir);
|
|
30
|
+
|
|
31
|
+
// ESM pakai file asli .js
|
|
31
32
|
const esmDir = path.resolve(__dirname, '../lib/esm');
|
|
33
|
+
const esmFiles = [];
|
|
34
|
+
function findEsmFiles(dir) {
|
|
35
|
+
const files = fs.readdirSync(dir);
|
|
36
|
+
for(const file of files) {
|
|
37
|
+
const full = path.join(dir, file);
|
|
38
|
+
const stat = fs.statSync(full);
|
|
39
|
+
if(stat.isDirectory()) findEsmFiles(full);
|
|
40
|
+
else if(file.endsWith('.js')) esmFiles.push(full);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
findEsmFiles(esmDir);
|
|
44
|
+
for(const full of esmFiles) {
|
|
45
|
+
let c = fs.readFileSync(full, 'utf8');
|
|
46
|
+
if(c.includes('whatsapp-rust-bridge')) {
|
|
47
|
+
const relToVendor = path.relative(
|
|
48
|
+
path.dirname(full),
|
|
49
|
+
path.join(esmDir, '..', 'vendor', 'whatsapp-rust-bridge.js')
|
|
50
|
+
).replace(/\\/g, '/');
|
|
51
|
+
c = c.replace(/from ["'].*?whatsapp-rust-bridge.*?["']/g, `from "${relToVendor}"`);
|
|
52
|
+
fs.writeFileSync(full, c);
|
|
53
|
+
console.log('Fixed ESM:', full, '->', relToVendor);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
32
56
|
|
|
33
|
-
fixDir(cjsDir, cjsDir);
|
|
34
|
-
fixDir(esmDir, esmDir);
|
|
35
57
|
console.log('All done!');
|