@hbmodsofc/baileys 1.5.0 → 1.7.6

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 (156) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/index.js +19671 -152026
  3. package/engine-requirements.js +4 -4
  4. package/lib/Defaults/index.d.ts +12 -8
  5. package/lib/Defaults/index.js +90 -124
  6. package/lib/Signal/Group/group_cipher.d.ts +0 -1
  7. package/lib/Signal/Group/group_cipher.js +28 -39
  8. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  9. package/lib/Signal/Group/sender-chain-key.js +9 -2
  10. package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
  11. package/lib/Signal/Group/sender-key-message.js +3 -3
  12. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  13. package/lib/Signal/Group/sender-key-state.js +47 -16
  14. package/lib/Signal/libsignal.d.ts +7 -3
  15. package/lib/Signal/libsignal.js +224 -39
  16. package/lib/Signal/lid-mapping.d.ts +26 -0
  17. package/lib/Signal/lid-mapping.js +146 -0
  18. package/lib/Socket/Client/index.d.ts +2 -3
  19. package/lib/Socket/Client/index.js +2 -3
  20. package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -3
  21. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
  22. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +10 -16
  23. package/lib/Socket/business.d.ts +94 -78
  24. package/lib/Socket/business.js +130 -11
  25. package/lib/Socket/chats.d.ts +63 -233
  26. package/lib/Socket/chats.js +234 -184
  27. package/lib/Socket/communities.d.ts +232 -0
  28. package/lib/Socket/communities.js +402 -0
  29. package/lib/Socket/groups.d.ts +62 -41
  30. package/lib/Socket/groups.js +76 -64
  31. package/lib/Socket/index.d.ts +129 -83
  32. package/lib/Socket/index.js +13 -6
  33. package/lib/Socket/messages-recv.d.ts +59 -48
  34. package/lib/Socket/messages-recv.js +516 -371
  35. package/lib/Socket/messages-send.d.ts +86 -67
  36. package/lib/Socket/messages-send.js +1091 -1
  37. package/lib/Socket/mex.d.ts +2 -0
  38. package/lib/Socket/mex.js +45 -0
  39. package/lib/Socket/newsletter.d.ts +76 -64
  40. package/lib/Socket/newsletter.js +184 -1
  41. package/lib/Socket/socket.d.ts +19 -13
  42. package/lib/Socket/socket.js +805 -1
  43. package/lib/Types/Auth.d.ts +4 -10
  44. package/lib/Types/Bussines.d.ts +24 -0
  45. package/lib/Types/Bussines.js +2 -0
  46. package/lib/Types/Call.d.ts +1 -1
  47. package/lib/Types/Chat.d.ts +29 -9
  48. package/lib/Types/Chat.js +7 -1
  49. package/lib/Types/Contact.d.ts +5 -1
  50. package/lib/Types/Events.d.ts +55 -14
  51. package/lib/Types/GroupMetadata.d.ts +15 -5
  52. package/lib/Types/Label.d.ts +11 -0
  53. package/lib/Types/Label.js +1 -1
  54. package/lib/Types/LabelAssociation.js +1 -1
  55. package/lib/Types/Message.d.ts +75 -49
  56. package/lib/Types/Message.js +10 -7
  57. package/lib/Types/Newsletter.d.ts +129 -98
  58. package/lib/Types/Newsletter.js +33 -38
  59. package/lib/Types/Product.d.ts +1 -1
  60. package/lib/Types/Signal.d.ts +29 -1
  61. package/lib/Types/Socket.d.ts +48 -22
  62. package/lib/Types/State.d.ts +13 -2
  63. package/lib/Types/State.js +12 -0
  64. package/lib/Types/USync.d.ts +1 -1
  65. package/lib/Types/index.d.ts +10 -3
  66. package/lib/Types/index.js +2 -2
  67. package/lib/Utils/auth-utils.d.ts +3 -3
  68. package/lib/Utils/auth-utils.js +378 -102
  69. package/lib/Utils/baileys-event-stream.js +1 -1
  70. package/lib/Utils/business.d.ts +2 -2
  71. package/lib/Utils/business.js +19 -13
  72. package/lib/Utils/chat-utils.d.ts +21 -22
  73. package/lib/Utils/chat-utils.js +201 -154
  74. package/lib/Utils/crypto.d.ts +18 -19
  75. package/lib/Utils/crypto.js +78 -37
  76. package/lib/Utils/decode-wa-message.d.ts +34 -7
  77. package/lib/Utils/decode-wa-message.js +138 -66
  78. package/lib/Utils/event-buffer.d.ts +6 -8
  79. package/lib/Utils/event-buffer.js +81 -43
  80. package/lib/Utils/generics.d.ts +27 -27
  81. package/lib/Utils/generics.js +128 -133
  82. package/lib/Utils/history.d.ts +9 -5
  83. package/lib/Utils/history.js +17 -23
  84. package/lib/Utils/index.d.ts +2 -0
  85. package/lib/Utils/index.js +2 -0
  86. package/lib/Utils/lidToJid-test.d.ts +11 -0
  87. package/lib/Utils/lidToJid-test.js +27 -0
  88. package/lib/Utils/link-preview.d.ts +4 -4
  89. package/lib/Utils/link-preview.js +40 -12
  90. package/lib/Utils/logger.d.ts +11 -3
  91. package/lib/Utils/lt-hash.d.ts +8 -8
  92. package/lib/Utils/lt-hash.js +23 -24
  93. package/lib/Utils/make-mutex.d.ts +2 -2
  94. package/lib/Utils/make-mutex.js +3 -2
  95. package/lib/Utils/message-retry-manager.d.ts +81 -0
  96. package/lib/Utils/message-retry-manager.js +152 -0
  97. package/lib/Utils/messages-media.d.ts +37 -41
  98. package/lib/Utils/messages-media.js +252 -368
  99. package/lib/Utils/messages.d.ts +13 -15
  100. package/lib/Utils/messages.js +274 -261
  101. package/lib/Utils/noise-handler.d.ts +13 -15
  102. package/lib/Utils/noise-handler.js +20 -26
  103. package/lib/Utils/process-message.d.ts +9 -8
  104. package/lib/Utils/process-message.js +157 -93
  105. package/lib/Utils/signal.d.ts +6 -5
  106. package/lib/Utils/signal.js +37 -29
  107. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
  108. package/lib/Utils/use-multi-file-auth-state.js +12 -7
  109. package/lib/Utils/validate-connection.d.ts +5 -6
  110. package/lib/Utils/validate-connection.js +39 -97
  111. package/lib/WABinary/constants.d.ts +24 -27
  112. package/lib/WABinary/constants.js +1276 -13
  113. package/lib/WABinary/decode.d.ts +3 -4
  114. package/lib/WABinary/decode.js +28 -14
  115. package/lib/WABinary/encode.d.ts +1 -2
  116. package/lib/WABinary/encode.js +134 -147
  117. package/lib/WABinary/generic-utils.d.ts +4 -7
  118. package/lib/WABinary/generic-utils.js +40 -125
  119. package/lib/WABinary/jid-utils.d.ts +13 -8
  120. package/lib/WABinary/jid-utils.js +27 -16
  121. package/lib/WAM/BinaryInfo.d.ts +2 -11
  122. package/lib/WAM/constants.d.ts +3 -2
  123. package/lib/WAM/constants.js +2252 -2359
  124. package/lib/WAM/encode.d.ts +1 -2
  125. package/lib/WAM/encode.js +8 -11
  126. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
  127. package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -4
  128. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  129. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
  130. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  131. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
  132. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  133. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -6
  134. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
  135. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  136. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +4 -3
  137. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
  138. package/lib/WAUSync/USyncQuery.d.ts +2 -2
  139. package/lib/WAUSync/USyncQuery.js +19 -15
  140. package/lib/WAUSync/USyncUser.d.ts +5 -5
  141. package/lib/WAUSync/index.d.ts +1 -1
  142. package/lib/WAUSync/index.js +1 -1
  143. package/package.json +102 -102
  144. package/lib/Defaults/baileys-version.json +0 -3
  145. package/lib/Defaults/phonenumber-mcc.json +0 -223
  146. package/lib/Signal/Group/queue-job.d.ts +0 -1
  147. package/lib/Signal/Group/queue-job.js +0 -57
  148. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  149. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  150. package/lib/Socket/hbmods.d.ts +0 -253
  151. package/lib/Socket/hbmods.js +0 -1
  152. package/lib/Socket/registration.d.ts +0 -267
  153. package/lib/Socket/registration.js +0 -166
  154. package/lib/Socket/usync.d.ts +0 -36
  155. package/lib/Socket/usync.js +0 -70
  156. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -1,103 +1,134 @@
