@vinzsocket/baileys 2.8.10 → 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.
Files changed (83) hide show
  1. package/lib/Defaults/index.js +75 -73
  2. package/lib/Signal/Group/ciphertext-message.js +9 -9
  3. package/lib/Signal/Group/group-session-builder.js +21 -21
  4. package/lib/Signal/Group/group_cipher.js +79 -81
  5. package/lib/Signal/Group/index.js +2 -2
  6. package/lib/Signal/Group/keyhelper.js +9 -9
  7. package/lib/Signal/Group/queue-job.js +43 -46
  8. package/lib/Signal/Group/sender-chain-key.js +24 -25
  9. package/lib/Signal/Group/sender-key-distribution-message.js +50 -58
  10. package/lib/Signal/Group/sender-key-message.js +55 -60
  11. package/lib/Signal/Group/sender-key-name.js +38 -39
  12. package/lib/Signal/Group/sender-key-record.js +39 -41
  13. package/lib/Signal/Group/sender-key-state.js +85 -89
  14. package/lib/Signal/Group/sender-message-key.js +22 -22
  15. package/lib/Signal/libsignal.js +387 -292
  16. package/lib/Signal/lid-mapping.js +98 -93
  17. package/lib/Socket/Client/types.js +6 -6
  18. package/lib/Socket/Client/websocket.js +44 -44
  19. package/lib/Socket/business.js +350 -365
  20. package/lib/Socket/chats.js +1019 -914
  21. package/lib/Socket/communities.js +454 -376
  22. package/lib/Socket/groups.js +378 -310
  23. package/lib/Socket/index.js +11 -11
  24. package/lib/Socket/messages-recv.js +1355 -1182
  25. package/lib/Socket/messages-send.js +1224 -1081
  26. package/lib/Socket/mex.js +40 -34
  27. package/lib/Socket/newsletter.js +212 -169
  28. package/lib/Socket/socket.js +896 -757
  29. package/lib/Store/index.js +1 -1
  30. package/lib/Store/make-cache-manager-store.js +75 -79
  31. package/lib/Store/make-in-memory-store.js +450 -389
  32. package/lib/Store/make-ordered-dictionary.js +73 -76
  33. package/lib/Store/object-repository.js +24 -22
  34. package/lib/Types/Chat.js +1 -7
  35. package/lib/Types/Label.js +20 -20
  36. package/lib/Types/LabelAssociation.js +2 -2
  37. package/lib/Types/Message.js +2 -2
  38. package/lib/Types/Newsletter.js +24 -24
  39. package/lib/Types/Socket.js +1 -1
  40. package/lib/Types/State.js +8 -8
  41. package/lib/Types/index.js +10 -10
  42. package/lib/Utils/auth-utils.js +408 -401
  43. package/lib/Utils/baileys-event-stream.js +44 -35
  44. package/lib/Utils/business.js +200 -197
  45. package/lib/Utils/chat-utils.js +775 -708
  46. package/lib/Utils/crypto.js +97 -85
  47. package/lib/Utils/decode-wa-message.js +240 -227
  48. package/lib/Utils/event-buffer.js +547 -518
  49. package/lib/Utils/extended-messages.js +250 -203
  50. package/lib/Utils/generics.js +300 -289
  51. package/lib/Utils/history.js +76 -69
  52. package/lib/Utils/lid-resolver.js +47 -42
  53. package/lib/Utils/link-preview.js +75 -65
  54. package/lib/Utils/logger.js +3 -1
  55. package/lib/Utils/lt-hash.js +38 -34
  56. package/lib/Utils/make-mutex.js +32 -34
  57. package/lib/Utils/mention.js +79 -86
  58. package/lib/Utils/message-retry-manager.js +148 -136
  59. package/lib/Utils/messages-media.js +652 -562
  60. package/lib/Utils/messages.js +753 -707
  61. package/lib/Utils/noise-handler.js +156 -135
  62. package/lib/Utils/process-message.js +404 -341
  63. package/lib/Utils/signal.js +180 -118
  64. package/lib/Utils/use-multi-file-auth-state.js +87 -91
  65. package/lib/Utils/validate-connection.js +167 -142
  66. package/lib/WABinary/constants.js +28 -1293
  67. package/lib/WABinary/decode.js +220 -218
  68. package/lib/WABinary/encode.js +199 -201
  69. package/lib/WABinary/generic-utils.js +80 -77
  70. package/lib/WABinary/jid-utils.js +41 -35
  71. package/lib/WAM/BinaryInfo.js +7 -7
  72. package/lib/WAM/constants.js +1 -15241
  73. package/lib/WAM/encode.js +124 -131
  74. package/lib/WAUSync/Protocols/USyncContactProtocol.js +23 -23
  75. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +51 -47
  76. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +22 -22
  77. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +30 -32
  78. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +19 -19
  79. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -43
  80. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +17 -17
  81. package/lib/WAUSync/USyncQuery.js +82 -84
  82. package/lib/WAUSync/USyncUser.js +20 -20
  83. package/package.json +5 -2
