gifted-baileys 1.5.4 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/WAProto.proto +88 -969
  3. package/WAProto/index.d.ts +1256 -13195
  4. package/WAProto/index.js +74730 -125106
  5. package/package.json +9 -27
  6. package/src/Defaults/baileys-version.json +3 -0
  7. package/{lib → src}/Defaults/index.js +14 -7
  8. package/src/Defaults/index.ts +131 -0
  9. package/src/README.md +1 -0
  10. package/src/Signal/libsignal.js +180 -0
  11. package/src/Signal/libsignal.ts +141 -0
  12. package/src/Socket/Client/abstract-socket-client.ts +19 -0
  13. package/{lib → src}/Socket/Client/index.js +3 -2
  14. package/src/Socket/Client/index.ts +3 -0
  15. package/src/Socket/Client/mobile-socket-client.js +78 -0
  16. package/src/Socket/Client/mobile-socket-client.ts +66 -0
  17. package/src/Socket/Client/web-socket-client.js +75 -0
  18. package/src/Socket/Client/web-socket-client.ts +57 -0
  19. package/{lib → src}/Socket/business.js +33 -28
  20. package/src/Socket/business.ts +281 -0
  21. package/{lib → src}/Socket/chats.js +176 -174
  22. package/src/Socket/chats.ts +1030 -0
  23. package/{lib → src}/Socket/groups.js +68 -80
  24. package/src/Socket/groups.ts +356 -0
  25. package/{lib → src}/Socket/index.js +1 -4
  26. package/src/Socket/index.ts +13 -0
  27. package/{lib → src}/Socket/messages-recv.js +211 -378
  28. package/src/Socket/messages-recv.ts +985 -0
  29. package/{lib → src}/Socket/messages-send.js +177 -452
  30. package/src/Socket/messages-send.ts +871 -0
  31. package/{lib → src}/Socket/newsletter.js +98 -107
  32. package/src/Socket/newsletter.ts +282 -0
  33. package/{lib → src}/Socket/registration.js +48 -56
  34. package/src/Socket/registration.ts +250 -0
  35. package/{lib → src}/Socket/socket.js +77 -77
  36. package/src/Socket/socket.ts +777 -0
  37. package/src/Store/index.ts +3 -0
  38. package/{lib → src}/Store/make-cache-manager-store.js +34 -25
  39. package/src/Store/make-cache-manager-store.ts +100 -0
  40. package/{lib → src}/Store/make-in-memory-store.js +32 -36
  41. package/src/Store/make-in-memory-store.ts +475 -0
  42. package/src/Store/make-ordered-dictionary.ts +86 -0
  43. package/{lib → src}/Store/object-repository.js +1 -1
  44. package/src/Store/object-repository.ts +32 -0
  45. package/src/Tests/test.app-state-sync.js +204 -0
  46. package/src/Tests/test.app-state-sync.ts +207 -0
  47. package/src/Tests/test.event-buffer.js +270 -0
  48. package/src/Tests/test.event-buffer.ts +319 -0
  49. package/src/Tests/test.key-store.js +76 -0
  50. package/src/Tests/test.key-store.ts +92 -0
  51. package/src/Tests/test.libsignal.js +141 -0
  52. package/src/Tests/test.libsignal.ts +186 -0
  53. package/src/Tests/test.media-download.js +93 -0
  54. package/src/Tests/test.media-download.ts +76 -0
  55. package/src/Tests/test.messages.js +33 -0
  56. package/src/Tests/test.messages.ts +37 -0
  57. package/src/Tests/utils.js +34 -0
  58. package/src/Tests/utils.ts +36 -0
  59. package/src/Types/Auth.ts +113 -0
  60. package/src/Types/Call.ts +15 -0
  61. package/src/Types/Chat.ts +106 -0
  62. package/{lib/Types/Contact.d.ts → src/Types/Contact.ts} +9 -8
  63. package/src/Types/Events.ts +93 -0
  64. package/src/Types/GroupMetadata.ts +53 -0
  65. package/src/Types/Label.ts +36 -0
  66. package/{lib/Types/LabelAssociation.d.ts → src/Types/LabelAssociation.ts} +22 -16
  67. package/src/Types/Message.ts +288 -0
  68. package/src/Types/Newsletter.ts +98 -0
  69. package/src/Types/Product.ts +85 -0
  70. package/src/Types/Signal.ts +68 -0
  71. package/{lib/Types/Socket.d.ts → src/Types/Socket.ts} +68 -61
  72. package/src/Types/State.ts +29 -0
  73. package/src/Types/index.ts +59 -0
  74. package/{lib → src}/Utils/auth-utils.js +90 -73
  75. package/src/Utils/auth-utils.ts +222 -0
  76. package/src/Utils/baileys-event-stream.js +92 -0
  77. package/src/Utils/baileys-event-stream.ts +66 -0
  78. package/{lib → src}/Utils/business.js +43 -15
  79. package/src/Utils/business.ts +275 -0
  80. package/{lib → src}/Utils/chat-utils.js +94 -87
  81. package/src/Utils/chat-utils.ts +860 -0
  82. package/{lib → src}/Utils/crypto.js +2 -4
  83. package/src/Utils/crypto.ts +131 -0
  84. package/src/Utils/decode-wa-message.js +211 -0
  85. package/src/Utils/decode-wa-message.ts +228 -0
  86. package/{lib → src}/Utils/event-buffer.js +13 -4
  87. package/src/Utils/event-buffer.ts +613 -0
  88. package/{lib → src}/Utils/generics.js +86 -67
  89. package/src/Utils/generics.ts +434 -0
  90. package/{lib → src}/Utils/history.js +39 -13
  91. package/src/Utils/history.ts +112 -0
  92. package/src/Utils/index.ts +17 -0
  93. package/{lib → src}/Utils/link-preview.js +54 -17
  94. package/src/Utils/link-preview.ts +122 -0
  95. package/src/Utils/logger.ts +3 -0
  96. package/src/Utils/lt-hash.ts +61 -0
  97. package/{lib → src}/Utils/make-mutex.js +13 -4
  98. package/src/Utils/make-mutex.ts +44 -0
  99. package/{lib → src}/Utils/messages-media.js +255 -193
  100. package/src/Utils/messages-media.ts +847 -0
  101. package/{lib → src}/Utils/messages.js +118 -588
  102. package/src/Utils/messages.ts +956 -0
  103. package/src/Utils/noise-handler.ts +197 -0
  104. package/{lib → src}/Utils/process-message.js +30 -27
  105. package/src/Utils/process-message.ts +414 -0
  106. package/{lib → src}/Utils/signal.js +42 -25
  107. package/src/Utils/signal.ts +177 -0
  108. package/{lib → src}/Utils/use-multi-file-auth-state.js +28 -27
  109. package/src/Utils/use-multi-file-auth-state.ts +90 -0
  110. package/{lib → src}/Utils/validate-connection.js +9 -40
  111. package/src/Utils/validate-connection.ts +238 -0
  112. package/src/WABinary/constants.ts +42 -0
  113. package/src/WABinary/decode.ts +265 -0
  114. package/{lib → src}/WABinary/encode.js +10 -16
  115. package/src/WABinary/encode.ts +236 -0
  116. package/src/WABinary/generic-utils.ts +121 -0
  117. package/src/WABinary/index.ts +5 -0
  118. package/src/WABinary/jid-utils.ts +68 -0
  119. package/src/WABinary/types.ts +17 -0
  120. package/src/WAM/BinaryInfo.ts +12 -0
  121. package/src/WAM/constants.ts +15382 -0
  122. package/src/WAM/encode.ts +174 -0
  123. package/src/WAM/index.ts +3 -0
  124. package/{lib → src}/index.js +0 -1
  125. package/src/index.ts +13 -0
  126. package/README.md +0 -1645
  127. package/lib/Defaults/baileys-version.json +0 -3
  128. package/lib/Defaults/index.d.ts +0 -284
  129. package/lib/Signal/libsignal.d.ts +0 -3
  130. package/lib/Signal/libsignal.js +0 -161
  131. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -15
  132. package/lib/Socket/Client/index.d.ts +0 -2
  133. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -12
  134. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  135. package/lib/Socket/Client/types.d.ts +0 -17
  136. package/lib/Socket/Client/types.js +0 -13
  137. package/lib/Socket/Client/websocket.d.ts +0 -12
  138. package/lib/Socket/Client/websocket.js +0 -62
  139. package/lib/Socket/business.d.ts +0 -170
  140. package/lib/Socket/chats.d.ts +0 -81
  141. package/lib/Socket/groups.d.ts +0 -115
  142. package/lib/Socket/index.d.ts +0 -172
  143. package/lib/Socket/messages-recv.d.ts +0 -158
  144. package/lib/Socket/messages-send.d.ts +0 -155
  145. package/lib/Socket/newsletter.d.ts +0 -132
  146. package/lib/Socket/registration.d.ts +0 -264
  147. package/lib/Socket/socket.d.ts +0 -44
  148. package/lib/Socket/usync.d.ts +0 -37
  149. package/lib/Socket/usync.js +0 -70
  150. package/lib/Store/index.d.ts +0 -3
  151. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  152. package/lib/Store/make-in-memory-store.d.ts +0 -118
  153. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  154. package/lib/Store/object-repository.d.ts +0 -10
  155. package/lib/Types/Auth.d.ts +0 -109
  156. package/lib/Types/Call.d.ts +0 -13
  157. package/lib/Types/Chat.d.ts +0 -107
  158. package/lib/Types/Events.d.ts +0 -172
  159. package/lib/Types/GroupMetadata.d.ts +0 -56
  160. package/lib/Types/Label.d.ts +0 -46
  161. package/lib/Types/Message.d.ts +0 -433
  162. package/lib/Types/Newsletter.d.ts +0 -92
  163. package/lib/Types/Product.d.ts +0 -78
  164. package/lib/Types/Signal.d.ts +0 -57
  165. package/lib/Types/State.d.ts +0 -27
  166. package/lib/Types/USync.d.ts +0 -25
  167. package/lib/Types/USync.js +0 -2
  168. package/lib/Types/index.d.ts +0 -66
  169. package/lib/Utils/auth-utils.d.ts +0 -18
  170. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  171. package/lib/Utils/baileys-event-stream.js +0 -63
  172. package/lib/Utils/business.d.ts +0 -22
  173. package/lib/Utils/chat-utils.d.ts +0 -70
  174. package/lib/Utils/crypto.d.ts +0 -40
  175. package/lib/Utils/decode-wa-message.d.ts +0 -36
  176. package/lib/Utils/decode-wa-message.js +0 -226
  177. package/lib/Utils/event-buffer.d.ts +0 -35
  178. package/lib/Utils/generics.d.ts +0 -88
  179. package/lib/Utils/history.d.ts +0 -19
  180. package/lib/Utils/index.d.ts +0 -17
  181. package/lib/Utils/link-preview.d.ts +0 -21
  182. package/lib/Utils/logger.d.ts +0 -2
  183. package/lib/Utils/lt-hash.d.ts +0 -12
  184. package/lib/Utils/make-mutex.d.ts +0 -7
  185. package/lib/Utils/messages-media.d.ts +0 -113
  186. package/lib/Utils/messages.d.ts +0 -77
  187. package/lib/Utils/noise-handler.d.ts +0 -20
  188. package/lib/Utils/process-message.d.ts +0 -41
  189. package/lib/Utils/signal.d.ts +0 -33
  190. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
  191. package/lib/Utils/validate-connection.d.ts +0 -11
  192. package/lib/WABinary/constants.d.ts +0 -27
  193. package/lib/WABinary/decode.d.ts +0 -6
  194. package/lib/WABinary/encode.d.ts +0 -2
  195. package/lib/WABinary/generic-utils.d.ts +0 -14
  196. package/lib/WABinary/index.d.ts +0 -5
  197. package/lib/WABinary/jid-utils.d.ts +0 -31
  198. package/lib/WABinary/types.d.ts +0 -18
  199. package/lib/WAM/BinaryInfo.d.ts +0 -8
  200. package/lib/WAM/constants.d.ts +0 -38
  201. package/lib/WAM/encode.d.ts +0 -2
  202. package/lib/WAM/index.d.ts +0 -3
  203. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  204. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -32
  205. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  206. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -57
  207. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  208. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -30
  209. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  210. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
  211. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  212. package/lib/WAUSync/Protocols/index.js +0 -20
  213. package/lib/WAUSync/USyncQuery.d.ts +0 -26
  214. package/lib/WAUSync/USyncQuery.js +0 -79
  215. package/lib/WAUSync/USyncUser.d.ts +0 -10
  216. package/lib/WAUSync/USyncUser.js +0 -22
  217. package/lib/WAUSync/index.d.ts +0 -3
  218. package/lib/WAUSync/index.js +0 -19
  219. /package/{lib → src}/Defaults/phonenumber-mcc.json +0 -0
  220. /package/{lib → src}/Socket/Client/abstract-socket-client.js +0 -0
  221. /package/{lib → src}/Store/index.js +0 -0
  222. /package/{lib → src}/Store/make-ordered-dictionary.js +0 -0
  223. /package/{lib → src}/Types/Auth.js +0 -0
  224. /package/{lib → src}/Types/Call.js +0 -0
  225. /package/{lib → src}/Types/Chat.js +0 -0
  226. /package/{lib → src}/Types/Contact.js +0 -0
  227. /package/{lib → src}/Types/Events.js +0 -0
  228. /package/{lib → src}/Types/GroupMetadata.js +0 -0
  229. /package/{lib → src}/Types/Label.js +0 -0
  230. /package/{lib → src}/Types/LabelAssociation.js +0 -0
  231. /package/{lib → src}/Types/Message.js +0 -0
  232. /package/{lib → src}/Types/Newsletter.js +0 -0
  233. /package/{lib → src}/Types/Product.js +0 -0
  234. /package/{lib → src}/Types/Signal.js +0 -0
  235. /package/{lib → src}/Types/Socket.js +0 -0
  236. /package/{lib → src}/Types/State.js +0 -0
  237. /package/{lib → src}/Types/index.js +0 -0
  238. /package/{lib → src}/Utils/index.js +0 -0
  239. /package/{lib → src}/Utils/logger.js +0 -0
  240. /package/{lib → src}/Utils/lt-hash.js +0 -0
  241. /package/{lib → src}/Utils/noise-handler.js +0 -0
  242. /package/{lib → src}/WABinary/constants.js +0 -0
  243. /package/{lib → src}/WABinary/decode.js +0 -0
  244. /package/{lib → src}/WABinary/generic-utils.js +0 -0
  245. /package/{lib → src}/WABinary/index.js +0 -0
  246. /package/{lib → src}/WABinary/jid-utils.js +0 -0
  247. /package/{lib → src}/WABinary/types.js +0 -0
  248. /package/{lib → src}/WAM/BinaryInfo.js +0 -0
  249. /package/{lib → src}/WAM/constants.js +0 -0
  250. /package/{lib → src}/WAM/encode.js +0 -0
  251. /package/{lib → src}/WAM/index.js +0 -0
  252. /package/{lib → src}/gifted +0 -0
