@sixcore/baileys 1.0.0 → 1.0.1

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 (228) hide show
  1. package/WAProto/index.js +14270 -302
  2. package/jessica.js +91 -0
  3. package/lib/Defaults/baileys-version.json +1 -1
  4. package/lib/Defaults/index.js +117 -79
  5. package/lib/Defaults/phonenumber-mcc.json +223 -0
  6. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  7. package/lib/Signal/Group/ciphertext-message.js +15 -0
  8. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  9. package/lib/Signal/Group/group-session-builder.js +64 -0
  10. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  11. package/lib/Signal/Group/group_cipher.js +96 -0
  12. package/lib/Signal/Group/index.d.ts +11 -0
  13. package/lib/Signal/Group/index.js +57 -0
  14. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  15. package/lib/Signal/Group/keyhelper.js +55 -0
  16. package/lib/Signal/Group/queue-job.d.ts +1 -0
  17. package/lib/Signal/Group/queue-job.js +57 -0
  18. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  19. package/lib/Signal/Group/sender-chain-key.js +34 -0
  20. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  22. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  23. package/lib/Signal/Group/sender-key-message.js +69 -0
  24. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  25. package/lib/Signal/Group/sender-key-name.js +51 -0
  26. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  27. package/lib/Signal/Group/sender-key-record.js +53 -0
  28. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  29. package/lib/Signal/Group/sender-key-state.js +99 -0
  30. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  31. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
  32. package/lib/Signal/libsignal.js +51 -29
  33. package/lib/Socket/business.d.ts +43 -42
  34. package/lib/Socket/chats.d.ts +222 -36
  35. package/lib/Socket/chats.js +173 -153
  36. package/lib/Socket/dugong.d.ts +254 -0
  37. package/lib/Socket/dugong.js +484 -0
  38. package/lib/Socket/groups.d.ts +7 -7
  39. package/lib/Socket/groups.js +37 -35
  40. package/lib/Socket/index.d.ts +52 -51
  41. package/lib/Socket/index.js +1 -0
  42. package/lib/Socket/messages-recv.d.ts +37 -34
  43. package/lib/Socket/messages-recv.js +175 -37
  44. package/lib/Socket/messages-send.d.ts +12 -18
  45. package/lib/Socket/messages-send.js +396 -574
  46. package/lib/Socket/newsletter.d.ts +28 -26
  47. package/lib/Socket/newsletter.js +123 -25
  48. package/lib/Socket/registration.d.ts +52 -49
  49. package/lib/Socket/registration.js +7 -7
  50. package/lib/Socket/socket.d.ts +0 -1
  51. package/lib/Socket/socket.js +49 -27
  52. package/lib/Socket/usync.d.ts +10 -11
  53. package/lib/Store/make-cache-manager-store.d.ts +1 -2
  54. package/lib/Store/make-in-memory-store.d.ts +2 -2
  55. package/lib/Store/make-in-memory-store.js +1 -5
  56. package/lib/Store/make-ordered-dictionary.js +2 -2
  57. package/lib/Types/Auth.d.ts +1 -0
  58. package/lib/Types/Call.d.ts +1 -1
  59. package/lib/Types/Chat.d.ts +7 -12
  60. package/lib/Types/Events.d.ts +2 -17
  61. package/lib/Types/GroupMetadata.d.ts +2 -3
  62. package/lib/Types/Label.d.ts +0 -11
  63. package/lib/Types/Label.js +1 -1
  64. package/lib/Types/LabelAssociation.js +1 -1
  65. package/lib/Types/Message.d.ts +10 -170
  66. package/lib/Types/Newsletter.d.ts +97 -86
  67. package/lib/Types/Newsletter.js +38 -32
  68. package/lib/Types/Socket.d.ts +2 -7
  69. package/lib/Types/index.d.ts +0 -9
  70. package/lib/Types/index.js +1 -1
  71. package/lib/Utils/auth-utils.js +14 -35
  72. package/lib/Utils/business.d.ts +1 -1
  73. package/lib/Utils/business.js +2 -2
  74. package/lib/Utils/chat-utils.d.ts +12 -11
  75. package/lib/Utils/chat-utils.js +36 -52
  76. package/lib/Utils/crypto.d.ts +16 -15
  77. package/lib/Utils/crypto.js +26 -74
  78. package/lib/Utils/decode-wa-message.d.ts +0 -17
  79. package/lib/Utils/decode-wa-message.js +17 -53
  80. package/lib/Utils/event-buffer.js +7 -10
  81. package/lib/Utils/generics.d.ts +17 -13
  82. package/lib/Utils/generics.js +79 -58
  83. package/lib/Utils/history.d.ts +2 -6
  84. package/lib/Utils/history.js +6 -4
  85. package/lib/Utils/logger.d.ts +3 -1
  86. package/lib/Utils/lt-hash.js +12 -12
  87. package/lib/Utils/make-mutex.d.ts +2 -2
  88. package/lib/Utils/messages-media.d.ts +28 -25
  89. package/lib/Utils/messages-media.js +733 -557
  90. package/lib/Utils/messages.js +68 -473
  91. package/lib/Utils/noise-handler.d.ts +5 -4
  92. package/lib/Utils/noise-handler.js +14 -19
  93. package/lib/Utils/process-message.d.ts +5 -5
  94. package/lib/Utils/process-message.js +23 -75
  95. package/lib/Utils/signal.d.ts +1 -2
  96. package/lib/Utils/signal.js +26 -32
  97. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  98. package/lib/Utils/use-multi-file-auth-state.js +66 -242
  99. package/lib/Utils/validate-connection.d.ts +1 -1
  100. package/lib/Utils/validate-connection.js +88 -64
  101. package/lib/WABinary/constants.d.ts +27 -24
  102. package/lib/WABinary/decode.d.ts +2 -1
  103. package/lib/WABinary/decode.js +11 -23
  104. package/lib/WABinary/encode.d.ts +2 -1
  105. package/lib/WABinary/encode.js +147 -134
  106. package/lib/WABinary/generic-utils.d.ts +5 -2
  107. package/lib/WABinary/generic-utils.js +125 -37
  108. package/lib/WABinary/jid-utils.d.ts +1 -1
  109. package/lib/WAM/BinaryInfo.d.ts +11 -2
  110. package/lib/WAM/encode.d.ts +2 -1
  111. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
  112. package/lib/WAUSync/USyncUser.d.ts +2 -0
  113. package/lib/index.d.ts +12 -0
  114. package/lib/index.js +64 -1
  115. package/package.json +113 -51
  116. package/WAProto/GenerateStatics.sh +0 -4
  117. package/WAProto/WAProto.proto +0 -4357
  118. package/WAProto/index.d.ts +0 -50383
  119. package/WASignalGroup/GroupProtocol.js +0 -1697
  120. package/WASignalGroup/ciphertext_message.js +0 -16
  121. package/WASignalGroup/generate-proto.sh +0 -1
  122. package/WASignalGroup/group.proto +0 -42
  123. package/WASignalGroup/group_cipher.js +0 -120
  124. package/WASignalGroup/group_session_builder.js +0 -46
  125. package/WASignalGroup/index.js +0 -5
  126. package/WASignalGroup/keyhelper.js +0 -21
  127. package/WASignalGroup/protobufs.js +0 -3
  128. package/WASignalGroup/queue_job.js +0 -69
  129. package/WASignalGroup/sender_chain_key.js +0 -50
  130. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  131. package/WASignalGroup/sender_key_message.js +0 -92
  132. package/WASignalGroup/sender_key_name.js +0 -70
  133. package/WASignalGroup/sender_key_record.js +0 -56
  134. package/WASignalGroup/sender_key_state.js +0 -129
  135. package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
  136. package/lib/Utils/use-single-file-auth-state.js +0 -75
  137. package/src/Defaults/baileys-version.json +0 -3
  138. package/src/Defaults/index.ts +0 -133
  139. package/src/Signal/Group/ciphertext-message.ts +0 -9
  140. package/src/Signal/Group/group-session-builder.ts +0 -56
  141. package/src/Signal/Group/group_cipher.ts +0 -117
  142. package/src/Signal/Group/index.ts +0 -11
  143. package/src/Signal/Group/keyhelper.ts +0 -28
  144. package/src/Signal/Group/sender-chain-key.ts +0 -34
  145. package/src/Signal/Group/sender-key-distribution-message.ts +0 -95
  146. package/src/Signal/Group/sender-key-message.ts +0 -96
  147. package/src/Signal/Group/sender-key-name.ts +0 -66
  148. package/src/Signal/Group/sender-key-record.ts +0 -69
  149. package/src/Signal/Group/sender-key-state.ts +0 -134
  150. package/src/Signal/Group/sender-message-key.ts +0 -36
  151. package/src/Signal/libsignal.ts +0 -447
  152. package/src/Signal/lid-mapping.ts +0 -209
  153. package/src/Socket/Client/index.ts +0 -2
  154. package/src/Socket/Client/types.ts +0 -22
  155. package/src/Socket/Client/websocket.ts +0 -56
  156. package/src/Socket/business.ts +0 -421
  157. package/src/Socket/chats.ts +0 -1223
  158. package/src/Socket/communities.ts +0 -477
  159. package/src/Socket/groups.ts +0 -361
  160. package/src/Socket/index.ts +0 -22
  161. package/src/Socket/messages-recv.ts +0 -1563
  162. package/src/Socket/messages-send.ts +0 -1210
  163. package/src/Socket/mex.ts +0 -58
  164. package/src/Socket/newsletter.ts +0 -229
  165. package/src/Socket/socket.ts +0 -1072
  166. package/src/Types/Auth.ts +0 -115
  167. package/src/Types/Bussines.ts +0 -20
  168. package/src/Types/Call.ts +0 -14
  169. package/src/Types/Chat.ts +0 -138
  170. package/src/Types/Contact.ts +0 -24
  171. package/src/Types/Events.ts +0 -132
  172. package/src/Types/GroupMetadata.ts +0 -70
  173. package/src/Types/Label.ts +0 -48
  174. package/src/Types/LabelAssociation.ts +0 -35
  175. package/src/Types/Message.ts +0 -424
  176. package/src/Types/Newsletter.ts +0 -98
  177. package/src/Types/Product.ts +0 -85
  178. package/src/Types/Signal.ts +0 -76
  179. package/src/Types/Socket.ts +0 -150
  180. package/src/Types/State.ts +0 -43
  181. package/src/Types/USync.ts +0 -27
  182. package/src/Types/globals.d.ts +0 -8
  183. package/src/Types/index.ts +0 -67
  184. package/src/Utils/auth-utils.ts +0 -331
  185. package/src/Utils/browser-utils.ts +0 -31
  186. package/src/Utils/business.ts +0 -286
  187. package/src/Utils/chat-utils.ts +0 -933
  188. package/src/Utils/crypto.ts +0 -184
  189. package/src/Utils/decode-wa-message.ts +0 -355
  190. package/src/Utils/event-buffer.ts +0 -662
  191. package/src/Utils/generics.ts +0 -470
  192. package/src/Utils/history.ts +0 -114
  193. package/src/Utils/index.ts +0 -18
  194. package/src/Utils/link-preview.ts +0 -111
  195. package/src/Utils/logger.ts +0 -13
  196. package/src/Utils/lt-hash.ts +0 -65
  197. package/src/Utils/make-mutex.ts +0 -45
  198. package/src/Utils/message-retry-manager.ts +0 -229
  199. package/src/Utils/messages-media.ts +0 -820
  200. package/src/Utils/messages.ts +0 -1137
  201. package/src/Utils/noise-handler.ts +0 -192
  202. package/src/Utils/pre-key-manager.ts +0 -126
  203. package/src/Utils/process-message.ts +0 -622
  204. package/src/Utils/signal.ts +0 -214
  205. package/src/Utils/use-multi-file-auth-state.ts +0 -136
  206. package/src/Utils/validate-connection.ts +0 -253
  207. package/src/WABinary/constants.ts +0 -1305
  208. package/src/WABinary/decode.ts +0 -281
  209. package/src/WABinary/encode.ts +0 -253
  210. package/src/WABinary/generic-utils.ts +0 -127
  211. package/src/WABinary/index.ts +0 -5
  212. package/src/WABinary/jid-utils.ts +0 -128
  213. package/src/WABinary/types.ts +0 -17
  214. package/src/WAM/BinaryInfo.ts +0 -12
  215. package/src/WAM/constants.ts +0 -22889
  216. package/src/WAM/encode.ts +0 -169
  217. package/src/WAM/index.ts +0 -3
  218. package/src/WAUSync/Protocols/USyncContactProtocol.ts +0 -32
  219. package/src/WAUSync/Protocols/USyncDeviceProtocol.ts +0 -78
  220. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.ts +0 -35
  221. package/src/WAUSync/Protocols/USyncStatusProtocol.ts +0 -44
  222. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.ts +0 -76
  223. package/src/WAUSync/Protocols/UsyncLIDProtocol.ts +0 -33
  224. package/src/WAUSync/Protocols/index.ts +0 -4
  225. package/src/WAUSync/USyncQuery.ts +0 -133
  226. package/src/WAUSync/USyncUser.ts +0 -32
  227. package/src/WAUSync/index.ts +0 -3
  228. package/src/index.ts +0 -13