@@ -1,79 +1,76 @@
1
1
  export function makeOrderedDictionary(idGetter) {
2
- const array = [];
3
- const dict = {};
4
- const get = (id) => dict[id];
5
- const update = (item) => {
6
- const id = idGetter(item);
7
- const idx = array.findIndex(i => idGetter(i) === id);
8
- if (idx >= 0) {
9
- array[idx] = item;
10
- dict[id] = item;
2
+ const array = [];
3
+ const dict = {};
4
+ const get = id => dict[id];
5
+ const update = item => {
6
+ const id = idGetter(item);
7
+ const idx = array.findIndex(i => idGetter(i) === id);
8
+ if (idx >= 0) {
9
+ array[idx] = item;
10
+ dict[id] = item;
11
+ }
12
+ return false;
13
+ };
14
+ const upsert = (item, mode) => {
15
+ const id = idGetter(item);
16
+ if (get(id)) {
17
+ update(item);
18
+ } else {
19
+ if (mode === 'append') {
20
+ array.push(item);
21
+ } else {
22
+ array.splice(0, 0, item);
23
+ }
24
+ dict[id] = item;
25
+ }
26
+ };
27
+ const remove = item => {
28
+ const id = idGetter(item);
29
+ const idx = array.findIndex(i => idGetter(i) === id);
30
+ if (idx >= 0) {
31
+ array.splice(idx, 1);
32
+ delete dict[id];
33
+ return true;
34
+ }
35
+ return false;
36
+ };
37
+ return {
38
+ array,
39
+ get,
40
+ upsert,
41
+ update,
42
+ remove,
43
+ updateAssign: (id, update) => {
44
+ const item = get(id);
45
+ if (item) {
46
+ Object.assign(item, update);
47
+ delete dict[id];
48
+ dict[idGetter(item)] = item;
49
+ return true;
50
+ }
51
+ return false;
52
+ },
53
+ clear: () => {
54
+ array.splice(0, array.length);
55
+ Object.keys(dict).forEach(key => {
56
+ delete dict[key];
57
+ });
58
+ },
59
+ filter: contain => {
60
+ let i = 0;
61
+ while (i < array.length) {
62
+ if (!contain(array[i])) {
63
+ delete dict[idGetter(array[i])];
64
+ array.splice(i, 1);
65
+ } else {
66
+ i += 1;
11
67
  }
12
- return false;
13
- };
14
- const upsert = (item, mode) => {
15
- const id = idGetter(item);
16
- if (get(id)) {
17
- update(item);
18
- }
19
- else {
20
- if (mode === 'append') {
21
- array.push(item);
22
- }
23
- else {
24
- array.splice(0, 0, item);
25
- }
26
- dict[id] = item;
27
- }
28
- };
29
- const remove = (item) => {
30
- const id = idGetter(item);
31
- const idx = array.findIndex(i => idGetter(i) === id);
32
- if (idx >= 0) {
33
- array.splice(idx, 1);
34
- delete dict[id];
35
- return true;
36
- }
37
- return false;
38
- };
39
- return {
40
- array,
41
- get,
42
- upsert,
43
- update,
44
- remove,
45
- updateAssign: (id, update) => {
46
- const item = get(id);
47
- if (item) {
48
- Object.assign(item, update);
49
- delete dict[id];
50
- dict[idGetter(item)] = item;
51
- return true;
52
- }
53
- return false;
54
- },
55
- clear: () => {
56
- array.splice(0, array.length);
57
- Object.keys(dict).forEach(key => {
58
- delete dict[key];
59
- });
60
- },
61
- filter: (contain) => {
62
- let i = 0;
63
- while (i < array.length) {
64
- if (!contain(array[i])) {
65
- delete dict[idGetter(array[i])];
66
- array.splice(i, 1);
67
- }
68
- else {
69
- i += 1;
70
- }
71
- }
72
- },
73
- toJSON: () => array,
74
- fromJSON: (newItems) => {
75
- array.splice(0, array.length, ...newItems);
76
- }
77
- };
68
+ }
69
+ },
70
+ toJSON: () => array,
71
+ fromJSON: newItems => {
72
+ array.splice(0, array.length, ...newItems);
73
+ }
74
+ };
78
75
  }
79
- export default makeOrderedDictionary;
76
+ export default makeOrderedDictionary;
@@ -1,23 +1,25 @@
1
1
  export class ObjectRepository {
2
- constructor(entities = {}) {
3
- this.entityMap = new Map(Object.entries(entities));
4
- }
5
- findById(id) {
6
- return this.entityMap.get(id);
7
- }
8
- findAll() {
9
- return Array.from(this.entityMap.values());
10
- }
11
- upsertById(id, entity) {
12
- return this.entityMap.set(id, { ...entity });
13
- }
14
- deleteById(id) {
15
- return this.entityMap.delete(id);
16
- }
17
- count() {
18
- return this.entityMap.size;
19
- }
20
- toJSON() {
21
- return this.findAll();
22
- }
23
- }
2
+ constructor(entities = {}) {
3
+ this.entityMap = new Map(Object.entries(entities));
4
+ }
5
+ findById(id) {
6
+ return this.entityMap.get(id);
7
+ }
8
+ findAll() {
9
+ return Array.from(this.entityMap.values());
10
+ }
11
+ upsertById(id, entity) {
12
+ return this.entityMap.set(id, {
13
+ ...entity
14
+ });
15
+ }
16
+ deleteById(id) {
17
+ return this.entityMap.delete(id);
18
+ }
19
+ count() {
20
+ return this.entityMap.size;
21
+ }
22
+ toJSON() {
23
+ return this.findAll();
24
+ }
25
+ }
package/lib/Types/Chat.js CHANGED
@@ -1,8 +1,2 @@
1
- export const ALL_WA_PATCH_NAMES = [
2
- 'critical_block',
3
- 'critical_unblock_low',
4
- 'regular_high',
5
- 'regular_low',
6
- 'regular'
7
- ];
1
+ export const ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular'];
8
2
  //# sourceMappingURL=Chat.js.map