@@ -0,0 +1,98 @@
1
+ import { proto } from '../../WAProto'
2
+
3
+ export type NewsletterReactionMode = 'ALL' | 'BASIC' | 'NONE'
4
+
5
+ export type NewsletterState = 'ACTIVE' | 'GEOSUSPENDED' | 'SUSPENDED'
6
+
7
+ export type NewsletterVerification = 'VERIFIED' | 'UNVERIFIED'
8
+
9
+ export type NewsletterMute = 'ON' | 'OFF' | 'UNDEFINED'
10
+
11
+ export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER'
12
+
13
+ export type NewsletterViewerMetadata = {
14
+ mute: NewsletterMute
15
+ view_role: NewsletterViewRole
16
+ }
17
+
18
+ export type NewsletterMetadata = {
19
+ /**jid of newsletter */
20
+ id: string
21
+ /**state of newsletter */
22
+ state: NewsletterState
23
+ /**creation timestamp of newsletter */
24
+ creation_time: number
25
+ /**name of newsletter */
26
+ name: string
27
+ /**timestamp of last name modification of newsletter */
28
+ nameTime: number
29
+ /**description of newsletter */
30
+ description: string
31
+ /**timestamp of last description modification of newsletter */
32
+ descriptionTime: number
33
+ /**invite code of newsletter */
34
+ invite: string
35
+ /**i dont know */
36
+ handle: null
37
+ /**direct path of picture */
38
+ picture: string | null
39
+ /**direct path of picture preview (lower quality) */
40
+ preview: string | null
41
+ /**reaction mode of newsletter */
42
+ reaction_codes?: NewsletterReactionMode
43
+ /**subscribers count of newsletter */
44
+ subscribers: number
45
+ /**verification state of newsletter */
46
+ verification: NewsletterVerification
47
+ /**viewer metadata */
48
+ viewer_metadata: NewsletterViewerMetadata
49
+ }
50
+
51
+ export type SubscriberAction = 'promote' | 'demote'
52
+
53
+ export type ReactionModeUpdate = {reaction_codes: {blocked_codes: null, enabled_ts_sec: null, value: NewsletterReactionMode}}
54
+
55
+ /**only exists reaction mode update */
56
+ export type NewsletterSettingsUpdate = ReactionModeUpdate
57
+
58
+ export type NewsletterReaction = {count: number, code: string}
59
+
60
+ export type NewsletterFetchedUpdate = {
61
+ /**id of message in newsletter, starts from 100 */
62
+ server_id: string
63
+ /**count of views in this message */
64
+ views?: number
65
+ /**reactions in this message */
66
+ reactions: NewsletterReaction[]
67
+ /**the message, if you requested only updates, you will not receive message */
68
+ message?: proto.IWebMessageInfo
69
+ }
70
+
71
+ export enum MexOperations {
72
+ PROMOTE = 'NotificationNewsletterAdminPromote',
73
+ DEMOTE = 'NotificationNewsletterAdminDemote',
74
+ UPDATE = 'NotificationNewsletterUpdate'
75
+ }
76
+
77
+ export enum XWAPaths {
78
+ PROMOTE = 'xwa2_notify_newsletter_admin_promote',
79
+ DEMOTE = 'xwa2_notify_newsletter_admin_demote',
80
+ ADMIN_COUNT = 'xwa2_newsletter_admin',
81
+ CREATE = 'xwa2_newsletter_create',
82
+ NEWSLETTER = 'xwa2_newsletter',
83
+ METADATA_UPDATE = 'xwa2_notify_newsletter_on_metadata_update'
84
+ }
85
+
86
+ export enum QueryIds {
87
+ JOB_MUTATION = '7150902998257522',
88
+ METADATA = '6620195908089573',
89
+ UNFOLLOW = '7238632346214362',
90
+ FOLLOW = '7871414976211147',
91
+ UNMUTE = '7337137176362961',
92
+ MUTE = '25151904754424642',
93
+ CREATE = '6996806640408138',
94
+ ADMIN_COUNT = '7130823597031706',
95
+ CHANGE_OWNER = '7341777602580933',
96
+ DELETE = '8316537688363079',
97
+ DEMOTE = '6551828931592903'
98
+ }
@@ -0,0 +1,85 @@
1
+ import { WAMediaUpload } from './Message'
2
+
3
+ export type CatalogResult = {
4
+ data: {
5
+ paging: { cursors: { before: string, after: string } }
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ data: any[]
8
+ }
9
+ }
10
+
11
+ export type ProductCreateResult = {
12
+ data: { product: {} }
13
+ }
14
+
15
+ export type CatalogStatus = {
16
+ status: string
17
+ canAppeal: boolean
18
+ }
19
+
20
+ export type CatalogCollection = {
21
+ id: string
22
+ name: string
23
+ products: Product[]
24
+
25
+ status: CatalogStatus
26
+ }
27
+
28
+ export type ProductAvailability = 'in stock'
29
+
30
+ export type ProductBase = {
31
+ name: string
32
+ retailerId?: string
33
+ url?: string
34
+ description: string
35
+ price: number
36
+ currency: string
37
+ isHidden?: boolean
38
+ }
39
+
40
+ export type ProductCreate = ProductBase & {
41
+ /** ISO country code for product origin. Set to undefined for no country */
42
+ originCountryCode: string | undefined
43
+ /** images of the product */
44
+ images: WAMediaUpload[]
45
+ }
46
+
47
+ export type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>
48
+
49
+ export type Product = ProductBase & {
50
+ id: string
51
+ imageUrls: { [_: string]: string }
52
+ reviewStatus: { [_: string]: string }
53
+ availability: ProductAvailability
54
+ }
55
+
56
+ export type OrderPrice = {
57
+ currency: string
58
+ total: number
59
+ }
60
+
61
+ export type OrderProduct = {
62
+ id: string
63
+ imageUrl: string
64
+ name: string
65
+ quantity: number
66
+
67
+ currency: string
68
+ price: number
69
+ }
70
+
71
+ export type OrderDetails = {
72
+ price: OrderPrice
73
+ products: OrderProduct[]
74
+ }
75
+
76
+ export type CatalogCursor = string
77
+
78
+ export type GetCatalogOptions = {
79
+ /** cursor to start from */
80
+ cursor?: CatalogCursor
81
+ /** number of products to fetch */
82
+ limit?: number
83
+
84
+ jid?: string
85
+ }
@@ -0,0 +1,68 @@
1
+ import { proto } from '../../WAProto'
2
+
3
+ type DecryptGroupSignalOpts = {
4
+ group: string
5
+ authorJid: string
6
+ msg: Uint8Array
7
+ }
8
+
9
+ type ProcessSenderKeyDistributionMessageOpts = {
10
+ item: proto.Message.ISenderKeyDistributionMessage
11
+ authorJid: string
12
+ }
13
+
14
+ type DecryptSignalProtoOpts = {
15
+ jid: string
16
+ type: 'pkmsg' | 'msg'
17
+ ciphertext: Uint8Array
18
+ }
19
+
20
+ type EncryptMessageOpts = {
21
+ jid: string
22
+ data: Uint8Array
23
+ }
24
+
25
+ type EncryptGroupMessageOpts = {
26
+ group: string
27
+ data: Uint8Array
28
+ meId: string
29
+ }
30
+
31
+ type PreKey = {
32
+ keyId: number
33
+ publicKey: Uint8Array
34
+ }
35
+
36
+ type SignedPreKey = PreKey & {
37
+ signature: Uint8Array
38
+ }
39
+
40
+ type E2ESession = {
41
+ registrationId: number
42
+ identityKey: Uint8Array
43
+ signedPreKey: SignedPreKey
44
+ preKey: PreKey
45
+ }
46
+
47
+ type E2ESessionOpts = {
48
+ jid: string
49
+ session: E2ESession
50
+ }
51
+
52
+ export type SignalRepository = {
53
+ decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>
54
+ processSenderKeyDistributionMessage(
55
+ opts: ProcessSenderKeyDistributionMessageOpts
56
+ ): Promise<void>
57
+ decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>
58
+ encryptMessage(opts: EncryptMessageOpts): Promise<{
59
+ type: 'pkmsg' | 'msg'
60
+ ciphertext: Uint8Array
61
+ }>
62
+ encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
63
+ senderKeyDistributionMessage: Uint8Array
64
+ ciphertext: Uint8Array
65
+ }>
66
+ injectE2ESession(opts: E2ESessionOpts): Promise<void>
67
+ jidToSignalProtocolAddress(jid: string): string
68
+ }
@@ -1,116 +1,123 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- import type { Agent } from 'https';
3
- import type { Logger } from 'pino';
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 { SignalRepository } from './Signal';
10
- export type WAVersion = [number, number, number];
11
- export type WABrowserDescription = [string, string, string];
1
+
2
+ import { AxiosRequestConfig } from 'axios'
3
+ import type { Agent } from 'https'
4
+ import type { Logger } from 'pino'
5
+ import type { URL } from 'url'
6
+ import { proto } from '../../WAProto'
7
+ import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth'
8
+ import { MediaConnInfo } from './Message'
9
+ import { SignalRepository } from './Signal'
10
+
11
+ export type WAVersion = [number, number, number]
12
+ export type WABrowserDescription = [string, string, string]
13
+
12
14
  export type CacheStore = {
13
15
  /** get a cached key and change the stats */
14
- get<T>(key: string): T | undefined;
16
+ get<T>(key: string): T | undefined
15
17
  /** set a key in the cache */
16
- set<T>(key: string, value: T): void;
18
+ set<T>(key: string, value: T): void
17
19
  /** delete a key from the cache */
18
- del(key: string): void;
20
+ del(key: string): void
19
21
  /** flush all data */
20
- flushAll(): void;
21
- };
22
+ flushAll(): void
23
+ }
24
+
22
25
  export type SocketConfig = {
23
26
  /** the WS url to connect to WA */
24
- waWebSocketUrl: string | URL;
27
+ waWebSocketUrl: string | URL
25
28
  /** Fails the connection if the socket times out in this interval */
26
- connectTimeoutMs: number;
29
+ connectTimeoutMs: number
27
30
  /** Default timeout for queries, undefined for no timeout */
28
- defaultQueryTimeoutMs: number | undefined;
31
+ defaultQueryTimeoutMs: number | undefined
29
32
  /** ping-pong interval for WS connection */
30
- keepAliveIntervalMs: number;
31
- /** should baileys use the mobile api instead of the multi device api */
32
- mobile?: boolean;
33
+ keepAliveIntervalMs: number
34
+ /** should baileys use the mobile api instead of the multi device api */
35
+ mobile?: boolean
33
36
  /** proxy agent */
34
- agent?: Agent;
37
+ agent?: Agent
35
38
  /** pino logger */
36
- logger: Logger;
39
+ logger: Logger
37
40
  /** version to connect with */
38
- version: WAVersion;
41
+ version: WAVersion
39
42
  /** override browser config */
40
- browser: WABrowserDescription;
43
+ browser: WABrowserDescription
41
44
  /** agent used for fetch requests -- uploading/downloading media */
42
- fetchAgent?: Agent;
45
+ fetchAgent?: Agent
43
46
  /** should the QR be printed in the terminal */
44
- printQRInTerminal: boolean;
47
+ printQRInTerminal: boolean
45
48
  /** should events be emitted for actions done by this socket connection */
46
- emitOwnEvents: boolean;
49
+ emitOwnEvents: boolean
47
50
  /** custom upload hosts to upload media to */
48
- customUploadHosts: MediaConnInfo['hosts'];
51
+ customUploadHosts: MediaConnInfo['hosts']
49
52
  /** time to wait between sending new retry requests */
50
- retryRequestDelayMs: number;
53
+ retryRequestDelayMs: number
51
54
  /** max retry count */
52
- maxMsgRetryCount: number;
55
+ maxMsgRetryCount: number
53
56
  /** time to wait for the generation of the next QR in ms */
54
- qrTimeout?: number;
57
+ qrTimeout?: number
55
58
  /** provide an auth state object to maintain the auth state */
56
- auth: AuthenticationState;
59
+ auth: AuthenticationState
57
60
  /** manage history processing with this control; by default will sync up everything */
58
- shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
61
+ shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean
59
62
  /** transaction capability options for SignalKeyStore */
60
- transactionOpts: TransactionCapabilityOptions;
63
+ transactionOpts: TransactionCapabilityOptions
61
64
  /** marks the client as online whenever the socket successfully connects */
62
- markOnlineOnConnect: boolean;
63
- /** alphanumeric country code (USA -> US) for the number used */
64
- countryCode: string;
65
+ markOnlineOnConnect: boolean
66
+
65
67
  /** provide a cache to store media, so does not have to be re-uploaded */
66
- mediaCache?: CacheStore;
68
+ mediaCache?: CacheStore
67
69
  /**
68
70
  * map to store the retry counts for failed messages;
69
71
  * used to determine whether to retry a message or not */
70
- msgRetryCounterCache?: CacheStore;
72
+ msgRetryCounterCache?: CacheStore
71
73
  /** provide a cache to store a user's device list */
72
- userDevicesCache?: CacheStore;
74
+ userDevicesCache?: CacheStore
73
75
  /** cache to store call offers */
74
- callOfferCache?: CacheStore;
75
- /** cache to track placeholder resends */
76
- placeholderResendCache?: CacheStore;
76
+ callOfferCache?: CacheStore
77
77
  /** width for link preview images */
78
- linkPreviewImageThumbnailWidth: number;
78
+ linkPreviewImageThumbnailWidth: number
79
79
  /** Should Baileys ask the phone for full history, will be received async */
80
- syncFullHistory: boolean;
80
+ syncFullHistory: boolean
81
81
  /** Should baileys fire init queries automatically, default true */
82
- fireInitQueries: boolean;
82
+ fireInitQueries: boolean
83
83
  /**
84
84
  * generate a high quality link preview,
85
85
  * entails uploading the jpegThumbnail to WA
86
86
  * */
87
- generateHighQualityLinkPreview: boolean;
87
+ generateHighQualityLinkPreview: boolean
88
+
88
89
  /**
89
90
  * Returns if a jid should be ignored,
90
91
  * no event for that jid will be triggered.
91
92
  * Messages from that jid will also not be decrypted
92
93
  * */
93
- shouldIgnoreJid: (jid: string) => boolean | undefined;
94
+ shouldIgnoreJid: (jid: string) => boolean | undefined
95
+
94
96
  /**
95
97
  * Optionally patch the message before sending out
96
98
  * */
97
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
99
+ patchMessageBeforeSending: (
100
+ msg: proto.IMessage,
101
+ recipientJids: string[],
102
+ ) => Promise<proto.IMessage> | proto.IMessage
103
+
98
104
  /** verify app state MACs */
99
105
  appStateMacVerification: {
100
- patch: boolean;
101
- snapshot: boolean;
102
- };
106
+ patch: boolean
107
+ snapshot: boolean
108
+ }
109
+
103
110
  /** options for axios */
