@vinzsocket/baileys 2.8.30 → 3.0.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/WAProto/fix-imports.js +7 -16
- package/WAProto/index.js +1 -37306
- package/lib/Defaults/index.js +37 -33
- package/lib/Signal/Group/ciphertext-message.js +6 -2
- package/lib/Signal/Group/group-session-builder.js +12 -7
- package/lib/Signal/Group/group_cipher.js +18 -13
- package/lib/Signal/Group/index.js +77 -12
- package/lib/Signal/Group/keyhelper.js +15 -8
- package/lib/Signal/Group/queue-job.js +7 -2
- package/lib/Signal/Group/sender-chain-key.js +11 -6
- package/lib/Signal/Group/sender-key-distribution-message.js +10 -6
- package/lib/Signal/Group/sender-key-message.js +14 -9
- package/lib/Signal/Group/sender-key-name.js +6 -2
- package/lib/Signal/Group/sender-key-record.js +13 -9
- package/lib/Signal/Group/sender-key-state.js +10 -6
- package/lib/Signal/Group/sender-message-key.js +9 -4
- package/lib/Signal/libsignal.js +34 -28
- package/lib/Signal/lid-mapping.js +24 -19
- package/lib/Socket/Client/index.js +25 -3
- package/lib/Socket/Client/types.js +8 -4
- package/lib/Socket/Client/websocket.js +16 -11
- package/lib/Socket/business.js +38 -34
- package/lib/Socket/chats.js +100 -95
- package/lib/Socket/communities.js +55 -49
- package/lib/Socket/groups.js +56 -51
- package/lib/Socket/index.js +9 -6
- package/lib/Socket/messages-recv.js +150 -145
- package/lib/Socket/messages-send.js +109 -104
- package/lib/Socket/mex.js +12 -8
- package/lib/Socket/newsletter.js +27 -23
- package/lib/Socket/socket.js +111 -107
- package/lib/Store/index.js +47 -4
- package/lib/Store/make-cache-manager-store.js +17 -11
- package/lib/Store/make-in-memory-store.js +31 -29
- package/lib/Store/make-ordered-dictionary.js +7 -2
- package/lib/Store/object-repository.js +7 -2
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -2
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.js +5 -2
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.js +1 -2
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.js +6 -3
- package/lib/Types/LabelAssociation.js +6 -3
- package/lib/Types/Message.js +16 -7
- package/lib/Types/Newsletter.js +8 -5
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.js +1 -2
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.js +7 -4
- package/lib/Types/USync.js +1 -2
- package/lib/Types/index.js +153 -15
- package/lib/Utils/auth-utils.js +32 -25
- package/lib/Utils/baileys-event-stream.js +21 -15
- package/lib/Utils/business.js +71 -61
- package/lib/Utils/chat-utils.js +91 -77
- package/lib/Utils/crypto.js +54 -32
- package/lib/Utils/decode-wa-message.js +46 -39
- package/lib/Utils/event-buffer.js +24 -19
- package/lib/Utils/extended-messages.js +14 -9
- package/lib/Utils/generics.js +100 -64
- package/lib/Utils/history.js +30 -23
- package/lib/Utils/index.js +234 -22
- package/lib/Utils/lid-resolver.js +12 -5
- package/lib/Utils/link-preview.js +11 -7
- package/lib/Utils/logger.js +8 -4
- package/lib/Utils/lt-hash.js +8 -5
- package/lib/Utils/make-mutex.js +8 -3
- package/lib/Utils/mention.js +12 -4
- package/lib/Utils/message-retry-manager.js +10 -6
- package/lib/Utils/messages-media.js +127 -95
- package/lib/Utils/messages.js +122 -98
- package/lib/Utils/noise-handler.js +25 -21
- package/lib/Utils/process-message.js +72 -63
- package/lib/Utils/signal.js +45 -33
- package/lib/Utils/use-multi-file-auth-state.js +24 -20
- package/lib/Utils/validate-connection.js +54 -47
- package/lib/WABinary/constants.js +9 -6
- package/lib/WABinary/decode.js +17 -10
- package/lib/WABinary/encode.js +11 -6
- package/lib/WABinary/generic-utils.js +31 -17
- package/lib/WABinary/index.js +58 -6
- package/lib/WABinary/jid-utils.js +36 -20
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +6 -2
- package/lib/WAM/constants.js +1 -1
- package/lib/WAM/encode.js +16 -12
- package/lib/WAM/index.js +36 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +9 -5
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +10 -6
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +8 -4
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +8 -4
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +9 -4
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +23 -19
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +6 -2
- package/lib/WAUSync/Protocols/index.js +58 -6
- package/lib/WAUSync/USyncQuery.js +21 -17
- package/lib/WAUSync/USyncUser.js +6 -2
- package/lib/WAUSync/index.js +36 -4
- package/lib/index.js +112 -12
- package/package.json +8 -6
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.assertNodeErrorFree = void 0;
|
|
5
|
+
exports.binaryNodeToString = binaryNodeToString;
|
|
6
|
+
exports.reduceBinaryNodeToDictionary = exports.getBinaryNodeMessages = exports.getBinaryNodeChildren = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = void 0;
|
|
7
|
+
var _boom = require("@hapi/boom");
|
|
8
|
+
var _index = require("../../WAProto/index.js");
|
|
9
|
+
require("./types.js");
|
|
4
10
|
// some extra useful utilities
|
|
5
|
-
|
|
11
|
+
const getBinaryNodeChildren = (node, childTag) => {
|
|
6
12
|
if (Array.isArray(node?.content)) {
|
|
7
13
|
return node.content.filter(item => item.tag === childTag);
|
|
8
14
|
}
|
|
9
15
|
return [];
|
|
10
16
|
};
|
|
11
|
-
|
|
17
|
+
exports.getBinaryNodeChildren = getBinaryNodeChildren;
|
|
18
|
+
const getAllBinaryNodeChildren = ({
|
|
12
19
|
content
|
|
13
20
|
}) => {
|
|
14
21
|
if (Array.isArray(content)) {
|
|
@@ -16,18 +23,21 @@ export const getAllBinaryNodeChildren = ({
|
|
|
16
23
|
}
|
|
17
24
|
return [];
|
|
18
25
|
};
|
|
19
|
-
|
|
26
|
+
exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
|
|
27
|
+
const getBinaryNodeChild = (node, childTag) => {
|
|
20
28
|
if (Array.isArray(node?.content)) {
|
|
21
29
|
return node?.content.find(item => item.tag === childTag);
|
|
22
30
|
}
|
|
23
31
|
};
|
|
24
|
-
|
|
32
|
+
exports.getBinaryNodeChild = getBinaryNodeChild;
|
|
33
|
+
const getBinaryNodeChildBuffer = (node, childTag) => {
|
|
25
34
|
const child = getBinaryNodeChild(node, childTag)?.content;
|
|
26
35
|
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
27
36
|
return child;
|
|
28
37
|
}
|
|
29
38
|
};
|
|
30
|
-
|
|
39
|
+
exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
|
|
40
|
+
const getBinaryNodeChildString = (node, childTag) => {
|
|
31
41
|
const child = getBinaryNodeChild(node, childTag)?.content;
|
|
32
42
|
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
33
43
|
return Buffer.from(child).toString('utf-8');
|
|
@@ -35,21 +45,24 @@ export const getBinaryNodeChildString = (node, childTag) => {
|
|
|
35
45
|
return child;
|
|
36
46
|
}
|
|
37
47
|
};
|
|
38
|
-
|
|
48
|
+
exports.getBinaryNodeChildString = getBinaryNodeChildString;
|
|
49
|
+
const getBinaryNodeChildUInt = (node, childTag, length) => {
|
|
39
50
|
const buff = getBinaryNodeChildBuffer(node, childTag);
|
|
40
51
|
if (buff) {
|
|
41
52
|
return bufferToUInt(buff, length);
|
|
42
53
|
}
|
|
43
54
|
};
|
|
44
|
-
|
|
55
|
+
exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
|
|
56
|
+
const assertNodeErrorFree = node => {
|
|
45
57
|
const errNode = getBinaryNodeChild(node, 'error');
|
|
46
58
|
if (errNode) {
|
|
47
|
-
throw new Boom(errNode.attrs.text || 'Unknown error', {
|
|
59
|
+
throw new _boom.Boom(errNode.attrs.text || 'Unknown error', {
|
|
48
60
|
data: +errNode.attrs.code
|
|
49
61
|
});
|
|
50
62
|
}
|
|
51
63
|
};
|
|
52
|
-
|
|
64
|
+
exports.assertNodeErrorFree = assertNodeErrorFree;
|
|
65
|
+
const reduceBinaryNodeToDictionary = (node, tag) => {
|
|
53
66
|
const nodes = getBinaryNodeChildren(node, tag);
|
|
54
67
|
const dict = nodes.reduce((dict, {
|
|
55
68
|
attrs
|
|
@@ -63,19 +76,21 @@ export const reduceBinaryNodeToDictionary = (node, tag) => {
|
|
|
63
76
|
}, {});
|
|
64
77
|
return dict;
|
|
65
78
|
};
|
|
66
|
-
|
|
79
|
+
exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
|
|
80
|
+
const getBinaryNodeMessages = ({
|
|
67
81
|
content
|
|
68
82
|
}) => {
|
|
69
83
|
const msgs = [];
|
|
70
84
|
if (Array.isArray(content)) {
|
|
71
85
|
for (const item of content) {
|
|
72
86
|
if (item.tag === 'message') {
|
|
73
|
-
msgs.push(proto.WebMessageInfo.decode(item.content));
|
|
87
|
+
msgs.push(_index.proto.WebMessageInfo.decode(item.content));
|
|
74
88
|
}
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
91
|
return msgs;
|
|
78
92
|
};
|
|
93
|
+
exports.getBinaryNodeMessages = getBinaryNodeMessages;
|
|
79
94
|
function bufferToUInt(e, t) {
|
|
80
95
|
let a = 0;
|
|
81
96
|
for (let i = 0; i < t; i++) {
|
|
@@ -84,7 +99,7 @@ function bufferToUInt(e, t) {
|
|
|
84
99
|
return a;
|
|
85
100
|
}
|
|
86
101
|
const tabs = n => '\t'.repeat(n);
|
|
87
|
-
|
|
102
|
+
function binaryNodeToString(node, i = 0) {
|
|
88
103
|
if (!node) {
|
|
89
104
|
return node;
|
|
90
105
|
}
|
|
@@ -101,5 +116,4 @@ export function binaryNodeToString(node, i = 0) {
|
|
|
101
116
|
const tag = `<${node.tag} ${Object.entries(node.attrs || {}).filter(([, v]) => v !== undefined).map(([k, v]) => `${k}='${v}'`).join(' ')}`;
|
|
102
117
|
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
|
|
103
118
|
return tag + content;
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=generic-utils.js.map
|
|
119
|
+
}
|
package/lib/WABinary/index.js
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
var _encode = require("./encode.js");
|
|
5
|
+
Object.keys(_encode).forEach(function (key) {
|
|
6
|
+
if (key === "default" || key === "__esModule") return;
|
|
7
|
+
if (key in exports && exports[key] === _encode[key]) return;
|
|
8
|
+
Object.defineProperty(exports, key, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _encode[key];
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
var _decode = require("./decode.js");
|
|
16
|
+
Object.keys(_decode).forEach(function (key) {
|
|
17
|
+
if (key === "default" || key === "__esModule") return;
|
|
18
|
+
if (key in exports && exports[key] === _decode[key]) return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _decode[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
var _genericUtils = require("./generic-utils.js");
|
|
27
|
+
Object.keys(_genericUtils).forEach(function (key) {
|
|
28
|
+
if (key === "default" || key === "__esModule") return;
|
|
29
|
+
if (key in exports && exports[key] === _genericUtils[key]) return;
|
|
30
|
+
Object.defineProperty(exports, key, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _genericUtils[key];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
var _jidUtils = require("./jid-utils.js");
|
|
38
|
+
Object.keys(_jidUtils).forEach(function (key) {
|
|
39
|
+
if (key === "default" || key === "__esModule") return;
|
|
40
|
+
if (key in exports && exports[key] === _jidUtils[key]) return;
|
|
41
|
+
Object.defineProperty(exports, key, {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () {
|
|
44
|
+
return _jidUtils[key];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
var _types = require("./types.js");
|
|
49
|
+
Object.keys(_types).forEach(function (key) {
|
|
50
|
+
if (key === "default" || key === "__esModule") return;
|
|
51
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
52
|
+
Object.defineProperty(exports, key, {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () {
|
|
55
|
+
return _types[key];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.transferDevice = exports.jidNormalizedUser = exports.jidEncode = exports.jidDecode = exports.isPnUser = exports.isLidUser = exports.isJidStatusBroadcast = exports.isJidNewsletter = exports.isJidMetaAI = exports.isJidGroup = exports.isJidBroadcast = exports.isJidBot = exports.areJidsSameUser = exports.S_WHATSAPP_NET = exports.STORIES_JID = exports.SERVER_JID = exports.PSA_WID = exports.OFFICIAL_BIZ_JID = exports.META_AI_JID = void 0;
|
|
5
|
+
const S_WHATSAPP_NET = exports.S_WHATSAPP_NET = '@s.whatsapp.net';
|
|
6
|
+
const OFFICIAL_BIZ_JID = exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
|
|
7
|
+
const SERVER_JID = exports.SERVER_JID = 'server@c.us';
|
|
8
|
+
const PSA_WID = exports.PSA_WID = '0@c.us';
|
|
9
|
+
const STORIES_JID = exports.STORIES_JID = 'status@broadcast';
|
|
10
|
+
const META_AI_JID = exports.META_AI_JID = '13135550002@c.us';
|
|
11
|
+
const jidEncode = (user, server, device, agent) => {
|
|
8
12
|
return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
|
|
9
13
|
};
|
|
10
|
-
|
|
14
|
+
exports.jidEncode = jidEncode;
|
|
15
|
+
const jidDecode = jid => {
|
|
11
16
|
const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
|
|
12
17
|
if (sepIdx < 0) {
|
|
13
18
|
return undefined;
|
|
@@ -24,24 +29,34 @@ export const jidDecode = jid => {
|
|
|
24
29
|
};
|
|
25
30
|
};
|
|
26
31
|
/** is the jid a user */
|
|
27
|
-
|
|
32
|
+
exports.jidDecode = jidDecode;
|
|
33
|
+
const areJidsSameUser = (jid1, jid2) => jidDecode(jid1)?.user === jidDecode(jid2)?.user;
|
|
28
34
|
/** is the jid Meta AI */
|
|
29
|
-
|
|
35
|
+
exports.areJidsSameUser = areJidsSameUser;
|
|
36
|
+
const isJidMetaAI = jid => jid?.endsWith('@bot');
|
|
30
37
|
/** is the jid a PN user */
|
|
31
|
-
|
|
38
|
+
exports.isJidMetaAI = isJidMetaAI;
|
|
39
|
+
const isPnUser = jid => jid?.endsWith('@s.whatsapp.net');
|
|
32
40
|
/** is the jid a LID */
|
|
33
|
-
|
|
41
|
+
exports.isPnUser = isPnUser;
|
|
42
|
+
const isLidUser = jid => jid?.endsWith('@lid');
|
|
34
43
|
/** is the jid a broadcast */
|
|
35
|
-
|
|
44
|
+
exports.isLidUser = isLidUser;
|
|
45
|
+
const isJidBroadcast = jid => jid?.endsWith('@broadcast');
|
|
36
46
|
/** is the jid a group */
|
|
37
|
-
|
|
47
|
+
exports.isJidBroadcast = isJidBroadcast;
|
|
48
|
+
const isJidGroup = jid => jid?.endsWith('@g.us');
|
|
38
49
|
/** is the jid the status broadcast */
|
|
39
|
-
|
|
50
|
+
exports.isJidGroup = isJidGroup;
|
|
51
|
+
const isJidStatusBroadcast = jid => jid === 'status@broadcast';
|
|
40
52
|
/** is the jid a newsletter */
|
|
41
|
-
|
|
53
|
+
exports.isJidStatusBroadcast = isJidStatusBroadcast;
|
|
54
|
+
const isJidNewsletter = jid => jid?.endsWith('@newsletter');
|
|
55
|
+
exports.isJidNewsletter = isJidNewsletter;
|
|
42
56
|
const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
const isJidBot = jid => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
|
|
58
|
+
exports.isJidBot = isJidBot;
|
|
59
|
+
const jidNormalizedUser = jid => {
|
|
45
60
|
const result = jidDecode(jid);
|
|
46
61
|
if (!result) {
|
|
47
62
|
return '';
|
|
@@ -52,7 +67,8 @@ export const jidNormalizedUser = jid => {
|
|
|
52
67
|
} = result;
|
|
53
68
|
return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server);
|
|
54
69
|
};
|
|
55
|
-
|
|
70
|
+
exports.jidNormalizedUser = jidNormalizedUser;
|
|
71
|
+
const transferDevice = (fromJid, toJid) => {
|
|
56
72
|
const fromDecoded = jidDecode(fromJid);
|
|
57
73
|
const deviceId = fromDecoded?.device || 0;
|
|
58
74
|
const {
|
|
@@ -61,4 +77,4 @@ export const transferDevice = (fromJid, toJid) => {
|
|
|
61
77
|
} = jidDecode(toJid);
|
|
62
78
|
return jidEncode(user, server, deviceId);
|
|
63
79
|
};
|
|
64
|
-
|
|
80
|
+
exports.transferDevice = transferDevice;
|
package/lib/WABinary/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var constants = _interopRequireWildcard(require("./constants.js"));
|
|
2
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
package/lib/WAM/BinaryInfo.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.BinaryInfo = void 0;
|
|
5
|
+
class BinaryInfo {
|
|
2
6
|
constructor(options = {}) {
|
|
3
7
|
this.protocolVersion = 5;
|
|
4
8
|
this.sequence = 0;
|
|
@@ -7,4 +11,4 @@ export class BinaryInfo {
|
|
|
7
11
|
Object.assign(this, options);
|
|
8
12
|
}
|
|
9
13
|
}
|
|
10
|
-
|
|
14
|
+
exports.BinaryInfo = BinaryInfo;
|