@@ -1,25 +1,25 @@
1
1
  /** WhatsApp has 20 predefined colors */
2
2
  export var LabelColor;
3
3
  (function (LabelColor) {
4
- LabelColor[LabelColor["Color1"] = 0] = "Color1";
5
- LabelColor[LabelColor["Color2"] = 1] = "Color2";
6
- LabelColor[LabelColor["Color3"] = 2] = "Color3";
7
- LabelColor[LabelColor["Color4"] = 3] = "Color4";
8
- LabelColor[LabelColor["Color5"] = 4] = "Color5";
9
- LabelColor[LabelColor["Color6"] = 5] = "Color6";
10
- LabelColor[LabelColor["Color7"] = 6] = "Color7";
11
- LabelColor[LabelColor["Color8"] = 7] = "Color8";
12
- LabelColor[LabelColor["Color9"] = 8] = "Color9";
13
- LabelColor[LabelColor["Color10"] = 9] = "Color10";
14
- LabelColor[LabelColor["Color11"] = 10] = "Color11";
15
- LabelColor[LabelColor["Color12"] = 11] = "Color12";
16
- LabelColor[LabelColor["Color13"] = 12] = "Color13";
17
- LabelColor[LabelColor["Color14"] = 13] = "Color14";
18
- LabelColor[LabelColor["Color15"] = 14] = "Color15";
19
- LabelColor[LabelColor["Color16"] = 15] = "Color16";
20
- LabelColor[LabelColor["Color17"] = 16] = "Color17";
21
- LabelColor[LabelColor["Color18"] = 17] = "Color18";
22
- LabelColor[LabelColor["Color19"] = 18] = "Color19";
23
- LabelColor[LabelColor["Color20"] = 19] = "Color20";
4
+ LabelColor[LabelColor["Color1"] = 0] = "Color1";
5
+ LabelColor[LabelColor["Color2"] = 1] = "Color2";
6
+ LabelColor[LabelColor["Color3"] = 2] = "Color3";
7
+ LabelColor[LabelColor["Color4"] = 3] = "Color4";
8
+ LabelColor[LabelColor["Color5"] = 4] = "Color5";
9
+ LabelColor[LabelColor["Color6"] = 5] = "Color6";
10
+ LabelColor[LabelColor["Color7"] = 6] = "Color7";
11
+ LabelColor[LabelColor["Color8"] = 7] = "Color8";
12
+ LabelColor[LabelColor["Color9"] = 8] = "Color9";
13
+ LabelColor[LabelColor["Color10"] = 9] = "Color10";
14
+ LabelColor[LabelColor["Color11"] = 10] = "Color11";
15
+ LabelColor[LabelColor["Color12"] = 11] = "Color12";
16
+ LabelColor[LabelColor["Color13"] = 12] = "Color13";
17
+ LabelColor[LabelColor["Color14"] = 13] = "Color14";
18
+ LabelColor[LabelColor["Color15"] = 14] = "Color15";
19
+ LabelColor[LabelColor["Color16"] = 15] = "Color16";
20
+ LabelColor[LabelColor["Color17"] = 16] = "Color17";
21
+ LabelColor[LabelColor["Color18"] = 17] = "Color18";
22
+ LabelColor[LabelColor["Color19"] = 18] = "Color19";
23
+ LabelColor[LabelColor["Color20"] = 19] = "Color20";
24
24
  })(LabelColor || (LabelColor = {}));
