@skycodee/baileys 8.0.4 → 8.0.5

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 (224) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/WAProto.proto +352 -520
  3. package/WAProto/index.js +558 -4154
  4. package/lib/Defaults/index.js +123 -0
  5. package/lib/Defaults/index.js.bak +123 -0
  6. package/lib/KeyDB/BinarySearch.js +20 -0
  7. package/lib/KeyDB/KeyedDB.js +167 -0
  8. package/lib/KeyDB/index.js +4 -0
  9. package/lib/Signal/Group/ciphertext-message.js +13 -0
  10. package/lib/Signal/Group/group-session-builder.js +32 -0
  11. package/lib/Signal/Group/group_cipher.js +84 -0
  12. package/lib/Signal/Group/index.js +13 -0
  13. package/lib/Signal/Group/keyhelper.js +20 -0
  14. package/lib/Signal/Group/sender-chain-key.js +28 -0
  15. package/lib/Signal/Group/sender-key-distribution-message.js +65 -0
  16. package/lib/Signal/Group/sender-key-message.js +68 -0
  17. package/lib/Signal/Group/sender-key-name.js +52 -0
  18. package/lib/Signal/Group/sender-key-record.js +43 -0
  19. package/lib/Signal/Group/sender-key-state.js +86 -0
  20. package/lib/Signal/Group/sender-message-key.js +28 -0
  21. package/lib/Signal/libsignal.js +324 -0
  22. package/lib/Signal/lid-mapping.js +155 -0
  23. package/lib/Socket/Client/index.js +4 -0
  24. package/lib/Socket/Client/types.js +13 -0
  25. package/lib/Socket/Client/websocket.js +52 -0
  26. package/lib/Socket/Client/websocket.js.bak +53 -0
  27. package/lib/Socket/business.js +377 -0
  28. package/lib/Socket/chats.js +885 -0
  29. package/lib/Socket/communities.js +413 -0
  30. package/lib/Socket/groups.js +312 -0
  31. package/lib/Socket/index.js +16 -0
  32. package/lib/Socket/messages-recv.js +1163 -0
  33. package/lib/Socket/messages-send.js +1100 -0
  34. package/lib/Socket/mex.js +45 -0
  35. package/lib/Socket/newsletter.js +247 -0
  36. package/lib/Socket/socket.js +820 -0
  37. package/lib/Store/index.js +6 -0
  38. package/lib/Store/make-cache-manager-store.js +75 -0
  39. package/lib/Store/make-in-memory-store.js +290 -0
  40. package/lib/Store/make-ordered-dictionary.js +79 -0
  41. package/lib/Store/object-repository.js +25 -0
  42. package/lib/Types/Auth.js +3 -0
  43. package/lib/Types/Bussines.js +3 -0
  44. package/lib/Types/Call.js +3 -0
  45. package/lib/Types/Chat.js +9 -0
  46. package/lib/Types/Contact.js +3 -0
  47. package/lib/Types/Events.js +3 -0
  48. package/lib/Types/GroupMetadata.js +3 -0
  49. package/lib/Types/Label.js +25 -0
  50. package/lib/Types/LabelAssociation.js +7 -0
  51. package/lib/Types/Message.js +12 -0
  52. package/lib/Types/Newsletter.js +33 -0
  53. package/lib/Types/Newsletter.js.bak +33 -0
  54. package/lib/Types/Product.js +3 -0
  55. package/lib/Types/Signal.js +3 -0
  56. package/lib/Types/Socket.js +4 -0
  57. package/lib/Types/State.js +11 -0
  58. package/lib/Types/USync.js +3 -0
  59. package/lib/Types/index.js +28 -0
  60. package/lib/Utils/auth-utils.js +219 -0
  61. package/lib/Utils/baileys-event-stream.js +44 -0
  62. package/lib/Utils/browser-utils.js +25 -0
  63. package/lib/Utils/business.js +233 -0
  64. package/lib/Utils/chat-utils.js +752 -0
  65. package/lib/Utils/crypto.js +130 -0
  66. package/lib/Utils/decode-wa-message.js +267 -0
  67. package/lib/Utils/event-buffer.js +528 -0
  68. package/lib/Utils/generics.js +355 -0
  69. package/lib/Utils/history.js +87 -0
  70. package/lib/Utils/index.js +21 -0
  71. package/lib/Utils/link-preview.js +81 -0
  72. package/lib/Utils/logger.js +5 -0
  73. package/lib/Utils/lt-hash.js +45 -0
  74. package/lib/Utils/make-mutex.js +36 -0
  75. package/lib/Utils/message-retry-manager.js +113 -0
  76. package/lib/Utils/messages-media.js +627 -0
  77. package/lib/Utils/messages.js +909 -0
  78. package/lib/Utils/noise-handler.js +144 -0
  79. package/lib/Utils/pre-key-manager.js +85 -0
  80. package/lib/Utils/process-message.js +341 -0
  81. package/lib/Utils/signal.js +161 -0
  82. package/lib/Utils/use-multi-file-auth-state.js +111 -0
  83. package/lib/Utils/validate-connection.js +200 -0
  84. package/lib/WABinary/constants.js +1303 -0
  85. package/lib/WABinary/decode.js +240 -0
  86. package/lib/WABinary/encode.js +218 -0
  87. package/lib/WABinary/generic-utils.js +189 -0
  88. package/lib/WABinary/index.js +7 -0
  89. package/lib/WABinary/jid-utils.js +93 -0
  90. package/lib/WABinary/types.js +3 -0
  91. package/lib/WAM/BinaryInfo.js +11 -0
  92. package/lib/WAM/constants.js +22853 -0
  93. package/lib/WAM/encode.js +154 -0
  94. package/lib/WAM/index.js +5 -0
  95. package/lib/WAUSync/Protocols/USyncContactProtocol.js +30 -0
  96. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
  97. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +29 -0
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -0
  99. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  100. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +30 -0
  101. package/lib/WAUSync/Protocols/index.js +6 -0
  102. package/lib/WAUSync/USyncQuery.js +90 -0
  103. package/lib/WAUSync/USyncUser.js +24 -0
  104. package/lib/WAUSync/index.js +5 -0
  105. package/lib/index.js +21 -0
  106. package/package.json +84 -57
  107. package/README.md +0 -1312
  108. package/WAProto/GenerateStatics.sh +0 -3
  109. package/WAProto/fix-imports.js +0 -81
  110. package/WAProto/index.d.ts +0 -14017
  111. package/engine-requirements.js +0 -10
  112. package/src/Defaults/baileys-version.json +0 -1
  113. package/src/Defaults/index.ts +0 -149
  114. package/src/Signal/Group/ciphertext-message.ts +0 -9
  115. package/src/Signal/Group/group-session-builder.ts +0 -56
  116. package/src/Signal/Group/group_cipher.ts +0 -117
  117. package/src/Signal/Group/index.ts +0 -11
  118. package/src/Signal/Group/keyhelper.ts +0 -28
  119. package/src/Signal/Group/sender-chain-key.ts +0 -34
  120. package/src/Signal/Group/sender-key-distribution-message.ts +0 -95
  121. package/src/Signal/Group/sender-key-message.ts +0 -96
  122. package/src/Signal/Group/sender-key-name.ts +0 -66
  123. package/src/Signal/Group/sender-key-record.ts +0 -69
  124. package/src/Signal/Group/sender-key-state.ts +0 -134
  125. package/src/Signal/Group/sender-message-key.ts +0 -36
  126. package/src/Signal/libsignal.ts +0 -521
  127. package/src/Signal/lid-mapping.ts +0 -328
  128. package/src/Socket/Client/index.ts +0 -2
  129. package/src/Socket/Client/types.ts +0 -22
  130. package/src/Socket/Client/websocket.ts +0 -63
  131. package/src/Socket/business.ts +0 -424
  132. package/src/Socket/chats.ts +0 -1272
  133. package/src/Socket/communities.ts +0 -477
  134. package/src/Socket/groups.ts +0 -361
  135. package/src/Socket/index.ts +0 -15
  136. package/src/Socket/messages-recv.ts +0 -1668
  137. package/src/Socket/messages-send.ts +0 -1296
  138. package/src/Socket/mex.ts +0 -58
  139. package/src/Socket/newsletter.ts +0 -229
  140. package/src/Socket/socket.ts +0 -1184
  141. package/src/Types/Auth.ts +0 -116
  142. package/src/Types/Bussines.ts +0 -20
  143. package/src/Types/Call.ts +0 -15
  144. package/src/Types/Chat.ts +0 -138
  145. package/src/Types/Contact.ts +0 -24
  146. package/src/Types/Events.ts +0 -159
  147. package/src/Types/GroupMetadata.ts +0 -70
  148. package/src/Types/Label.ts +0 -48
  149. package/src/Types/LabelAssociation.ts +0 -35
  150. package/src/Types/Message.ts +0 -380
  151. package/src/Types/Newsletter.ts +0 -98
  152. package/src/Types/Product.ts +0 -85
  153. package/src/Types/Signal.ts +0 -76
  154. package/src/Types/Socket.ts +0 -150
  155. package/src/Types/State.ts +0 -43
  156. package/src/Types/USync.ts +0 -27
  157. package/src/Types/globals.d.ts +0 -8
  158. package/src/Types/index.ts +0 -67
  159. package/src/Utils/auth-utils.ts +0 -368
  160. package/src/Utils/browser-utils.ts +0 -31
  161. package/src/Utils/business.ts +0 -286
  162. package/src/Utils/chat-utils.ts +0 -974
  163. package/src/Utils/crypto.ts +0 -147
  164. package/src/Utils/decode-wa-message.ts +0 -355
  165. package/src/Utils/event-buffer.ts +0 -692
  166. package/src/Utils/generics.ts +0 -474
  167. package/src/Utils/history.ts +0 -161
  168. package/src/Utils/identity-change-handler.ts +0 -83
  169. package/src/Utils/index.ts +0 -19
  170. package/src/Utils/link-preview.ts +0 -111
  171. package/src/Utils/logger.ts +0 -13
  172. package/src/Utils/lt-hash.ts +0 -8
  173. package/src/Utils/make-mutex.ts +0 -42
  174. package/src/Utils/message-retry-manager.ts +0 -295
  175. package/src/Utils/messages-media.ts +0 -984
  176. package/src/Utils/messages.ts +0 -1097
  177. package/src/Utils/noise-handler.ts +0 -268
  178. package/src/Utils/pre-key-manager.ts +0 -126
  179. package/src/Utils/process-message.ts +0 -670
  180. package/src/Utils/reporting-utils.ts +0 -344
  181. package/src/Utils/signal.ts +0 -214
  182. package/src/Utils/sync-action-utils.ts +0 -74
  183. package/src/Utils/tc-token-utils.ts +0 -34
  184. package/src/Utils/use-multi-file-auth-state.ts +0 -136
  185. package/src/Utils/validate-connection.ts +0 -253
  186. package/src/WABinary/constants.ts +0 -1305
  187. package/src/WABinary/decode.ts +0 -308
  188. package/src/WABinary/encode.ts +0 -258
  189. package/src/WABinary/generic-utils.ts +0 -141
  190. package/src/WABinary/index.ts +0 -5
  191. package/src/WABinary/jid-utils.ts +0 -128
  192. package/src/WABinary/types.ts +0 -17
  193. package/src/WAM/BinaryInfo.ts +0 -12
  194. package/src/WAM/constants.ts +0 -22889
  195. package/src/WAM/encode.ts +0 -169
  196. package/src/WAM/index.ts +0 -3
  197. package/src/WAUSync/Protocols/USyncContactProtocol.ts +0 -32
  198. package/src/WAUSync/Protocols/USyncDeviceProtocol.ts +0 -78
  199. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.ts +0 -35
  200. package/src/WAUSync/Protocols/USyncStatusProtocol.ts +0 -44
  201. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.ts +0 -76
  202. package/src/WAUSync/Protocols/UsyncLIDProtocol.ts +0 -33
  203. package/src/WAUSync/Protocols/index.ts +0 -4
  204. package/src/WAUSync/USyncQuery.ts +0 -133
  205. package/src/WAUSync/USyncUser.ts +0 -32
  206. package/src/WAUSync/index.ts +0 -3
  207. package/src/__tests__/Signal/Group/sender-key-state-regression.test.ts +0 -22
  208. package/src/__tests__/Signal/lid-mapping.test.ts +0 -47
  209. package/src/__tests__/Socket/identity-change-handling.test.ts +0 -207
  210. package/src/__tests__/TestUtils/session.ts +0 -47
  211. package/src/__tests__/Utils/generics.test.ts +0 -70
  212. package/src/__tests__/Utils/history.test.ts +0 -362
  213. package/src/__tests__/Utils/messages-media.test.ts +0 -405
  214. package/src/__tests__/Utils/noise-handler.test.ts +0 -339
  215. package/src/__tests__/Utils/process-message.test.ts +0 -138
  216. package/src/__tests__/Utils/process-sync-action.test.ts +0 -359
  217. package/src/__tests__/Utils/reporting-utils.test.ts +0 -160
  218. package/src/__tests__/Utils/signal.test.ts +0 -69
  219. package/src/__tests__/Utils/sync-action-utils.test.ts +0 -183
  220. package/src/__tests__/binary/connection-deadlock.test.ts +0 -54
  221. package/src/__tests__/e2e/fetch-wa-web-version.test-e2e.ts +0 -60
  222. package/src/__tests__/e2e/send-receive-message.test-e2e.ts +0 -644
  223. package/src/__tests__/proto-tojson-long.test.ts +0 -31
  224. package/src/index.ts +0 -13
