fca-riyad 37.0.0

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 (242) hide show
  1. package/CHANGELOG.md +325 -0
  2. package/DOCS.md +2712 -0
  3. package/README.md +410 -0
  4. package/func/checkUpdate.js +7 -0
  5. package/func/logAdapter.js +33 -0
  6. package/func/logger.js +48 -0
  7. package/index.d.ts +751 -0
  8. package/index.js +22 -0
  9. package/module/config.js +40 -0
  10. package/module/login.js +133 -0
  11. package/module/loginHelper.js +1359 -0
  12. package/module/options.js +44 -0
  13. package/package.json +95 -0
  14. package/src/api/action/addExternalModule.js +25 -0
  15. package/src/api/action/changeAvatar.js +137 -0
  16. package/src/api/action/changeBio.js +75 -0
  17. package/src/api/action/enableAutoSaveAppState.js +73 -0
  18. package/src/api/action/getCurrentUserID.js +7 -0
  19. package/src/api/action/handleFriendRequest.js +57 -0
  20. package/src/api/action/logout.js +76 -0
  21. package/src/api/action/refreshFb_dtsg.js +48 -0
  22. package/src/api/action/setPostReaction.js +106 -0
  23. package/src/api/action/unfriend.js +54 -0
  24. package/src/api/http/httpGet.js +46 -0
  25. package/src/api/http/httpPost.js +52 -0
  26. package/src/api/http/postFormData.js +47 -0
  27. package/src/api/messaging/addUserToGroup.js +68 -0
  28. package/src/api/messaging/changeAdminStatus.js +126 -0
  29. package/src/api/messaging/changeArchivedStatus.js +55 -0
  30. package/src/api/messaging/changeBlockedStatus.js +48 -0
  31. package/src/api/messaging/changeGroupImage.js +91 -0
  32. package/src/api/messaging/changeNickname.js +70 -0
  33. package/src/api/messaging/changeThreadColor.js +79 -0
  34. package/src/api/messaging/changeThreadEmoji.js +111 -0
  35. package/src/api/messaging/createNewGroup.js +88 -0
  36. package/src/api/messaging/createPoll.js +46 -0
  37. package/src/api/messaging/createThemeAI.js +98 -0
  38. package/src/api/messaging/deleteMessage.js +136 -0
  39. package/src/api/messaging/deleteThread.js +56 -0
  40. package/src/api/messaging/editMessage.js +90 -0
  41. package/src/api/messaging/forwardAttachment.js +57 -0
  42. package/src/api/messaging/forwardMessage.js +134 -0
  43. package/src/api/messaging/getEmojiUrl.js +29 -0
  44. package/src/api/messaging/getFriendsList.js +82 -0
  45. package/src/api/messaging/getMessage.js +829 -0
  46. package/src/api/messaging/getThemePictures.js +62 -0
  47. package/src/api/messaging/handleMessageRequest.js +65 -0
  48. package/src/api/messaging/markAsDelivered.js +57 -0
  49. package/src/api/messaging/markAsRead.js +88 -0
  50. package/src/api/messaging/markAsReadAll.js +49 -0
  51. package/src/api/messaging/markAsSeen.js +61 -0
  52. package/src/api/messaging/muteThread.js +50 -0
  53. package/src/api/messaging/pinMessage.js +115 -0
  54. package/src/api/messaging/removeUserFromGroup.js +62 -0
  55. package/src/api/messaging/resolvePhotoUrl.js +43 -0
  56. package/src/api/messaging/scheduler.js +264 -0
  57. package/src/api/messaging/searchForThread.js +53 -0
  58. package/src/api/messaging/sendBroadcast.js +93 -0
  59. package/src/api/messaging/sendMessage.js +269 -0
  60. package/src/api/messaging/sendTypingIndicator.js +74 -0
  61. package/src/api/messaging/sessionGuard.js +130 -0
  62. package/src/api/messaging/setMessageReaction.js +95 -0
  63. package/src/api/messaging/setTitle.js +124 -0
  64. package/src/api/messaging/shareContact.js +49 -0
  65. package/src/api/messaging/threadColors.js +128 -0
  66. package/src/api/messaging/unsendMessage.js +81 -0
  67. package/src/api/messaging/uploadAttachment.js +492 -0
  68. package/src/api/socket/OldMessage.js +186 -0
  69. package/src/api/socket/core/connectMqtt.js +269 -0
  70. package/src/api/socket/core/emitAuth.js +103 -0
  71. package/src/api/socket/core/getSeqID.js +321 -0
  72. package/src/api/socket/core/getTaskResponseData.js +25 -0
  73. package/src/api/socket/core/parseDelta.js +387 -0
  74. package/src/api/socket/detail/buildStream.js +215 -0
  75. package/src/api/socket/detail/constants.js +28 -0
  76. package/src/api/socket/e2ee/crypto.js +173 -0
  77. package/src/api/socket/e2ee/e2ee/crypto.js +173 -0
  78. package/src/api/socket/e2ee/e2ee/index.js +421 -0
  79. package/src/api/socket/e2ee/e2ee/proto/ArmadilloApplication.proto +281 -0
  80. package/src/api/socket/e2ee/e2ee/proto/ArmadilloICDC.proto +14 -0
  81. package/src/api/socket/e2ee/e2ee/proto/ConsumerApplication.proto +232 -0
  82. package/src/api/socket/e2ee/e2ee/proto/MessageApplication.proto +82 -0
  83. package/src/api/socket/e2ee/e2ee/proto/MessageTransport.proto +77 -0
  84. package/src/api/socket/e2ee/e2ee/proto/WACommon.proto +66 -0
  85. package/src/api/socket/e2ee/e2ee/proto/WAMediaTransport.proto +176 -0
  86. package/src/api/socket/e2ee/e2ee/proto/proto-writer.ts +76 -0
  87. package/src/api/socket/e2ee/e2ee/protocol.js +196 -0
  88. package/src/api/socket/e2ee/e2ee/ratchet.js +219 -0
  89. package/src/api/socket/e2ee/e2ee/store.js +182 -0
  90. package/src/api/socket/e2ee/e2ee/vendor/fb-e2ee.cjs +9162 -0
  91. package/src/api/socket/e2ee/e2ee/vendor/proto/ArmadilloApplication.proto +281 -0
  92. package/src/api/socket/e2ee/e2ee/vendor/proto/ArmadilloICDC.proto +14 -0
  93. package/src/api/socket/e2ee/e2ee/vendor/proto/ConsumerApplication.proto +232 -0
  94. package/src/api/socket/e2ee/e2ee/vendor/proto/MessageApplication.proto +82 -0
  95. package/src/api/socket/e2ee/e2ee/vendor/proto/MessageTransport.proto +77 -0
  96. package/src/api/socket/e2ee/e2ee/vendor/proto/WACommon.proto +66 -0
  97. package/src/api/socket/e2ee/e2ee/vendor/proto/WAMediaTransport.proto +176 -0
  98. package/src/api/socket/e2ee/e2ee/vendor/proto/proto-writer.ts +76 -0
  99. package/src/api/socket/e2ee/index.js +437 -0
  100. package/src/api/socket/e2ee/proto/ArmadilloApplication.proto +281 -0
  101. package/src/api/socket/e2ee/proto/ArmadilloICDC.proto +14 -0
  102. package/src/api/socket/e2ee/proto/ConsumerApplication.proto +232 -0
  103. package/src/api/socket/e2ee/proto/MessageApplication.proto +82 -0
  104. package/src/api/socket/e2ee/proto/MessageTransport.proto +77 -0
  105. package/src/api/socket/e2ee/proto/WACommon.proto +66 -0
  106. package/src/api/socket/e2ee/proto/WAMediaTransport.proto +176 -0
  107. package/src/api/socket/e2ee/proto/proto-writer.ts +76 -0
  108. package/src/api/socket/e2ee/protocol.js +196 -0
  109. package/src/api/socket/e2ee/ratchet.js +219 -0
  110. package/src/api/socket/e2ee/store.js +182 -0
  111. package/src/api/socket/e2ee/vendor/fb-e2ee.cjs +9162 -0
  112. package/src/api/socket/e2ee/vendor/proto/ArmadilloApplication.proto +281 -0
  113. package/src/api/socket/e2ee/vendor/proto/ArmadilloICDC.proto +14 -0
  114. package/src/api/socket/e2ee/vendor/proto/ConsumerApplication.proto +232 -0
  115. package/src/api/socket/e2ee/vendor/proto/MessageApplication.proto +82 -0
  116. package/src/api/socket/e2ee/vendor/proto/MessageTransport.proto +77 -0
  117. package/src/api/socket/e2ee/vendor/proto/WACommon.proto +66 -0
  118. package/src/api/socket/e2ee/vendor/proto/WAMediaTransport.proto +176 -0
  119. package/src/api/socket/e2ee/vendor/proto/proto-writer.ts +76 -0
  120. package/src/api/socket/listenE2EE.js +75 -0
  121. package/src/api/socket/listenMqtt.js +388 -0
  122. package/src/api/socket/middleware/index.js +216 -0
  123. package/src/api/socket/sendMessage.js +309 -0
  124. package/src/api/socket/sendMessageMqtt.js +69 -0
  125. package/src/api/threads/getThreadHistory.js +664 -0
  126. package/src/api/threads/getThreadInfo.js +296 -0
  127. package/src/api/threads/getThreadList.js +293 -0
  128. package/src/api/threads/getThreadPictures.js +78 -0
  129. package/src/api/users/getUserID.js +65 -0
  130. package/src/api/users/getUserInfo.js +402 -0
  131. package/src/api/users/getUserInfoV2.js +134 -0
  132. package/src/app/MessengerBot.js +209 -0
  133. package/src/app/MessengerContext.js +32 -0
  134. package/src/app/createFcaClient.js +136 -0
  135. package/src/app/threadInfoRealtimeSync.js +284 -0
  136. package/src/core/sendReqMqtt.js +96 -0
  137. package/src/database/helpers.js +53 -0
  138. package/src/database/models/index.js +88 -0
  139. package/src/database/models/thread.js +50 -0
  140. package/src/database/models/user.js +46 -0
  141. package/src/database/threadData.js +94 -0
  142. package/src/database/userData.js +98 -0
  143. package/src/remote/remoteClient.js +123 -0
  144. package/src/utils/broadcast.js +51 -0
  145. package/src/utils/client.js +10 -0
  146. package/src/utils/constants.js +23 -0
  147. package/src/utils/cookies.js +68 -0
  148. package/src/utils/format/attachment.js +357 -0
  149. package/src/utils/format/cookie.js +9 -0
  150. package/src/utils/format/date.js +50 -0
  151. package/src/utils/format/decode.js +44 -0
  152. package/src/utils/format/delta.js +194 -0
  153. package/src/utils/format/ids.js +64 -0
  154. package/src/utils/format/index.js +64 -0
  155. package/src/utils/format/message.js +88 -0
  156. package/src/utils/format/presence.js +132 -0
  157. package/src/utils/format/readTyp.js +44 -0
  158. package/src/utils/format/thread.js +42 -0
  159. package/src/utils/format/utils.js +141 -0
  160. package/src/utils/headers.js +115 -0
  161. package/src/utils/loginParser/autoLogin.js +125 -0
  162. package/src/utils/loginParser/helpers.js +43 -0
  163. package/src/utils/loginParser/index.js +10 -0
  164. package/src/utils/loginParser/parseAndCheckLogin.js +220 -0
  165. package/src/utils/loginParser/textUtils.js +28 -0
  166. package/src/utils/nexca-logger.js +144 -0
  167. package/src/utils/nexca-utils.js +686 -0
  168. package/src/utils/request/client.js +26 -0
  169. package/src/utils/request/config.js +23 -0
  170. package/src/utils/request/defaults.js +46 -0
  171. package/src/utils/request/helpers.js +46 -0
  172. package/src/utils/request/index.js +17 -0
  173. package/src/utils/request/methods.js +163 -0
  174. package/src/utils/request/proxy.js +21 -0
  175. package/src/utils/request/retry.js +77 -0
  176. package/src/utils/request/sanitize.js +49 -0
  177. package/src/utils/versionCheck.js +47 -0
  178. package/src/vendor/fca-unofficial/.github/workflows/nodejs.yml +26 -0
  179. package/src/vendor/fca-unofficial/.github/workflows/npmpublish.yml +30 -0
  180. package/src/vendor/fca-unofficial/.travis.yml +6 -0
  181. package/src/vendor/fca-unofficial/DOCS.md +1731 -0
  182. package/src/vendor/fca-unofficial/LICENSE-MIT +21 -0
  183. package/src/vendor/fca-unofficial/README.md +225 -0
  184. package/src/vendor/fca-unofficial/index.js +619 -0
  185. package/src/vendor/fca-unofficial/package.json +76 -0
  186. package/src/vendor/fca-unofficial/src/addExternalModule.js +19 -0
  187. package/src/vendor/fca-unofficial/src/addUserToGroup.js +113 -0
  188. package/src/vendor/fca-unofficial/src/changeAdminStatus.js +79 -0
  189. package/src/vendor/fca-unofficial/src/changeArchivedStatus.js +55 -0
  190. package/src/vendor/fca-unofficial/src/changeBio.js +77 -0
  191. package/src/vendor/fca-unofficial/src/changeBlockedStatus.js +47 -0
  192. package/src/vendor/fca-unofficial/src/changeGroupImage.js +129 -0
  193. package/src/vendor/fca-unofficial/src/changeNickname.js +59 -0
  194. package/src/vendor/fca-unofficial/src/changeThreadColor.js +71 -0
  195. package/src/vendor/fca-unofficial/src/changeThreadEmoji.js +55 -0
  196. package/src/vendor/fca-unofficial/src/createNewGroup.js +86 -0
  197. package/src/vendor/fca-unofficial/src/createPoll.js +71 -0
  198. package/src/vendor/fca-unofficial/src/deleteMessage.js +56 -0
  199. package/src/vendor/fca-unofficial/src/deleteThread.js +56 -0
  200. package/src/vendor/fca-unofficial/src/forwardAttachment.js +60 -0
  201. package/src/vendor/fca-unofficial/src/getCurrentUserID.js +7 -0
  202. package/src/vendor/fca-unofficial/src/getEmojiUrl.js +29 -0
  203. package/src/vendor/fca-unofficial/src/getFriendsList.js +84 -0
  204. package/src/vendor/fca-unofficial/src/getThreadHistory.js +645 -0
  205. package/src/vendor/fca-unofficial/src/getThreadHistoryDeprecated.js +93 -0
  206. package/src/vendor/fca-unofficial/src/getThreadInfo.js +201 -0
  207. package/src/vendor/fca-unofficial/src/getThreadInfoDeprecated.js +80 -0
  208. package/src/vendor/fca-unofficial/src/getThreadList.js +238 -0
  209. package/src/vendor/fca-unofficial/src/getThreadListDeprecated.js +75 -0
  210. package/src/vendor/fca-unofficial/src/getThreadPictures.js +79 -0
  211. package/src/vendor/fca-unofficial/src/getUserID.js +66 -0
  212. package/src/vendor/fca-unofficial/src/getUserInfo.js +72 -0
  213. package/src/vendor/fca-unofficial/src/handleFriendRequest.js +61 -0
  214. package/src/vendor/fca-unofficial/src/handleMessageRequest.js +65 -0
  215. package/src/vendor/fca-unofficial/src/httpGet.js +52 -0
  216. package/src/vendor/fca-unofficial/src/httpPost.js +52 -0
  217. package/src/vendor/fca-unofficial/src/listenMqtt.js +788 -0
  218. package/src/vendor/fca-unofficial/src/logout.js +75 -0
  219. package/src/vendor/fca-unofficial/src/markAsDelivered.js +58 -0
  220. package/src/vendor/fca-unofficial/src/markAsRead.js +80 -0
  221. package/src/vendor/fca-unofficial/src/markAsReadAll.js +50 -0
  222. package/src/vendor/fca-unofficial/src/markAsSeen.js +59 -0
  223. package/src/vendor/fca-unofficial/src/muteThread.js +52 -0
  224. package/src/vendor/fca-unofficial/src/removeUserFromGroup.js +79 -0
  225. package/src/vendor/fca-unofficial/src/resolvePhotoUrl.js +45 -0
  226. package/src/vendor/fca-unofficial/src/searchForThread.js +53 -0
  227. package/src/vendor/fca-unofficial/src/sendMessage.js +459 -0
  228. package/src/vendor/fca-unofficial/src/sendTypingIndicator.js +103 -0
  229. package/src/vendor/fca-unofficial/src/setMessageReaction.js +117 -0
  230. package/src/vendor/fca-unofficial/src/setPostReaction.js +76 -0
  231. package/src/vendor/fca-unofficial/src/setTitle.js +86 -0
  232. package/src/vendor/fca-unofficial/src/threadColors.js +57 -0
  233. package/src/vendor/fca-unofficial/src/unfriend.js +52 -0
  234. package/src/vendor/fca-unofficial/src/unsendMessage.js +49 -0
  235. package/src/vendor/fca-unofficial/test/data/shareAttach.js +146 -0
  236. package/src/vendor/fca-unofficial/test/data/something.mov +0 -0
  237. package/src/vendor/fca-unofficial/test/data/test.png +0 -0
  238. package/src/vendor/fca-unofficial/test/data/test.txt +7 -0
  239. package/src/vendor/fca-unofficial/test/example-config.json +18 -0
  240. package/src/vendor/fca-unofficial/test/test-page.js +140 -0
  241. package/src/vendor/fca-unofficial/test/test.js +385 -0
  242. package/src/vendor/fca-unofficial/utils.js +1358 -0