25
25
  //# sourceMappingURL=Label.js.map
@@ -1,7 +1,7 @@
1
1
  /** Association type */
2
2
  export var LabelAssociationType;
3
3
  (function (LabelAssociationType) {
4
- LabelAssociationType["Chat"] = "label_jid";
5
- LabelAssociationType["Message"] = "label_message";
4
+ LabelAssociationType["Chat"] = "label_jid";
5
+ LabelAssociationType["Message"] = "label_message";
6
6
  })(LabelAssociationType || (LabelAssociationType = {}));
7
7
  //# sourceMappingURL=LabelAssociation.js.map
@@ -5,7 +5,7 @@ export const WAMessageStubType = proto.WebMessageInfo.StubType;
5
5
  export const WAMessageStatus = proto.WebMessageInfo.Status;
6
6
  export var WAMessageAddressingMode;
7
7
  (function (WAMessageAddressingMode) {
8
- WAMessageAddressingMode["PN"] = "pn";
9
- WAMessageAddressingMode["LID"] = "lid";
8
+ WAMessageAddressingMode["PN"] = "pn";
9
+ WAMessageAddressingMode["LID"] = "lid";
10
10
  })(WAMessageAddressingMode || (WAMessageAddressingMode = {}));
11
11
  //# sourceMappingURL=Message.js.map
@@ -1,31 +1,31 @@
1
1
  export var XWAPaths;
2
2
  (function (XWAPaths) {
3
- XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
4
- XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
5
- XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
6
- XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
7
- XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
8
- XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
9
- XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
10
- XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
11
- XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
12
- XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
13
- XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
14
- XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
3
+ XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
4
+ XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
5
+ XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
6
+ XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
7
+ XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
8
+ XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
9
+ XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
10
+ XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
11
+ XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
12
+ XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
13
+ XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
14
+ XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
15
15
  })(XWAPaths || (XWAPaths = {}));
16
16
  export var QueryIds;
