@vinzsocket/baileys 2.8.9 → 2.8.20
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 +75 -73
- package/lib/Signal/Group/ciphertext-message.js +9 -9
- package/lib/Signal/Group/group-session-builder.js +21 -21
- package/lib/Signal/Group/group_cipher.js +79 -81
- package/lib/Signal/Group/index.js +2 -2
- package/lib/Signal/Group/keyhelper.js +9 -9
- package/lib/Signal/Group/queue-job.js +43 -46
- package/lib/Signal/Group/sender-chain-key.js +24 -25
- package/lib/Signal/Group/sender-key-distribution-message.js +50 -58
- package/lib/Signal/Group/sender-key-message.js +55 -60
- package/lib/Signal/Group/sender-key-name.js +38 -39
- package/lib/Signal/Group/sender-key-record.js +39 -41
- package/lib/Signal/Group/sender-key-state.js +85 -89
- package/lib/Signal/Group/sender-message-key.js +22 -22
- package/lib/Signal/libsignal.js +387 -292
- package/lib/Signal/lid-mapping.js +98 -93
- package/lib/Socket/Client/types.js +6 -6
- package/lib/Socket/Client/websocket.js +44 -44
- package/lib/Socket/business.js +350 -365
- package/lib/Socket/chats.js +1019 -914
- package/lib/Socket/communities.js +454 -376
- package/lib/Socket/groups.js +378 -310
- package/lib/Socket/index.js +11 -11
- package/lib/Socket/messages-recv.js +1355 -1182
- package/lib/Socket/messages-send.js +1224 -1081
- package/lib/Socket/mex.js +40 -34
- package/lib/Socket/newsletter.js +212 -169
- package/lib/Socket/socket.js +896 -757
- package/lib/Store/index.js +1 -1
- package/lib/Store/make-cache-manager-store.js +75 -79
- package/lib/Store/make-in-memory-store.js +450 -389
- package/lib/Store/make-ordered-dictionary.js +73 -76
- package/lib/Store/object-repository.js +24 -22
- package/lib/Types/Chat.js +1 -7
- package/lib/Types/Label.js +20 -20
- package/lib/Types/LabelAssociation.js +2 -2
- package/lib/Types/Message.js +2 -2
- package/lib/Types/Newsletter.js +24 -24
- package/lib/Types/Socket.js +1 -1
- package/lib/Types/State.js +8 -8
- package/lib/Types/index.js +10 -10
- package/lib/Utils/auth-utils.js +408 -401
- package/lib/Utils/baileys-event-stream.js +44 -35
- package/lib/Utils/business.js +200 -197
- package/lib/Utils/chat-utils.js +775 -708
- package/lib/Utils/crypto.js +97 -85
- package/lib/Utils/decode-wa-message.js +240 -227
- package/lib/Utils/event-buffer.js +547 -518
- package/lib/Utils/extended-messages.js +250 -203
- package/lib/Utils/generics.js +300 -289
- package/lib/Utils/history.js +76 -69
- package/lib/Utils/lid-resolver.js +47 -42
- package/lib/Utils/link-preview.js +75 -65
- package/lib/Utils/logger.js +3 -1
- package/lib/Utils/lt-hash.js +38 -34
- package/lib/Utils/make-mutex.js +32 -34
- package/lib/Utils/mention.js +79 -86
- package/lib/Utils/message-retry-manager.js +148 -136
- package/lib/Utils/messages-media.js +652 -562
- package/lib/Utils/messages.js +753 -707
- package/lib/Utils/noise-handler.js +156 -135
- package/lib/Utils/process-message.js +404 -341
- package/lib/Utils/signal.js +180 -118
- package/lib/Utils/use-multi-file-auth-state.js +87 -91
- package/lib/Utils/validate-connection.js +167 -142
- package/lib/WABinary/constants.js +28 -1293
- package/lib/WABinary/decode.js +220 -218
- package/lib/WABinary/encode.js +199 -201
- package/lib/WABinary/generic-utils.js +80 -77
- package/lib/WABinary/jid-utils.js +41 -35
- package/lib/WAM/BinaryInfo.js +7 -7
- package/lib/WAM/constants.js +1 -15241
- package/lib/WAM/encode.js +124 -131
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +23 -23
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +51 -47
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +22 -22
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +30 -32
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +19 -19
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -43
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +17 -17
- package/lib/WAUSync/USyncQuery.js +82 -84
- package/lib/WAUSync/USyncUser.js +20 -20
- package/package.json +4 -1
|
@@ -5,54 +5,60 @@ export const PSA_WID = '0@c.us';
|
|
|
5
5
|
export const STORIES_JID = 'status@broadcast';
|
|
6
6
|
export const META_AI_JID = '13135550002@c.us';
|
|
7
7
|
export const jidEncode = (user, server, device, agent) => {
|
|
8
|
-
|
|
8
|
+
return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
|
|
9
9
|
};
|
|
10
|
-
export const jidDecode =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
export const jidDecode = jid => {
|
|
11
|
+
const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
|
|
12
|
+
if (sepIdx < 0) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const server = jid.slice(sepIdx + 1);
|
|
16
|
+
const userCombined = jid.slice(0, sepIdx);
|
|
17
|
+
const [userAgent, device] = userCombined.split(':');
|
|
18
|
+
const user = userAgent.split('_')[0];
|
|
19
|
+
return {
|
|
20
|
+
server: server,
|
|
21
|
+
user,
|
|
22
|
+
domainType: server === 'lid' ? 1 : 0,
|
|
23
|
+
device: device ? +device : undefined
|
|
24
|
+
};
|
|
25
25
|
};
|
|
26
26
|
/** is the jid a user */
|
|
27
27
|
export const areJidsSameUser = (jid1, jid2) => jidDecode(jid1)?.user === jidDecode(jid2)?.user;
|
|
28
28
|
/** is the jid Meta AI */
|
|
29
|
-
export const isJidMetaAI =
|
|
29
|
+
export const isJidMetaAI = jid => jid?.endsWith('@bot');
|
|
30
30
|
/** is the jid a PN user */
|
|
31
|
-
export const isPnUser =
|
|
31
|
+
export const isPnUser = jid => jid?.endsWith('@s.whatsapp.net');
|
|
32
32
|
/** is the jid a LID */
|
|
33
|
-
export const isLidUser =
|
|
33
|
+
export const isLidUser = jid => jid?.endsWith('@lid');
|
|
34
34
|
/** is the jid a broadcast */
|
|
35
|
-
export const isJidBroadcast =
|
|
35
|
+
export const isJidBroadcast = jid => jid?.endsWith('@broadcast');
|
|
36
36
|
/** is the jid a group */
|
|
37
|
-
export const isJidGroup =
|
|
37
|
+
export const isJidGroup = jid => jid?.endsWith('@g.us');
|
|
38
38
|
/** is the jid the status broadcast */
|
|
39
|
-
export const isJidStatusBroadcast =
|
|
39
|
+
export const isJidStatusBroadcast = jid => jid === 'status@broadcast';
|
|
40
40
|
/** is the jid a newsletter */
|
|
41
|
-
export const isJidNewsletter =
|
|
41
|
+
export const isJidNewsletter = jid => jid?.endsWith('@newsletter');
|
|
42
42
|
const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
|
|
43
|
-
export const isJidBot =
|
|
44
|
-
export const jidNormalizedUser =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
export const isJidBot = jid => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
|
|
44
|
+
export const jidNormalizedUser = jid => {
|
|
45
|
+
const result = jidDecode(jid);
|
|
46
|
+
if (!result) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
const {
|
|
50
|
+
user,
|
|
51
|
+
server
|
|
52
|
+
} = result;
|
|
53
|
+
return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server);
|
|
51
54
|
};
|
|
52
55
|
export const transferDevice = (fromJid, toJid) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
const fromDecoded = jidDecode(fromJid);
|
|
57
|
+
const deviceId = fromDecoded?.device || 0;
|
|
58
|
+
const {
|
|
59
|
+
server,
|
|
60
|
+
user
|
|
61
|
+
} = jidDecode(toJid);
|
|
62
|
+
return jidEncode(user, server, deviceId);
|
|
57
63
|
};
|
|
58
64
|
//# sourceMappingURL=jid-utils.js.map
|
package/lib/WAM/BinaryInfo.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export class BinaryInfo {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
constructor(options = {}) {
|
|
3
|
+
this.protocolVersion = 5;
|
|
4
|
+
this.sequence = 0;
|
|
5
|
+
this.events = [];
|
|
6
|
+
this.buffer = [];
|
|
7
|
+
Object.assign(this, options);
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=BinaryInfo.js.map
|