@hansaka02/baileys 7.3.2 → 7.3.4

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 (202) hide show
  1. package/README.md +247 -203
  2. package/lib/Defaults/connection.js +51 -0
  3. package/lib/Defaults/constants.js +62 -0
  4. package/lib/Defaults/history.js +17 -0
  5. package/lib/Defaults/index.js +36 -142
  6. package/lib/Defaults/media.js +48 -0
  7. package/lib/Defaults/prefix.js +18 -0
  8. package/lib/Signal/Group/group-session-builder.js +10 -42
  9. package/lib/Signal/Group/group_cipher.js +9 -6
  10. package/lib/Signal/Group/index.js +39 -53
  11. package/lib/Signal/Group/keyhelper.js +8 -41
  12. package/lib/Signal/Group/sender-chain-key.js +4 -4
  13. package/lib/Signal/Group/sender-key-distribution-message.js +5 -5
  14. package/lib/Signal/Group/sender-key-message.js +12 -8
  15. package/lib/Signal/Group/sender-key-record.js +7 -7
  16. package/lib/Signal/Group/sender-key-state.js +4 -4
  17. package/lib/Signal/Group/sender-message-key.js +2 -2
  18. package/lib/Signal/libsignal.js +45 -69
  19. package/lib/Signal/lid-mapping.js +15 -11
  20. package/lib/Socket/Client/types.js +2 -2
  21. package/lib/Socket/Client/websocket.js +16 -14
  22. package/lib/Socket/business.js +41 -32
  23. package/lib/Socket/chats.js +123 -98
  24. package/lib/Socket/community.js +50 -40
  25. package/lib/Socket/groups.js +59 -47
  26. package/lib/Socket/index.js +4 -4
  27. package/lib/Socket/messages-recv.js +219 -172
  28. package/lib/Socket/messages-send.js +187 -143
  29. package/lib/Socket/newsletter.js +61 -47
  30. package/lib/Socket/socket.js +133 -90
  31. package/lib/Socket/usync.js +6 -6
  32. package/lib/Store/index.js +27 -11
  33. package/lib/Store/make-cache-manager-store.js +14 -15
  34. package/lib/Store/make-in-memory-store.js +28 -24
  35. package/lib/Types/LabelAssociation.js +2 -2
  36. package/lib/Types/Message.js +6 -6
  37. package/lib/Types/MexUpdates.js +5 -5
  38. package/lib/Types/State.js +4 -4
  39. package/lib/Types/index.js +28 -12
  40. package/lib/Utils/auth-utils.js +28 -26
  41. package/lib/Utils/baileys-event-stream.js +68 -69
  42. package/lib/Utils/business.js +63 -53
  43. package/lib/Utils/chat-utils.js +81 -71
  44. package/lib/Utils/crypto.js +25 -45
  45. package/lib/Utils/decode-wa-message.js +319 -311
  46. package/lib/Utils/event-buffer.js +21 -22
  47. package/lib/Utils/generics.js +65 -82
  48. package/lib/Utils/history.js +21 -21
  49. package/lib/Utils/index.js +27 -13
  50. package/lib/Utils/link-preview.js +7 -30
  51. package/lib/Utils/logger.js +5 -5
  52. package/lib/Utils/lt-hash.js +3 -3
  53. package/lib/Utils/message-retry-manager.js +4 -4
  54. package/lib/Utils/messages-media.js +104 -109
  55. package/lib/Utils/messages.js +203 -171
  56. package/lib/Utils/noise-handler.js +28 -19
  57. package/lib/Utils/process-message.js +111 -96
  58. package/lib/Utils/signal.js +36 -25
  59. package/lib/Utils/use-multi-file-auth-state.js +18 -22
  60. package/lib/Utils/validate-connection.js +52 -45
  61. package/lib/WABinary/decode.js +6 -32
  62. package/lib/WABinary/encode.js +3 -29
  63. package/lib/WABinary/generic-utils.js +4 -4
  64. package/lib/WABinary/index.js +27 -11
  65. package/lib/WAM/encode.js +16 -8
  66. package/lib/WAM/index.js +27 -11
  67. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
  68. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  69. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
  70. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  71. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
  72. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
  73. package/lib/WAUSync/Protocols/index.js +27 -11
  74. package/lib/WAUSync/USyncQuery.js +17 -10
  75. package/lib/WAUSync/index.js +27 -11
  76. package/lib/index.js +60 -31
  77. package/package.json +8 -14
  78. package/WAProto/AICommon/AICommon.d.ts +0 -11702
  79. package/WAProto/Adv/Adv.d.ts +0 -643
  80. package/WAProto/BotMetadata/BotMetadata.d.ts +0 -5654
  81. package/WAProto/Cert/Cert.d.ts +0 -613
  82. package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +0 -476
  83. package/WAProto/CompanionReg/CompanionReg.d.ts +0 -1361
  84. package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +0 -577
  85. package/WAProto/E2E/E2E.d.ts +0 -41724
  86. package/WAProto/Ephemeral/Ephemeral.d.ts +0 -114
  87. package/WAProto/HistorySync/HistorySync.d.ts +0 -51700
  88. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +0 -229
  89. package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +0 -583
  90. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +0 -42897
  91. package/WAProto/MmsRetry/MmsRetry.d.ts +0 -243
  92. package/WAProto/Protocol/Protocol.d.ts +0 -270
  93. package/WAProto/Reporting/Reporting.d.ts +0 -371
  94. package/WAProto/ServerSync/ServerSync.d.ts +0 -1285
  95. package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +0 -1868
  96. package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +0 -767
  97. package/WAProto/StatusAttributions/StatusAttributions.d.ts +0 -1027
  98. package/WAProto/SyncAction/SyncAction.d.ts +0 -11193
  99. package/WAProto/UserPassword/UserPassword.d.ts +0 -363
  100. package/WAProto/VnameCert/VnameCert.d.ts +0 -821
  101. package/WAProto/Wa6/Wa6.d.ts +0 -2128
  102. package/WAProto/Web/Web.d.ts +0 -46383
  103. package/WAProto/index.d.ts +0 -55
  104. package/lib/Defaults/index.d.ts +0 -77
  105. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  106. package/lib/Signal/Group/group-session-builder.d.ts +0 -17
  107. package/lib/Signal/Group/group_cipher.d.ts +0 -19
  108. package/lib/Signal/Group/index.d.ts +0 -11
  109. package/lib/Signal/Group/keyhelper.d.ts +0 -16
  110. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  111. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  112. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  113. package/lib/Signal/Group/sender-key-name.d.ts +0 -19
  114. package/lib/Signal/Group/sender-key-record.d.ts +0 -32
  115. package/lib/Signal/Group/sender-key-state.d.ts +0 -44
  116. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  117. package/lib/Signal/libsignal.d.ts +0 -8
  118. package/lib/Signal/lid-mapping.d.ts +0 -28
  119. package/lib/Socket/Client/index.d.ts +0 -2
  120. package/lib/Socket/Client/types.d.ts +0 -16
  121. package/lib/Socket/Client/websocket.d.ts +0 -13
  122. package/lib/Socket/business.d.ts +0 -187
  123. package/lib/Socket/chats.d.ts +0 -97
  124. package/lib/Socket/community.d.ts +0 -129
  125. package/lib/Socket/groups.d.ts +0 -129
  126. package/lib/Socket/index.d.ts +0 -191
  127. package/lib/Socket/messages-recv.d.ts +0 -174
  128. package/lib/Socket/messages-send.d.ts +0 -165
  129. package/lib/Socket/newsletter.d.ts +0 -145
  130. package/lib/Socket/socket.d.ts +0 -45
  131. package/lib/Socket/usync.d.ts +0 -37
  132. package/lib/Store/index.d.ts +0 -4
  133. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  134. package/lib/Store/make-in-memory-store.d.ts +0 -123
  135. package/lib/Store/make-ordered-dictionary.d.ts +0 -12
  136. package/lib/Store/object-repository.d.ts +0 -10
  137. package/lib/Types/Auth.d.ts +0 -121
  138. package/lib/Types/Bussiness.d.ts +0 -28
  139. package/lib/Types/Call.d.ts +0 -14
  140. package/lib/Types/Chat.d.ts +0 -143
  141. package/lib/Types/Contact.d.ts +0 -23
  142. package/lib/Types/Events.d.ts +0 -226
  143. package/lib/Types/GroupMetadata.d.ts +0 -66
  144. package/lib/Types/Label.d.ts +0 -48
  145. package/lib/Types/LabelAssociation.d.ts +0 -35
  146. package/lib/Types/Message.d.ts +0 -484
  147. package/lib/Types/MexUpdates.d.ts +0 -9
  148. package/lib/Types/Newsletter.d.ts +0 -109
  149. package/lib/Types/Product.d.ts +0 -92
  150. package/lib/Types/Signal.d.ts +0 -98
  151. package/lib/Types/Socket.d.ts +0 -141
  152. package/lib/Types/State.d.ts +0 -41
  153. package/lib/Types/USync.d.ts +0 -26
  154. package/lib/Types/index.d.ts +0 -80
  155. package/lib/Utils/auth-utils.d.ts +0 -21
  156. package/lib/Utils/baileys-event-stream.d.ts +0 -18
  157. package/lib/Utils/business.d.ts +0 -29
  158. package/lib/Utils/chat-utils.d.ts +0 -82
  159. package/lib/Utils/crypto.d.ts +0 -56
  160. package/lib/Utils/decode-wa-message.d.ts +0 -53
  161. package/lib/Utils/event-buffer.d.ts +0 -39
  162. package/lib/Utils/generics.d.ts +0 -117
  163. package/lib/Utils/history.d.ts +0 -23
  164. package/lib/Utils/index.d.ts +0 -20
  165. package/lib/Utils/link-preview.d.ts +0 -23
  166. package/lib/Utils/logger.d.ts +0 -13
  167. package/lib/Utils/lt-hash.d.ts +0 -14
  168. package/lib/Utils/make-mutex.d.ts +0 -9
  169. package/lib/Utils/message-retry-manager.d.ts +0 -88
  170. package/lib/Utils/messages-media.d.ts +0 -135
  171. package/lib/Utils/messages.d.ts +0 -105
  172. package/lib/Utils/noise-handler.d.ts +0 -20
  173. package/lib/Utils/process-message.d.ts +0 -49
  174. package/lib/Utils/signal.d.ts +0 -42
  175. package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
  176. package/lib/Utils/use-mongo-file-auth-state.js +0 -84
  177. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  178. package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
  179. package/lib/Utils/use-single-file-auth-state.js +0 -80
  180. package/lib/Utils/validate-connection.d.ts +0 -13
  181. package/lib/WABinary/constants.d.ts +0 -30
  182. package/lib/WABinary/decode.d.ts +0 -9
  183. package/lib/WABinary/encode.d.ts +0 -3
  184. package/lib/WABinary/generic-utils.d.ts +0 -28
  185. package/lib/WABinary/index.d.ts +0 -5
  186. package/lib/WABinary/jid-utils.d.ts +0 -58
  187. package/lib/WABinary/types.d.ts +0 -22
  188. package/lib/WAM/BinaryInfo.d.ts +0 -16
  189. package/lib/WAM/constants.d.ts +0 -47
  190. package/lib/WAM/encode.d.ts +0 -3
  191. package/lib/WAM/index.d.ts +0 -3
  192. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
  193. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  194. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
  195. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
  196. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
  197. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
  198. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  199. package/lib/WAUSync/USyncQuery.d.ts +0 -31
  200. package/lib/WAUSync/USyncUser.d.ts +0 -12
  201. package/lib/WAUSync/index.d.ts +0 -3
  202. package/lib/index.d.ts +0 -13