104
- options: AxiosRequestConfig<{}>;
111
+ options: AxiosRequestConfig<{}>
105
112
  /**
106
113
  * fetch a message from your store
107
114
  * implement this so that messages failed to send
108
115
  * (solves the "this message can take a while" issue) can be retried
109
116
  * */
110
- getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
111
- /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
112
- cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
113
- makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
117
+ getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>
118
+
119
+ makeSignalRepository: (auth: SignalAuthState) => SignalRepository
120
+
114
121
  /** Socket passthrough */
115
- socket?: any;
116
- };
122
+ socket?: any
123
+ }
@@ -0,0 +1,29 @@
1
+ import { Contact } from './Contact'
2
+
3
+ export type WAConnectionState = 'open' | 'connecting' | 'close'
4
+
5
+ export type ConnectionState = {
6
+ /** connection is now open, connecting or closed */
7
+ connection: WAConnectionState
8
+ /** the error that caused the connection to close */
9
+ lastDisconnect?: {
10
+ error: Error | undefined
11
+ date: Date
12
+ }
13
+ /** is this a new login */
14
+ isNewLogin?: boolean
15
+ /** the current QR code */
16
+ qr?: string
17
+ /** has the device received all pending notifications while it was offline */
18
+ receivedPendingNotifications?: boolean
19
+ /** legacy connection options */
20
+ legacy?: {
21
+ phoneConnected: boolean
22
+ user?: Contact
23
+ }
24
+ /**
25
+ * if the client is shown as an active, online client.
26
+ * If this is false, the primary phone and other devices will receive notifs
27
+ * */
28
+ isOnline?: boolean
29
+ }
@@ -0,0 +1,59 @@
1
+ export * from './Auth'
2
+ export * from './GroupMetadata'
3
+ export * from './Chat'
4
+ export * from './Contact'
5
+ export * from './State'
6
+ export * from './Message'
7
+ export * from './Newsletter'
8
+ export * from './Socket'
9
+ export * from './Events'
10
+ export * from './Product'
11
+ export * from './Call'
12
+ export * from './Signal'
13
+
14
+ import { AuthenticationState } from './Auth'
15
+ import { SocketConfig } from './Socket'
16
+
17
+ export type UserFacingSocketConfig = Partial<SocketConfig> & { auth: AuthenticationState }
18
+
19
+ export enum DisconnectReason {
20
+ connectionClosed = 428,
21
+ connectionLost = 408,
22
+ connectionReplaced = 440,
23
+ timedOut = 408,
24
+ loggedOut = 401,
25
+ badSession = 500,
26
+ restartRequired = 515,
27
+ multideviceMismatch = 411,
28
+ forbidden = 403,
29
+ unavailableService = 503
30
+ }
31
+
32
+ export type WAInitResponse = {
33
+ ref: string
34
+ ttl: number
35
+ status: 200
36
+ }
37
+
38
+ export type WABusinessHoursConfig = {
39
+ day_of_week: string
40
+ mode: string
41
+ open_time?: number
42
+ close_time?: number
43
+ }
44
+
45
+ export type WABusinessProfile = {
46
+ description: string
47
+ email: string | undefined
48
+ business_hours: {
49
+ timezone?: string
50
+ config?: WABusinessHoursConfig[]
51
+ business_config?: WABusinessHoursConfig[]
52
+ }
53
+ website: string[]
54
+ category?: string
55
+ wid?: string
56
+ address?: string
57
+ }
58
+
59
+ export type CurveKeyPair = { private: Uint8Array, public: Uint8Array }