@@ -0,0 +1,66 @@
1
+ syntax = "proto2";
2
+ package WACommon;
3
+
4
+ enum FutureProofBehavior {
5
+ PLACEHOLDER = 0;
6
+ NO_PLACEHOLDER = 1;
7
+ IGNORE = 2;
8
+ }
9
+
10
+ message MessageKey {
11
+ optional string remoteJID = 1;
12
+ optional bool fromMe = 2;
13
+ optional string ID = 3;
14
+ optional string participant = 4;
15
+ }
16
+
17
+ message Command {
18
+ enum CommandType {
19
+ EVERYONE = 1;
20
+ SILENT = 2;
21
+ AI = 3;
22
+ AI_IMAGINE = 4;
23
+ }
24
+
25
+ optional CommandType commandType = 1;
26
+ optional uint32 offset = 2;
27
+ optional uint32 length = 3;
28
+ optional string validationToken = 4;
29
+ }
30
+
31
+ message Mention {
32
+ enum MentionType {
33
+ PROFILE = 0;
34
+ }
35
+
36
+ optional MentionType mentionType = 1;
37
+ optional string mentionedJID = 2;
38
+ optional uint32 offset = 3;
39
+ optional uint32 length = 4;
40
+ }
41
+
42
+ message MessageText {
43
+ optional string text = 1;
44
+ repeated string mentionedJID = 2;
45
+ repeated Command commands = 3;
46
+ repeated Mention mentions = 4;
47
+ }
48
+
49
+ message SubProtocol {
50
+ optional bytes payload = 1;
51
+ optional int32 version = 2;
52
+ }
53
+
54
+ message LimitSharing {
55
+ enum Trigger {
56
+ UNKNOWN = 0;
57
+ CHAT_SETTING = 1;
58
+ BIZ_SUPPORTS_FB_HOSTING = 2;
59
+ UNKNOWN_GROUP = 3;
60
+ }
61
+
62
+ optional bool sharingLimited = 1;
63
+ optional Trigger trigger = 2;
64
+ optional int64 limitSharingSettingTimestamp = 3;
65
+ optional bool initiatedByMe = 4;
66
+ }
@@ -0,0 +1,176 @@
1
+ syntax = "proto2";
2
+ package WAMediaTransport;
3
+
4
+ import "WACommon.proto";
5
+
6
+ message WAMediaTransport {
7
+ message Ancillary {
8
+ message Thumbnail {
9
+ message DownloadableThumbnail {
10
+ optional bytes fileSHA256 = 1;
11
+ optional bytes fileEncSHA256 = 2;
12
+ optional string directPath = 3;
13
+ optional bytes mediaKey = 4;
14
+ optional int64 mediaKeyTimestamp = 5;
15
+ optional string objectID = 6;
16
+ optional bytes thumbnailScansSidecar = 7;
17
+ repeated uint32 thumbnailScanLengths = 8;
18
+ }
19
+
20
+ optional bytes JPEGThumbnail = 1;
21
+ optional DownloadableThumbnail downloadableThumbnail = 2;
22
+ optional uint32 thumbnailWidth = 3;
23
+ optional uint32 thumbnailHeight = 4;
24
+ }
25
+
26
+ optional uint64 fileLength = 1;
27
+ optional string mimetype = 2;
28
+ optional Thumbnail thumbnail = 3;
29
+ optional string objectID = 4;
30
+ }
31
+
32
+ message Integral {
33
+ optional bytes fileSHA256 = 1;
34
+ optional bytes mediaKey = 2;
35
+ optional bytes fileEncSHA256 = 3;
36
+ optional string directPath = 4;
37
+ optional int64 mediaKeyTimestamp = 5;
38
+ }
39
+
40
+ optional Integral integral = 1;
41
+ optional Ancillary ancillary = 2;
42
+ }
43
+
44
+ message ImageTransport {
45
+ message Ancillary {
46
+ enum HdType {
47
+ NONE = 0;
48
+ LQ_4K = 1;
49
+ HQ_4K = 2;
50
+ }
51
+
52
+ optional uint32 height = 1;
53
+ optional uint32 width = 2;
54
+ optional bytes scansSidecar = 3;
55
+ repeated uint32 scanLengths = 4;
56
+ optional bytes midQualityFileSHA256 = 5;
57
+ optional HdType hdType = 6;
58
+ repeated float memoriesConceptScores = 7 [packed=true];
59
+ repeated uint32 memoriesConceptIDs = 8 [packed=true];
60
+ }
61
+
62
+ message Integral {
63
+ optional WAMediaTransport transport = 1;
64
+ }
65
+
66
+ optional Integral integral = 1;
67
+ optional Ancillary ancillary = 2;
68
+ }
69
+
70
+ message VideoTransport {
71
+ message Ancillary {
72
+ enum Attribution {
73
+ NONE = 0;
74
+ GIPHY = 1;
75
+ TENOR = 2;
76
+ }
77
+
78
+ optional uint32 seconds = 1;
79
+ optional WACommon.MessageText caption = 2;
80
+ optional bool gifPlayback = 3;
81
+ optional uint32 height = 4;
82
+ optional uint32 width = 5;
83
+ optional bytes sidecar = 6;
84
+ optional Attribution gifAttribution = 7;
85
+ optional string accessibilityLabel = 8;
86
+ optional bool isHd = 9;
87
+ }
88
+
89
+ message Integral {
90
+ optional WAMediaTransport transport = 1;
91
+ }
92
+
93
+ optional Integral integral = 1;
94
+ optional Ancillary ancillary = 2;
95
+ }
96
+
97
+ message AudioTransport {
98
+ message Ancillary {
99
+ message AvatarAudio {
100
+ enum AnimationsType {
101
+ TALKING_A = 0;
102
+ IDLE_A = 1;
103
+ TALKING_B = 2;
104
+ IDLE_B = 3;
105
+ BACKGROUND = 4;
106
+ }
107
+
108
+ message DownloadableAvatarAnimations {
109
+ optional bytes fileSHA256 = 1;
110
+ optional bytes fileEncSHA256 = 2;
111
+ optional string directPath = 3;
112
+ optional bytes mediaKey = 4;
113
+ optional int64 mediaKeyTimestamp = 5;
114
+ optional string objectID = 6;
115
+ optional AnimationsType animationsType = 7;
116
+ }
117
+
118
+ optional uint32 poseID = 1;
119
+ repeated DownloadableAvatarAnimations avatarAnimations = 2;
120
+ }
121
+
122
+ optional uint32 seconds = 1;
123
+ optional AvatarAudio avatarAudio = 2;
124
+ optional string waveformData = 3;
125
+ optional bytes waveform = 4;
126
+ }
127
+
128
+ message Integral {
129
+ enum AudioFormat {
130
+ UNKNOWN = 0;
131
+ OPUS = 1;
132
+ }
133
+
134
+ optional WAMediaTransport transport = 1;
135
+ optional AudioFormat audioFormat = 2;
136
+ }
137
+
138
+ optional Integral integral = 1;
139
+ optional Ancillary ancillary = 2;
140
+ }
141
+
142
+ message DocumentTransport {
143
+ message Ancillary {
144
+ optional uint32 pageCount = 1;
145
+ }
146
+
147
+ message Integral {
148
+ optional WAMediaTransport transport = 1;
149
+ }
150
+
151
+ optional Integral integral = 1;
152
+ optional Ancillary ancillary = 2;
153
+ }
154
+
155
+ message StickerTransport {
156
+ message Ancillary {
157
+ optional uint32 pageCount = 1;
158
+ optional uint32 height = 2;
159
+ optional uint32 width = 3;
160
+ optional uint32 firstFrameLength = 4;
161
+ optional bytes firstFrameSidecar = 5;
162
+ optional string mustacheText = 6;
163
+ optional bool isThirdParty = 7;
164
+ optional string receiverFetchID = 8;
165
+ optional string accessibilityLabel = 9;
166
+ }
167
+
168
+ message Integral {
169
+ optional WAMediaTransport transport = 1;
170
+ optional bool isAnimated = 2;
171
+ optional string receiverFetchID = 3;
172
+ }
173
+
174
+ optional Integral integral = 1;
175
+ optional Ancillary ancillary = 2;
176
+ }
@@ -0,0 +1,76 @@
1
+ /** Minimal protobuf writer - only what we need */
2
+ export class ProtoWriter {
3
+ private chunks: Buffer[] = [];
4
+
5
+ private encodeVarint(value: number): Buffer {
6
+ const bytes: number[] = [];
7
+ let v = value >>> 0;
8
+ while (v > 127) {
9
+ bytes.push((v & 0x7f) | 0x80);
10
+ v >>>= 7;
11
+ }
12
+ bytes.push(v);
13
+ return Buffer.from(bytes);
14
+ }
15
+
16
+ private fieldHeader(fieldNum: number, wireType: number): Buffer {
17
+ return this.encodeVarint((fieldNum << 3) | wireType);
18
+ }
19
+
20
+ /** Wire type 0 (varint) but supports bigint */
21
+ private encodeVarintBigInt(value: bigint): Buffer {
22
+ const bytes: number[] = [];
23
+ let v = value;
24
+ while (v > 127n) {
25
+ bytes.push(Number((v & 0x7fn) | 0x80n));
26
+ v >>= 7n;
27
+ }
28
+ bytes.push(Number(v));
29
+ return Buffer.from(bytes);
30
+ }
31
+
32
+ /** Wire type 0 (varint) for uint64 fields */
33
+ uint64_varint(fieldNum: number, value: bigint): this {
34
+ this.chunks.push(this.fieldHeader(fieldNum, 0));
35
+ this.chunks.push(this.encodeVarintBigInt(value));
36
+ return this;
37
+ }
38
+
39
+ /** Wire type 2 (length-delimited) - bytes, string, embedded message */
40
+ bytes(fieldNum: number, data: Uint8Array): this {
41
+ const d = Buffer.from(data);
42
+ this.chunks.push(this.fieldHeader(fieldNum, 2));
43
+ this.chunks.push(this.encodeVarint(d.length));
44
+ this.chunks.push(d);
45
+ return this;
46
+ }
47
+
48
+ string(fieldNum: number, value: string): this {
49
+ return this.bytes(fieldNum, Buffer.from(value, "utf8"));
50
+ }
51
+
52
+ /** Wire type 0 (varint) */
53
+ varint(fieldNum: number, value: number): this {
54
+ this.chunks.push(this.fieldHeader(fieldNum, 0));
55
+ this.chunks.push(this.encodeVarint(value));
56
+ return this;
57
+ }
58
+
59
+ /** Wire type 0, bool */
60
+ bool(fieldNum: number, value: boolean): this {
61
+ return this.varint(fieldNum, value ? 1 : 0);
62
+ }
63
+
64
+ /** Wire type 1 (64-bit fixed) - uint64 */
65
+ uint64(fieldNum: number, value: bigint): this {
66
+ const buf = Buffer.alloc(8);
67
+ buf.writeBigUInt64LE(value);
68
+ this.chunks.push(this.fieldHeader(fieldNum, 1));
69
+ this.chunks.push(buf);
70
+ return this;
71
+ }
72
+
73
+ build(): Buffer {
74
+ return Buffer.concat(this.chunks);
75
+ }
76
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ var logger = require("../../utils/nexca-logger");
4
+ var EventEmitter = require("events");
5
+
6
+ /**
7
+ * listenE2EE — merges E2EE messages into the same event stream as MQTT.
8
+ *
9
+ * Usage (identical to api.listen):
10
+ * api.listenE2EE(callback) // Node-style callback(err, event)
11
+ * api.listenE2EE() // returns MessageEmitter
12
+ *
13
+ * Combines:
14
+ * - Regular MQTT messages (from api.listenMqtt)
15
+ * - E2EE encrypted messages (received via NEXCA native Noise WebSocket)
16
+ *
17
+ * All events share the same shape (type, senderID, threadID, body, etc.),
18
+ * with E2EE events carrying `isE2EE: true`.
19
+ */
20
+ module.exports = function (defaultFuncs, api, ctx) {
21
+ return function listenE2EE(callback) {
22
+ class CombinedEmitter extends EventEmitter {
23
+ stopListening(cb) {
24
+ if (api._mqttEmitter && typeof api._mqttEmitter.stopListening === "function") {
25
+ api._mqttEmitter.stopListening(cb);
26
+ } else if (typeof cb === "function") {
27
+ cb([]);
28
+ }
29
+ if (ctx.e2ee && ctx.e2ee.connected) {
30
+ ctx.e2ee.disconnect().catch(() => {});
31
+ }
32
+ }
33
+ stopListeningAsync() {
34
+ return new Promise(res => this.stopListening(res));
35
+ }
36
+ }
37
+
38
+ var emitter = new CombinedEmitter();
39
+
40
+ var isCallbackMode = typeof callback === "function";
41
+ var globalCallback = isCallbackMode ? callback : function (err, event) {
42
+ if (err) return emitter.emit("error", err);
43
+ emitter.emit("message", event);
44
+ };
45
+
46
+ // Start regular MQTT listener
47
+ var mqttEmitter = (api._listenMqttRaw || api.listenMqtt)(globalCallback);
48
+ api._mqttEmitter = mqttEmitter;
49
+
50
+ // Hook E2EE incoming messages (NEXCA native Noise WebSocket)
51
+ var e2ee = api.e2ee || ctx.e2ee;
52
+ if (!e2ee || !e2ee.isConnected()) {
53
+ logger.warn(
54
+ "listenE2EE",
55
+ "E2EE not connected. E2EE messages will not be received. " +
56
+ "Call api.connectE2EE() before listenE2EE() to enable encrypted message reception."
57
+ );
58
+ } else {
59
+ e2ee.onMessage(function (err, event) {
60
+ if (err) return globalCallback(err, null);
61
+ if (!event) return;
62
+
63
+ // Filter self-messages unless selfListen is enabled
64
+ if (!ctx.globalOptions.selfListen && event.senderID === ctx.userID) return;
65
+
66
+ event.isE2EE = true;
67
+ globalCallback(null, event);
68
+ });
69
+
70
+ logger.success("listenE2EE", "Combined MQTT + E2EE (Signal/Noise) listener active.");
71
+ }
72
+
73
+ return emitter;
74
+ };
75
+ };