@@ -1,98 +0,0 @@
1
- import { proto } from '../../WAProto'
2
- import { LIDMappingStore } from '../Signal/lid-mapping'
3
-
4
- type DecryptGroupSignalOpts = {
5
- group: string
6
- authorJid: string
7
- msg: Uint8Array
8
- }
9
-
10
- type EncryptMessageWithWireOpts = {
11
- encryptionJid: string
12
- wireJid: string
13
- data: Uint8Array
14
- }
15
-
16
- type ProcessSenderKeyDistributionMessageOpts = {
17
- item: proto.Message.ISenderKeyDistributionMessage
18
- authorJid: string
19
- }
20
-
21
- type DecryptSignalProtoOpts = {
22
- jid: string
23
- type: 'pkmsg' | 'msg'
24
- ciphertext: Uint8Array
25
- }
26
-
27
- type EncryptMessageOpts = {
28
- jid: string
29
- data: Uint8Array
30
- }
31
-
32
- type EncryptGroupMessageOpts = {
33
- group: string
34
- data: Uint8Array
35
- meId: string
36
- }
37
-
38
- type PreKey = {
39
- keyId: number
40
- publicKey: Uint8Array
41
- }
42
-
43
- type SignedPreKey = PreKey & {
44
- signature: Uint8Array
45
- }
46
-
47
- type E2ESession = {
48
- registrationId: number
49
- identityKey: Uint8Array
50
- signedPreKey: SignedPreKey
51
- preKey: PreKey
52
- }
53
-
54
- type E2ESessionOpts = {
55
- jid: string
56
- session: E2ESession
57
- }
58
-
59
- export type SignalRepository = {
60
- decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>
61
- processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>
62
- decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>
63
- encryptMessage(opts: EncryptMessageOpts): Promise<{
64
- type: 'pkmsg' | 'msg'
65
- ciphertext: Uint8Array
66
- }>
67
- encryptMessageWithWire(opts: EncryptMessageWithWireOpts): Promise<{
68
- type: 'pkmsg' | 'msg'
69
- ciphertext: Uint8Array
70
- wireJid: string
71
- }>
72
- encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
73
- senderKeyDistributionMessage: Uint8Array
74
- ciphertext: Uint8Array
75
- }>
76
- injectE2ESession(opts: E2ESessionOpts): Promise<void>
77
- validateSession(jid: string): Promise<{
78
- exists: boolean
79
- reason?: string
80
- }>
81
- jidToSignalProtocolAddress(jid: string): string
82
- migrateSession(fromJids: string[], toJid: string): Promise<{
83
- migrated: number
84
- skipped: number
85
- total: number
86
- }>
87
- validateSession(jid: string): Promise<{
88
- exists: boolean
89
- reason?: string
90
- }>
91
- deleteSession(jids: string[]): Promise<void>
92
- }
93
-
94
- export interface SignalRepositoryWithLIDStore extends SignalRepository {
95
- lidMapping: LIDMappingStore
96
- }
97
-
98
- export {}
@@ -1,141 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios'
2
- import type { Agent } from 'https'
3
- import { ILogger } from '../Utils/logger'
4
- import type { URL } from 'url'
5
- import { proto } from '../../WAProto'
6
- import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth'
7
- import { GroupMetadata } from './GroupMetadata'
8
- import { MediaConnInfo } from './Message'
9
- import { SignalRepositoryWithLIDStore } from './Signal'
10
-
11
- export type WAVersion = [number, number, number]
12
-
13
- export type WABrowserDescription = [string, string, string]
14
-
15
- export type CacheStore = {
16
- /** get a cached key and change the stats */
17
- get<T>(key: string): Promise<T> | T | undefined
18
- /** set a key in the cache */
19
- set<T>(key: string, value: T): Promise<void> | void | number | boolean
20
- /** delete a key from the cache */
21
- del(key: string): void | Promise<void> | number | boolean
22
- /** flush all data */
23
- flushAll(): void | Promise<void>
24
- }
25
-
26
- export type PossiblyExtendedCacheStore = CacheStore & {
27
- mget?: <T>(keys: string[]) => Promise<Record<string, T | undefined>>
28
- mset?: <T>(entries: {
29
- key: string
30
- value: T
31
- }[]) => Promise<void> | void | number | boolean
32
- mdel?: (keys: string[]) => void | Promise<void> | number | boolean
33
- }
34
-
35
- export type PatchedMessageWithRecipientJID = proto.IMessage & {
36
- recipientJid?: string
37
- }
38
-
39
- export type SocketConfig = {
40
- /** the WS url to connect to WA */
41
- waWebSocketUrl: string | URL
42
- /** Fails the connection if the socket times out in this interval */
43
- connectTimeoutMs: number
44
- /** Default timeout for queries, undefined for no timeout */
45
- defaultQueryTimeoutMs: number | undefined
46
- /** ping-pong interval for WS connection */
47
- keepAliveIntervalMs: number
48
- /** should baileys use the mobile api instead of the multi device api
49
- * @deprecated This feature has been removed
50
- */
51
- mobile?: boolean
52
- /** proxy agent */
53
- agent?: Agent
54
- /** logger */
55
- logger: ILogger
56
- /** version to connect with */
57
- version: WAVersion
58
- /** override browser config */
59
- browser: WABrowserDescription
60
- /** agent used for fetch requests -- uploading/downloading media */
61
- fetchAgent?: Agent
62
- /** should the QR be printed in the terminal */
63
- printQRInTerminal: boolean
64
- /** should events be emitted for actions done by this socket connection */
65
- emitOwnEvents: boolean
66
- /** custom upload hosts to upload media to */
67
- customUploadHosts: MediaConnInfo['hosts']
68
- /** time to wait between sending new retry requests */
69
- retryRequestDelayMs: number
70
- /** max retry count */
71
- maxMsgRetryCount: number
72
- /** time to wait for the generation of the next QR in ms */
73
- qrTimeout?: number
74
- /** provide an auth state object to maintain the auth state */
75
- auth: AuthenticationState
76
- /** manage history processing with this control by default will sync up everything */
77
- shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean
78
- /** transaction capability options for SignalKeyStore */
79
- transactionOpts: TransactionCapabilityOptions
80
- /** marks the client as online whenever the socket successfully connects */
81
- markOnlineOnConnect: boolean
82
- /** alphanumeric country code (USA -> US) for the number used */
83
- countryCode: string
84
- /** provide a cache to store media, so does not have to be re-uploaded */
85
- mediaCache?: CacheStore
86
- /**
87
- * map to store the retry counts for failed messages
88
- * used to determine whether to retry a message or not */
89
- msgRetryCounterCache?: CacheStore
90
- /** provide a cache to store a user's device list */
91
- userDevicesCache?: PossiblyExtendedCacheStore
92
- /** cache to store call offers */
93
- callOfferCache?: CacheStore
94
- /** cache to track placeholder resends */
95
- placeholderResendCache?: CacheStore
96
- /** width for link preview images */
97
- linkPreviewImageThumbnailWidth: number
98
- /** Should Baileys ask the phone for full history, will be received async */
99
- syncFullHistory: boolean
100
- /** Should baileys fire init queries automatically, default true */
101
- fireInitQueries: boolean
102
- /**
103
- * generate a high quality link preview,
104
- * entails uploading the jpegThumbnail to WA
105
- * */
106
- generateHighQualityLinkPreview: boolean
107
- /** Enable automatic session recreation for failed messages */
108
- enableAutoSessionRecreation: boolean
109
- /** Enable recent message caching for retry handling */
110
- enableRecentMessageCache: boolean
111
- /**
112
- * Returns if a jid should be ignored,
113
- * no event for that jid will be triggered.
114
- * Messages from that jid will also not be decrypted
115
- * */
116
- shouldIgnoreJid: (jid: string) => boolean | undefined
117
- /**
118
- * Optionally patch the message before sending out
119
- * */
120
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID
121
- /** verify app state MACs */
122
- appStateMacVerification: {
123
- patch: boolean
124
- snapshot: boolean
125
- }
126
- /** options for axios */
127
- options: AxiosRequestConfig<{}>
128
- /**
129
- * fetch a message from your store
130
- * implement this so that messages failed to send
131
- * (solves the "this message can take a while" issue) can be retried
132
- * */
133
- getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>
134
- /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
135
- cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>
136
- makeSignalRepository: (auth: SignalAuthState, onWhatsAppFunc?: (...jids: string[]) => Promise<{
137
- jid: string
138
- exists: boolean
139
- lid: string
140
- }[] | undefined>) => SignalRepositoryWithLIDStore
141
- }
@@ -1,41 +0,0 @@
1
- import { Boom } from '@hapi/boom'
2
- import { Contact } from './Contact'
3
-
4
- export declare const enum SyncState {
5
- /** The socket is connecting, but we haven't received pending notifications yet. */
6
- Connecting = 0,
7
- /** Pending notifications received. Buffering events until we decide whether to sync or not. */
8
- AwaitingInitialSync = 1,
9
- /** The initial app state sync (history, etc.) is in progress. Buffering continues. */
10
- Syncing = 2,
11
- /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
12
- Online = 3
13
- }
14
-
15
- export type WAConnectionState = 'open' | 'connecting' | 'close'
16
-
17
- export type ConnectionState = {
18
- /** connection is now open, connecting or closed */
19
- connection: WAConnectionState
20
- /** the error that caused the connection to close */
21
- lastDisconnect?: {
22
- error: Boom | Error | undefined
23
- date: Date
24
- }
25
- /** is this a new login */
26
- isNewLogin?: boolean
27
- /** the current QR code */
28
- qr?: string
29
- /** has the device received all pending notifications while it was offline */
30
- receivedPendingNotifications?: boolean
31
- /** legacy connection options */
32
- legacy?: {
33
- phoneConnected: boolean
34
- user?: Contact
35
- }
36
- /**
37
- * if the client is shown as an active, online client.
38
- * If this is false, the primary phone and other devices will receive notifs
39
- * */
40
- isOnline?: boolean
41
- }
@@ -1,26 +0,0 @@
1
- import { BinaryNode } from '../WABinary'
2
- import { USyncUser } from '../WAUSync'
3
-
4
- /**
5
- * Defines the interface for a USyncQuery protocol
6
- */
7
- export interface USyncQueryProtocol {
8
- /**
9
- * The name of the protocol
10
- */
11
- name: string
12
- /**
13
- * Defines what goes inside the query part of a USyncQuery
14
- */
15
- getQueryElement: () => BinaryNode
16
- /**
17
- * Defines what goes inside the user part of a USyncQuery
18
- */
19
- getUserElement: (user: USyncUser) => BinaryNode | null
20
- /**
21
- * Parse the result of the query
22
- * @param data Data from the result
23
- * @returns Whatever the protocol is supposed to return
24
- */
25
- parser: (data: BinaryNode) => unknown
26
- }
@@ -1,80 +0,0 @@
1
- export * from './Auth'
2
- export * from './Bussines'
3
- export * from './Chat'
4
- export * from './Contact'
5
- export * from './GroupMetadata'
6
- export * from './State'
7
- export * from './MexUpdates'
8
- export * from './Message'
9
- export * from './Newsletter'
10
- export * from './Socket'
11
- export * from './Events'
12
- export * from './Product'
13
- export * from './Call'
14
- export * from './Signal'
15
-
16
- import { AuthenticationState } from './Auth'
17
- import { SocketConfig } from './Socket'
18
-
19
- export type UserFacingSocketConfig = Partial<SocketConfig> & {
20
- auth: AuthenticationState
21
- }
22
-
23
- export type BrowsersMap = {
24
- ubuntu(browser: string): [string, string, string]
25
- macOS(browser: string): [string, string, string]
26
- windows(browser: string): [string, string, string]
27
- linux(browser: string): [string, string, string]
28
- android(browser: string): [string, string, string]
29
- iOS(browser: string): [string, string, string]
30
- baileys(browser: string): [string, string, string]
31
- kaiOS(browser: string): [string, string, string]
32
- chromeOS(browser: string): [string, string, string]
33
- appropriate(browser: string): [string, string, string]
34
- custom(platform: string, browser: string, version: string): [string, string, string]
35
- }
36
-
37
- export declare const enum DisconnectReason {
38
- connectionClosed = 428,
39
- connectionLost = 408,
40
- connectionReplaced = 440,
41
- timedOut = 408,
42
- loggedOut = 401,
43
- badSession = 500,
44
- restartRequired = 515,
45
- multideviceMismatch = 411,
46
- forbidden = 403,
47
- unavailableService = 503
48
- }
49
-
50
- export type WAInitResponse = {
51
- ref: string
52
- ttl: number
53
- status: 200
54
- }
55
-
56
- export type WABusinessHoursConfig = {
57
- day_of_week: string
58
- mode: string
59
- open_time?: number
60
- close_time?: number
61
- }
62
-
63
- export type WABusinessProfile = {
64
- description: string
65
- email: string | undefined
66
- business_hours: {
67
- timezone?: string
68
- config?: WABusinessHoursConfig[]
69
- business_config?: WABusinessHoursConfig[]
70
- }
71
- website: string[]
72
- category?: string
73
- wid?: string
74
- address?: string
75
- }
76
-
77
- export type CurveKeyPair = {
78
- private: Uint8Array
79
- public: Uint8Array
80
- }
@@ -1,21 +0,0 @@
1
- import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types'
2
- import { ILogger } from './logger'
3
-
4
- /**
5
- * Adds caching capability to a SignalKeyStore
6
- * @param store the store to add caching to
7
- * @param logger to log trace events
8
- * @param _cache cache store to use
9
- */
10
- export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger?: ILogger, _cache?: CacheStore): SignalKeyStore
11
-
12
- /**
13
- * Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
14
- * this allows batch read & write operations & improves the performance of the lib
15
- * @param state the key store to apply this capability to
16
- * @param logger logger to log events
17
- * @returns SignalKeyStore with transaction capability
18
- */
19
- export declare const addTransactionCapability: (state: SignalKeyStore, logger?: ILogger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction
20
-
21
- export declare const initAuthCreds: () => AuthenticationCreds
@@ -1,18 +0,0 @@
1
- import type { BaileysEventEmitter } from '../Types'
2
-
3
- /**
4
- * Captures events from a baileys event emitter & stores them in a file
5
- * @param ev The event emitter to read events from
6
- * @param filename File to save to
7
- */
8
- export declare const captureEventStream: (ev: BaileysEventEmitter, filename: string) => void
9
-
10
- /**
11
- * Read event file and emit events from there
12
- * @param filename filename containing event data
13
- * @param delayIntervalMs delay between each event emit
14
- */
15
- export declare const readAndEmitEventStream: (filename: string, delayIntervalMs?: number) => {
16
- ev: BaileysEventEmitter
17
- task: Promise<void>
18
- }
@@ -1,29 +0,0 @@
1
- import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types'
2
- import { BinaryNode } from '../WABinary'
3
-
4
- export declare const parseCatalogNode: (node: BinaryNode) => {
5
- products: Product[]
6
- nextPageCursor: string | undefined
7
- }
8
-
9
- export declare const parseCollectionsNode: (node: BinaryNode) => {
10
- collections: CatalogCollection[]
11
- }
12
-
13
- export declare const parseOrderDetailsNode: (node: BinaryNode) => OrderDetails
14
-
15
- export declare const toProductNode: (productId: string | undefined, product: ProductCreate | ProductUpdate) => BinaryNode
16
-
17
- export declare const parseProductNode: (productNode: BinaryNode) => Product
18
-
19
- /**
20
- * Uploads images not already uploaded to WA's servers
21
- */
22
- export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdate | ProductCreate>(product: T, waUploadToServer: WAMediaUploadFunction, timeoutMs?: number): Promise<T>
23
-
24
- /**
25
- * Uploads images not already uploaded to WA's servers
26
- */
27
- export declare const uploadingNecessaryImages: (images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs?: number) => Promise<{
28
- url: string
29
- }[]>
@@ -1,82 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios'
2
- import { proto } from '../../WAProto'
3
- import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types'
4
- import { BinaryNode } from '../WABinary'
5
- import { ILogger } from './logger'
6
-
7
- type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>
8
-
9
- export type ChatMutationMap = {
10
- [index: string]: ChatMutation
11
- }
12
-
13
- export declare const newLTHashState: () => LTHashState
14
-
15
- export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, operation }: WAPatchCreate, myAppStateKeyId: string, state: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey) => Promise<{
16
- patch: proto.ISyncdPatch
17
- state: LTHashState
18
- }>
19
-
20
- export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
21
- hash: Buffer
22
- indexValueMap: {
23
- [indexMacBase64: string]: {
24
- valueMac: Uint8Array | Buffer
25
- }
26
- }
27
- }>
28
-
29
- export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
30
- hash: Buffer
31
- indexValueMap: {
32
- [indexMacBase64: string]: {
33
- valueMac: Uint8Array | Buffer
34
- }
35
- }
36
- }>
37
-
38
- export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<{}>) => Promise<{
39
- critical_block: {
40
- patches: proto.ISyncdPatch[]
41
- hasMorePatches: boolean
42
- snapshot?: proto.ISyncdSnapshot | undefined
43
- }
44
- critical_unblock_low: {
45
- patches: proto.ISyncdPatch[]
46
- hasMorePatches: boolean
47
- snapshot?: proto.ISyncdSnapshot | undefined
48
- }
49
- regular_high: {
50
- patches: proto.ISyncdPatch[]
51
- hasMorePatches: boolean
52
- snapshot?: proto.ISyncdSnapshot | undefined
53
- }
54
- regular_low: {
55
- patches: proto.ISyncdPatch[]
56
- hasMorePatches: boolean
57
- snapshot?: proto.ISyncdSnapshot | undefined
58
- }
59
- regular: {
60
- patches: proto.ISyncdPatch[]
61
- hasMorePatches: boolean
62
- snapshot?: proto.ISyncdSnapshot | undefined
63
- }
64
- }>
65
-
66
- export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<Buffer>
67
- export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>
68
- export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
69
- state: LTHashState
70
- mutationMap: ChatMutationMap
71
- }>
72
-
73
- export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<{}>, minimumVersionNumber?: number, logger?: ILogger, validateMacs?: boolean) => Promise<{
74
- state: LTHashState
75
- mutationMap: ChatMutationMap
76
- }>
77
-
78
- export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate
79
-
80
- export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: ILogger) => void
81
-
82
- export {}
@@ -1,56 +0,0 @@
1
- import { KeyPair } from '../Types'
2
-
3
- /** prefix version byte to the pub keys, required for some curve crypto functions */
4
- export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) => Uint8Array | Buffer
5
-
6
- export declare const Curve: {
7
- generateKeyPair: () => KeyPair
8
- sharedKey: (privateKey: Uint8Array, publicKey: Uint8Array) => Buffer
9
- sign: (privateKey: Uint8Array, buf: Uint8Array) => any
10
- verify: (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean
11
- }
12
-
13
- export declare const signedKeyPair: (identityKeyPair: KeyPair, keyId: number) => {
14
- keyPair: KeyPair
15
- signature: any
16
- keyId: number
17
- }
18
-
19
- /**
20
- * encrypt AES 256 GCM
21
- * where the tag tag is suffixed to the ciphertext
22
- * */
23
- export declare function aesEncryptGCM(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): Buffer
24
-
25
- /**
26
- * decrypt AES 256 GCM
27
- * where the auth tag is suffixed to the ciphertext
28
- * */
29
- export declare function aesDecryptGCM(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): Buffer
30
-
31
- export declare function aesEncryptCTR(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array): Buffer
32
-
33
- export declare function aesDecryptCTR(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array): Buffer
34
-
35
- /** decrypt AES 256 CBC where the IV is prefixed to the buffer */
36
- export declare function aesDecrypt(buffer: Buffer, key: Buffer): Buffer
37
- /** decrypt AES 256 CBC */
38
-
39
- export declare function aesDecryptWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer
40
-
41
- export declare function aesEncrypt(buffer: Buffer | Uint8Array, key: Buffer): Buffer
42
-
43
- export declare function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer
44
-
45
- export declare function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant?: 'sha256' | 'sha512'): Buffer
46
-
47
- export declare function sha256(buffer: Buffer): Buffer
48
-
49
- export declare function md5(buffer: Buffer): Buffer
50
-
51
- export declare function hkdf(buffer: Uint8Array | Buffer, expandedLength: number, info: {
52
- salt?: Buffer
53
- info?: string
54
- }): Promise<Buffer>
55
-
56
- export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Promise<Buffer>
@@ -1,53 +0,0 @@
1
- import { proto } from '../../WAProto'
2
- import { SignalRepository } from '../Types'
3
- import { BinaryNode } from '../WABinary'
4
- import { ILogger } from './logger'
5
-
6
- export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node"
7
-
8
- export declare const MISSING_KEYS_ERROR_TEXT = "Key used already or never filled"
9
-
10
- export declare const DECRYPTION_RETRY_CONFIG: {
11
- maxRetries: number
12
- baseDelayMs: number
13
- sessionRecordErrors: string[]
14
- }
15
-
16
- export declare const NACK_REASONS: {
17
- ParsingError: number
18
- UnrecognizedStanza: number
19
- UnrecognizedStanzaClass: number
20
- UnrecognizedStanzaType: number
21
- InvalidProtobuf: number
22
- InvalidHostedCompanionStanza: number
23
- MissingMessageSecret: number
24
- SignalErrorOldCounter: number
25
- MessageDeletedOnPeer: number
26
- UnhandledError: number
27
- UnsupportedAdminRevoke: number
28
- UnsupportedLIDGroup: number
29
- DBOperationFailed: number
30
- }
31
-
32
- export declare const extractAddressingContext: (stanza: BinaryNode) => {
33
- addressingMode: string
34
- senderAlt: string | undefined
35
- recipientAlt: string | undefined
36
- }
37
-
38
- /**
39
- * Decode the received node as a message.
40
- * @note this will only parse the message, not decrypt it
41
- */
42
- export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): {
43
- fullMessage: proto.IWebMessageInfo
44
- author: string
45
- sender: string
46
- }
47
-
48
- export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepository, logger: ILogger) => {
49
- fullMessage: proto.IWebMessageInfo
50
- category: string
51
- author: string
52
- decrypt(): Promise<void>
53
- }