jagproject 26.3.25 → 26.3.27
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/Defaults/index.js +61 -2
- package/lib/Defaults/wileys-version.json +2 -2
- package/lib/Utils/bridge-runtime.d.ts +1 -0
- package/lib/Utils/bridge-runtime.js +14 -0
- package/lib/Utils/chat-utils.js +2 -2
- package/lib/Utils/crypto.d.ts +1 -1
- package/lib/Utils/crypto.js +3 -3
- package/lib/Utils/lt-hash.d.ts +1 -1
- package/lib/Utils/lt-hash.js +2 -2
- package/lib/Utils/rust-bridge-shim.d.ts +22 -0
- package/lib/Utils/rust-bridge-shim.js +70 -0
- package/package.json +2 -2
package/lib/Defaults/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const libsignal_js_1 = require("../Signal/libsignal.js");
|
|
|
11
11
|
const browser_utils_js_1 = require("../Utils/browser-utils.js");
|
|
12
12
|
const logger_js_1 = __importDefault(require("../Utils/logger.js"));
|
|
13
13
|
const waVer = require('./wileys-version.json');
|
|
14
|
-
exports.version = waVer?.version || [2, 3000,
|
|
14
|
+
exports.version = waVer?.version || [2, 3000, 1036833994];
|
|
15
15
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
16
16
|
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
17
17
|
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
@@ -48,6 +48,65 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
48
48
|
index_js_1.proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
49
49
|
index_js_1.proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
|
|
50
50
|
];
|
|
51
|
+
const INTERACTIVE_MESSAGE_KEYS = ['interactiveMessage', 'buttonsMessage', 'listMessage', 'templateMessage'];
|
|
52
|
+
const buildInteractiveMessageContextInfo = (existing) => ({
|
|
53
|
+
...(existing || {}),
|
|
54
|
+
deviceListMetadata: existing?.deviceListMetadata || {},
|
|
55
|
+
deviceListMetadataVersion: existing?.deviceListMetadataVersion || 2
|
|
56
|
+
});
|
|
57
|
+
const wrapInteractiveMessageForLegacyCompatibility = (msg) => {
|
|
58
|
+
if (!msg || typeof msg !== 'object') {
|
|
59
|
+
return msg;
|
|
60
|
+
}
|
|
61
|
+
const topLevelHasInteractive = INTERACTIVE_MESSAGE_KEYS.some(key => !!msg[key]);
|
|
62
|
+
const wrappedViewOnceMessage = msg.viewOnceMessage?.message;
|
|
63
|
+
const wrappedViewOnceV2Message = msg.viewOnceMessageV2?.message;
|
|
64
|
+
const wrappedViewOnceV2ExtMessage = msg.viewOnceMessageV2Extension?.message;
|
|
65
|
+
const wrappedMessage = wrappedViewOnceMessage || wrappedViewOnceV2Message || wrappedViewOnceV2ExtMessage;
|
|
66
|
+
const wrappedHasInteractive = !!(wrappedMessage && INTERACTIVE_MESSAGE_KEYS.some(key => !!wrappedMessage[key]));
|
|
67
|
+
if (wrappedHasInteractive) {
|
|
68
|
+
const patchedWrappedMessage = {
|
|
69
|
+
...wrappedMessage,
|
|
70
|
+
messageContextInfo: buildInteractiveMessageContextInfo(wrappedMessage.messageContextInfo)
|
|
71
|
+
};
|
|
72
|
+
if (wrappedViewOnceMessage) {
|
|
73
|
+
return {
|
|
74
|
+
...msg,
|
|
75
|
+
viewOnceMessage: {
|
|
76
|
+
...msg.viewOnceMessage,
|
|
77
|
+
message: patchedWrappedMessage
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (wrappedViewOnceV2Message) {
|
|
82
|
+
return {
|
|
83
|
+
...msg,
|
|
84
|
+
viewOnceMessageV2: {
|
|
85
|
+
...msg.viewOnceMessageV2,
|
|
86
|
+
message: patchedWrappedMessage
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
...msg,
|
|
92
|
+
viewOnceMessageV2Extension: {
|
|
93
|
+
...msg.viewOnceMessageV2Extension,
|
|
94
|
+
message: patchedWrappedMessage
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (!topLevelHasInteractive) {
|
|
99
|
+
return msg;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
viewOnceMessage: {
|
|
103
|
+
message: {
|
|
104
|
+
...msg,
|
|
105
|
+
messageContextInfo: buildInteractiveMessageContextInfo(msg.messageContextInfo)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
51
110
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
52
111
|
version: exports.version,
|
|
53
112
|
browser: browser_utils_js_1.Browsers.macOS('Chrome'),
|
|
@@ -64,7 +123,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
64
123
|
auth: undefined,
|
|
65
124
|
markOnlineOnConnect: true,
|
|
66
125
|
syncFullHistory: true,
|
|
67
|
-
patchMessageBeforeSending: msg => msg,
|
|
126
|
+
patchMessageBeforeSending: msg => wrapInteractiveMessageForLegacyCompatibility(msg),
|
|
68
127
|
shouldSyncHistoryMessage: ({ syncType }) => {
|
|
69
128
|
return syncType !== index_js_1.proto.HistorySync.HistorySyncType.FULL;
|
|
70
129
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { md5, hkdf, expandAppStateKeys, LTHashAntiTampering } from './rust-bridge-shim.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LTHashAntiTampering = exports.expandAppStateKeys = exports.hkdf = exports.md5 = void 0;
|
|
4
|
+
let runtime;
|
|
5
|
+
try {
|
|
6
|
+
runtime = require("whatsapp-rust-bridge");
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
runtime = require("./rust-bridge-shim.js");
|
|
10
|
+
}
|
|
11
|
+
exports.md5 = runtime.md5;
|
|
12
|
+
exports.hkdf = runtime.hkdf;
|
|
13
|
+
exports.expandAppStateKeys = runtime.expandAppStateKeys;
|
|
14
|
+
exports.LTHashAntiTampering = runtime.LTHashAntiTampering;
|
package/lib/Utils/chat-utils.js
CHANGED
|
@@ -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
|
|
5
|
+
const bridge_runtime_js_1 = require("./bridge-runtime.js");
|
|
6
6
|
const index_js_1 = require("../../WAProto/index.js");
|
|
7
7
|
const LabelAssociation_js_1 = require("../Types/LabelAssociation.js");
|
|
8
8
|
const index_js_2 = require("../WABinary/index.js");
|
|
@@ -12,7 +12,7 @@ const lt_hash_js_1 = require("./lt-hash.js");
|
|
|
12
12
|
const messages_media_js_1 = require("./messages-media.js");
|
|
13
13
|
const sync_action_utils_js_1 = require("./sync-action-utils.js");
|
|
14
14
|
const mutationKeys = (keydata) => {
|
|
15
|
-
const keys = (0,
|
|
15
|
+
const keys = (0, bridge_runtime_js_1.expandAppStateKeys)(keydata);
|
|
16
16
|
return {
|
|
17
17
|
indexKey: keys.indexKey,
|
|
18
18
|
valueEncryptionKey: keys.valueEncryptionKey,
|
package/lib/Utils/crypto.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { KeyPair } from '../Types/index.js';
|
|
2
|
-
export { md5, hkdf } from '
|
|
2
|
+
export { md5, hkdf } from './bridge-runtime.js';
|
|
3
3
|
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
|
4
4
|
export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) => Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>;
|
|
5
5
|
export declare const Curve: {
|
package/lib/Utils/crypto.js
CHANGED
|
@@ -48,9 +48,9 @@ exports.derivePairingCodeKey = derivePairingCodeKey;
|
|
|
48
48
|
const crypto_1 = require("crypto");
|
|
49
49
|
const curve = __importStar(require("libsignal/src/curve.js"));
|
|
50
50
|
const index_js_1 = require("../Defaults/index.js");
|
|
51
|
-
var
|
|
52
|
-
Object.defineProperty(exports, "md5", { enumerable: true, get: function () { return
|
|
53
|
-
Object.defineProperty(exports, "hkdf", { enumerable: true, get: function () { return
|
|
51
|
+
var bridge_runtime_js_1 = require("./bridge-runtime.js");
|
|
52
|
+
Object.defineProperty(exports, "md5", { enumerable: true, get: function () { return bridge_runtime_js_1.md5; } });
|
|
53
|
+
Object.defineProperty(exports, "hkdf", { enumerable: true, get: function () { return bridge_runtime_js_1.hkdf; } });
|
|
54
54
|
// insure browser & node compatibility
|
|
55
55
|
const { subtle } = globalThis.crypto;
|
|
56
56
|
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
package/lib/Utils/lt-hash.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LTHashAntiTampering } from '
|
|
1
|
+
import { LTHashAntiTampering } from './bridge-runtime.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
|
package/lib/Utils/lt-hash.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LT_HASH_ANTI_TAMPERING = void 0;
|
|
4
|
-
const
|
|
4
|
+
const bridge_runtime_js_1 = require("./bridge-runtime.js");
|
|
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
|
|
8
8
|
* if the same series of mutations was made sequentially.
|
|
9
9
|
*/
|
|
10
|
-
exports.LT_HASH_ANTI_TAMPERING = new
|
|
10
|
+
exports.LT_HASH_ANTI_TAMPERING = new bridge_runtime_js_1.LTHashAntiTampering();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type HKDFOptions = {
|
|
2
|
+
salt?: Uint8Array | Buffer | string;
|
|
3
|
+
info?: Uint8Array | Buffer | string;
|
|
4
|
+
};
|
|
5
|
+
export declare function md5(data: Uint8Array | Buffer | string): Buffer;
|
|
6
|
+
export declare function hkdf(key: Uint8Array | Buffer | string, length: number, options?: HKDFOptions): Buffer;
|
|
7
|
+
export declare function expandAppStateKeys(keyData: Uint8Array | Buffer | string): {
|
|
8
|
+
indexKey: Buffer;
|
|
9
|
+
valueEncryptionKey: Buffer;
|
|
10
|
+
valueMacKey: Buffer;
|
|
11
|
+
snapshotMacKey: Buffer;
|
|
12
|
+
patchMacKey: Buffer;
|
|
13
|
+
};
|
|
14
|
+
export declare class LTHashAntiTampering {
|
|
15
|
+
private readonly info;
|
|
16
|
+
private readonly size;
|
|
17
|
+
constructor(info?: string | Uint8Array | Buffer, size?: number);
|
|
18
|
+
subtractThenAdd(base: Uint8Array | Buffer, subtract?: Array<Uint8Array | Buffer>, add?: Array<Uint8Array | Buffer>): Buffer;
|
|
19
|
+
subtractThenAddInPlace(base: Buffer, subtract?: Array<Uint8Array | Buffer>, add?: Array<Uint8Array | Buffer>): Buffer;
|
|
20
|
+
private multipleOp;
|
|
21
|
+
private performPointwiseWithOverflow;
|
|
22
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LTHashAntiTampering = void 0;
|
|
4
|
+
exports.md5 = md5;
|
|
5
|
+
exports.hkdf = hkdf;
|
|
6
|
+
exports.expandAppStateKeys = expandAppStateKeys;
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
8
|
+
function toBuffer(input) {
|
|
9
|
+
if (Buffer.isBuffer(input)) return input;
|
|
10
|
+
if (input instanceof Uint8Array) return Buffer.from(input);
|
|
11
|
+
if (ArrayBuffer.isView(input)) return Buffer.from(input.buffer, input.byteOffset, input.byteLength);
|
|
12
|
+
if (input instanceof ArrayBuffer) return Buffer.from(input);
|
|
13
|
+
if (typeof input === "string") return Buffer.from(input);
|
|
14
|
+
return Buffer.from(input || []);
|
|
15
|
+
}
|
|
16
|
+
function normalizeHkdfOptions(options = {}) {
|
|
17
|
+
const salt = options.salt == null ? Buffer.alloc(0) : toBuffer(options.salt);
|
|
18
|
+
const info = options.info == null ? Buffer.alloc(0) : toBuffer(options.info);
|
|
19
|
+
return { salt, info };
|
|
20
|
+
}
|
|
21
|
+
function md5(data) {
|
|
22
|
+
return (0, crypto_1.createHash)("md5").update(toBuffer(data)).digest();
|
|
23
|
+
}
|
|
24
|
+
function hkdf(key, length, options = {}) {
|
|
25
|
+
const { salt, info } = normalizeHkdfOptions(options);
|
|
26
|
+
const out = crypto_1.hkdfSync("sha256", toBuffer(key), salt, info, length);
|
|
27
|
+
return Buffer.from(out);
|
|
28
|
+
}
|
|
29
|
+
function expandAppStateKeys(keyData) {
|
|
30
|
+
const expanded = hkdf(toBuffer(keyData), 160, { info: "WhatsApp Mutation Keys" });
|
|
31
|
+
return {
|
|
32
|
+
indexKey: expanded.subarray(0, 32),
|
|
33
|
+
valueEncryptionKey: expanded.subarray(32, 64),
|
|
34
|
+
valueMacKey: expanded.subarray(64, 96),
|
|
35
|
+
snapshotMacKey: expanded.subarray(96, 128),
|
|
36
|
+
patchMacKey: expanded.subarray(128, 160)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
class LTHashAntiTampering {
|
|
40
|
+
constructor(info = "WhatsApp Patch Integrity", size = 128) {
|
|
41
|
+
this.info = toBuffer(info);
|
|
42
|
+
this.size = size;
|
|
43
|
+
}
|
|
44
|
+
subtractThenAdd(base, subtract = [], add = []) {
|
|
45
|
+
const output = Buffer.from(toBuffer(base));
|
|
46
|
+
this.subtractThenAddInPlace(output, subtract, add);
|
|
47
|
+
return output;
|
|
48
|
+
}
|
|
49
|
+
subtractThenAddInPlace(base, subtract = [], add = []) {
|
|
50
|
+
this.multipleOp(base, subtract, true);
|
|
51
|
+
this.multipleOp(base, add, false);
|
|
52
|
+
return base;
|
|
53
|
+
}
|
|
54
|
+
multipleOp(base, items, subtract) {
|
|
55
|
+
for (const item of items || []) {
|
|
56
|
+
const expanded = hkdf(item, this.size, { info: this.info });
|
|
57
|
+
this.performPointwiseWithOverflow(base, expanded, subtract);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
performPointwiseWithOverflow(base, input, subtract) {
|
|
61
|
+
for (let i = 0; i < base.length; i += 2) {
|
|
62
|
+
const x = base.readUInt16LE(i);
|
|
63
|
+
const y = input.readUInt16LE(i);
|
|
64
|
+
const result = subtract ? (x - y + 0x10000) & 0xFFFF : (x + y) & 0xFFFF;
|
|
65
|
+
base.writeUInt16LE(result, i);
|
|
66
|
+
}
|
|
67
|
+
return base;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.LTHashAntiTampering = LTHashAntiTampering;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jagproject",
|
|
3
|
-
"version": "26.03.
|
|
3
|
+
"version": "26.03.27",
|
|
4
4
|
"update": "22 Maret 2026",
|
|
5
5
|
"description": "WhatsApp Web API Library",
|
|
6
6
|
"keywords": [
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"fflate": "^0.8.2",
|
|
70
70
|
"audio-decode": "^2.1.3",
|
|
71
71
|
"lru-cache": "^11.1.0",
|
|
72
|
-
"whatsapp-rust-bridge": "0.5.
|
|
72
|
+
"whatsapp-rust-bridge": "0.5.3"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
|