1
- import { proto } from "../../WAProto"
2
-
3
- export type NewsletterReactionMode = "ALL" | "BASIC" | "NONE"
4
- export type NewsletterState = "ACTIVE" | "GEOSUSPENDED" | "SUSPENDED"
5
- export type NewsletterVerification = "VERIFIED" | "UNVERIFIED"
6
- export type NewsletterMute = "ON" | "OFF" | "UNDEFINED"
7
- export type NewsletterViewRole = "ADMIN" | "GUEST" | "OWNER" | "SUBSCRIBER"
8
-
9
- export type NewsletterViewerMetadata = {
10
- mute: NewsletterMute
11
- view_role: NewsletterViewRole
1
+ export declare enum XWAPaths {
2
+ xwa2_newsletter_create = "xwa2_newsletter_create",
3
+ xwa2_newsletter_subscribers = "xwa2_newsletter_subscribers",
4
+ xwa2_newsletter_view = "xwa2_newsletter_view",
5
+ xwa2_newsletter_metadata = "xwa2_newsletter",
6
+ xwa2_newsletter_admin_count = "xwa2_newsletter_admin",
7
+ xwa2_newsletter_mute_v2 = "xwa2_newsletter_mute_v2",
8
+ xwa2_newsletter_unmute_v2 = "xwa2_newsletter_unmute_v2",
9
+ xwa2_newsletter_follow = "xwa2_newsletter_follow",
10
+ xwa2_newsletter_unfollow = "xwa2_newsletter_unfollow",
11
+ xwa2_newsletter_change_owner = "xwa2_newsletter_change_owner",
12
+ xwa2_newsletter_demote = "xwa2_newsletter_demote",
13
+ xwa2_newsletter_delete_v2 = "xwa2_newsletter_delete_v2"
12
14
  }
13
-
14
- export type NewsletterMetadata = {
15
- /** jid of newsletter */
16
- id: string
17
- /** state of newsletter */
18
- state: NewsletterState
19
- /** creation timestamp of newsletter */
20
- creation_time: number
21
- /** name of newsletter */
22
- name: string
23
- /** timestamp of last name modification of newsletter */
24
- nameTime: number
25
- /** description of newsletter */
26
- description: string
27
- /** timestamp of last description modification of newsletter */
28
- descriptionTime: number
29
- /** invite code of newsletter */
30
- invite: string
31
- /** direct path of picture */
32
- picture: string | null
33
- /** direct path of picture preview (lower quality) */
34
- preview: string | null
35
- /** reaction mode of newsletter */
36
- reaction_codes?: NewsletterReactionMode
37
- /** subscribers count of newsletter */
38
- subscribers: number
39
- /** verification state of newsletter */
40
- verification: NewsletterVerification
41
- /** viewer metadata */
42
- viewer_metadata: NewsletterViewerMetadata
15
+ export declare enum QueryIds {
16
+ CREATE = "8823471724422422",
17
+ UPDATE_METADATA = "24250201037901610",
18
+ METADATA = "6563316087068696",
19
+ SUBSCRIBERS = "9783111038412085",
20
+ FOLLOW = "7871414976211147",
21
+ UNFOLLOW = "7238632346214362",
22
+ MUTE = "29766401636284406",
23
+ UNMUTE = "9864994326891137",
24
+ ADMIN_COUNT = "7130823597031706",
25
+ CHANGE_OWNER = "7341777602580933",
26
+ DEMOTE = "6551828931592903",
27
+ DELETE = "30062808666639665"
43
28
  }
44
-
45
- export type SubscriberAction = "promote" | "demote"
46
-
47
- export type ReactionModeUpdate = {
48
- reaction_codes: {
49
- blocked_codes: null
50
- enabled_ts_sec: null
51
- value: NewsletterReactionMode
52
- }
29
+ export type NewsletterUpdate = {
30
+ name?: string;
31
+ description?: string;
32
+ picture?: string;
33
+ };
34
+ export interface NewsletterCreateResponse {
35
+ id: string;
36
+ state: {
37
+ type: string;
38
+ };
39
+ thread_metadata: {
40
+ creation_time: string;
41
+ description: {
42
+ id: string;
43
+ text: string;
44
+ update_time: string;
45
+ };
46
+ handle: string | null;
47
+ invite: string;
48
+ name: {
49
+ id: string;
50
+ text: string;
51
+ update_time: string;
52
+ };
53
+ picture: {
54
+ direct_path: string;
55
+ id: string;
56
+ type: string;
57
+ };
58
+ preview: {
59
+ direct_path: string;
60
+ id: string;
61
+ type: string;
62
+ };
63
+ subscribers_count: string;
64
+ verification: 'VERIFIED' | 'UNVERIFIED';
65
+ };
66
+ viewer_metadata: {
67
+ mute: 'ON' | 'OFF';
68
+ role: NewsletterViewRole;
69
+ };
53
70
  }
54
-
55
- /** only exists reaction mode update */
56
- export type NewsletterSettingsUpdate = ReactionModeUpdate
57
-
58
- export type NewsletterReaction = {
59
- count: number
60
- code: string
71
+ export interface NewsletterCreateResponse {
72
+ id: string;
73
+ state: {
74
+ type: string;
75
+ };
76
+ thread_metadata: {
77
+ creation_time: string;
78
+ description: {
79
+ id: string;
80
+ text: string;
81
+ update_time: string;
82
+ };
83
+ handle: string | null;
84
+ invite: string;
85
+ name: {
86
+ id: string;
87
+ text: string;
88
+ update_time: string;
89
+ };
90
+ picture: {
91
+ direct_path: string;
92
+ id: string;
93
+ type: string;
94
+ };
95
+ preview: {
96
+ direct_path: string;
97
+ id: string;
98
+ type: string;
99
+ };
100
+ subscribers_count: string;
101
+ verification: 'VERIFIED' | 'UNVERIFIED';
102
+ };
103
+ viewer_metadata: {
104
+ mute: 'ON' | 'OFF';
105
+ role: NewsletterViewRole;
106
+ };
61
107
  }
62
-
63
- export type NewsletterFetchedUpdate = {
64
- /** id of message in newsletter, starts from 100 */
65
- server_id: string
66
- /** count of views in this message */
67
- views?: number
68
- /** reactions in this message */
69
- reactions: NewsletterReaction[]
70
- /** the message, if you requested only updates, you will not receive message */
71
- message?: proto.IWebMessageInfo
108
+ export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
109
+ export interface NewsletterMetadata {
110
+ id: string;
111
+ owner?: string;
112
+ name: string;
113
+ description?: string;
114
+ invite?: string;
115
+ creation_time?: number;
116
+ subscribers?: number;
117
+ picture?: {
118
+ url?: string;
119
+ directPath?: string;
120
+ mediaKey?: string;
121
+ id?: string;
122
+ };
123
+ verification?: 'VERIFIED' | 'UNVERIFIED';
124
+ reaction_codes?: {
125
+ code: string;
126
+ count: number;
127
+ }[];
128
+ mute_state?: 'ON' | 'OFF';
129
+ thread_metadata?: {
130
+ creation_time?: number;
131
+ name?: string;
132
+ description?: string;
133
+ };
72
134
  }
73
-
74
- export const MexOperations = {
75
- PROMOTE: "NotificationNewsletterAdminPromote",
76
- DEMOTE: "NotificationNewsletterAdminDemote",
77
- UPDATE: "NotificationNewsletterUpdate"
78
- } as const
79
-
80
- export const XWAPaths = {
81
- PROMOTE: "xwa2_notify_newsletter_admin_promote",
82
- DEMOTE: "xwa2_notify_newsletter_admin_demote",
83
- ADMIN_COUNT: "xwa2_newsletter_admin",
84
- CREATE: "xwa2_newsletter_create",
85
- NEWSLETTER: "xwa2_newsletter",
86
- SUBSCRIBED: "xwa2_newsletter_subscribed",
87
- METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
88
- } as const
89
-
90
- export const QueryIds = {
91
- JOB_MUTATION: "7150902998257522",
92
- METADATA: "6620195908089573",
93
- UNFOLLOW: "7238632346214362",
94
- FOLLOW: "7871414976211147",
95
- UNMUTE: "7337137176362961",
96
- MUTE: "25151904754424642",
97
- CREATE: "6996806640408138",
98
- ADMIN_COUNT: "7130823597031706",
99
- CHANGE_OWNER: "7341777602580933",
100
- DELETE: "8316537688363079",
101
- DEMOTE: "6551828931592903",
102
- SUBSCRIBED: "6388546374527196"
103
- } as const
@@ -1,38 +1,33 @@
1
- "use strict"
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true })
4
-
5
- const MexOperations = {
6
- PROMOTE: "NotificationNewsletterAdminPromote",
7
- DEMOTE: "NotificationNewsletterAdminDemote",
8
- UPDATE: "NotificationNewsletterUpdate"
9
- }
10
-
11
- const XWAPaths = {
12
- PROMOTE: "xwa2_notify_newsletter_admin_promote",
13
- DEMOTE: "xwa2_notify_newsletter_admin_demote",
14
- ADMIN_COUNT: "xwa2_newsletter_admin",
15
- CREATE: "xwa2_newsletter_create",
16
- NEWSLETTER: "xwa2_newsletter",
17
- SUBSCRIBED: "xwa2_newsletter_subscribed",
18
- METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
19
- }
20
-
21
- const QueryIds = {
22
- JOB_MUTATION: "7150902998257522",
23
- METADATA: "6620195908089573",
24
- UNFOLLOW: "7238632346214362",
25
- FOLLOW: "7871414976211147",
26
- UNMUTE: "7337137176362961",
27
- MUTE: "25151904754424642",
28
- CREATE: "6996806640408138",
29
- ADMIN_COUNT: "7130823597031706",
30
- CHANGE_OWNER: "7341777602580933",
31
- DELETE: "8316537688363079",
32
- DEMOTE: "6551828931592903",
33
- SUBSCRIBED: "6388546374527196"
34
- }
35
-
36
- exports.MexOperations = MexOperations
37
- exports.XWAPaths = XWAPaths
38
- exports.QueryIds = QueryIds
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryIds = exports.XWAPaths = void 0;
4
+ var XWAPaths;
5
+ (function (XWAPaths) {
6
+ XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
7
+ XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
8
+ XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
9
+ XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
10
+ XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
11
+ XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
12
+ XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
13
+ XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
14
+ XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
15
+ XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
16
+ XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
17
+ XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
18
+ })(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
19
+ var QueryIds;
20
+ (function (QueryIds) {
21
+ QueryIds["CREATE"] = "8823471724422422";
22
+ QueryIds["UPDATE_METADATA"] = "24250201037901610";
23
+ QueryIds["METADATA"] = "6563316087068696";
24
+ QueryIds["SUBSCRIBERS"] = "9783111038412085";
25
+ QueryIds["FOLLOW"] = "7871414976211147";
26
+ QueryIds["UNFOLLOW"] = "7238632346214362";
27
+ QueryIds["MUTE"] = "29766401636284406";
28
+ QueryIds["UNMUTE"] = "9864994326891137";
29
+ QueryIds["ADMIN_COUNT"] = "7130823597031706";
30
+ QueryIds["CHANGE_OWNER"] = "7341777602580933";
31
+ QueryIds["DEMOTE"] = "6551828931592903";
32
+ QueryIds["DELETE"] = "30062808666639665";
33
+ })(QueryIds || (exports.QueryIds = QueryIds = {}));
@@ -1,4 +1,4 @@
1
- import { WAMediaUpload } from './Message';
1
+ import type { WAMediaUpload } from './Message';
2
2
  export type CatalogResult = {
3
3
  data: {
4
4
  paging: {
@@ -1,4 +1,5 @@
1
- import { proto } from '../../WAProto';
1
+ import { proto } from '../../WAProto/index.js';
2
+ import type { LIDMappingStore } from '../Signal/lid-mapping';
2
3
  type DecryptGroupSignalOpts = {
3
4
  group: string;
4
5
  authorJid: string;
@@ -17,6 +18,11 @@ type EncryptMessageOpts = {
17
18
  jid: string;
18
19
  data: Uint8Array;
19
20
  };
21
+ type EncryptMessageWithWireOpts = {
22
+ encryptionJid: string;
23
+ wireJid: string;
24
+ data: Uint8Array;
25
+ };
20
26
  type EncryptGroupMessageOpts = {
21
27
  group: string;
22
28
  data: Uint8Array;
@@ -47,11 +53,33 @@ export type SignalRepository = {
47
53
  type: 'pkmsg' | 'msg';
48
54
  ciphertext: Uint8Array;
49
55
  }>;
56
+ encryptMessageWithWire(opts: EncryptMessageWithWireOpts): Promise<{
57
+ type: 'pkmsg' | 'msg';
58
+ ciphertext: Uint8Array;
59
+ wireJid: string;
60
+ }>;
50
61
  encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
51
62
  senderKeyDistributionMessage: Uint8Array;
52
63
  ciphertext: Uint8Array;
53
64
  }>;
54
65
  injectE2ESession(opts: E2ESessionOpts): Promise<void>;
66
+ validateSession(jid: string): Promise<{
67
+ exists: boolean;
68
+ reason?: string;
69
+ }>;
55
70
  jidToSignalProtocolAddress(jid: string): string;
71
+ migrateSession(fromJids: string[], toJid: string): Promise<{
72
+ migrated: number;
73
+ skipped: number;
74
+ total: number;
75
+ }>;
76
+ validateSession(jid: string): Promise<{
77
+ exists: boolean;
78
+ reason?: string;
79
+ }>;
80
+ deleteSession(jids: string[]): Promise<void>;
56
81
  };
82
+ export interface SignalRepositoryWithLIDStore extends SignalRepository {
83
+ lidMapping: LIDMappingStore;
84
+ }
57
85
  export {};
@@ -1,24 +1,34 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { AxiosRequestConfig } from 'axios';
1
+ import type { AxiosRequestConfig } from 'axios';
4
2
  import type { Agent } from 'https';
5
- import type { Logger } from 'pino';
6
3
  import type { URL } from 'url';
7
- import { proto } from '../../WAProto';
8
- import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
9
- import { MediaConnInfo } from './Message';
10
- import { SignalRepository } from './Signal';
4
+ import { proto } from '../../WAProto/index.js';
5
+ import type { ILogger } from '../Utils/logger';
6
+ import type { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
7
+ import type { GroupMetadata } from './GroupMetadata';
8
+ import { type MediaConnInfo } from './Message';
9
+ import type { SignalRepositoryWithLIDStore } from './Signal';
11
10
  export type WAVersion = [number, number, number];
12
11
  export type WABrowserDescription = [string, string, string];
13
12
  export type CacheStore = {
14
13
  /** get a cached key and change the stats */
15
- get<T>(key: string): T | undefined;
14
+ get<T>(key: string): Promise<T> | T | undefined;
16
15
  /** set a key in the cache */
17
- set<T>(key: string, value: T): void;
16
+ set<T>(key: string, value: T): Promise<void> | void | number | boolean;
18
17
  /** delete a key from the cache */
19
- del(key: string): void;
18
+ del(key: string): void | Promise<void> | number | boolean;
20
19
  /** flush all data */
21
- flushAll(): void;
20
+ flushAll(): void | Promise<void>;
21
+ };
22
+ export type PossiblyExtendedCacheStore = CacheStore & {
23
+ mget?: <T>(keys: string[]) => Promise<Record<string, T | undefined>>;
24
+ mset?: <T>(entries: {
25
+ key: string;
26
+ value: T;
27
+ }[]) => Promise<void> | void | number | boolean;
28
+ mdel?: (keys: string[]) => void | Promise<void> | number | boolean;
29
+ };
30
+ export type PatchedMessageWithRecipientJID = proto.IMessage & {
31
+ recipientJid?: string;
22
32
  };
23
33
  export type SocketConfig = {
24
34
  /** the WS url to connect to WA */
@@ -29,20 +39,24 @@ export type SocketConfig = {
29
39
  defaultQueryTimeoutMs: number | undefined;
30
40
  /** ping-pong interval for WS connection */
31
41
  keepAliveIntervalMs: number;
32
- /** should baileys use the mobile api instead of the multi device api */
42
+ /** should baileys use the mobile api instead of the multi device api
43
+ * @deprecated This feature has been removed
44
+ */
33
45
  mobile?: boolean;
34
46
  /** proxy agent */
35
47
  agent?: Agent;
36
- /** pino logger */
37
- logger: Logger;
48
+ /** logger */
49
+ logger: ILogger;
38
50
  /** version to connect with */
39
51
  version: WAVersion;
40
52
  /** override browser config */
41
53
  browser: WABrowserDescription;
42
54
  /** agent used for fetch requests -- uploading/downloading media */
43
55
  fetchAgent?: Agent;
44
- /** should the QR be printed in the terminal */
45
- printQRInTerminal: boolean;
56
+ /** should the QR be printed in the terminal
57
+ * @deprecated This feature has been removed
58
+ */
59
+ printQRInTerminal?: boolean;
46
60
  /** should events be emitted for actions done by this socket connection */
47
61
  emitOwnEvents: boolean;
48
62
  /** custom upload hosts to upload media to */
@@ -61,6 +75,8 @@ export type SocketConfig = {
61
75
  transactionOpts: TransactionCapabilityOptions;
62
76
  /** marks the client as online whenever the socket successfully connects */
63
77
  markOnlineOnConnect: boolean;
78
+ /** alphanumeric country code (USA -> US) for the number used */
79
+ countryCode: string;
64
80
  /** provide a cache to store media, so does not have to be re-uploaded */
65
81
  mediaCache?: CacheStore;
66
82
  /**
@@ -68,9 +84,11 @@ export type SocketConfig = {
68
84
  * used to determine whether to retry a message or not */
69
85
  msgRetryCounterCache?: CacheStore;
70
86
  /** provide a cache to store a user's device list */
71
- userDevicesCache?: CacheStore;
87
+ userDevicesCache?: PossiblyExtendedCacheStore;
72
88
  /** cache to store call offers */
73
89
  callOfferCache?: CacheStore;
90
+ /** cache to track placeholder resends */
91
+ placeholderResendCache?: CacheStore;
74
92
  /** width for link preview images */
75
93
  linkPreviewImageThumbnailWidth: number;
76
94
  /** Should Baileys ask the phone for full history, will be received async */
@@ -82,6 +100,10 @@ export type SocketConfig = {
82
100
  * entails uploading the jpegThumbnail to WA
83
101
  * */
84
102
  generateHighQualityLinkPreview: boolean;
103
+ /** Enable automatic session recreation for failed messages */
104
+ enableAutoSessionRecreation: boolean;
105
+ /** Enable recent message caching for retry handling */
106
+ enableRecentMessageCache: boolean;
85
107
  /**
86
108
  * Returns if a jid should be ignored,
87
109
  * no event for that jid will be triggered.
@@ -91,7 +113,7 @@ export type SocketConfig = {
91
113
  /**
92
114
  * Optionally patch the message before sending out
93
115
  * */
94
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
116
+ patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
95
117
  /** verify app state MACs */
96
118
  appStateMacVerification: {
97
119
  patch: boolean;
@@ -105,7 +127,11 @@ export type SocketConfig = {
105
127
  * (solves the "this message can take a while" issue) can be retried
106
128
  * */
107
129
  getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
108
- makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
109
- /** Socket passthrough */
110
- socket?: any;
130
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
131
+ cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
132
+ makeSignalRepository: (auth: SignalAuthState, onWhatsAppFunc?: (...jids: string[]) => Promise<{
133
+ jid: string;
134
+ exists: boolean;
135
+ lid: string;
136
+ }[] | undefined>) => SignalRepositoryWithLIDStore;
111
137
  };
@@ -1,11 +1,22 @@
1
- import { Contact } from './Contact';
1
+ import { Boom } from '@hapi/boom';
2
+ import type { Contact } from './Contact';
3
+ export declare enum SyncState {
4
+ /** The socket is connecting, but we haven't received pending notifications yet. */
5
+ Connecting = 0,
6
+ /** Pending notifications received. Buffering events until we decide whether to sync or not. */
7
+ AwaitingInitialSync = 1,
8
+ /** The initial app state sync (history, etc.) is in progress. Buffering continues. */
9
+ Syncing = 2,
10
+ /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
11
+ Online = 3
12
+ }
2
13
  export type WAConnectionState = 'open' | 'connecting' | 'close';
3
14
  export type ConnectionState = {
4
15
  /** connection is now open, connecting or closed */
5
16
  connection: WAConnectionState;
6
17
  /** the error that caused the connection to close */
7
18
  lastDisconnect?: {
8
- error: Error | undefined;
19
+ error: Boom | Error | undefined;
9
20
  date: Date;
10
21
  };
11
22
  /** is this a new login */
@@ -1,2 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SyncState = void 0;
4
+ var SyncState;
5
+ (function (SyncState) {
6
+ /** The socket is connecting, but we haven't received pending notifications yet. */
7
+ SyncState[SyncState["Connecting"] = 0] = "Connecting";
8
+ /** Pending notifications received. Buffering events until we decide whether to sync or not. */
9
+ SyncState[SyncState["AwaitingInitialSync"] = 1] = "AwaitingInitialSync";
10
+ /** The initial app state sync (history, etc.) is in progress. Buffering continues. */
11
+ SyncState[SyncState["Syncing"] = 2] = "Syncing";
12
+ /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
13
+ SyncState[SyncState["Online"] = 3] = "Online";
14
+ })(SyncState || (exports.SyncState = SyncState = {}));
@@ -1,4 +1,4 @@
1
- import { BinaryNode } from '../WABinary';
1
+ import type { BinaryNode } from '../WABinary';
2
2
  import { USyncUser } from '../WAUSync';
3
3
  /**
4
4
  * Defines the interface for a USyncQuery protocol
@@ -4,17 +4,24 @@ export * from './Chat';
4
4
  export * from './Contact';
5
5
  export * from './State';
6
6
  export * from './Message';
7
- export * from './Newsletter';
8
7
  export * from './Socket';
9
8
  export * from './Events';
10
9
  export * from './Product';
11
10
  export * from './Call';
12
11
  export * from './Signal';
13
- import { AuthenticationState } from './Auth';
14
- import { SocketConfig } from './Socket';
12
+ export * from './Newsletter';
13
+ import type { AuthenticationState } from './Auth';
14
+ import type { SocketConfig } from './Socket';
15
15
  export type UserFacingSocketConfig = Partial<SocketConfig> & {
16
16
  auth: AuthenticationState;
17
17
  };
18
+ export type BrowsersMap = {
19
+ ubuntu(browser: string): [string, string, string];
20
+ macOS(browser: string): [string, string, string];
21
+ baileys(browser: string): [string, string, string];
22
+ windows(browser: string): [string, string, string];
23
+ appropriate(browser: string): [string, string, string];
24
+ };
18
25
  export declare enum DisconnectReason {
19
26
  connectionClosed = 428,
20
27
  connectionLost = 408,
@@ -21,12 +21,12 @@ __exportStar(require("./Chat"), exports);
21
21
  __exportStar(require("./Contact"), exports);
22
22
  __exportStar(require("./State"), exports);
23
23
  __exportStar(require("./Message"), exports);
24
- __exportStar(require("./Newsletter"), exports);
25
24
  __exportStar(require("./Socket"), exports);
26
25
  __exportStar(require("./Events"), exports);
27
26
  __exportStar(require("./Product"), exports);
28
27
  __exportStar(require("./Call"), exports);
29
28
  __exportStar(require("./Signal"), exports);
29
+ __exportStar(require("./Newsletter"), exports);
30
30
  var DisconnectReason;
31
31
  (function (DisconnectReason) {
32
32
  DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
@@ -39,4 +39,4 @@ var DisconnectReason;
39
39
  DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
40
40
  DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
41
41
  DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
42
- })(DisconnectReason = exports.DisconnectReason || (exports.DisconnectReason = {}));
42
+ })(DisconnectReason || (exports.DisconnectReason = DisconnectReason = {}));
@@ -1,12 +1,12 @@
1
- import type { Logger } from 'pino';
2
1
  import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types';
2
+ import type { ILogger } from './logger';
3
3
  /**
4
4
  * Adds caching capability to a SignalKeyStore
5
5
  * @param store the store to add caching to
6
6
  * @param logger to log trace events
7
7
  * @param _cache cache store to use
8
8
  */
9
- export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger: Logger, _cache?: CacheStore): SignalKeyStore;
9
+ export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger?: ILogger, _cache?: CacheStore): SignalKeyStore;
10
10
  /**
11
11
  * Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
12
12
  * this allows batch read & write operations & improves the performance of the lib
@@ -14,5 +14,5 @@ export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logge
14
14
  * @param logger logger to log events
15
15
  * @returns SignalKeyStore with transaction capability
16
16
  */
17
- export declare const addTransactionCapability: (state: SignalKeyStore, logger: Logger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
17
+ export declare const addTransactionCapability: (state: SignalKeyStore, logger: ILogger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
18
18
  export declare const initAuthCreds: () => AuthenticationCreds;