package/src/Types/Auth.ts DELETED
@@ -1,116 +0,0 @@
1
- import type { proto } from '../../WAProto/index.js'
2
- import type { Contact } from './Contact'
3
- import type { MinimalMessage } from './Message'
4
-
5
- export type KeyPair = { public: Uint8Array; private: Uint8Array }
6
- export type SignedKeyPair = {
7
- keyPair: KeyPair
8
- signature: Uint8Array
9
- keyId: number
10
- timestampS?: number
11
- }
12
-
13
- export type ProtocolAddress = {
14
- name: string // jid
15
- deviceId: number
16
- }
17
- export type SignalIdentity = {
18
- identifier: ProtocolAddress
19
- identifierKey: Uint8Array
20
- }
21
-
22
- export type LIDMapping = {
23
- pn: string
24
- lid: string
25
- }
26
-
27
- export type LTHashState = {
28
- version: number
29
- hash: Buffer
30
- indexValueMap: {
31
- [indexMacBase64: string]: { valueMac: Uint8Array | Buffer }
32
- }
33
- }
34
-
35
- export type SignalCreds = {
36
- readonly signedIdentityKey: KeyPair
37
- readonly signedPreKey: SignedKeyPair
38
- readonly registrationId: number
39
- }
40
-
41
- export type AccountSettings = {
42
- /** unarchive chats when a new message is received */
43
- unarchiveChats: boolean
44
- /** the default mode to start new conversations with */
45
- defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>
46
- }
47
-
48
- export type AuthenticationCreds = SignalCreds & {
49
- readonly noiseKey: KeyPair
50
- readonly pairingEphemeralKeyPair: KeyPair
51
- advSecretKey: string
52
-
53
- me?: Contact
54
- account?: proto.IADVSignedDeviceIdentity
55
- signalIdentities?: SignalIdentity[]
56
- myAppStateKeyId?: string
57
- firstUnuploadedPreKeyId: number
58
- nextPreKeyId: number
59
-
60
- lastAccountSyncTimestamp?: number
61
- platform?: string
62
-
63
- processedHistoryMessages: MinimalMessage[]
64
- /** number of times history & app state has been synced */
65
- accountSyncCounter: number
66
- accountSettings: AccountSettings
67
- registered: boolean
68
- pairingCode: string | undefined
69
- lastPropHash: string | undefined
70
- routingInfo: Buffer | undefined
71
- additionalData?: any | undefined
72
- }
73
-
74
- export type SignalDataTypeMap = {
75
- 'pre-key': KeyPair
76
- session: Uint8Array
77
- 'sender-key': Uint8Array
78
- 'sender-key-memory': { [jid: string]: boolean }
79
- 'app-state-sync-key': proto.Message.IAppStateSyncKeyData
80
- 'app-state-sync-version': LTHashState
81
- 'lid-mapping': string
82
- 'device-list': string[]
83
- tctoken: { token: Buffer; timestamp?: string }
84
- 'identity-key': Uint8Array
85
- }
86
-
87
- export type SignalDataSet = { [T in keyof SignalDataTypeMap]?: { [id: string]: SignalDataTypeMap[T] | null } }
88
-
89
- type Awaitable<T> = T | Promise<T>
90
-
91
- export type SignalKeyStore = {
92
- get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{ [id: string]: SignalDataTypeMap[T] }>
93
- set(data: SignalDataSet): Awaitable<void>
94
- /** clear all the data in the store */
95
- clear?(): Awaitable<void>
96
- }
97
-
98
- export type SignalKeyStoreWithTransaction = SignalKeyStore & {
99
- isInTransaction: () => boolean
100
- transaction<T>(exec: () => Promise<T>, key: string): Promise<T>
101
- }
102
-
103
- export type TransactionCapabilityOptions = {
104
- maxCommitRetries: number
105
- delayBetweenTriesMs: number
106
- }
107
-
108
- export type SignalAuthState = {
109
- creds: SignalCreds
110
- keys: SignalKeyStore | SignalKeyStoreWithTransaction
111
- }
112
-
113
- export type AuthenticationState = {
114
- creds: AuthenticationCreds
115
- keys: SignalKeyStore
116
- }
@@ -1,20 +0,0 @@
1
- import type { proto } from '../../WAProto'
2
-
3
- export type DayOfWeekBussines = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'
4
-
5
- export type HoursDay =
6
- | { day: DayOfWeekBussines; mode: 'specific_hours'; openTimeInMinutes: string; closeTimeInMinutes: string }
7
- | { day: DayOfWeekBussines; mode: 'open_24h' | 'appointment_only' }
8
-
9
- export type UpdateBussinesProfileProps = {
10
- address?: string
11
- websites?: string[]
12
- email?: string
13
- description?: string
14
- hours?: {
15
- timezone: string
16
- days: HoursDay[]
17
- }
18
- }
19
-
20
- export type QuickReplyAction = proto.SyncActionValue.IQuickReplyAction & { timestamp?: string }
package/src/Types/Call.ts DELETED
@@ -1,15 +0,0 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate'
2
-
3
- export type WACallEvent = {
4
- chatId: string
5
- from: string
6
- callerPn?: string
7
- isGroup?: boolean
8
- groupJid?: string
9
- id: string
10
- date: Date
11
- isVideo?: boolean
12
- status: WACallUpdateType
13
- offline: boolean
14
- latencyMs?: number
15
- }
package/src/Types/Chat.ts DELETED
@@ -1,138 +0,0 @@
1
- import type { proto } from '../../WAProto/index.js'
2
- import type { AccountSettings } from './Auth'
3
- import type { QuickReplyAction } from './Bussines.js'
4
- import type { BufferedEventData } from './Events'
5
- import type { LabelActionBody } from './Label'
6
- import type { ChatLabelAssociationActionBody } from './LabelAssociation'
7
- import type { MessageLabelAssociationActionBody } from './LabelAssociation'
8
- import type { MinimalMessage, WAMessageKey } from './Message'
9
-
10
- /** privacy settings in WhatsApp Web */
11
- export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none'
12
-
13
- export type WAPrivacyOnlineValue = 'all' | 'match_last_seen'
14
-
15
- export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist'
16
-
17
- export type WAReadReceiptsValue = 'all' | 'none'
18
-
19
- export type WAPrivacyCallValue = 'all' | 'known'
20
-
21
- export type WAPrivacyMessagesValue = 'all' | 'contacts'
22
-
23
- /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
24
- export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
25
-
26
- export const ALL_WA_PATCH_NAMES = [
27
- 'critical_block',
28
- 'critical_unblock_low',
29
- 'regular_high',
30
- 'regular_low',
31
- 'regular'
32
- ] as const
33
-
34
- export type WAPatchName = (typeof ALL_WA_PATCH_NAMES)[number]
35
-
36
- export interface PresenceData {
37
- lastKnownPresence: WAPresence
38
- lastSeen?: number
39
- }
40
-
41
- export type BotListInfo = {
42
- jid: string
43
- personaId: string
44
- }
45
-
46
- export type ChatMutation = {
47
- syncAction: proto.ISyncActionData
48
- index: string[]
49
- }
50
-
51
- export type WAPatchCreate = {
52
- syncAction: proto.ISyncActionValue
53
- index: string[]
54
- type: WAPatchName
55
- apiVersion: number
56
- operation: proto.SyncdMutation.SyncdOperation
57
- }
58
-
59
- export type Chat = proto.IConversation & {
60
- /** unix timestamp of when the last message was received in the chat */
61
- lastMessageRecvTimestamp?: number
62
- }
63
-
64
- export type ChatUpdate = Partial<
65
- Chat & {
66
- /**
67
- * if specified in the update,
68
- * the EV buffer will check if the condition gets fulfilled before applying the update
69
- * Right now, used to determine when to release an app state sync event
70
- *
71
- * @returns true, if the update should be applied;
72
- * false if it can be discarded;
73
- * undefined if the condition is not yet fulfilled
74
- * */
75
- conditional: (bufferedData: BufferedEventData) => boolean | undefined
76
- /** last update time */
77
- timestamp?: number
78
- }
79
- >
80
-
81
- /**
82
- * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
83
- * for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
84
- * */
85
- export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange
86
-
87
- export type ChatModification =
88
- | {
89
- archive: boolean
90
- lastMessages: LastMessageList
91
- }
92
- | { pushNameSetting: string }
93
- | { pin: boolean }
94
- | {
95
- /** mute for duration, or provide timestamp of mute to remove*/
96
- mute: number | null
97
- }
98
- | {
99
- clear: boolean
100
- lastMessages: LastMessageList
101
- }
102
- | {
103
- deleteForMe: { deleteMedia: boolean; key: WAMessageKey; timestamp: number }
104
- }
105
- | {
106
- star: {
107
- messages: { id: string; fromMe?: boolean }[]
108
- star: boolean
109
- }
110
- }
111
- | {
112
- markRead: boolean
113
- lastMessages: LastMessageList
114
- }
115
- | { delete: true; lastMessages: LastMessageList }
116
- | { contact: proto.SyncActionValue.IContactAction | null }
117
- | { disableLinkPreviews: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction }
118
- // Label
119
- | { addLabel: LabelActionBody }
120
- // Label assosiation
121
- | { addChatLabel: ChatLabelAssociationActionBody }
122
- | { removeChatLabel: ChatLabelAssociationActionBody }
123
- | { addMessageLabel: MessageLabelAssociationActionBody }
124
- | { removeMessageLabel: MessageLabelAssociationActionBody }
125
- | { quickReply: QuickReplyAction }
126
-
127
- export type InitialReceivedChatsState = {
128
- [jid: string]: {
129
- /** the last message received from the other party */
130
- lastMsgRecvTimestamp?: number
131
- /** the absolute last message in the chat */
132
- lastMsgTimestamp: number
133
- }
134
- }
135
-
136
- export type InitialAppStateSyncOptions = {
137
- accountSettings: AccountSettings
138
- }
@@ -1,24 +0,0 @@
1
- export interface Contact {
2
- /** ID either in lid or jid format (preferred) **/
3
- id: string
4
- /** ID in LID format (@lid) **/
5
- lid?: string
6
- /** ID in PN format (@s.whatsapp.net) **/
7
- phoneNumber?: string
8
- /** name of the contact, you have saved on your WA */
9
- name?: string
10
- /** name of the contact, the contact has set on their own on WA */
11
- notify?: string
12
- /** I have no idea */
13
- verifiedName?: string
14
- // Baileys Added
15
- /**
16
- * Url of the profile picture of the contact
17
- *
18
- * 'changed' => if the profile picture has changed
19
- * null => if the profile picture has not been set (default profile picture)
20
- * any other string => url of the profile picture
21
- */
22
- imgUrl?: string | null
23
- status?: string
24
- }
@@ -1,159 +0,0 @@
1
- import type { Boom } from '@hapi/boom'
2
- import { proto } from '../../WAProto/index.js'
3
- import type { AuthenticationCreds, LIDMapping } from './Auth'
4
- import type { WACallEvent } from './Call'
5
- import type { Chat, ChatUpdate, PresenceData } from './Chat'
6
- import type { Contact } from './Contact'
7
- import type {
8
- GroupMetadata,
9
- GroupParticipant,
10
- ParticipantAction,
11
- RequestJoinAction,
12
- RequestJoinMethod
13
- } from './GroupMetadata'
14
- import type { Label } from './Label'
15
- import type { LabelAssociation } from './LabelAssociation'
16
- import type { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message'
17
- import type { ConnectionState } from './State'
18
-
19
- // TODO: refactor this mess
20
- export type BaileysEventMap = {
21
- /** connection state has been updated -- WS closed, opened, connecting etc. */
22
- 'connection.update': Partial<ConnectionState>
23
- /** credentials updated -- some metadata, keys or something */
24
- 'creds.update': Partial<AuthenticationCreds>
25
- /** set chats (history sync), everything is reverse chronologically sorted */
26
- 'messaging-history.set': {
27
- chats: Chat[]
28
- contacts: Contact[]
29
- messages: WAMessage[]
30
- lidPnMappings?: LIDMapping[]
31
- isLatest?: boolean
32
- progress?: number | null
33
- syncType?: proto.HistorySync.HistorySyncType | null
34
- peerDataRequestSessionId?: string | null
35
- }
36
- /** upsert chats */
37
- 'chats.upsert': Chat[]
38
- /** update the given chats */
39
- 'chats.update': ChatUpdate[]
40
- 'lid-mapping.update': LIDMapping
41
- /** delete chats with given ID */
42
- 'chats.delete': string[]
43
- /** presence of contact in a chat updated */
44
- 'presence.update': { id: string; presences: { [participant: string]: PresenceData } }
45
-
46
- 'contacts.upsert': Contact[]
47
- 'contacts.update': Partial<Contact>[]
48
-
49
- 'messages.delete': { keys: WAMessageKey[] } | { jid: string; all: true }
50
- 'messages.update': WAMessageUpdate[]
51
- 'messages.media-update': { key: WAMessageKey; media?: { ciphertext: Uint8Array; iv: Uint8Array }; error?: Boom }[]
52
- /**
53
- * add/update the given messages. If they were received while the connection was online,
54
- * the update will have type: "notify"
55
- * if requestId is provided, then the messages was received from the phone due to it being unavailable
56
- * */
57
- 'messages.upsert': { messages: WAMessage[]; type: MessageUpsertType; requestId?: string }
58
- /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
59
- 'messages.reaction': { key: WAMessageKey; reaction: proto.IReaction }[]
60
-
61
- 'message-receipt.update': MessageUserReceiptUpdate[]
62
-
63
- 'groups.upsert': GroupMetadata[]
64
- 'groups.update': Partial<GroupMetadata>[]
65
- /** apply an action to participants in a group */
66
- 'group-participants.update': {
67
- id: string
68
- author: string
69
- authorPn?: string
70
- participants: GroupParticipant[]
71
- action: ParticipantAction
72
- }
73
- 'group.join-request': {
74
- id: string
75
- author: string
76
- authorPn?: string
77
- participant: string
78
- participantPn?: string
79
- action: RequestJoinAction
80
- method: RequestJoinMethod
81
- }
82
- /* update the labels assigned to a group participant */
83
- 'group.member-tag.update': {
84
- groupId: string
85
- participant: string
86
- participantAlt?: string
87
- label: string
88
- messageTimestamp?: number
89
- }
90
-
91
- 'blocklist.set': { blocklist: string[] }
92
- 'blocklist.update': { blocklist: string[]; type: 'add' | 'remove' }
93
-
94
- /** Receive an update on a call, including when the call was received, rejected, accepted */
95
- call: WACallEvent[]
96
- 'labels.edit': Label
97
- 'labels.association': { association: LabelAssociation; type: 'add' | 'remove' }
98
-
99
- /** Newsletter-related events */
100
- 'newsletter.reaction': {
101
- id: string
102
- server_id: string
103
- reaction: { code?: string; count?: number; removed?: boolean }
104
- }
105
- 'newsletter.view': { id: string; server_id: string; count: number }
106
- 'newsletter-participants.update': { id: string; author: string; user: string; new_role: string; action: string }
107
- 'newsletter-settings.update': { id: string; update: any }
108
-
109
- /** Settings and actions sync events */
110
- 'chats.lock': { id: string; locked: boolean }
111
- 'settings.update':
112
- | { setting: 'unarchiveChats'; value: boolean }
113
- | { setting: 'locale'; value: string }
114
- | { setting: 'disableLinkPreviews'; value: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction }
115
- | { setting: 'timeFormat'; value: proto.SyncActionValue.ITimeFormatAction }
116
- | { setting: 'privacySettingRelayAllCalls'; value: proto.SyncActionValue.IPrivacySettingRelayAllCalls }
117
- | { setting: 'statusPrivacy'; value: proto.SyncActionValue.IStatusPrivacyAction }
118
- | {
119
- setting: 'notificationActivitySetting'
120
- value: proto.SyncActionValue.NotificationActivitySettingAction.NotificationActivitySetting
121
- }
122
- | {
123
- setting: 'channelsPersonalisedRecommendation'
124
- value: proto.SyncActionValue.IPrivacySettingChannelsPersonalisedRecommendationAction
125
- }
126
- }
127
-
128
- export type BufferedEventData = {
129
- historySets: {
130
- chats: { [jid: string]: Chat }
131
- contacts: { [jid: string]: Contact }
132
- messages: { [uqId: string]: WAMessage }
133
- empty: boolean
134
- isLatest: boolean
135
- progress?: number | null
136
- syncType?: proto.HistorySync.HistorySyncType
137
- peerDataRequestSessionId?: string
138
- }
139
- chatUpserts: { [jid: string]: Chat }
140
- chatUpdates: { [jid: string]: ChatUpdate }
141
- chatDeletes: Set<string>
142
- contactUpserts: { [jid: string]: Contact }
143
- contactUpdates: { [jid: string]: Partial<Contact> }
144
- messageUpserts: { [key: string]: { type: MessageUpsertType; message: WAMessage } }
145
- messageUpdates: { [key: string]: WAMessageUpdate }
146
- messageDeletes: { [key: string]: WAMessageKey }
147
- messageReactions: { [key: string]: { key: WAMessageKey; reactions: proto.IReaction[] } }
148
- messageReceipts: { [key: string]: { key: WAMessageKey; userReceipt: proto.IUserReceipt[] } }
149
- groupUpdates: { [jid: string]: Partial<GroupMetadata> }
150
- }
151
-
152
- export type BaileysEvent = keyof BaileysEventMap
153
-
154
- export interface BaileysEventEmitter {
155
- on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
156
- off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
157
- removeAllListeners<T extends keyof BaileysEventMap>(event: T): void
158
- emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean
159
- }
@@ -1,70 +0,0 @@
1
- import type { Contact } from './Contact'
2
- import type { WAMessageAddressingMode } from './Message'
3
-
4
- export type GroupParticipant = Contact & {
5
- isAdmin?: boolean
6
- isSuperAdmin?: boolean
7
- admin?: 'admin' | 'superadmin' | null
8
- }
9
-
10
- export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify'
11
-
12
- export type RequestJoinAction = 'created' | 'revoked' | 'rejected'
13
-
14
- export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined
15
-
16
- export interface GroupMetadata {
17
- id: string
18
- notify?: string
19
- /** group uses 'lid' or 'pn' to send messages */
20
- addressingMode?: WAMessageAddressingMode
21
- owner: string | undefined
22
- ownerPn?: string | undefined
23
- owner_country_code?: string | undefined
24
- subject: string
25
- /** group subject owner */
26
- subjectOwner?: string
27
- subjectOwnerPn?: string
28
- /** group subject modification date */
29
- subjectTime?: number
30
- creation?: number
31
- desc?: string
32
- descOwner?: string
33
- descOwnerPn?: string
34
- descId?: string
35
- descTime?: number
36
- /** if this group is part of a community, it returns the jid of the community to which it belongs */
37
- linkedParent?: string
38
- /** is set when the group only allows admins to change group settings */
39
- restrict?: boolean
40
- /** is set when the group only allows admins to write messages */
41
- announce?: boolean
42
- /** is set when the group also allows members to add participants */
43
- memberAddMode?: boolean
44
- /** Request approval to join the group */
45
- joinApprovalMode?: boolean
46
- /** is this a community */
47
- isCommunity?: boolean
48
- /** is this the announce of a community */
49
- isCommunityAnnounce?: boolean
50
- /** number of group participants */
51
- size?: number
52
- // Baileys modified array
53
- participants: GroupParticipant[]
54
- ephemeralDuration?: number
55
- inviteCode?: string
56
- /** the person who added you to group or changed some setting in group */
57
- author?: string
58
- authorPn?: string
59
- }
60
-
61
- export interface WAGroupCreateResponse {
62
- status: number
63
- gid?: string
64
- participants?: [{ [key: string]: {} }]
65
- }
66
-
67
- export interface GroupModificationResponse {
68
- status: number
69
- participants?: { [key: string]: {} }
70
- }
@@ -1,48 +0,0 @@
1
- export interface Label {
2
- /** Label uniq ID */
3
- id: string
4
- /** Label name */
5
- name: string
6
- /** Label color ID */
7
- color: number
8
- /** Is label has been deleted */
9
- deleted: boolean
10
- /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
11
- predefinedId?: string
12
- }
13
-
14
- export interface LabelActionBody {
15
- id: string
16
- /** Label name */
17
- name?: string
18
- /** Label color ID */
19
- color?: number
20
- /** Is label has been deleted */
21
- deleted?: boolean
22
- /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
23
- predefinedId?: number
24
- }
25
-
26
- /** WhatsApp has 20 predefined colors */
27
- export enum LabelColor {
28
- Color1 = 0,
29
- Color2,
30
- Color3,
31
- Color4,
32
- Color5,
33
- Color6,
34
- Color7,
35
- Color8,
36
- Color9,
37
- Color10,
38
- Color11,
39
- Color12,
40
- Color13,
41
- Color14,
42
- Color15,
43
- Color16,
44
- Color17,
45
- Color18,
46
- Color19,
47
- Color20
48
- }
@@ -1,35 +0,0 @@
1
- /** Association type */
2
- export enum LabelAssociationType {
3
- Chat = 'label_jid',
4
- Message = 'label_message'
5
- }
6
-
7
- export type LabelAssociationTypes = `${LabelAssociationType}`
8
-
9
- /** Association for chat */
10
- export interface ChatLabelAssociation {
11
- type: LabelAssociationType.Chat
12
- chatId: string
13
- labelId: string
14
- }
15
-
16
- /** Association for message */
17
- export interface MessageLabelAssociation {
18
- type: LabelAssociationType.Message
19
- chatId: string
20
- messageId: string
21
- labelId: string
22
- }
23
-
24
- export type LabelAssociation = ChatLabelAssociation | MessageLabelAssociation
25
-
26
- /** Body for add/remove chat label association action */
27
- export interface ChatLabelAssociationActionBody {
28
- labelId: string
29
- }
30
-
31
- /** body for add/remove message label association action */
32
- export interface MessageLabelAssociationActionBody {
33
- labelId: string
34
- messageId: string
35
- }