17
17
  (function (QueryIds) {
18
- QueryIds["CREATE"] = "8823471724422422";
19
- QueryIds["UPDATE_METADATA"] = "24250201037901610";
20
- QueryIds["METADATA"] = "6563316087068696";
21
- QueryIds["SUBSCRIBERS"] = "9783111038412085";
22
- QueryIds["FOLLOW"] = "7871414976211147";
23
- QueryIds["UNFOLLOW"] = "7238632346214362";
24
- QueryIds["MUTE"] = "29766401636284406";
25
- QueryIds["UNMUTE"] = "9864994326891137";
26
- QueryIds["ADMIN_COUNT"] = "7130823597031706";
27
- QueryIds["CHANGE_OWNER"] = "7341777602580933";
28
- QueryIds["DEMOTE"] = "6551828931592903";
29
- QueryIds["DELETE"] = "30062808666639665";
18
+ QueryIds["CREATE"] = "8823471724422422";
19
+ QueryIds["UPDATE_METADATA"] = "24250201037901610";
20
+ QueryIds["METADATA"] = "6563316087068696";
21
+ QueryIds["SUBSCRIBERS"] = "9783111038412085";
22
+ QueryIds["FOLLOW"] = "7871414976211147";
23
+ QueryIds["UNFOLLOW"] = "7238632346214362";
24
+ QueryIds["MUTE"] = "29766401636284406";
25
+ QueryIds["UNMUTE"] = "9864994326891137";
26
+ QueryIds["ADMIN_COUNT"] = "7130823597031706";
27
+ QueryIds["CHANGE_OWNER"] = "7341777602580933";
28
+ QueryIds["DEMOTE"] = "6551828931592903";
29
+ QueryIds["DELETE"] = "30062808666639665";
30
30
  })(QueryIds || (QueryIds = {}));
31
31
  //# sourceMappingURL=Newsletter.js.map
@@ -1,3 +1,3 @@
1
1
  import { proto } from '../../WAProto/index.js';
2
- import {} from './Message.js';
2
+ import './Message.js';
3
3
  //# sourceMappingURL=Socket.js.map
@@ -1,13 +1,13 @@
1
1
  import { Boom } from '@hapi/boom';
2
2
  export var SyncState;
3
3
  (function (SyncState) {
4
- /** The socket is connecting, but we haven't received pending notifications yet. */
5
- SyncState[SyncState["Connecting"] = 0] = "Connecting";
6
- /** Pending notifications received. Buffering events until we decide whether to sync or not. */
7
- SyncState[SyncState["AwaitingInitialSync"] = 1] = "AwaitingInitialSync";
8
- /** The initial app state sync (history, etc.) is in progress. Buffering continues. */
9
- SyncState[SyncState["Syncing"] = 2] = "Syncing";
10
- /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
11
- SyncState[SyncState["Online"] = 3] = "Online";
4
+ /** The socket is connecting, but we haven't received pending notifications yet. */
5
+ SyncState[SyncState["Connecting"] = 0] = "Connecting";
6
+ /** Pending notifications received. Buffering events until we decide whether to sync or not. */
7
+ SyncState[SyncState["AwaitingInitialSync"] = 1] = "AwaitingInitialSync";
8
+ /** The initial app state sync (history, etc.) is in progress. Buffering continues. */
9
+ SyncState[SyncState["Syncing"] = 2] = "Syncing";
10
+ /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
11
+ SyncState[SyncState["Online"] = 3] = "Online";
12
12
  })(SyncState || (SyncState = {}));
13
13
  //# sourceMappingURL=State.js.map
@@ -12,15 +12,15 @@ export * from './Signal.js';
12
12
  export * from './Newsletter.js';
13
13
  export var DisconnectReason;
14
14
  (function (DisconnectReason) {
15
- DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
16
- DisconnectReason[DisconnectReason["connectionLost"] = 408] = "connectionLost";
17
- DisconnectReason[DisconnectReason["connectionReplaced"] = 440] = "connectionReplaced";
18
- DisconnectReason[DisconnectReason["timedOut"] = 408] = "timedOut";
19
- DisconnectReason[DisconnectReason["loggedOut"] = 401] = "loggedOut";
20
- DisconnectReason[DisconnectReason["badSession"] = 500] = "badSession";
21
- DisconnectReason[DisconnectReason["restartRequired"] = 515] = "restartRequired";
22
- DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
23
- DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
24
- DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
15
+ DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
16
+ DisconnectReason[DisconnectReason["connectionLost"] = 408] = "connectionLost";
17
+ DisconnectReason[DisconnectReason["connectionReplaced"] = 440] = "connectionReplaced";
18
+ DisconnectReason[DisconnectReason["timedOut"] = 408] = "timedOut";
19
+ DisconnectReason[DisconnectReason["loggedOut"] = 401] = "loggedOut";
20
+ DisconnectReason[DisconnectReason["badSession"] = 500] = "badSession";
21
+ DisconnectReason[DisconnectReason["restartRequired"] = 515] = "restartRequired";
22
+ DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
23
+ DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
24
+ DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
25
25
  })(DisconnectReason || (DisconnectReason = {}));
26
26
  //# sourceMappingURL=index.js.map