package/src/Types/Auth.ts DELETED
@@ -1,115 +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
- }
85
-
86
- export type SignalDataSet = { [T in keyof SignalDataTypeMap]?: { [id: string]: SignalDataTypeMap[T] | null } }
87
-
88
- type Awaitable<T> = T | Promise<T>
89
-
90
- export type SignalKeyStore = {
91
- get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{ [id: string]: SignalDataTypeMap[T] }>
92
- set(data: SignalDataSet): Awaitable<void>
93
- /** clear all the data in the store */
94
- clear?(): Awaitable<void>
95
- }
96
-
97
- export type SignalKeyStoreWithTransaction = SignalKeyStore & {
98
- isInTransaction: () => boolean
99
- transaction<T>(exec: () => Promise<T>, key: string): Promise<T>
100
- }
101
-
102
- export type TransactionCapabilityOptions = {
103
- maxCommitRetries: number
104
- delayBetweenTriesMs: number
105
- }
106
-
107
- export type SignalAuthState = {
108
- creds: SignalCreds
109
- keys: SignalKeyStore | SignalKeyStoreWithTransaction
110
- }
111
-
112
- export type AuthenticationState = {
113
- creds: AuthenticationCreds
114
- keys: SignalKeyStore
115
- }
@@ -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,14 +0,0 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate'
2
-
3
- export type WACallEvent = {
4
- chatId: string
5
- from: string
6
- isGroup?: boolean
7
- groupJid?: string
8
- id: string
9
- date: Date
10
- isVideo?: boolean
11
- status: WACallUpdateType
12
- offline: boolean
13
- latencyMs?: number
14
- }
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,132 +0,0 @@
1
- import type { Boom } from '@hapi/boom'
2
- import { proto } from '../../WAProto/index.js'
3
- import type { AuthenticationCreds } 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
- isLatest?: boolean
31
- progress?: number | null
32
- syncType?: proto.HistorySync.HistorySyncType | null
33
- peerDataRequestSessionId?: string | null
34
- }
35
- /** upsert chats */
36
- 'chats.upsert': Chat[]
37
- /** update the given chats */
38
- 'chats.update': ChatUpdate[]
39
- 'lid-mapping.update': { lid: string; pn: string }
40
- /** delete chats with given ID */
41
- 'chats.delete': string[]
42
- /** presence of contact in a chat updated */
43
- 'presence.update': { id: string; presences: { [participant: string]: PresenceData } }
44
-
45
- 'contacts.upsert': Contact[]
46
- 'contacts.update': Partial<Contact>[]
47
-
48
- 'messages.delete': { keys: WAMessageKey[] } | { jid: string; all: true }
49
- 'messages.update': WAMessageUpdate[]
50
- 'messages.media-update': { key: WAMessageKey; media?: { ciphertext: Uint8Array; iv: Uint8Array }; error?: Boom }[]
51
- /**
52
- * add/update the given messages. If they were received while the connection was online,
53
- * the update will have type: "notify"
54
- * if requestId is provided, then the messages was received from the phone due to it being unavailable
55
- * */
56
- 'messages.upsert': { messages: WAMessage[]; type: MessageUpsertType; requestId?: string }
57
- /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
58
- 'messages.reaction': { key: WAMessageKey; reaction: proto.IReaction }[]
59
-
60
- 'message-receipt.update': MessageUserReceiptUpdate[]
61
-
62
- 'groups.upsert': GroupMetadata[]
63
- 'groups.update': Partial<GroupMetadata>[]
64
- /** apply an action to participants in a group */
65
- 'group-participants.update': {
66
- id: string
67
- author: string
68
- authorPn?: string
69
- participants: GroupParticipant[]
70
- action: ParticipantAction
71
- }
72
- 'group.join-request': {
73
- id: string
74
- author: string
75
- authorPn?: string
76
- participant: string
77
- participantPn?: string
78
- action: RequestJoinAction
79
- method: RequestJoinMethod
80
- }
81
-
82
- 'blocklist.set': { blocklist: string[] }
83
- 'blocklist.update': { blocklist: string[]; type: 'add' | 'remove' }
84
-
85
- /** Receive an update on a call, including when the call was received, rejected, accepted */
86
- call: WACallEvent[]
87
- 'labels.edit': Label
88
- 'labels.association': { association: LabelAssociation; type: 'add' | 'remove' }
89
-
90
- /** Newsletter-related events */
91
- 'newsletter.reaction': {
92
- id: string
93
- server_id: string
94
- reaction: { code?: string; count?: number; removed?: boolean }
95
- }
96
- 'newsletter.view': { id: string; server_id: string; count: number }
97
- 'newsletter-participants.update': { id: string; author: string; user: string; new_role: string; action: string }
98
- 'newsletter-settings.update': { id: string; update: any }
99
- }
100
-
101
- export type BufferedEventData = {
102
- historySets: {
103
- chats: { [jid: string]: Chat }
104
- contacts: { [jid: string]: Contact }
105
- messages: { [uqId: string]: WAMessage }
106
- empty: boolean
107
- isLatest: boolean
108
- progress?: number | null
109
- syncType?: proto.HistorySync.HistorySyncType
110
- peerDataRequestSessionId?: string
111
- }
112
- chatUpserts: { [jid: string]: Chat }
113
- chatUpdates: { [jid: string]: ChatUpdate }
114
- chatDeletes: Set<string>
115
- contactUpserts: { [jid: string]: Contact }
116
- contactUpdates: { [jid: string]: Partial<Contact> }
117
- messageUpserts: { [key: string]: { type: MessageUpsertType; message: WAMessage } }
118
- messageUpdates: { [key: string]: WAMessageUpdate }
119
- messageDeletes: { [key: string]: WAMessageKey }
120
- messageReactions: { [key: string]: { key: WAMessageKey; reactions: proto.IReaction[] } }
121
- messageReceipts: { [key: string]: { key: WAMessageKey; userReceipt: proto.IUserReceipt[] } }
122
- groupUpdates: { [jid: string]: Partial<GroupMetadata> }
123
- }
124
-
125
- export type BaileysEvent = keyof BaileysEventMap
126
-
127
- export interface BaileysEventEmitter {
128
- on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
129
- off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
130
- removeAllListeners<T extends keyof BaileysEventMap>(event: T): void
131
- emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean
132
- }
@@ -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
- }