fca-smart-shankar 10.9.1 → 12.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 (363) hide show
  1. package/.cache/nix/binary-cache-v6.sqlite +0 -0
  2. package/.cache/replit/env/latest +117 -48
  3. package/.cache/replit/env/latest.json +1 -1
  4. package/.cache/replit/modules/nix.res +1 -0
  5. package/.cache/replit/modules/nodejs-20.res +1 -0
  6. package/.cache/replit/nix/env.json +1 -0
  7. package/.cache/typescript/5.6/node_modules/.package-lock.json +171 -0
  8. package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +21 -0
  9. package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +15 -0
  10. package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +1365 -0
  11. package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +25 -0
  12. package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +21 -0
  13. package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +48 -0
  14. package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +29 -0
  15. package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +35 -0
  16. package/.cache/typescript/5.6/node_modules/@types/cheerio/LICENSE +21 -0
  17. package/.cache/typescript/5.6/node_modules/@types/cheerio/README.md +15 -0
  18. package/.cache/typescript/5.6/node_modules/@types/cheerio/index.d.ts +318 -0
  19. package/.cache/typescript/5.6/node_modules/@types/cheerio/package.json +71 -0
  20. package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +21 -0
  21. package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +15 -0
  22. package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +2929 -0
  23. package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +56 -0
  24. package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +21 -0
  25. package/.cache/typescript/5.6/node_modules/@types/node/README.md +15 -0
  26. package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +8 -0
  27. package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +1040 -0
  28. package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +541 -0
  29. package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +385 -0
  30. package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +1933 -0
  31. package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +1549 -0
  32. package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +579 -0
  33. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
  34. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +9 -0
  35. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
  36. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  37. package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +452 -0
  38. package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +19 -0
  39. package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +4475 -0
  40. package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +596 -0
  41. package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
  42. package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +476 -0
  43. package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +865 -0
  44. package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +124 -0
  45. package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +170 -0
  46. package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +931 -0
  47. package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +1275 -0
  48. package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +4396 -0
  49. package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +566 -0
  50. package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +21 -0
  51. package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +1958 -0
  52. package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +2558 -0
  53. package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +543 -0
  54. package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +92 -0
  55. package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +3966 -0
  56. package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +402 -0
  57. package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +1001 -0
  58. package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +495 -0
  59. package/.cache/typescript/5.6/node_modules/@types/node/package.json +220 -0
  60. package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +200 -0
  61. package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +965 -0
  62. package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +1963 -0
  63. package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +117 -0
  64. package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +153 -0
  65. package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +162 -0
  66. package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +589 -0
  67. package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +430 -0
  68. package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +153 -0
  69. package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +213 -0
  70. package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +12 -0
  71. package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +90 -0
  72. package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +609 -0
  73. package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +1726 -0
  74. package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +67 -0
  75. package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +2248 -0
  76. package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +97 -0
  77. package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +240 -0
  78. package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +1226 -0
  79. package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +197 -0
  80. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
  81. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
  82. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +92 -0
  83. package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +208 -0
  84. package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +972 -0
  85. package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +2371 -0
  86. package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +808 -0
  87. package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +976 -0
  88. package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +181 -0
  89. package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +745 -0
  90. package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +539 -0
  91. package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +21 -0
  92. package/.cache/typescript/5.6/node_modules/@types/request/README.md +15 -0
  93. package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +395 -0
  94. package/.cache/typescript/5.6/node_modules/@types/request/package.json +70 -0
  95. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +21 -0
  96. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +15 -0
  97. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +321 -0
  98. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +35 -0
  99. package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +21 -0
  100. package/.cache/typescript/5.6/node_modules/asynckit/README.md +233 -0
  101. package/.cache/typescript/5.6/node_modules/asynckit/bench.js +76 -0
  102. package/.cache/typescript/5.6/node_modules/asynckit/index.js +6 -0
  103. package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +29 -0
  104. package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +34 -0
  105. package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +26 -0
  106. package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +75 -0
  107. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  108. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +25 -0
  109. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +25 -0
  110. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  111. package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +37 -0
  112. package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +141 -0
  113. package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +29 -0
  114. package/.cache/typescript/5.6/node_modules/asynckit/package.json +63 -0
  115. package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +43 -0
  116. package/.cache/typescript/5.6/node_modules/asynckit/serial.js +17 -0
  117. package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +75 -0
  118. package/.cache/typescript/5.6/node_modules/asynckit/stream.js +21 -0
  119. package/.cache/typescript/5.6/node_modules/combined-stream/License +19 -0
  120. package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +138 -0
  121. package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +208 -0
  122. package/.cache/typescript/5.6/node_modules/combined-stream/package.json +25 -0
  123. package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +17 -0
  124. package/.cache/typescript/5.6/node_modules/delayed-stream/License +19 -0
  125. package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +7 -0
  126. package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +141 -0
  127. package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  128. package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +27 -0
  129. package/.cache/typescript/5.6/node_modules/form-data/License +19 -0
  130. package/.cache/typescript/5.6/node_modules/form-data/Readme.md +350 -0
  131. package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +51 -0
  132. package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +2 -0
  133. package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +484 -0
  134. package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +10 -0
  135. package/.cache/typescript/5.6/node_modules/form-data/package.json +72 -0
  136. package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +507 -0
  137. package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +23 -0
  138. package/.cache/typescript/5.6/node_modules/mime-db/README.md +100 -0
  139. package/.cache/typescript/5.6/node_modules/mime-db/db.json +8519 -0
  140. package/.cache/typescript/5.6/node_modules/mime-db/index.js +12 -0
  141. package/.cache/typescript/5.6/node_modules/mime-db/package.json +60 -0
  142. package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +397 -0
  143. package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +23 -0
  144. package/.cache/typescript/5.6/node_modules/mime-types/README.md +113 -0
  145. package/.cache/typescript/5.6/node_modules/mime-types/index.js +188 -0
  146. package/.cache/typescript/5.6/node_modules/mime-types/package.json +44 -0
  147. package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +21 -0
  148. package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +584 -0
  149. package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +187 -0
  150. package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +65 -0
  151. package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +51 -0
  152. package/.cache/typescript/5.6/node_modules/types-registry/README.md +2 -0
  153. package/.cache/typescript/5.6/node_modules/types-registry/index.json +1 -0
  154. package/.cache/typescript/5.6/node_modules/types-registry/package.json +20 -0
  155. package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +21 -0
  156. package/.cache/typescript/5.6/node_modules/undici-types/README.md +6 -0
  157. package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +31 -0
  158. package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +43 -0
  159. package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +29 -0
  160. package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +36 -0
  161. package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +108 -0
  162. package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +34 -0
  163. package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +21 -0
  164. package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +28 -0
  165. package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
  166. package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +255 -0
  167. package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
  168. package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +149 -0
  169. package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +61 -0
  170. package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +209 -0
  171. package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +39 -0
  172. package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +54 -0
  173. package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +108 -0
  174. package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  175. package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +7 -0
  176. package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +15 -0
  177. package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +4 -0
  178. package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +71 -0
  179. package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +17 -0
  180. package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +50 -0
  181. package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +25 -0
  182. package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +12 -0
  183. package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  184. package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +25 -0
  185. package/.cache/typescript/5.6/node_modules/undici-types/package.json +55 -0
  186. package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +33 -0
  187. package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +19 -0
  188. package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +39 -0
  189. package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +28 -0
  190. package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +60 -0
  191. package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +8 -0
  192. package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +116 -0
  193. package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +18 -0
  194. package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +222 -0
  195. package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +150 -0
  196. package/.cache/typescript/5.6/package-lock.json +183 -0
  197. package/.cache/typescript/5.6/package.json +1 -0
  198. package/.replit +3 -3
  199. package/LICENSE-MIT +21 -0
  200. package/README.md +176 -30
  201. package/index.js +452 -425
  202. package/package.json +39 -90
  203. package/replit.nix +3 -0
  204. package/src/addExternalModule.js +14 -5
  205. package/src/addUserToGroup.js +57 -21
  206. package/src/changeAdminStatus.js +46 -22
  207. package/src/changeArchivedStatus.js +26 -12
  208. package/src/changeAvatar.js +136 -0
  209. package/src/{changeAvt.js → changeAvatarV2.js} +4 -3
  210. package/src/changeBio.js +26 -15
  211. package/src/changeBlockedStatus.js +22 -9
  212. package/src/changeBlockedStatusMqtt.js +80 -0
  213. package/src/changeCover.js +73 -0
  214. package/src/changeGroupImage.js +55 -26
  215. package/src/changeName.js +79 -0
  216. package/src/changeNickname.js +28 -14
  217. package/src/changeThreadColor.js +22 -19
  218. package/src/changeThreadEmoji.js +25 -12
  219. package/src/changeUsername.js +59 -0
  220. package/src/createCommentPost.js +230 -0
  221. package/src/createNewGroup.js +36 -18
  222. package/src/createPoll.js +28 -17
  223. package/src/createPost.js +276 -0
  224. package/src/data/getThreadInfo.json +1 -0
  225. package/src/deleteMessage.js +25 -14
  226. package/src/deleteThread.js +26 -13
  227. package/src/editMessage.js +56 -50
  228. package/src/editMessageOld.js +67 -0
  229. package/src/follow.js +74 -0
  230. package/src/forwardAttachment.js +28 -16
  231. package/src/getAccess.js +112 -0
  232. package/src/getAvatarUser.js +78 -0
  233. package/src/getCurrentUserID.js +3 -3
  234. package/src/getEmojiUrl.js +10 -8
  235. package/src/getFriendsList.js +25 -15
  236. package/src/getMessage.js +813 -81
  237. package/src/getRegion.js +7 -0
  238. package/src/getThreadHistory.js +241 -98
  239. package/src/getThreadHistoryDeprecated.js +93 -0
  240. package/src/getThreadInfo.js +90 -287
  241. package/src/getThreadInfoDeprecated.js +80 -0
  242. package/src/getThreadList.js +215 -158
  243. package/src/getThreadListDeprecated.js +75 -0
  244. package/src/getThreadPictures.js +40 -20
  245. package/src/getUID.js +113 -50
  246. package/src/getUserID.js +18 -14
  247. package/src/getUserInfo.js +35 -75
  248. package/src/handleFriendRequest.js +25 -14
  249. package/src/handleMessageRequest.js +37 -21
  250. package/src/httpGet.js +36 -20
  251. package/src/httpPost.js +37 -20
  252. package/src/httpPostFormData.js +53 -24
  253. package/src/listenMqtt.js +413 -666
  254. package/src/listenNotification.js +85 -0
  255. package/src/logout.js +24 -17
  256. package/src/markAsDelivered.js +23 -16
  257. package/src/markAsRead.js +43 -28
  258. package/src/markAsReadAll.js +22 -15
  259. package/src/markAsSeen.js +29 -19
  260. package/src/muteThread.js +18 -13
  261. package/src/pinMessage.js +59 -0
  262. package/src/refreshFb_dtsg.js +89 -0
  263. package/src/removeUserFromGroup.js +48 -18
  264. package/src/resolvePhotoUrl.js +22 -14
  265. package/src/searchForThread.js +23 -13
  266. package/src/searchStickers.js +53 -0
  267. package/src/sendMessage.js +180 -122
  268. package/src/sendMessageMqtt.js +322 -0
  269. package/src/sendTypingIndicator.js +42 -21
  270. package/src/sendTypingIndicatorV2.js +28 -0
  271. package/src/setMessageReaction.js +33 -20
  272. package/src/setMessageReactionMqtt.js +62 -0
  273. package/src/setPostReaction.js +105 -95
  274. package/src/setProfileGuard.js +45 -0
  275. package/src/setStoryReaction.js +64 -0
  276. package/src/setTitle.js +35 -19
  277. package/src/shareContact.js +92 -37
  278. package/src/shareLink.js +6 -5
  279. package/src/stopListenMqtt.js +23 -0
  280. package/src/threadColors.js +110 -18
  281. package/src/unfriend.js +20 -11
  282. package/src/unsendMessage.js +31 -34
  283. package/src/uploadAttachment.js +94 -0
  284. package/test/test-page.js +1 -1
  285. package/test/test.js +1 -1
  286. package/utils.js +1237 -2935
  287. package/.cache/replit/modules/nodejs-14.res +0 -1
  288. package/.cache/replit/modules/web.res +0 -1
  289. package/.cache/typescript/5.5/package.json +0 -1
  290. package/.config/configstore/update-notifier-npm.json +0 -4
  291. package/.gitattributes +0 -2
  292. package/.upm/store.json +0 -1
  293. package/Extra/Balancer.js +0 -49
  294. package/Extra/Bypass/956/index.js +0 -234
  295. package/Extra/Bypass/test/aaaa.json +0 -170
  296. package/Extra/Bypass/test/index.js +0 -188
  297. package/Extra/Database/index.js +0 -469
  298. package/Extra/ExtraAddons.js +0 -82
  299. package/Extra/ExtraFindUID.js +0 -62
  300. package/Extra/ExtraGetThread.js +0 -365
  301. package/Extra/ExtraScreenShot.js +0 -430
  302. package/Extra/ExtraUptimeRobot.js +0 -38
  303. package/Extra/Html/Classic/script.js +0 -119
  304. package/Extra/Html/Classic/style.css +0 -8
  305. package/Extra/Security/Base/Step_1.js +0 -6
  306. package/Extra/Security/Base/Step_2.js +0 -22
  307. package/Extra/Security/Base/Step_3.js +0 -22
  308. package/Extra/Security/Base/index.js +0 -191
  309. package/Extra/Security/Index.js +0 -5
  310. package/Extra/Security/Step_1.js +0 -6
  311. package/Extra/Security/Step_2.js +0 -22
  312. package/Extra/Security/Step_3.js +0 -22
  313. package/Extra/Src/Change_Environment.js +0 -24
  314. package/Extra/Src/Check_Update.js +0 -67
  315. package/Extra/Src/History.js +0 -115
  316. package/Extra/Src/Instant_Update.js +0 -65
  317. package/Extra/Src/Last-Run.js +0 -65
  318. package/Extra/Src/Premium.js +0 -81
  319. package/Extra/Src/Release_Memory.js +0 -160
  320. package/Extra/Src/Websocket.js +0 -213
  321. package/Extra/Src/image/checkmate.jpg +0 -0
  322. package/Extra/Src/test.js +0 -28
  323. package/Extra/Src/uuid.js +0 -137
  324. package/Func/AcceptAgreement.js +0 -31
  325. package/Func/ClearCache.js +0 -64
  326. package/Func/ReportV1.js +0 -54
  327. package/LICENSE +0 -678
  328. package/Language/index.json +0 -228
  329. package/Main.js +0 -1444
  330. package/SECURITY.md +0 -18
  331. package/broadcast.js +0 -44
  332. package/logger.js +0 -66
  333. package/src/Dev_Horizon_Data.js +0 -125
  334. package/src/Dev_getThreadInfoOLD.js +0 -422
  335. package/src/Dev_shareTest2.js +0 -68
  336. package/src/Dev_shareTest3.js +0 -71
  337. package/src/Premium.js +0 -25
  338. package/src/Screenshot.js +0 -83
  339. package/src/getAccessToken.js +0 -28
  340. package/src/getThreadInfoOLD.js +0 -422
  341. package/src/getThreadMain.js +0 -220
  342. package/src/getUserInfoMain.js +0 -65
  343. package/src/getUserInfoV2.js +0 -32
  344. package/src/getUserInfoV3.js +0 -63
  345. package/src/getUserInfoV4.js +0 -55
  346. package/src/getUserInfoV5.js +0 -61
  347. package/src/listenMqttV1.js +0 -846
  348. package/src/sendMqttMessage.js +0 -71
  349. package/src/unsendMqttMessage.js +0 -66
  350. package/test/Database_Test.js +0 -4
  351. package/test/Db2.js +0 -530
  352. package/test/Shankar_Database/A_README.md +0 -1
  353. package/test/Shankar_Database/Database.db +0 -0
  354. package/test/data/shareAttach.js +0 -146
  355. package/test/data/something.mov +0 -0
  356. package/test/data/test.png +0 -0
  357. package/test/data/test.txt +0 -7
  358. package/test/env/.env +0 -0
  359. package/test/example-db.db +0 -0
  360. package/test/memoryleak.js +0 -18
  361. package/test/testname.js +0 -1342
  362. package/test/testv2.js +0 -3
  363. /package/{Extra/Security/AES_256_GCM/index.js → .cache/nix/binary-cache-v6.sqlite-journal} +0 -0
package/utils.js CHANGED
@@ -1,3077 +1,1379 @@
1
- // @ts-nocheck
2
- /* eslint-disable no-undef */
3
-
4
- /* eslint-disable no-prototype-builtins */
5
1
 
2
+ /* eslint-disable no-prototype-builtins */
6
3
  "use strict";
7
- var url = require("url");
8
- var log = require("npmlog");
9
- var stream = require("stream");
10
- var bluebird = require("bluebird");
11
- var querystring = require("querystring");
12
- var request = bluebird.promisify(require("request").defaults({ jar: true }));
13
-
14
- /**
15
- * @param {any} url
16
- */
17
-
18
- function setProxy(url) {
19
- if (typeof url == "undefined") return request = bluebird.promisify(require("request").defaults({ jar: true }));
20
- return request = bluebird.promisify(require("request").defaults({ jar: true, proxy: url }));
21
- }
22
4
 
23
- /**
24
- * @param {string | URL} url
25
- * @param {{ userAgent: any; }} options
26
- * @param {{ region: any; }} [ctx]
27
- * @param {undefined} [customHeader]
28
- */
5
+ let request = require("request").defaults({ jar: true });
6
+ const stream = require("stream");
7
+ const querystring = require("querystring");
8
+ const url = require("url");
9
+
10
+ function setProxy(proxy) {
11
+ if (typeof proxy == 'string')
12
+ request = require("request").defaults({ jar: !0, proxy });
13
+ else
14
+ request = require('request').defaults({ jar: !0 });
15
+ return;
16
+ }
29
17
 
30
18
  function getHeaders(url, options, ctx, customHeader) {
31
- var headers = {
32
- "Content-Type": "application/x-www-form-urlencoded",
33
- Referer: "https://www.facebook.com/",
34
- Host: url.replace("https://", "").split("/")[0],
35
- Origin: "https://www.facebook.com",
36
- "user-agent": (options.userAgent || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"),
37
- Connection: "keep-alive",
38
- "sec-fetch-site": 'same-origin',
39
- "sec-fetch-mode": 'cors'
40
- };
41
- if (customHeader) Object.assign(headers, customHeader);
42
- if (ctx && ctx.region) headers["X-MSGR-Region"] = ctx.region;
43
-
44
- return headers;
19
+ var headers = {
20
+ "Content-Type": "application/x-www-form-urlencoded",
21
+ Referer: "https://www.facebook.com/",
22
+ Host: new URL(url).hostname,
23
+ Origin: "https://www.facebook.com",
24
+ "User-Agent": options.userAgent,
25
+ Connection: "keep-alive",
26
+ "Sec-Fetch-Site": "same-origin",
27
+ 'Sec-Fetch-User': '?1'
28
+ };
29
+ if (customHeader) {
30
+ Object.assign(headers, customHeader);
31
+ if (customHeader.noRef)
32
+ delete headers.Referer;
33
+ }
34
+ if (ctx && ctx.region)
35
+ headers["X-MSGR-Region"] = ctx.region;
36
+
37
+ return headers;
45
38
  }
46
39
 
47
- /**
48
- * @param {{ _read: any; _readableState: any; }} obj
49
- */
50
-
51
40
  function isReadableStream(obj) {
52
- return (
53
- obj instanceof stream.Stream &&
54
- (getType(obj._read) === "Function" ||
55
- getType(obj._read) === "AsyncFunction") &&
56
- getType(obj._readableState) === "Object"
57
- );
41
+ return obj instanceof stream.Stream && typeof obj._read == "function" && getType(obj._readableState) == "Object";
58
42
  }
59
43
 
60
- /**
61
- * @param {any} url
62
- * @param {any} jar
63
- * @param {{ [x: string]: any; fb_dtsg?: any; jazoest?: any; hasOwnProperty?: any; }} qs
64
- * @param {any} options
65
- * @param {any} ctx
66
- */
67
-
68
- function get(url, jar, qs, options, ctx) {
69
- // I'm still confused about this
70
- if (getType(qs) === "Object")
71
- for (var prop in qs)
72
- if (qs.hasOwnProperty(prop) && getType(qs[prop]) === "Object") qs[prop] = JSON.stringify(qs[prop]);
73
- var op = {
74
- headers: getHeaders(url, options, ctx),
75
- timeout: 60000,
76
- qs: qs,
77
- url: url,
78
- method: "GET",
79
- jar: jar,
80
- gzip: true
81
- };
82
-
83
- return request(op).then(function(res) {
84
- return res;
85
- });
44
+ function get(url, jar, qs, options, ctx, customHeader) {
45
+ let callback;
46
+ var returnPromise = new Promise(function (resolve, reject) {
47
+ callback = (error, res) => error ? reject(error) : resolve(res);
48
+ });
49
+ if (getType(qs) == "Object")
50
+ for (let prop in qs) {
51
+ if (getType(qs[prop]) == 'Object')
52
+ qs[prop] = JSON.stringify(qs[prop]);
53
+ }
54
+ var op = {
55
+ headers: getHeaders(url, options, ctx, customHeader),
56
+ timeout: 60000,
57
+ qs,
58
+ jar,
59
+ gzip: !0
60
+ }
61
+
62
+ request.get(url, op, callback);
63
+
64
+ return returnPromise;
86
65
  }
87
66
 
88
67
  function post(url, jar, form, options, ctx, customHeader) {
89
- var op = {
90
- headers: getHeaders(url, options),
91
- timeout: 60000,
92
- url: url,
93
- method: "POST",
94
- form: form,
95
- jar: jar,
96
- gzip: true
97
- };
98
- return request(op).then(function(res) {
99
- return res;
100
- });
68
+ let callback;
69
+ var returnPromise = new Promise(function (resolve, reject) {
70
+ callback = (error, res) => error ? reject(error) : resolve(res);
71
+ });
72
+
73
+ var op = {
74
+ headers: getHeaders(url, options, ctx, customHeader),
75
+ timeout: 60000,
76
+ form,
77
+ jar,
78
+ gzip: !0
79
+ }
80
+
81
+ request.post(url, op, callback);
82
+
83
+ return returnPromise;
101
84
  }
102
85
 
103
- /**
104
- * @param {any} url
105
- * @param {any} jar
106
- * @param {{ __user: any; __req: string; __rev: any; __a: number;
107
- // __af: siteData.features,
108
- fb_dtsg: any; jazoest: any; }} form
109
- * @param {{ __user: any; __req: string; __rev: any; __a: number;
110
- // __af: siteData.features,
111
- fb_dtsg: any; jazoest: any; }} qs
112
- * @param {any} options
113
- * @param {any} ctx
114
- */
115
-
116
86
  function postFormData(url, jar, form, qs, options, ctx) {
117
- var headers = getHeaders(url, options, ctx);
118
- headers["Content-Type"] = "multipart/form-data";
119
- var op = {
120
- headers: headers,
121
- timeout: 60000,
122
- url: url,
123
- method: "POST",
124
- formData: form,
125
- qs: qs,
126
- jar: jar,
127
- gzip: true
128
- };
129
-
130
- return request(op).then(function(res) {
131
- return res;
132
- });
87
+ let callback;
88
+ var returnPromise = new Promise(function (resolve, reject) {
89
+ callback = (error, res) => error ? reject(error) : resolve(res);
90
+ });
91
+ if (getType(qs) == "Object")
92
+ for (let prop in qs) {
93
+ if (getType(qs[prop]) == 'Object')
94
+ qs[prop] = JSON.stringify(qs[prop]);
95
+ }
96
+ var op = {
97
+ headers: getHeaders(url, options, ctx, {
98
+ 'Content-Type': 'multipart/form-data'
99
+ }),
100
+ timeout: 60000,
101
+ formData: form,
102
+ qs,
103
+ jar,
104
+ gzip: !0
105
+ }
106
+
107
+ request.post(url, op, callback);
108
+
109
+ return returnPromise;
133
110
  }
134
111
 
135
- /**
136
- * @param {string | number | any[]} val
137
- * @param {number} [len]
138
- */
139
-
140
112
  function padZeros(val, len) {
141
- val = String(val);
142
- len = len || 2;
143
- while (val.length < len) val = "0" + val;
144
- return val;
113
+ val = String(val);
114
+ len = len || 2;
115
+ while (val.length < len) val = "0" + val;
116
+ return val;
145
117
  }
146
118
 
147
- /**
148
- * @param {any} clientID
149
- */
150
-
151
119
  function generateThreadingID(clientID) {
152
- var k = Date.now();
153
- var l = Math.floor(Math.random() * 4294967295);
154
- var m = clientID;
155
- return "<" + k + ":" + l + "-" + m + "@mail.projektitan.com>";
120
+ const k = Date.now();
121
+ const l = Math.floor(Math.random() * 4294967295);
122
+ const m = clientID;
123
+ return "<" + k + ":" + l + "-" + m + "@mail.projektitan.com>";
156
124
  }
157
125
 
158
- /**
159
- * @param {string | any[]} data
160
- */
161
-
162
126
  function binaryToDecimal(data) {
163
- var ret = "";
164
- while (data !== "0") {
165
- var end = 0;
166
- var fullName = "";
167
- var i = 0;
168
- for (; i < data.length; i++) {
169
- end = 2 * end + parseInt(data[i], 10);
170
- if (end >= 10) {
171
- fullName += "1";
172
- end -= 10;
173
- } else fullName += "0";
174
- }
175
- ret = end.toString() + ret;
176
- data = fullName.slice(fullName.indexOf("1"));
177
- }
178
- return ret;
127
+ let ret = "";
128
+ while (data !== "0") {
129
+ let end = 0;
130
+ let fullName = "";
131
+ let i = 0;
132
+ for (; i < data.length; i++) {
133
+ end = 2 * end + parseInt(data[i], 10);
134
+ if (end >= 10) {
135
+ fullName += "1";
136
+ end -= 10;
137
+ }
138
+ else {
139
+ fullName += "0";
140
+ }
141
+ }
142
+ ret = end.toString() + ret;
143
+ data = fullName.slice(fullName.indexOf("1"));
144
+ }
145
+ return ret;
179
146
  }
180
147
 
181
148
  function generateOfflineThreadingID() {
182
- var ret = Date.now();
183
- var value = Math.floor(Math.random() * 4294967295);
184
- var str = ("0000000000000000000000" + value.toString(2)).slice(-22);
185
- var msgs = ret.toString(2) + str;
186
- return binaryToDecimal(msgs);
149
+ const ret = Date.now();
150
+ const value = Math.floor(Math.random() * 4294967295);
151
+ const str = ("0000000000000000000000" + value.toString(2)).slice(-22);
152
+ const msgs = ret.toString(2) + str;
153
+ return binaryToDecimal(msgs);
187
154
  }
188
155
 
189
- var h;
190
- var i = {};
191
- var j = {
192
- _: "%",
193
- A: "%2",
194
- B: "000",
195
- C: "%7d",
196
- D: "%7b%22",
197
- E: "%2c%22",
198
- F: "%22%3a",
199
- G: "%2c%22ut%22%3a1",
200
- H: "%2c%22bls%22%3a",
201
- I: "%2c%22n%22%3a%22%",
202
- J: "%22%3a%7b%22i%22%3a0%7d",
203
- K: "%2c%22pt%22%3a0%2c%22vis%22%3a",
204
- L: "%2c%22ch%22%3a%7b%22h%22%3a%22",
205
- M: "%7b%22v%22%3a2%2c%22time%22%3a1",
206
- N: ".channel%22%2c%22sub%22%3a%5b",
207
- O: "%2c%22sb%22%3a1%2c%22t%22%3a%5b",
208
- P: "%2c%22ud%22%3a100%2c%22lc%22%3a0",
209
- Q: "%5d%2c%22f%22%3anull%2c%22uct%22%3a",
210
- R: ".channel%22%2c%22sub%22%3a%5b1%5d",
211
- S: "%22%2c%22m%22%3a0%7d%2c%7b%22i%22%3a",
212
- T: "%2c%22blc%22%3a1%2c%22snd%22%3a1%2c%22ct%22%3a",
213
- U: "%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
214
- V: "%2c%22blc%22%3a0%2c%22snd%22%3a0%2c%22ct%22%3a",
215
- W: "%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a",
216
- X: "%2c%22ri%22%3a0%7d%2c%22state%22%3a%7b%22p%22%3a0%2c%22ut%22%3a1",
217
- Y: "%2c%22pt%22%3a0%2c%22vis%22%3a1%2c%22bls%22%3a0%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
218
- Z: "%2c%22sb%22%3a1%2c%22t%22%3a%5b%5d%2c%22f%22%3anull%2c%22uct%22%3a0%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a"
156
+ let h;
157
+ const i = {};
158
+ const j = {
159
+ _: "%",
160
+ A: "%2",
161
+ B: "000",
162
+ C: "%7d",
163
+ D: "%7b%22",
164
+ E: "%2c%22",
165
+ F: "%22%3a",
166
+ G: "%2c%22ut%22%3a1",
167
+ H: "%2c%22bls%22%3a",
168
+ I: "%2c%22n%22%3a%22%",
169
+ J: "%22%3a%7b%22i%22%3a0%7d",
170
+ K: "%2c%22pt%22%3a0%2c%22vis%22%3a",
171
+ L: "%2c%22ch%22%3a%7b%22h%22%3a%22",
172
+ M: "%7b%22v%22%3a2%2c%22time%22%3a1",
173
+ N: ".channel%22%2c%22sub%22%3a%5b",
174
+ O: "%2c%22sb%22%3a1%2c%22t%22%3a%5b",
175
+ P: "%2c%22ud%22%3a100%2c%22lc%22%3a0",
176
+ Q: "%5d%2c%22f%22%3anull%2c%22uct%22%3a",
177
+ R: ".channel%22%2c%22sub%22%3a%5b1%5d",
178
+ S: "%22%2c%22m%22%3a0%7d%2c%7b%22i%22%3a",
179
+ T: "%2c%22blc%22%3a1%2c%22snd%22%3a1%2c%22ct%22%3a",
180
+ U: "%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
181
+ V: "%2c%22blc%22%3a0%2c%22snd%22%3a0%2c%22ct%22%3a",
182
+ W: "%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a",
183
+ X: "%2c%22ri%22%3a0%7d%2c%22state%22%3a%7b%22p%22%3a0%2c%22ut%22%3a1",
184
+ Y:
185
+ "%2c%22pt%22%3a0%2c%22vis%22%3a1%2c%22bls%22%3a0%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
186
+ Z:
187
+ "%2c%22sb%22%3a1%2c%22t%22%3a%5b%5d%2c%22f%22%3anull%2c%22uct%22%3a0%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a"
219
188
  };
220
- (function() {
221
- var l = [];
222
- for (var m in j) {
223
- i[j[m]] = m;
224
- l.push(j[m]);
225
- }
226
- l.reverse();
227
- h = new RegExp(l.join("|"), "g");
189
+ (function () {
190
+ const l = [];
191
+ for (const m in j) {
192
+ i[j[m]] = m;
193
+ l.push(j[m]);
194
+ }
195
+ l.reverse();
196
+ h = new RegExp(l.join("|"), "g");
228
197
  })();
229
198
 
230
- /**
231
- * @param {string | number | boolean} str
232
- */
233
-
234
199
  function presenceEncode(str) {
235
- return encodeURIComponent(str)
236
- .replace(/([_A-Z])|%../g, function(m, n) {
237
- return n ? "%" + n.charCodeAt(0).toString(16) : m;
238
- })
239
- .toLowerCase()
240
- .replace(h, function(m) {
241
- return i[m];
242
- });
200
+ return encodeURIComponent(str)
201
+ .replace(/([_A-Z])|%../g, function (m, n) {
202
+ return n ? "%" + n.charCodeAt(0).toString(16) : m;
203
+ })
204
+ .toLowerCase()
205
+ .replace(h, function (m) {
206
+ return i[m];
207
+ });
243
208
  }
244
209
 
245
210
  // eslint-disable-next-line no-unused-vars
246
- /**
247
- * @param {string} str
248
- */
249
-
250
211
  function presenceDecode(str) {
251
- return decodeURIComponent(
252
- str.replace(/[_A-Z]/g, function(/** @type {string | number} */m) {
253
- return j[m];
254
- })
255
- );
212
+ return decodeURIComponent(
213
+ str.replace(/[_A-Z]/g, function (m) {
214
+ return j[m];
215
+ })
216
+ );
256
217
  }
257
218
 
258
- /**
259
- * @param {string} userID
260
- */
261
-
262
219
  function generatePresence(userID) {
263
- var time = Date.now();
264
- return (
265
- "E" +
266
- presenceEncode(
267
- JSON.stringify({
268
- v: 3,
269
- time: parseInt(time / 1000, 10),
270
- user: userID,
271
- state: {
272
- ut: 0,
273
- t2: [],
274
- lm2: null,
275
- uct2: time,
276
- tr: null,
277
- tw: Math.floor(Math.random() * 4294967295) + 1,
278
- at: time
279
- },
280
- ch: {
281
- ["p_" + userID]: 0
282
- }
283
- })
284
- )
285
- );
220
+ const time = Date.now();
221
+ return (
222
+ "E" +
223
+ presenceEncode(
224
+ JSON.stringify({
225
+ v: 3,
226
+ time: parseInt(time / 1000, 10),
227
+ user: userID,
228
+ state: {
229
+ ut: 0,
230
+ t2: [],
231
+ lm2: null,
232
+ uct2: time,
233
+ tr: null,
234
+ tw: Math.floor(Math.random() * 4294967295) + 1,
235
+ at: time
236
+ },
237
+ ch: {
238
+ ["p_" + userID]: 0
239
+ }
240
+ })
241
+ )
242
+ );
286
243
  }
287
244
 
288
245
  function generateAccessiblityCookie() {
289
- var time = Date.now();
290
- return encodeURIComponent(
291
- JSON.stringify({
292
- sr: 0,
293
- "sr-ts": time,
294
- jk: 0,
295
- "jk-ts": time,
296
- kb: 0,
297
- "kb-ts": time,
298
- hcm: 0,
299
- "hcm-ts": time
300
- })
301
- );
246
+ const time = Date.now();
247
+ return encodeURIComponent(
248
+ JSON.stringify({
249
+ sr: 0,
250
+ "sr-ts": time,
251
+ jk: 0,
252
+ "jk-ts": time,
253
+ kb: 0,
254
+ "kb-ts": time,
255
+ hcm: 0,
256
+ "hcm-ts": time
257
+ })
258
+ );
302
259
  }
303
260
 
304
261
  function getGUID() {
305
- /** @type {number} */
306
-
307
- var sectionLength = Date.now();
308
- /** @type {string} */
309
-
310
- var id = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
311
- /** @type {number} */
312
-
313
- var r = Math.floor((sectionLength + Math.random() * 16) % 16);
314
- /** @type {number} */
315
-
316
- sectionLength = Math.floor(sectionLength / 16);
317
- /** @type {string} */
318
-
319
- var _guid = (c == "x" ? r : (r & 7) | 8).toString(16);
320
- return _guid;
321
- });
322
- return id;
262
+ /** @type {number} */
263
+ let sectionLength = Date.now();
264
+ /** @type {string} */
265
+ const id = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
266
+ /** @type {number} */
267
+ const r = Math.floor((sectionLength + Math.random() * 16) % 16);
268
+ /** @type {number} */
269
+ sectionLength = Math.floor(sectionLength / 16);
270
+ /** @type {string} */
271
+ const _guid = (c == "x" ? r : (r & 7) | 8).toString(16);
272
+ return _guid;
273
+ });
274
+ return id;
323
275
  }
324
276
 
325
- /**
326
- * @param {{ mercury: any; blob_attachment: any; attach_type: any; sticker_attachment: any; extensible_attachment: { story_attachment: { target: { __typename: string; }; }; }; metadata: { stickerID: { toString: () => any; }; packID: { toString: () => any; }; spriteURI: any; spriteURI2x: any; width: any; height: any; frameCount: any; frameRate: any; framesPerRow: any; framesPerCol: any; fbid: { toString: () => any; }; url: any; dimensions: { split: (arg0: string) => any[]; width: any; height: any; }; duration: any; }; url: any; name: any; fileName: any; thumbnail_url: any; preview_url: any; preview_width: any; preview_height: any; large_preview_url: any; large_preview_width: any; large_preview_height: any; share: { share_id: { toString: () => any; }; title: any; description: any; source: any; media: { image: any; image_size: { width: any; height: any; }; playable: any; duration: any; animated_image_size: any; }; subattachments: any; uri: any; target: any; style_list: any; }; }} attachment1
327
- * @param {{ caption?: any; description?: any; id: any; is_malicious?: any; mime_type?: any; file_size?: any; filename?: any; image_data: any; href?: any; }} [attachment2]
328
- */
277
+ function getExtension(original_extension, fullFileName = "") {
278
+ if (original_extension) {
279
+ return original_extension;
280
+ }
281
+ else {
282
+ const extension = fullFileName.split(".").pop();
283
+ if (extension === fullFileName) {
284
+ return "";
285
+ }
286
+ else {
287
+ return extension;
288
+ }
289
+ }
290
+ }
329
291
 
330
292
  function _formatAttachment(attachment1, attachment2) {
331
- // TODO: THIS IS REALLY BAD
332
- // This is an attempt at fixing Facebook's inconsistencies. Sometimes they give us
333
- // two attachment objects, but sometimes only one. They each contain part of the
334
- // data that you'd want so we merge them for convenience.
335
- // Instead of having a bunch of if statements guarding every access to image_data,
336
- // we set it to empty object and use the fact that it'll return undefined.
337
-
338
- attachment2 = attachment2 || { id: "", image_data: {} };
339
- attachment1 = attachment1.mercury ? attachment1.mercury : attachment1;
340
- var blob = attachment1.blob_attachment;
341
- var type =
342
- blob && blob.__typename ? blob.__typename : attachment1.attach_type;
343
- if (!type && attachment1.sticker_attachment) {
344
- type = "StickerAttachment";
345
- blob = attachment1.sticker_attachment;
346
- } else if (!type && attachment1.extensible_attachment) {
347
- if (
348
- attachment1.extensible_attachment.story_attachment &&
349
- attachment1.extensible_attachment.story_attachment.target &&
350
- attachment1.extensible_attachment.story_attachment.target.__typename &&
351
- attachment1.extensible_attachment.story_attachment.target.__typename === "MessageLocation"
352
- ) type = "MessageLocation";
353
- else type = "ExtensibleAttachment";
354
-
355
- blob = attachment1.extensible_attachment;
356
- }
357
- // TODO: Determine whether "sticker", "photo", "file" etc are still used
358
- // KEEP IN SYNC WITH getThreadHistory
359
- switch (type) {
360
- case "sticker":
361
- return {
362
- type: "sticker",
363
- ID: attachment1.metadata.stickerID.toString(),
364
- url: attachment1.url,
365
-
366
- packID: attachment1.metadata.packID.toString(),
367
- spriteUrl: attachment1.metadata.spriteURI,
368
- spriteUrl2x: attachment1.metadata.spriteURI2x,
369
- width: attachment1.metadata.width,
370
- height: attachment1.metadata.height,
371
-
372
- caption: attachment2.caption,
373
- description: attachment2.description,
374
-
375
- frameCount: attachment1.metadata.frameCount,
376
- frameRate: attachment1.metadata.frameRate,
377
- framesPerRow: attachment1.metadata.framesPerRow,
378
- framesPerCol: attachment1.metadata.framesPerCol,
379
-
380
- stickerID: attachment1.metadata.stickerID.toString(), // @Legacy
381
- spriteURI: attachment1.metadata.spriteURI, // @Legacy
382
- spriteURI2x: attachment1.metadata.spriteURI2x // @Legacy
383
- };
384
- case "file":
385
- return {
386
- type: "file",
387
- filename: attachment1.name,
388
- ID: attachment2.id.toString(),
389
- url: attachment1.url,
390
-
391
- isMalicious: attachment2.is_malicious,
392
- contentType: attachment2.mime_type,
393
-
394
- name: attachment1.name, // @Legacy
395
- mimeType: attachment2.mime_type, // @Legacy
396
- fileSize: attachment2.file_size // @Legacy
397
- };
398
- case "photo":
399
- return {
400
- type: "photo",
401
- ID: attachment1.metadata.fbid.toString(),
402
- filename: attachment1.fileName,
403
- thumbnailUrl: attachment1.thumbnail_url,
404
-
405
- previewUrl: attachment1.preview_url,
406
- previewWidth: attachment1.preview_width,
407
- previewHeight: attachment1.preview_height,
408
-
409
- largePreviewUrl: attachment1.large_preview_url,
410
- largePreviewWidth: attachment1.large_preview_width,
411
- largePreviewHeight: attachment1.large_preview_height,
412
-
413
- url: attachment1.metadata.url, // @Legacy
414
- width: attachment1.metadata.dimensions.split(",")[0], // @Legacy
415
- height: attachment1.metadata.dimensions.split(",")[1], // @Legacy
416
- name: attachment1.fileName // @Legacy
417
- };
418
- case "animated_image":
419
- return {
420
- type: "animated_image",
421
- ID: attachment2.id.toString(),
422
- filename: attachment2.filename,
423
-
424
- previewUrl: attachment1.preview_url,
425
- previewWidth: attachment1.preview_width,
426
- previewHeight: attachment1.preview_height,
427
-
428
- url: attachment2.image_data.url,
429
- width: attachment2.image_data.width,
430
- height: attachment2.image_data.height,
431
-
432
- name: attachment1.name, // @Legacy
433
- facebookUrl: attachment1.url, // @Legacy
434
- thumbnailUrl: attachment1.thumbnail_url, // @Legacy
435
- mimeType: attachment2.mime_type, // @Legacy
436
- rawGifImage: attachment2.image_data.raw_gif_image, // @Legacy
437
- rawWebpImage: attachment2.image_data.raw_webp_image, // @Legacy
438
- animatedGifUrl: attachment2.image_data.animated_gif_url, // @Legacy
439
- animatedGifPreviewUrl: attachment2.image_data.animated_gif_preview_url, // @Legacy
440
- animatedWebpUrl: attachment2.image_data.animated_webp_url, // @Legacy
441
- animatedWebpPreviewUrl: attachment2.image_data.animated_webp_preview_url // @Legacy
442
- };
443
- case "share":
444
- return {
445
- type: "share",
446
- ID: attachment1.share.share_id.toString(),
447
- url: attachment2.href,
448
-
449
- title: attachment1.share.title,
450
- description: attachment1.share.description,
451
- source: attachment1.share.source,
452
-
453
- image: attachment1.share.media.image,
454
- width: attachment1.share.media.image_size.width,
455
- height: attachment1.share.media.image_size.height,
456
- playable: attachment1.share.media.playable,
457
- duration: attachment1.share.media.duration,
458
-
459
- subattachments: attachment1.share.subattachments,
460
- properties: {},
461
-
462
- animatedImageSize: attachment1.share.media.animated_image_size, // @Legacy
463
- facebookUrl: attachment1.share.uri, // @Legacy
464
- target: attachment1.share.target, // @Legacy
465
- styleList: attachment1.share.style_list // @Legacy
466
- };
467
- case "video":
468
- return {
469
- type: "video",
470
- ID: attachment1.metadata.fbid.toString(),
471
- filename: attachment1.name,
472
-
473
- previewUrl: attachment1.preview_url,
474
- previewWidth: attachment1.preview_width,
475
- previewHeight: attachment1.preview_height,
476
-
477
- url: attachment1.url,
478
- width: attachment1.metadata.dimensions.width,
479
- height: attachment1.metadata.dimensions.height,
480
-
481
- duration: attachment1.metadata.duration,
482
- videoType: "unknown",
483
-
484
- thumbnailUrl: attachment1.thumbnail_url // @Legacy
485
- };
486
- case "error":
487
- return {
488
- type: "error",
489
-
490
- // Save error attachments because we're unsure of their format,
491
- // and whether there are cases they contain something useful for debugging.
492
- attachment1: attachment1,
493
- attachment2: attachment2
494
- };
495
- case "MessageImage":
496
- return {
497
- type: "photo",
498
- ID: blob.legacy_attachment_id,
499
- filename: blob.filename,
500
- thumbnailUrl: blob.thumbnail.uri,
501
-
502
- previewUrl: blob.preview.uri,
503
- previewWidth: blob.preview.width,
504
- previewHeight: blob.preview.height,
505
-
506
- largePreviewUrl: blob.large_preview.uri,
507
- largePreviewWidth: blob.large_preview.width,
508
- largePreviewHeight: blob.large_preview.height,
509
-
510
- url: blob.large_preview.uri, // @Legacy
511
- width: blob.original_dimensions.x, // @Legacy
512
- height: blob.original_dimensions.y, // @Legacy
513
- name: blob.filename // @Legacy
514
- };
515
- case "MessageAnimatedImage":
516
- return {
517
- type: "animated_image",
518
- ID: blob.legacy_attachment_id,
519
- filename: blob.filename,
520
-
521
- previewUrl: blob.preview_image.uri,
522
- previewWidth: blob.preview_image.width,
523
- previewHeight: blob.preview_image.height,
524
-
525
- url: blob.animated_image.uri,
526
- width: blob.animated_image.width,
527
- height: blob.animated_image.height,
528
-
529
- thumbnailUrl: blob.preview_image.uri, // @Legacy
530
- name: blob.filename, // @Legacy
531
- facebookUrl: blob.animated_image.uri, // @Legacy
532
- rawGifImage: blob.animated_image.uri, // @Legacy
533
- animatedGifUrl: blob.animated_image.uri, // @Legacy
534
- animatedGifPreviewUrl: blob.preview_image.uri, // @Legacy
535
- animatedWebpUrl: blob.animated_image.uri, // @Legacy
536
- animatedWebpPreviewUrl: blob.preview_image.uri // @Legacy
537
- };
538
- case "MessageVideo":
539
- return {
540
- type: "video",
541
- filename: blob.filename,
542
- ID: blob.legacy_attachment_id,
543
-
544
- previewUrl: blob.large_image.uri,
545
- previewWidth: blob.large_image.width,
546
- previewHeight: blob.large_image.height,
547
-
548
- url: blob.playable_url,
549
- width: blob.original_dimensions.x,
550
- height: blob.original_dimensions.y,
551
-
552
- duration: blob.playable_duration_in_ms,
553
- videoType: blob.video_type.toLowerCase(),
554
-
555
- thumbnailUrl: blob.large_image.uri // @Legacy
556
- };
557
- case "MessageAudio":
558
- return {
559
- type: "audio",
560
- filename: blob.filename,
561
- ID: blob.url_shimhash,
562
-
563
- audioType: blob.audio_type,
564
- duration: blob.playable_duration_in_ms,
565
- url: blob.playable_url,
566
-
567
- isVoiceMail: blob.is_voicemail
568
- };
569
- case "StickerAttachment":
570
- return {
571
- type: "sticker",
572
- ID: blob.id,
573
- url: blob.url,
574
-
575
- packID: blob.pack ? blob.pack.id : null,
576
- spriteUrl: blob.sprite_image,
577
- spriteUrl2x: blob.sprite_image_2x,
578
- width: blob.width,
579
- height: blob.height,
580
-
581
- caption: blob.label,
582
- description: blob.label,
583
-
584
- frameCount: blob.frame_count,
585
- frameRate: blob.frame_rate,
586
- framesPerRow: blob.frames_per_row,
587
- framesPerCol: blob.frames_per_column,
588
-
589
- stickerID: blob.id, // @Legacy
590
- spriteURI: blob.sprite_image, // @Legacy
591
- spriteURI2x: blob.sprite_image_2x // @Legacy
592
- };
593
- case "MessageLocation":
594
- var urlAttach = blob.story_attachment.url;
595
- var mediaAttach = blob.story_attachment.media;
596
-
597
- var u = querystring.parse(url.parse(urlAttach).query).u;
598
- var where1 = querystring.parse(url.parse(u).query).where1;
599
- var address = where1.split(", ");
600
-
601
- var latitude;
602
- var longitude;
603
-
604
- try {
605
- latitude = Number.parseFloat(address[0]);
606
- longitude = Number.parseFloat(address[1]);
607
- } catch (err) {
608
- /* empty */
609
-
610
- }
611
-
612
- var imageUrl;
613
- var width;
614
- var height;
615
-
616
- if (mediaAttach && mediaAttach.image) {
617
- imageUrl = mediaAttach.image.uri;
618
- width = mediaAttach.image.width;
619
- height = mediaAttach.image.height;
620
- }
621
-
622
- return {
623
- type: "location",
624
- ID: blob.legacy_attachment_id,
625
- latitude: latitude,
626
- longitude: longitude,
627
- image: imageUrl,
628
- width: width,
629
- height: height,
630
- url: u || urlAttach,
631
- address: where1,
632
-
633
- facebookUrl: blob.story_attachment.url, // @Legacy
634
- target: blob.story_attachment.target, // @Legacy
635
- styleList: blob.story_attachment.style_list // @Legacy
636
- };
637
- case "ExtensibleAttachment":
638
- return {
639
- type: "share",
640
- ID: blob.legacy_attachment_id,
641
- url: blob.story_attachment.url,
642
-
643
- title: blob.story_attachment.title_with_entities.text,
644
- description: blob.story_attachment.description &&
645
- blob.story_attachment.description.text,
646
- source: blob.story_attachment.source ? blob.story_attachment.source.text : null,
647
-
648
- image: blob.story_attachment.media &&
649
- blob.story_attachment.media.image &&
650
- blob.story_attachment.media.image.uri,
651
- width: blob.story_attachment.media &&
652
- blob.story_attachment.media.image &&
653
- blob.story_attachment.media.image.width,
654
- height: blob.story_attachment.media &&
655
- blob.story_attachment.media.image &&
656
- blob.story_attachment.media.image.height,
657
- playable: blob.story_attachment.media &&
658
- blob.story_attachment.media.is_playable,
659
- duration: blob.story_attachment.media &&
660
- blob.story_attachment.media.playable_duration_in_ms,
661
- playableUrl: blob.story_attachment.media == null ? null : blob.story_attachment.media.playable_url,
662
-
663
- subattachments: blob.story_attachment.subattachments,
664
- properties: blob.story_attachment.properties.reduce(function(/** @type {{ [x: string]: any; }} */obj, /** @type {{ key: string | number; value: { text: any; }; }} */cur) {
665
- obj[cur.key] = cur.value.text;
666
- return obj;
667
- }, {}),
668
-
669
- facebookUrl: blob.story_attachment.url, // @Legacy
670
- target: blob.story_attachment.target, // @Legacy
671
- styleList: blob.story_attachment.style_list // @Legacy
672
- };
673
- case "MessageFile":
674
- return {
675
- type: "file",
676
- filename: blob.filename,
677
- ID: blob.message_file_fbid,
678
-
679
- url: blob.url,
680
- isMalicious: blob.is_malicious,
681
- contentType: blob.content_type,
682
-
683
- name: blob.filename,
684
- mimeType: "",
685
- fileSize: -1
686
- };
687
- default:
688
- throw new Error(
689
- "unrecognized attach_file of type " +
690
- type +
691
- "`" +
692
- JSON.stringify(attachment1, null, 4) +
693
- " attachment2: " +
694
- JSON.stringify(attachment2, null, 4) +
695
- "`"
696
- );
697
- }
293
+ // TODO: THIS IS REALLY BAD
294
+ // This is an attempt at fixing Facebook's inconsistencies. Sometimes they give us
295
+ // two attachment objects, but sometimes only one. They each contain part of the
296
+ // data that you'd want so we merge them for convenience.
297
+ // Instead of having a bunch of if statements guarding every access to image_data,
298
+ // we set it to empty object and use the fact that it'll return undefined.
299
+ const fullFileName = attachment1.filename;
300
+ const fileSize = Number(attachment1.fileSize || 0);
301
+ const durationVideo = attachment1.genericMetadata ? Number(attachment1.genericMetadata.videoLength) : undefined;
302
+ const durationAudio = attachment1.genericMetadata ? Number(attachment1.genericMetadata.duration) : undefined;
303
+ const mimeType = attachment1.mimeType;
304
+
305
+ attachment2 = attachment2 || { id: "", image_data: {} };
306
+ attachment1 = attachment1.mercury || attachment1;
307
+ let blob = attachment1.blob_attachment || attachment1.sticker_attachment;
308
+ let type =
309
+ blob && blob.__typename ? blob.__typename : attachment1.attach_type;
310
+ if (!type && attachment1.sticker_attachment) {
311
+ type = "StickerAttachment";
312
+ blob = attachment1.sticker_attachment;
313
+ }
314
+ else if (!type && attachment1.extensible_attachment) {
315
+ if (
316
+ attachment1.extensible_attachment.story_attachment &&
317
+ attachment1.extensible_attachment.story_attachment.target &&
318
+ attachment1.extensible_attachment.story_attachment.target.__typename &&
319
+ attachment1.extensible_attachment.story_attachment.target.__typename === "MessageLocation"
320
+ ) {
321
+ type = "MessageLocation";
322
+ }
323
+ else {
324
+ type = "ExtensibleAttachment";
325
+ }
326
+
327
+ blob = attachment1.extensible_attachment;
328
+ }
329
+ // TODO: Determine whether "sticker", "photo", "file" etc are still used
330
+ // KEEP IN SYNC WITH getThreadHistory
331
+ switch (type) {
332
+ case "sticker":
333
+ return {
334
+ type: "sticker",
335
+ ID: attachment1.metadata.stickerID.toString(),
336
+ url: attachment1.url,
337
+
338
+ packID: attachment1.metadata.packID.toString(),
339
+ spriteUrl: attachment1.metadata.spriteURI,
340
+ spriteUrl2x: attachment1.metadata.spriteURI2x,
341
+ width: attachment1.metadata.width,
342
+ height: attachment1.metadata.height,
343
+
344
+ caption: attachment2.caption,
345
+ description: attachment2.description,
346
+
347
+ frameCount: attachment1.metadata.frameCount,
348
+ frameRate: attachment1.metadata.frameRate,
349
+ framesPerRow: attachment1.metadata.framesPerRow,
350
+ framesPerCol: attachment1.metadata.framesPerCol,
351
+
352
+ stickerID: attachment1.metadata.stickerID.toString(), // @Legacy
353
+ spriteURI: attachment1.metadata.spriteURI, // @Legacy
354
+ spriteURI2x: attachment1.metadata.spriteURI2x // @Legacy
355
+ };
356
+ case "file":
357
+ return {
358
+ type: "file",
359
+ ID: attachment2.id.toString(),
360
+ fullFileName: fullFileName,
361
+ filename: attachment1.name,
362
+ fileSize: fileSize,
363
+ original_extension: getExtension(attachment1.original_extension, fullFileName),
364
+ mimeType: mimeType,
365
+ url: attachment1.url,
366
+
367
+ isMalicious: attachment2.is_malicious,
368
+ contentType: attachment2.mime_type,
369
+
370
+ name: attachment1.name // @Legacy
371
+ };
372
+ case "photo":
373
+ return {
374
+ type: "photo",
375
+ ID: attachment1.metadata.fbid.toString(),
376
+ filename: attachment1.fileName,
377
+ fullFileName: fullFileName,
378
+ fileSize: fileSize,
379
+ original_extension: getExtension(attachment1.original_extension, fullFileName),
380
+ mimeType: mimeType,
381
+ thumbnailUrl: attachment1.thumbnail_url,
382
+
383
+ previewUrl: attachment1.preview_url,
384
+ previewWidth: attachment1.preview_width,
385
+ previewHeight: attachment1.preview_height,
386
+
387
+ largePreviewUrl: attachment1.large_preview_url,
388
+ largePreviewWidth: attachment1.large_preview_width,
389
+ largePreviewHeight: attachment1.large_preview_height,
390
+
391
+ url: attachment1.metadata.url, // @Legacy
392
+ width: attachment1.metadata.dimensions.split(",")[0], // @Legacy
393
+ height: attachment1.metadata.dimensions.split(",")[1], // @Legacy
394
+ name: fullFileName // @Legacy
395
+ };
396
+ case "animated_image":
397
+ return {
398
+ type: "animated_image",
399
+ ID: attachment2.id.toString(),
400
+ filename: attachment2.filename,
401
+ fullFileName: fullFileName,
402
+ original_extension: getExtension(attachment2.original_extension, fullFileName),
403
+ mimeType: mimeType,
404
+
405
+ previewUrl: attachment1.preview_url,
406
+ previewWidth: attachment1.preview_width,
407
+ previewHeight: attachment1.preview_height,
408
+
409
+ url: attachment2.image_data.url,
410
+ width: attachment2.image_data.width,
411
+ height: attachment2.image_data.height,
412
+
413
+ name: attachment1.name, // @Legacy
414
+ facebookUrl: attachment1.url, // @Legacy
415
+ thumbnailUrl: attachment1.thumbnail_url, // @Legacy
416
+ rawGifImage: attachment2.image_data.raw_gif_image, // @Legacy
417
+ rawWebpImage: attachment2.image_data.raw_webp_image, // @Legacy
418
+ animatedGifUrl: attachment2.image_data.animated_gif_url, // @Legacy
419
+ animatedGifPreviewUrl: attachment2.image_data.animated_gif_preview_url, // @Legacy
420
+ animatedWebpUrl: attachment2.image_data.animated_webp_url, // @Legacy
421
+ animatedWebpPreviewUrl: attachment2.image_data.animated_webp_preview_url // @Legacy
422
+ };
423
+ case "share":
424
+ return {
425
+ type: "share",
426
+ ID: attachment1.share.share_id.toString(),
427
+ url: attachment2.href,
428
+
429
+ title: attachment1.share.title,
430
+ description: attachment1.share.description,
431
+ source: attachment1.share.source,
432
+
433
+ image: attachment1.share.media.image,
434
+ width: attachment1.share.media.image_size.width,
435
+ height: attachment1.share.media.image_size.height,
436
+ playable: attachment1.share.media.playable,
437
+ duration: attachment1.share.media.duration,
438
+
439
+ subattachments: attachment1.share.subattachments,
440
+ properties: {},
441
+
442
+ animatedImageSize: attachment1.share.media.animated_image_size, // @Legacy
443
+ facebookUrl: attachment1.share.uri, // @Legacy
444
+ target: attachment1.share.target, // @Legacy
445
+ styleList: attachment1.share.style_list // @Legacy
446
+ };
447
+ case "video":
448
+ return {
449
+ type: "video",
450
+ ID: attachment1.metadata.fbid.toString(),
451
+ filename: attachment1.name,
452
+ fullFileName: fullFileName,
453
+ original_extension: getExtension(attachment1.original_extension, fullFileName),
454
+ mimeType: mimeType,
455
+ duration: durationVideo,
456
+
457
+ previewUrl: attachment1.preview_url,
458
+ previewWidth: attachment1.preview_width,
459
+ previewHeight: attachment1.preview_height,
460
+
461
+ url: attachment1.url,
462
+ width: attachment1.metadata.dimensions.width,
463
+ height: attachment1.metadata.dimensions.height,
464
+
465
+ videoType: "unknown",
466
+
467
+ thumbnailUrl: attachment1.thumbnail_url // @Legacy
468
+ };
469
+ case "error":
470
+ return {
471
+ type: "error",
472
+
473
+ // Save error attachments because we're unsure of their format,
474
+ // and whether there are cases they contain something useful for debugging.
475
+ attachment1: attachment1,
476
+ attachment2: attachment2
477
+ };
478
+ case "MessageImage":
479
+ return {
480
+ type: "photo",
481
+ ID: blob.legacy_attachment_id,
482
+ filename: blob.filename,
483
+ fullFileName: fullFileName,
484
+ fileSize: fileSize,
485
+ original_extension: getExtension(blob.original_extension, fullFileName),
486
+ mimeType: mimeType,
487
+ thumbnailUrl: blob.thumbnail.uri,
488
+
489
+ previewUrl: blob.preview.uri,
490
+ previewWidth: blob.preview.width,
491
+ previewHeight: blob.preview.height,
492
+
493
+ largePreviewUrl: blob.large_preview.uri,
494
+ largePreviewWidth: blob.large_preview.width,
495
+ largePreviewHeight: blob.large_preview.height,
496
+
497
+ url: blob.large_preview.uri, // @Legacy
498
+ width: blob.original_dimensions.x, // @Legacy
499
+ height: blob.original_dimensions.y, // @Legacy
500
+ name: blob.filename // @Legacy
501
+ };
502
+ case "MessageAnimatedImage":
503
+ return {
504
+ type: "animated_image",
505
+ ID: blob.legacy_attachment_id,
506
+ filename: blob.filename,
507
+ fullFileName: fullFileName,
508
+ original_extension: getExtension(blob.original_extension, fullFileName),
509
+ mimeType: mimeType,
510
+
511
+ previewUrl: blob.preview_image.uri,
512
+ previewWidth: blob.preview_image.width,
513
+ previewHeight: blob.preview_image.height,
514
+
515
+ url: blob.animated_image.uri,
516
+ width: blob.animated_image.width,
517
+ height: blob.animated_image.height,
518
+
519
+ thumbnailUrl: blob.preview_image.uri, // @Legacy
520
+ name: blob.filename, // @Legacy
521
+ facebookUrl: blob.animated_image.uri, // @Legacy
522
+ rawGifImage: blob.animated_image.uri, // @Legacy
523
+ animatedGifUrl: blob.animated_image.uri, // @Legacy
524
+ animatedGifPreviewUrl: blob.preview_image.uri, // @Legacy
525
+ animatedWebpUrl: blob.animated_image.uri, // @Legacy
526
+ animatedWebpPreviewUrl: blob.preview_image.uri // @Legacy
527
+ };
528
+ case "MessageVideo":
529
+ return {
530
+ type: "video",
531
+ ID: blob.legacy_attachment_id,
532
+ filename: blob.filename,
533
+ fullFileName: fullFileName,
534
+ original_extension: getExtension(blob.original_extension, fullFileName),
535
+ fileSize: fileSize,
536
+ duration: durationVideo,
537
+ mimeType: mimeType,
538
+
539
+ previewUrl: blob.large_image.uri,
540
+ previewWidth: blob.large_image.width,
541
+ previewHeight: blob.large_image.height,
542
+
543
+ url: blob.playable_url,
544
+ width: blob.original_dimensions.x,
545
+ height: blob.original_dimensions.y,
546
+
547
+ videoType: blob.video_type.toLowerCase(),
548
+
549
+ thumbnailUrl: blob.large_image.uri // @Legacy
550
+ };
551
+ case "MessageAudio":
552
+ return {
553
+ type: "audio",
554
+ ID: blob.url_shimhash,
555
+ filename: blob.filename,
556
+ fullFileName: fullFileName,
557
+ fileSize: fileSize,
558
+ duration: durationAudio,
559
+ original_extension: getExtension(blob.original_extension, fullFileName),
560
+ mimeType: mimeType,
561
+
562
+ audioType: blob.audio_type,
563
+ url: blob.playable_url,
564
+
565
+ isVoiceMail: blob.is_voicemail
566
+ };
567
+ case "StickerAttachment":
568
+ case "Sticker":
569
+ return {
570
+ type: "sticker",
571
+ ID: blob.id,
572
+ url: blob.url,
573
+
574
+ packID: blob.pack ? blob.pack.id : null,
575
+ spriteUrl: blob.sprite_image,
576
+ spriteUrl2x: blob.sprite_image_2x,
577
+ width: blob.width,
578
+ height: blob.height,
579
+
580
+ caption: blob.label,
581
+ description: blob.label,
582
+
583
+ frameCount: blob.frame_count,
584
+ frameRate: blob.frame_rate,
585
+ framesPerRow: blob.frames_per_row,
586
+ framesPerCol: blob.frames_per_column,
587
+
588
+ stickerID: blob.id, // @Legacy
589
+ spriteURI: blob.sprite_image, // @Legacy
590
+ spriteURI2x: blob.sprite_image_2x // @Legacy
591
+ };
592
+ case "MessageLocation":
593
+ var urlAttach = blob.story_attachment.url;
594
+ var mediaAttach = blob.story_attachment.media;
595
+
596
+ var u = querystring.parse(url.parse(urlAttach).query).u;
597
+ var where1 = querystring.parse(url.parse(u).query).where1;
598
+ var address = where1.split(", ");
599
+
600
+ var latitude;
601
+ var longitude;
602
+
603
+ try {
604
+ latitude = Number.parseFloat(address[0]);
605
+ longitude = Number.parseFloat(address[1]);
606
+ } catch (err) {
607
+ /* empty */
608
+ }
609
+
610
+ var imageUrl;
611
+ var width;
612
+ var height;
613
+
614
+ if (mediaAttach && mediaAttach.image) {
615
+ imageUrl = mediaAttach.image.uri;
616
+ width = mediaAttach.image.width;
617
+ height = mediaAttach.image.height;
618
+ }
619
+
620
+ return {
621
+ type: "location",
622
+ ID: blob.legacy_attachment_id,
623
+ latitude: latitude,
624
+ longitude: longitude,
625
+ image: imageUrl,
626
+ width: width,
627
+ height: height,
628
+ url: u || urlAttach,
629
+ address: where1,
630
+
631
+ facebookUrl: blob.story_attachment.url, // @Legacy
632
+ target: blob.story_attachment.target, // @Legacy
633
+ styleList: blob.story_attachment.style_list // @Legacy
634
+ };
635
+ case "ExtensibleAttachment":
636
+ return {
637
+ type: "share",
638
+ ID: blob.legacy_attachment_id,
639
+ url: blob.story_attachment.url,
640
+
641
+ title: blob.story_attachment.title_with_entities.text,
642
+ description:
643
+ blob.story_attachment.description &&
644
+ blob.story_attachment.description.text,
645
+ source: blob.story_attachment.source
646
+ ? blob.story_attachment.source.text
647
+ : null,
648
+
649
+ image:
650
+ blob.story_attachment.media &&
651
+ blob.story_attachment.media.image &&
652
+ blob.story_attachment.media.image.uri,
653
+ width:
654
+ blob.story_attachment.media &&
655
+ blob.story_attachment.media.image &&
656
+ blob.story_attachment.media.image.width,
657
+ height:
658
+ blob.story_attachment.media &&
659
+ blob.story_attachment.media.image &&
660
+ blob.story_attachment.media.image.height,
661
+ playable:
662
+ blob.story_attachment.media &&
663
+ blob.story_attachment.media.is_playable,
664
+ duration:
665
+ blob.story_attachment.media &&
666
+ blob.story_attachment.media.playable_duration_in_ms,
667
+ playableUrl:
668
+ blob.story_attachment.media == null
669
+ ? null
670
+ : blob.story_attachment.media.playable_url,
671
+
672
+ subattachments: blob.story_attachment.subattachments,
673
+ properties: blob.story_attachment.properties.reduce(function (obj, cur) {
674
+ obj[cur.key] = cur.value.text;
675
+ return obj;
676
+ }, {}),
677
+
678
+ facebookUrl: blob.story_attachment.url, // @Legacy
679
+ target: blob.story_attachment.target, // @Legacy
680
+ styleList: blob.story_attachment.style_list // @Legacy
681
+ };
682
+ case "MessageFile":
683
+ return {
684
+ type: "file",
685
+ ID: blob.message_file_fbid,
686
+ fullFileName: fullFileName,
687
+ filename: blob.filename,
688
+ fileSize: fileSize,
689
+ mimeType: blob.mimetype,
690
+ original_extension: blob.original_extension || fullFileName.split(".").pop(),
691
+
692
+ url: blob.url,
693
+ isMalicious: blob.is_malicious,
694
+ contentType: blob.content_type,
695
+
696
+ name: blob.filename
697
+ };
698
+ default:
699
+ throw new Error(
700
+ "unrecognized attach_file of type " +
701
+ type +
702
+ "`" +
703
+ JSON.stringify(attachment1, null, 4) +
704
+ " attachment2: " +
705
+ JSON.stringify(attachment2, null, 4) +
706
+ "`"
707
+ );
708
+ }
698
709
  }
699
710
 
700
- /**
701
- * @param {any[]} attachments
702
- * @param {{ [x: string]: string | number; }} attachmentIds
703
- * @param {{ [x: string]: any; }} attachmentMap
704
- * @param {any} shareMap
705
- */
706
-
707
711
  function formatAttachment(attachments, attachmentIds, attachmentMap, shareMap) {
708
- attachmentMap = shareMap || attachmentMap;
709
- return attachments ?
710
- attachments.map(function(/** @type {any} */val, /** @type {string | number} */i) {
711
- if (!attachmentMap ||
712
- !attachmentIds ||
713
- !attachmentMap[attachmentIds[i]]
714
- ) {
715
- return _formatAttachment(val);
716
- }
717
- return _formatAttachment(val, attachmentMap[attachmentIds[i]]);
718
- }) : [];
712
+ attachmentMap = shareMap || attachmentMap;
713
+ return attachments
714
+ ? attachments.map(function (val, i) {
715
+ if (
716
+ !attachmentMap ||
717
+ !attachmentIds ||
718
+ !attachmentMap[attachmentIds[i]]
719
+ ) {
720
+ return _formatAttachment(val);
721
+ }
722
+ return _formatAttachment(val, attachmentMap[attachmentIds[i]]);
723
+ })
724
+ : [];
719
725
  }
720
726
 
721
- /**
722
- * @param {{ delta: { messageMetadata: any; data: { prng: string; }; body: string; attachments: any; participants: any; }; }} m
723
- */
724
-
725
727
  function formatDeltaMessage(m) {
726
- var md = m.messageMetadata;
727
- var mdata =
728
- m.data === undefined ? [] :
729
- m.data.prng === undefined ? [] :
730
- JSON.parse(m.data.prng);
731
- var m_id = mdata.map((/** @type {{ i: any; }} */u) => u.i);
732
- var m_offset = mdata.map((/** @type {{ o: any; }} */u) => u.o);
733
- var m_length = mdata.map((/** @type {{ l: any; }} */u) => u.l);
734
- var mentions = {};
735
- var body = m.body || "";
736
- var args = body == "" ? [] : body.trim().split(/\s+/);
737
- for (var i = 0; i < m_id.length; i++) mentions[m_id[i]] = m.body.substring(m_offset[i], m_offset[i] + m_length[i]);
738
-
739
- return {
740
- type: "message",
741
- senderID: formatID(md.actorFbId.toString()),
742
- threadID: formatID((md.threadKey.threadFbId || md.threadKey.otherUserFbId).toString()),
743
- messageID: md.messageId,
744
- args: args,
745
- body: body,
746
- attachments: (m.attachments || []).map((/** @type {any} */v) => _formatAttachment(v)),
747
- mentions: mentions,
748
- timestamp: md.timestamp,
749
- isGroup: !!md.threadKey.threadFbId,
750
- participantIDs: m.participants || []
751
- };
728
+ const md = m.delta.messageMetadata;
729
+
730
+ const mdata =
731
+ m.delta.data === undefined
732
+ ? []
733
+ : m.delta.data.prng === undefined
734
+ ? []
735
+ : JSON.parse(m.delta.data.prng);
736
+ const m_id = mdata.map(u => u.i);
737
+ const m_offset = mdata.map(u => u.o);
738
+ const m_length = mdata.map(u => u.l);
739
+ const mentions = {};
740
+ for (let i = 0; i < m_id.length; i++) {
741
+ mentions[m_id[i]] = m.delta.body.substring(
742
+ m_offset[i],
743
+ m_offset[i] + m_length[i]
744
+ );
745
+ }
746
+
747
+ return {
748
+ type: "message",
749
+ senderID: formatID(md.actorFbId.toString()),
750
+ body: m.delta.body || "",
751
+ threadID: formatID(
752
+ (md.threadKey.threadFbId || md.threadKey.otherUserFbId).toString()
753
+ ),
754
+ messageID: md.messageId,
755
+ attachments: (m.delta.attachments || []).map(v => _formatAttachment(v)),
756
+ mentions: mentions,
757
+ timestamp: md.timestamp,
758
+ isGroup: !!md.threadKey.threadFbId,
759
+ participantIDs: m.delta.participants
760
+ };
752
761
  }
753
762
 
754
- /**
755
- * @param {string} id
756
- */
757
-
758
763
  function formatID(id) {
759
- if (id != undefined && id != null) return id.replace(/(fb)?id[:.]/, "");
760
- else return id;
764
+ if (id != undefined && id != null) {
765
+ return id.replace(/(fb)?id[:.]/, "");
766
+ }
767
+ else {
768
+ return id;
769
+ }
761
770
  }
762
771
 
763
- /**
764
- * @param {{ message: any; type: string; realtime_viewer_fbid: { toString: () => any; }; }} m
765
- */
766
-
767
772
  function formatMessage(m) {
768
- var originalMessage = m.message ? m.message : m;
769
- var obj = {
770
- type: "message",
771
- senderName: originalMessage.sender_name,
772
- senderID: formatID(originalMessage.sender_fbid.toString()),
773
- participantNames: originalMessage.group_thread_info ? originalMessage.group_thread_info.participant_names : [originalMessage.sender_name.split(" ")[0]],
774
- participantIDs: originalMessage.group_thread_info ?
775
- originalMessage.group_thread_info.participant_ids.map(function(/** @type {{ toString: () => any; }} */v) {
776
- return formatID(v.toString());
777
- }) : [formatID(originalMessage.sender_fbid)],
778
- body: originalMessage.body || "",
779
- threadID: formatID((originalMessage.thread_fbid || originalMessage.other_user_fbid).toString()),
780
- threadName: originalMessage.group_thread_info ? originalMessage.group_thread_info.name : originalMessage.sender_name,
781
- location: originalMessage.coordinates ? originalMessage.coordinates : null,
782
- messageID: originalMessage.mid ? originalMessage.mid.toString() : originalMessage.message_id,
783
- attachments: formatAttachment(
784
- originalMessage.attachments,
785
- originalMessage.attachmentIds,
786
- originalMessage.attachment_map,
787
- originalMessage.share_map
788
- ),
789
- timestamp: originalMessage.timestamp,
790
- timestampAbsolute: originalMessage.timestamp_absolute,
791
- timestampRelative: originalMessage.timestamp_relative,
792
- timestampDatetime: originalMessage.timestamp_datetime,
793
- tags: originalMessage.tags,
794
- reactions: originalMessage.reactions ? originalMessage.reactions : [],
795
- isUnread: originalMessage.is_unread
796
- };
797
-
798
- if (m.type === "pages_messaging") obj.pageID = m.realtime_viewer_fbid.toString();
799
- obj.isGroup = obj.participantIDs.length > 2;
800
-
801
- return obj;
773
+ const originalMessage = m.message ? m.message : m;
774
+ const obj = {
775
+ type: "message",
776
+ senderName: originalMessage.sender_name,
777
+ senderID: formatID(originalMessage.sender_fbid.toString()),
778
+ participantNames: originalMessage.group_thread_info
779
+ ? originalMessage.group_thread_info.participant_names
780
+ : [originalMessage.sender_name.split(" ")[0]],
781
+ participantIDs: originalMessage.group_thread_info
782
+ ? originalMessage.group_thread_info.participant_ids.map(function (v) {
783
+ return formatID(v.toString());
784
+ })
785
+ : [formatID(originalMessage.sender_fbid)],
786
+ body: originalMessage.body || "",
787
+ threadID: formatID(
788
+ (
789
+ originalMessage.thread_fbid || originalMessage.other_user_fbid
790
+ ).toString()
791
+ ),
792
+ threadName: originalMessage.group_thread_info
793
+ ? originalMessage.group_thread_info.name
794
+ : originalMessage.sender_name,
795
+ location: originalMessage.coordinates ? originalMessage.coordinates : null,
796
+ messageID: originalMessage.mid
797
+ ? originalMessage.mid.toString()
798
+ : originalMessage.message_id,
799
+ attachments: formatAttachment(
800
+ originalMessage.attachments,
801
+ originalMessage.attachmentIds,
802
+ originalMessage.attachment_map,
803
+ originalMessage.share_map
804
+ ),
805
+ timestamp: originalMessage.timestamp,
806
+ timestampAbsolute: originalMessage.timestamp_absolute,
807
+ timestampRelative: originalMessage.timestamp_relative,
808
+ timestampDatetime: originalMessage.timestamp_datetime,
809
+ tags: originalMessage.tags,
810
+ reactions: originalMessage.reactions ? originalMessage.reactions : [],
811
+ isUnread: originalMessage.is_unread
812
+ };
813
+
814
+ if (m.type === "pages_messaging")
815
+ obj.pageID = m.realtime_viewer_fbid.toString();
816
+ obj.isGroup = obj.participantIDs.length > 2;
817
+
818
+ return obj;
802
819
  }
803
820
 
804
- /**
805
- * @param {{ message: any; }} m
806
- */
807
-
808
821
  function formatEvent(m) {
809
- var originalMessage = m.message ? m.message : m;
810
- var logMessageType = originalMessage.log_message_type;
811
- var logMessageData;
812
- if (logMessageType === "log:generic-admin-text") {
813
- logMessageData = originalMessage.log_message_data.untypedData;
814
- logMessageType = getAdminTextMessageType(originalMessage.log_message_data.message_type);
815
- } else logMessageData = originalMessage.log_message_data;
816
-
817
- return Object.assign(formatMessage(originalMessage), {
818
- type: "event",
819
- logMessageType: logMessageType,
820
- logMessageData: logMessageData,
821
- logMessageBody: originalMessage.log_message_body
822
- });
822
+ const originalMessage = m.message ? m.message : m;
823
+ let logMessageType = originalMessage.log_message_type;
824
+ let logMessageData;
825
+ if (logMessageType === "log:generic-admin-text") {
826
+ logMessageData = originalMessage.log_message_data.untypedData;
827
+ logMessageType = getAdminTextMessageType(
828
+ originalMessage.log_message_data.message_type
829
+ );
830
+ }
831
+ else {
832
+ logMessageData = originalMessage.log_message_data;
833
+ }
834
+
835
+ return Object.assign(formatMessage(originalMessage), {
836
+ type: "event",
837
+ logMessageType: logMessageType,
838
+ logMessageData: logMessageData,
839
+ logMessageBody: originalMessage.log_message_body
840
+ });
823
841
  }
824
842
 
825
- /**
826
- * @param {{ action_type: any; }} m
827
- */
828
-
829
843
  function formatHistoryMessage(m) {
830
- switch (m.action_type) {
831
- case "ma-type:log-message":
832
- return formatEvent(m);
833
- default:
834
- return formatMessage(m);
835
- }
844
+ switch (m.action_type) {
845
+ case "ma-type:log-message":
846
+ return formatEvent(m);
847
+ default:
848
+ return formatMessage(m);
849
+ }
836
850
  }
837
851
 
838
852
  // Get a more readable message type for AdminTextMessages
839
- /**
840
- * @param {{ type: any; }} m
841
- */
842
-
843
- function getAdminTextMessageType(m) {
844
- switch (m.type) {
845
- case "joinable_group_link_mode_change":
846
- return "log:link-status";
847
- case "magic_words":
848
- return "log:magic-words";
849
- case "change_thread_theme":
850
- return "log:thread-color";
851
- case "change_thread_icon":
852
- return "log:thread-icon";
853
- case "change_thread_nickname":
854
- return "log:user-nickname";
855
- case "change_thread_admins":
856
- return "log:thread-admins";
857
- case "group_poll":
858
- return "log:thread-poll";
859
- case "change_thread_approval_mode":
860
- return "log:thread-approval-mode";
861
- case "messenger_call_log":
862
- case "participant_joined_group_call":
863
- return "log:thread-call";
864
- case "pin_messages_v2":
865
- return "log:thread-pinned";
866
- }
853
+ function getAdminTextMessageType(type) {
854
+ switch (type) {
855
+ case 'unpin_messages_v2':
856
+ return 'log:unpin-message';
857
+ case 'pin_messages_v2':
858
+ return 'log:pin-message';
859
+ case "change_thread_theme":
860
+ return "log:thread-color";
861
+ case "change_thread_icon":
862
+ case 'change_thread_quick_reaction':
863
+ return "log:thread-icon";
864
+ case "change_thread_nickname":
865
+ return "log:user-nickname";
866
+ case "change_thread_admins":
867
+ return "log:thread-admins";
868
+ case "group_poll":
869
+ return "log:thread-poll";
870
+ case "change_thread_approval_mode":
871
+ return "log:thread-approval-mode";
872
+ case "messenger_call_log":
873
+ case "participant_joined_group_call":
874
+ return "log:thread-call";
875
+ default:
876
+ return type;
877
+ }
867
878
  }
868
879
 
869
- /**
870
- * @param {string} name
871
- */
872
-
873
- function getGenderByPhysicalMethod(name) {
874
- const female_name = [
875
- "Phương Chi",
876
- "An Bình",
877
- "An Di",
878
- "An Hạ",
879
- "An Hằng",
880
- "An Khê",
881
- "An Nhiên",
882
- "An Nhàn",
883
- "Anh Chi",
884
- "Anh Hương",
885
- "Anh Mai",
886
- "Anh Phương",
887
- "Anh Thi",
888
- "Anh Thy",
889
- "Anh Thơ",
890
- "Anh Thư",
891
- "Anh Thảo",
892
- "Anh Vũ",
893
- "Anh Ðào",
894
- "Ban Mai",
895
- "Bình Minh",
896
- "Bình Yên",
897
- "Bích Chiêu",
898
- "Bích Châu",
899
- "Bích Duyên",
900
- "Bích Hiền",
901
- "Bích Huệ",
902
- "Bích Hà",
903
- "Bích Hạnh",
904
- "Bích Hải",
905
- "Bích Hảo",
906
- "Bích Hậu",
907
- "Bích Hằng",
908
- "Bích Hồng",
909
- "Bích Hợp",
910
- "Bích Lam",
911
- "Bích Liên",
912
- "Bích Loan",
913
- "Bích Nga",
914
- "Bích Ngà",
915
- "Bích Ngân",
916
- "Bích Ngọc",
917
- "Bích Như",
918
- "Bích Phượng",
919
- "Bích Quyên",
920
- "Bích Quân",
921
- "Bích San",
922
- "Bích Thoa",
923
- "Bích Thu",
924
- "Bích Thảo",
925
- "Bích Thủy",
926
- "Bích Trang",
927
- "Bích Trâm",
928
- "Bích Ty",
929
- "Bích Vân",
930
- "Bích Ðiệp",
931
- "Bích Ðào",
932
- "Băng Băng",
933
- "Băng Tâm",
934
- "Bạch Cúc",
935
- "Bạch Hoa",
936
- "Bạch Kim",
937
- "Bạch Liên",
938
- "Bạch Loan",
939
- "Bạch Mai",
940
- "Bạch Quỳnh",
941
- "Bạch Trà",
942
- "Bạch Tuyết",
943
- "Bạch Vân",
944
- "Bạch Yến",
945
- "Bảo Anh",
946
- "Bảo Bình",
947
- "Bảo Châu",
948
- "Bảo Huệ",
949
- "Bảo Hà",
950
- "Bảo Hân",
951
- "Bảo Lan",
952
- "Bảo Lễ",
953
- "Bảo Ngọc",
954
- "Bảo Phương",
955
- "Bảo Quyên",
956
- "Bảo Quỳnh",
957
- "Bảo Thoa",
958
- "Bảo Thúy",
959
- "Bảo Tiên",
960
- "Bảo Trâm",
961
- "Bảo Trân",
962
- "Bảo Trúc",
963
- "Bảo Uyên",
964
- "Bảo Vy",
965
- "Bảo Vân",
966
- "Bội Linh",
967
- "Cam Thảo",
968
- "Chi Lan",
969
- "Chi Mai",
970
- "Chiêu Dương",
971
- "Cát Cát",
972
- "Cát Linh",
973
- "Cát Ly",
974
- "Cát Tiên",
975
- "Cát Tường",
976
- "Cẩm Hiền",
977
- "Cẩm Hường",
978
- "Cẩm Hạnh",
979
- "Cẩm Linh",
980
- "Cẩm Liên",
981
- "Cẩm Ly",
982
- "Cẩm Nhi",
983
- "Cẩm Nhung",
984
- "Cẩm Thúy",
985
- "Cẩm Tú",
986
- "Cẩm Vân",
987
- "Cẩm Yến",
988
- "Di Nhiên",
989
- "Diên Vỹ",
990
- "Diễm Chi",
991
- "Diễm Châu",
992
- "Diễm Hương",
993
- "Diễm Hạnh",
994
- "Diễm Hằng",
995
- "Diễm Khuê",
996
- "Diễm Kiều",
997
- "Diễm Liên",
998
- "Diễm Lộc",
999
- "Diễm My",
1000
- "Diễm Phúc",
1001
- "Diễm Phương",
1002
- "Diễm Phước",
1003
- "Diễm Phượng",
1004
- "Diễm Quyên",
1005
- "Diễm Quỳnh",
1006
- "Diễm Thúy",
1007
- "Diễm Thư",
1008
- "Diễm Thảo",
1009
- "Diễm Trang",
1010
- "Diễm Trinh",
1011
- "Diễm Uyên",
1012
- "Diệp Anh",
1013
- "Diệp Vy",
1014
- "Diệu Anh",
1015
- "Diệu Hiền",
1016
- "Diệu Hoa",
1017
- "Diệu Huyền",
1018
- "Diệu Hương",
1019
- "Diệu Hạnh",
1020
- "Diệu Hằng",
1021
- "Diệu Hồng",
1022
- "Diệu Lan",
1023
- "Diệu Linh",
1024
- "Diệu Loan",
1025
- "Diệu Nga",
1026
- "Diệu Ngà",
1027
- "Diệu Ngọc",
1028
- "Diệu Nương",
1029
- "Diệu Thiện",
1030
- "Diệu Thúy",
1031
- "Diệu Vân",
1032
- "Diệu Ái",
1033
- "Duy Hạnh",
1034
- "Duy Mỹ",
1035
- "Duy Uyên",
1036
- "Duyên Hồng",
1037
- "Duyên My",
1038
- "Duyên Mỹ",
1039
- "Duyên Nương",
1040
- "Dã Lan",
1041
- "Dã Lâm",
1042
- "Dã Thảo",
1043
- "Dạ Hương",
1044
- "Dạ Lan",
1045
- "Dạ Nguyệt",
1046
- "Dạ Thi",
1047
- "Dạ Thảo",
1048
- "Dạ Yến",
1049
- "Gia Hân",
1050
- "Gia Khanh",
1051
- "Gia Linh",
1052
- "Gia Nhi",
1053
- "Gia Quỳnh",
1054
- "Giang Thanh",
1055
- "Giang Thiên",
1056
- "Giao Hưởng",
1057
- "Giao Kiều",
1058
- "Giao Linh",
1059
- "Giáng Ngọc",
1060
- "Giáng Tiên",
1061
- "Giáng Uyên",
1062
- "Hiếu Giang",
1063
- "Hiếu Hạnh",
1064
- "Hiếu Khanh",
1065
- "Hiếu Minh",
1066
- "Hiền Chung",
1067
- "Hiền Hòa",
1068
- "Hiền Mai",
1069
- "Hiền Nhi",
1070
- "Hiền Nương",
1071
- "Hiền Thục",
1072
- "Hiểu Lam",
1073
- "Hiểu Vân",
1074
- "Hoa Liên",
1075
- "Hoa Lý",
1076
- "Hoa Thiên",
1077
- "Hoa Tiên",
1078
- "Hoa Tranh",
1079
- "Hoài An",
1080
- "Hoài Giang",
1081
- "Hoài Hương",
1082
- "Hoài Phương",
1083
- "Hoài Thương",
1084
- "Hoài Trang",
1085
- "Hoài Vỹ",
1086
- "Hoàn Châu",
1087
- "Hoàn Vi",
1088
- "Hoàng Cúc",
1089
- "Hoàng Hà",
1090
- "Hoàng Kim",
1091
- "Hoàng Lan",
1092
- "Hoàng Mai",
1093
- "Hoàng Miên",
1094
- "Hoàng Nguyên",
1095
- "Hoàng Oanh",
1096
- "Hoàng Sa",
1097
- "Hoàng Thư",
1098
- "Hoàng Xuân",
1099
- "Hoàng Yến",
1100
- "Hoạ Mi",
1101
- "Huyền Anh",
1102
- "Huyền Diệu",
1103
- "Huyền Linh",
1104
- "Huyền Ngọc",
1105
- "Huyền Nhi",
1106
- "Huyền Thoại",
1107
- "Huyền Thư",
1108
- "Huyền Trang",
1109
- "Huyền Trâm",
1110
- "Huyền Trân",
1111
- "Huệ An",
1112
- "Huệ Hương",
1113
- "Huệ Hồng",
1114
- "Huệ Lan",
1115
- "Huệ Linh",
1116
- "Huệ Lâm",
1117
- "Huệ My",
1118
- "Huệ Phương",
1119
- "Huệ Thương",
1120
- "Huệ Ân",
1121
- "Huỳnh Anh",
1122
- "Hà Giang",
1123
- "Hà Liên",
1124
- "Hà Mi",
1125
- "Hà My",
1126
- "Hà Nhi",
1127
- "Hà Phương",
1128
- "Hà Thanh",
1129
- "Hà Tiên",
1130
- "Hàm Duyên",
1131
- "Hàm Nghi",
1132
- "Hàm Thơ",
1133
- "Hàm Ý",
1134
- "Hương Chi",
1135
- "Hương Giang",
1136
- "Hương Lan",
1137
- "Hương Liên",
1138
- "Hương Ly",
1139
- "Hương Lâm",
1140
- "Hương Mai",
1141
- "Hương Nhi",
1142
- "Hương Thu",
1143
- "Hương Thảo",
1144
- "Hương Thủy",
1145
- "Hương Tiên",
1146
- "Hương Trang",
1147
- "Hương Trà",
1148
- "Hương Xuân",
1149
- "Hướng Dương",
1150
- "Hạ Băng",
1151
- "Hạ Giang",
1152
- "Hạ Phương",
1153
- "Hạ Tiên",
1154
- "Hạ Uyên",
1155
- "Hạ Vy",
1156
- "Hạc Cúc",
1157
- "Hạnh Chi",
1158
- "Hạnh Dung",
1159
- "Hạnh Linh",
1160
- "Hạnh My",
1161
- "Hạnh Nga",
1162
- "Hạnh Nhơn",
1163
- "Hạnh Phương",
1164
- "Hạnh San",
1165
- "Hạnh Thảo",
1166
- "Hạnh Trang",
1167
- "Hạnh Vi",
1168
- "Hải Anh",
1169
- "Hải Châu",
1170
- "Hải Duyên",
1171
- "Hải Dương",
1172
- "Hải Miên",
1173
- "Hải My",
1174
- "Hải Mỹ",
1175
- "Hải Ngân",
1176
- "Hải Nhi",
1177
- "Hải Phương",
1178
- "Hải Phượng",
1179
- "Hải San",
1180
- "Hải Sinh",
1181
- "Hải Thanh",
1182
- "Hải Thảo",
1183
- "Hải Thụy",
1184
- "Hải Uyên",
1185
- "Hải Vy",
1186
- "Hải Vân",
1187
- "Hải Yến",
1188
- "Hải Ân",
1189
- "Hải Ðường",
1190
- "Hảo Nhi",
1191
- "Hằng Anh",
1192
- "Hằng Nga",
1193
- "Họa Mi",
1194
- "Hồ Diệp",
1195
- "Hồng Anh",
1196
- "Hồng Bạch Thảo",
1197
- "Hồng Châu",
1198
- "Hồng Diễm",
1199
- "Hồng Giang",
1200
- "Hồng Hoa",
1201
- "Hồng Hà",
1202
- "Hồng Hạnh",
1203
- "Hồng Khanh",
1204
- "Hồng Khuê",
1205
- "Hồng Khôi",
1206
- "Hồng Linh",
1207
- "Hồng Liên",
1208
- "Hồng Lâm",
1209
- "Hồng Mai",
1210
- "Hồng Nga",
1211
- "Hồng Ngân",
1212
- "Hồng Ngọc",
1213
- "Hồng Nhung",
1214
- "Hồng Như",
1215
- "Hồng Nhạn",
1216
- "Hồng Oanh",
1217
- "Hồng Phúc",
1218
- "Hồng Phương",
1219
- "Hồng Quế",
1220
- "Hồng Thu",
1221
- "Hồng Thúy",
1222
- "Hồng Thư",
1223
- "Hồng Thảo",
1224
- "Hồng Thắm",
1225
- "Hồng Thủy",
1226
- "Hồng Trúc",
1227
- "Hồng Tâm",
1228
- "Hồng Vân",
1229
- "Hồng Xuân",
1230
- "Hồng Ðiệp",
1231
- "Hồng Ðào",
1232
- "Hồng Đăng",
1233
- "Khiết Linh",
1234
- "Khiết Tâm",
1235
- "Khuê Trung",
1236
- "Khánh Chi",
1237
- "Khánh Giang",
1238
- "Khánh Giao",
1239
- "Khánh Huyền",
1240
- "Khánh Hà",
1241
- "Khánh Hằng",
1242
- "Khánh Linh",
1243
- "Khánh Ly",
1244
- "Khánh Mai",
1245
- "Khánh My",
1246
- "Khánh Ngân",
1247
- "Khánh Ngọc",
1248
- "Khánh Quyên",
1249
- "Khánh Quỳnh",
1250
- "Khánh Thủy",
1251
- "Khánh Trang",
1252
- "Khánh Vi",
1253
- "Khánh Vy",
1254
- "Khánh Vân",
1255
- "Khúc Lan",
1256
- "Khả Khanh",
1257
- "Khả Tú",
1258
- "Khả Ái",
1259
- "Khải Ca",
1260
- "Khải Hà",
1261
- "Khải Tâm",
1262
- "Kim Anh",
1263
- "Kim Chi",
1264
- "Kim Cương",
1265
- "Kim Dung",
1266
- "Kim Duyên",
1267
- "Kim Hoa",
1268
- "Kim Hương",
1269
- "Kim Khanh",
1270
- "Kim Khuyên",
1271
- "Kim Khánh",
1272
- "Kim Lan",
1273
- "Kim Liên",
1274
- "Kim Loan",
1275
- "Kim Ly",
1276
- "Kim Mai",
1277
- "Kim Ngân",
1278
- "Kim Ngọc",
1279
- "Kim Oanh",
1280
- "Kim Phượng",
1281
- "Kim Quyên",
1282
- "Kim Sa",
1283
- "Kim Thanh",
1284
- "Kim Thoa",
1285
- "Kim Thu",
1286
- "Kim Thy",
1287
- "Kim Thông",
1288
- "Kim Thư",
1289
- "Kim Thảo",
1290
- "Kim Thủy",
1291
- "Kim Trang",
1292
- "Kim Tuyến",
1293
- "Kim Tuyết",
1294
- "Kim Tuyền",
1295
- "Kim Xuyến",
1296
- "Kim Xuân",
1297
- "Kim Yến",
1298
- "Kim Ánh",
1299
- "Kim Đan",
1300
- "Kiết Hồng",
1301
- "Kiết Trinh",
1302
- "Kiều Anh",
1303
- "Kiều Diễm",
1304
- "Kiều Dung",
1305
- "Kiều Giang",
1306
- "Kiều Hoa",
1307
- "Kiều Hạnh",
1308
- "Kiều Khanh",
1309
- "Kiều Loan",
1310
- "Kiều Mai",
1311
- "Kiều Minh",
1312
- "Kiều Mỹ",
1313
- "Kiều Nga",
1314
- "Kiều Nguyệt",
1315
- "Kiều Nương",
1316
- "Kiều Thu",
1317
- "Kiều Trang",
1318
- "Kiều Trinh",
1319
- "Kỳ Anh",
1320
- "Kỳ Diệu",
1321
- "Kỳ Duyên",
1322
- "Lam Giang",
1323
- "Lam Hà",
1324
- "Lam Khê",
1325
- "Lam Ngọc",
1326
- "Lam Tuyền",
1327
- "Lan Anh",
1328
- "Lan Chi",
1329
- "Lan Hương",
1330
- "Lan Khuê",
1331
- "Lan Ngọc",
1332
- "Lan Nhi",
1333
- "Lan Phương",
1334
- "Lan Thương",
1335
- "Lan Trúc",
1336
- "Lan Vy",
1337
- "Linh Chi",
1338
- "Linh Châu",
1339
- "Linh Duyên",
1340
- "Linh Giang",
1341
- "Linh Hà",
1342
- "Linh Lan",
1343
- "Linh Nhi",
1344
- "Linh Phương",
1345
- "Linh Phượng",
1346
- "Linh San",
1347
- "Linh Trang",
1348
- "Linh Ðan",
1349
- "Liên Chi",
1350
- "Liên Hoa",
1351
- "Liên Hương",
1352
- "Liên Như",
1353
- "Liên Phương",
1354
- "Liên Trân",
1355
- "Liễu Oanh",
1356
- "Loan Châu",
1357
- "Ly Châu",
1358
- "Lâm Nhi",
1359
- "Lâm Oanh",
1360
- "Lâm Tuyền",
1361
- "Lâm Uyên",
1362
- "Lê Quỳnh",
1363
- "Lưu Ly",
1364
- "Lệ Băng",
1365
- "Lệ Chi",
1366
- "Lệ Giang",
1367
- "Lệ Hoa",
1368
- "Lệ Huyền",
1369
- "Lệ Khanh",
1370
- "Lệ Nga",
1371
- "Lệ Nhi",
1372
- "Lệ Quyên",
1373
- "Lệ Quân",
1374
- "Lệ Thanh",
1375
- "Lệ Thu",
1376
- "Lệ Thủy",
1377
- "Lộc Uyên",
1378
- "Lộc Uyển",
1379
- "Lục Bình",
1380
- "Mai Anh",
1381
- "Mai Chi",
1382
- "Mai Châu",
1383
- "Mai Hiền",
1384
- "Mai Hà",
1385
- "Mai Hương",
1386
- "Mai Hạ",
1387
- "Mai Khanh",
1388
- "Mai Khôi",
1389
- "Mai Lan",
1390
- "Mai Linh",
1391
- "Mai Liên",
1392
- "Mai Loan",
1393
- "Mai Ly",
1394
- "Mai Nhi",
1395
- "Mai Phương",
1396
- "Mai Quyên",
1397
- "Mai Thanh",
1398
- "Mai Thu",
1399
- "Mai Thy",
1400
- "Mai Thảo",
1401
- "Mai Trinh",
1402
- "Mai Tâm",
1403
- "Mai Vy",
1404
- "Minh An",
1405
- "Minh Châu",
1406
- "Minh Duyên",
1407
- "Minh Hiền",
1408
- "Minh Huyền",
1409
- "Minh Huệ",
1410
- "Minh Hà",
1411
- "Minh Hương",
1412
- "Minh Hạnh",
1413
- "Minh Hằng",
1414
- "Minh Hồng",
1415
- "Minh Khai",
1416
- "Minh Khuê",
1417
- "Minh Loan",
1418
- "Minh Minh",
1419
- "Minh Nguyệt",
1420
- "Minh Ngọc",
1421
- "Minh Nhi",
1422
- "Minh Như",
1423
- "Minh Phương",
1424
- "Minh Phượng",
1425
- "Minh Thu",
1426
- "Minh Thúy",
1427
- "Minh Thư",
1428
- "Minh Thương",
1429
- "Minh Thảo",
1430
- "Minh Thủy",
1431
- "Minh Trang",
1432
- "Minh Tuyết",
1433
- "Minh Tuệ",
1434
- "Minh Tâm",
1435
- "Minh Uyên",
1436
- "Minh Vy",
1437
- "Minh Xuân",
1438
- "Minh Yến",
1439
- "Minh Đan",
1440
- "Mậu Xuân",
1441
- "Mộc Miên",
1442
- "Mộng Hoa",
1443
- "Mộng Hương",
1444
- "Mộng Hằng",
1445
- "Mộng Lan",
1446
- "Mộng Liễu",
1447
- "Mộng Nguyệt",
1448
- "Mộng Nhi",
1449
- "Mộng Quỳnh",
1450
- "Mộng Thi",
1451
- "Mộng Thu",
1452
- "Mộng Tuyền",
1453
- "Mộng Vi",
1454
- "Mộng Vy",
1455
- "Mộng Vân",
1456
- "Mộng Ðiệp",
1457
- "Mỹ Anh",
1458
- "Mỹ Diễm",
1459
- "Mỹ Dung",
1460
- "Mỹ Duyên",
1461
- "Mỹ Hiệp",
1462
- "Mỹ Hoàn",
1463
- "Mỹ Huyền",
1464
- "Mỹ Huệ",
1465
- "Mỹ Hường",
1466
- "Mỹ Hạnh",
1467
- "Mỹ Khuyên",
1468
- "Mỹ Kiều",
1469
- "Mỹ Lan",
1470
- "Mỹ Loan",
1471
- "Mỹ Lệ",
1472
- "Mỹ Lợi",
1473
- "Mỹ Nga",
1474
- "Mỹ Ngọc",
1475
- "Mỹ Nhi",
1476
- "Mỹ Nhân",
1477
- "Mỹ Nương",
1478
- "Mỹ Phương",
1479
- "Mỹ Phượng",
1480
- "Mỹ Phụng",
1481
- "Mỹ Thuần",
1482
- "Mỹ Thuận",
1483
- "Mỹ Trang",
1484
- "Mỹ Trâm",
1485
- "Mỹ Tâm",
1486
- "Mỹ Uyên",
1487
- "Mỹ Vân",
1488
- "Mỹ Xuân",
1489
- "Mỹ Yến",
1490
- "Nghi Dung",
1491
- "Nghi Minh",
1492
- "Nghi Xuân",
1493
- "Nguyên Hồng",
1494
- "Nguyên Thảo",
1495
- "Nguyết Ánh",
1496
- "Nguyệt Anh",
1497
- "Nguyệt Cát",
1498
- "Nguyệt Cầm",
1499
- "Nguyệt Hà",
1500
- "Nguyệt Hồng",
1501
- "Nguyệt Lan",
1502
- "Nguyệt Minh",
1503
- "Nguyệt Nga",
1504
- "Nguyệt Quế",
1505
- "Nguyệt Uyển",
1506
- "Nguyệt Ánh",
1507
- "Ngân Anh",
1508
- "Ngân Hà",
1509
- "Ngân Thanh",
1510
- "Ngân Trúc",
1511
- "Ngọc Anh",
1512
- "Ngọc Bích",
1513
- "Ngọc Cầm",
1514
- "Ngọc Diệp",
1515
- "Ngọc Dung",
1516
- "Ngọc Hiền",
1517
- "Ngọc Hoa",
1518
- "Ngọc Hoan",
1519
- "Ngọc Hoàn",
1520
- "Ngọc Huyền",
1521
- "Ngọc Huệ",
1522
- "Ngọc Hà",
1523
- "Ngọc Hân",
1524
- "Ngọc Hạ",
1525
- "Ngọc Hạnh",
1526
- "Ngọc Hằng",
1527
- "Ngọc Khanh",
1528
- "Ngọc Khuê",
1529
- "Ngọc Khánh",
1530
- "Ngọc Lam",
1531
- "Ngọc Lan",
1532
- "Ngọc Linh",
1533
- "Ngọc Liên",
1534
- "Ngọc Loan",
1535
- "Ngọc Ly",
1536
- "Ngọc Lâm",
1537
- "Ngọc Lý",
1538
- "Ngọc Lệ",
1539
- "Ngọc Mai",
1540
- "Ngọc Nhi",
1541
- "Ngọc Nữ",
1542
- "Ngọc Oanh",
1543
- "Ngọc Phụng",
1544
- "Ngọc Quyên",
1545
- "Ngọc Quế",
1546
- "Ngọc Quỳnh",
1547
- "Ngọc San",
1548
- "Ngọc Sương",
1549
- "Ngọc Thi",
1550
- "Ngọc Thy",
1551
- "Ngọc Thơ",
1552
- "Ngọc Trinh",
1553
- "Ngọc Trâm",
1554
- "Ngọc Tuyết",
1555
- "Ngọc Tâm",
1556
- "Ngọc Tú",
1557
- "Ngọc Uyên",
1558
- "Ngọc Uyển",
1559
- "Ngọc Vy",
1560
- "Ngọc Vân",
1561
- "Ngọc Yến",
1562
- "Ngọc Ái",
1563
- "Ngọc Ánh",
1564
- "Ngọc Ðiệp",
1565
- "Ngọc Ðàn",
1566
- "Ngọc Ðào",
1567
- "Nhan Hồng",
1568
- "Nhã Hương",
1569
- "Nhã Hồng",
1570
- "Nhã Khanh",
1571
- "Nhã Lý",
1572
- "Nhã Mai",
1573
- "Nhã Sương",
1574
- "Nhã Thanh",
1575
- "Nhã Trang",
1576
- "Nhã Trúc",
1577
- "Nhã Uyên",
1578
- "Nhã Yến",
1579
- "Nhã Ý",
1580
- "Như Anh",
1581
- "Như Bảo",
1582
- "Như Hoa",
1583
- "Như Hảo",
1584
- "Như Hồng",
1585
- "Như Loan",
1586
- "Như Mai",
1587
- "Như Ngà",
1588
- "Như Ngọc",
1589
- "Như Phương",
1590
- "Như Quân",
1591
- "Như Quỳnh",
1592
- "Như Thảo",
1593
- "Như Trân",
1594
- "Như Tâm",
1595
- "Như Ý",
1596
- "Nhất Thương",
1597
- "Nhật Dạ",
1598
- "Nhật Hà",
1599
- "Nhật Hạ",
1600
- "Nhật Lan",
1601
- "Nhật Linh",
1602
- "Nhật Lệ",
1603
- "Nhật Mai",
1604
- "Nhật Phương",
1605
- "Nhật Ánh",
1606
- "Oanh Thơ",
1607
- "Oanh Vũ",
1608
- "Phi Khanh",
1609
- "Phi Nhung",
1610
- "Phi Nhạn",
1611
- "Phi Phi",
1612
- "Phi Phượng",
1613
- "Phong Lan",
1614
- "Phương An",
1615
- "Phương Anh",
1616
- "Phương Chi",
1617
- "Phương Châu",
1618
- "Phương Diễm",
1619
- "Phương Dung",
1620
- "Phương Giang",
1621
- "Phương Hiền",
1622
- "Phương Hoa",
1623
- "Phương Hạnh",
1624
- "Phương Lan",
1625
- "Phương Linh",
1626
- "Phương Liên",
1627
- "Phương Loan",
1628
- "Phương Mai",
1629
- "Phương Nghi",
1630
- "Phương Ngọc",
1631
- "Phương Nhi",
1632
- "Phương Nhung",
1633
- "Phương Phương",
1634
- "Phương Quyên",
1635
- "Phương Quân",
1636
- "Phương Quế",
1637
- "Phương Quỳnh",
1638
- "Phương Thanh",
1639
- "Phương Thi",
1640
- "Phương Thùy",
1641
- "Phương Thảo",
1642
- "Phương Thủy",
1643
- "Phương Trang",
1644
- "Phương Trinh",
1645
- "Phương Trà",
1646
- "Phương Trâm",
1647
- "Phương Tâm",
1648
- "Phương Uyên",
1649
- "Phương Yến",
1650
- "Phước Bình",
1651
- "Phước Huệ",
1652
- "Phượng Bích",
1653
- "Phượng Liên",
1654
- "Phượng Loan",
1655
- "Phượng Lệ",
1656
- "Phượng Nga",
1657
- "Phượng Nhi",
1658
- "Phượng Tiên",
1659
- "Phượng Uyên",
1660
- "Phượng Vy",
1661
- "Phượng Vũ",
1662
- "Phụng Yến",
1663
- "Quế Anh",
1664
- "Quế Chi",
1665
- "Quế Linh",
1666
- "Quế Lâm",
1667
- "Quế Phương",
1668
- "Quế Thu",
1669
- "Quỳnh Anh",
1670
- "Quỳnh Chi",
1671
- "Quỳnh Dao",
1672
- "Quỳnh Dung",
1673
- "Quỳnh Giang",
1674
- "Quỳnh Giao",
1675
- "Quỳnh Hoa",
1676
- "Quỳnh Hà",
1677
- "Quỳnh Hương",
1678
- "Quỳnh Lam",
1679
- "Quỳnh Liên",
1680
- "Quỳnh Lâm",
1681
- "Quỳnh Nga",
1682
- "Quỳnh Ngân",
1683
- "Quỳnh Nhi",
1684
- "Quỳnh Nhung",
1685
- "Quỳnh Như",
1686
- "Quỳnh Phương",
1687
- "Quỳnh Sa",
1688
- "Quỳnh Thanh",
1689
- "Quỳnh Thơ",
1690
- "Quỳnh Tiên",
1691
- "Quỳnh Trang",
1692
- "Quỳnh Trâm",
1693
- "Quỳnh Vân",
1694
- "Sao Băng",
1695
- "Sao Mai",
1696
- "Song Kê",
1697
- "Song Lam",
1698
- "Song Oanh",
1699
- "Song Thư",
1700
- "Sông Hà",
1701
- "Sông Hương",
1702
- "Sơn Ca",
1703
- "Sơn Tuyền",
1704
- "Sương Sương",
1705
- "Thanh Bình",
1706
- "Thanh Dân",
1707
- "Thanh Giang",
1708
- "Thanh Hiếu",
1709
- "Thanh Hiền",
1710
- "Thanh Hoa",
1711
- "Thanh Huyền",
1712
- "Thanh Hà",
1713
- "Thanh Hương",
1714
- "Thanh Hường",
1715
- "Thanh Hạnh",
1716
- "Thanh Hảo",
1717
- "Thanh Hằng",
1718
- "Thanh Hồng",
1719
- "Thanh Kiều",
1720
- "Thanh Lam",
1721
- "Thanh Lan",
1722
- "Thanh Loan",
1723
- "Thanh Lâm",
1724
- "Thanh Mai",
1725
- "Thanh Mẫn",
1726
- "Thanh Nga",
1727
- "Thanh Nguyên",
1728
- "Thanh Ngân",
1729
- "Thanh Ngọc",
1730
- "Thanh Nhung",
1731
- "Thanh Nhàn",
1732
- "Thanh Nhã",
1733
- "Thanh Phương",
1734
- "Thanh Thanh",
1735
- "Thanh Thiên",
1736
- "Thanh Thu",
1737
- "Thanh Thúy",
1738
- "Thanh Thư",
1739
- "Thanh Thảo",
1740
- "Thanh Thủy",
1741
- "Thanh Trang",
1742
- "Thanh Trúc",
1743
- "Thanh Tuyết",
1744
- "Thanh Tuyền",
1745
- "Thanh Tâm",
1746
- "Thanh Uyên",
1747
- "Thanh Vy",
1748
- "Thanh Vân",
1749
- "Thanh Xuân",
1750
- "Thanh Yến",
1751
- "Thanh Đan",
1752
- "Thi Cầm",
1753
- "Thi Ngôn",
1754
- "Thi Thi",
1755
- "Thi Xuân",
1756
- "Thi Yến",
1757
- "Thiên Di",
1758
- "Thiên Duyên",
1759
- "Thiên Giang",
1760
- "Thiên Hà",
1761
- "Thiên Hương",
1762
- "Thiên Khánh",
1763
- "Thiên Kim",
1764
- "Thiên Lam",
1765
- "Thiên Lan",
1766
- "Thiên Mai",
1767
- "Thiên Mỹ",
1768
- "Thiên Nga",
1769
- "Thiên Nương",
1770
- "Thiên Phương",
1771
- "Thiên Thanh",
1772
- "Thiên Thêu",
1773
- "Thiên Thư",
1774
- "Thiên Thảo",
1775
- "Thiên Trang",
1776
- "Thiên Tuyền",
1777
- "Thiếu Mai",
1778
- "Thiều Ly",
1779
- "Thiện Mỹ",
1780
- "Thiện Tiên",
1781
- "Thu Duyên",
1782
- "Thu Giang",
1783
- "Thu Hiền",
1784
- "Thu Hoài",
1785
- "Thu Huyền",
1786
- "Thu Huệ",
1787
- "Thu Hà",
1788
- "Thu Hậu",
1789
- "Thu Hằng",
1790
- "Thu Hồng",
1791
- "Thu Linh",
1792
- "Thu Liên",
1793
- "Thu Loan",
1794
- "Thu Mai",
1795
- "Thu Minh",
1796
- "Thu Nga",
1797
- "Thu Nguyệt",
1798
- "Thu Ngà",
1799
- "Thu Ngân",
1800
- "Thu Ngọc",
1801
- "Thu Nhiên",
1802
- "Thu Oanh",
1803
- "Thu Phong",
1804
- "Thu Phương",
1805
- "Thu Phượng",
1806
- "Thu Sương",
1807
- "Thu Thuận",
1808
- "Thu Thảo",
1809
- "Thu Thủy",
1810
- "Thu Trang",
1811
- "Thu Việt",
1812
- "Thu Vân",
1813
- "Thu Vọng",
1814
- "Thu Yến",
1815
- "Thuần Hậu",
1816
- "Thy Khanh",
1817
- "Thy Oanh",
1818
- "Thy Trúc",
1819
- "Thy Vân",
1820
- "Thái Chi",
1821
- "Thái Hà",
1822
- "Thái Hồng",
1823
- "Thái Lan",
1824
- "Thái Lâm",
1825
- "Thái Thanh",
1826
- "Thái Thảo",
1827
- "Thái Tâm",
1828
- "Thái Vân",
1829
- "Thùy Anh",
1830
- "Thùy Dung",
1831
- "Thùy Dương",
1832
- "Thùy Giang",
1833
- "Thùy Linh",
1834
- "Thùy Mi",
1835
- "Thùy My",
1836
- "Thùy Nhi",
1837
- "Thùy Như",
1838
- "Thùy Oanh",
1839
- "Thùy Uyên",
1840
- "Thùy Vân",
1841
- "Thúy Anh",
1842
- "Thúy Diễm",
1843
- "Thúy Hiền",
1844
- "Thúy Huyền",
1845
- "Thúy Hà",
1846
- "Thúy Hương",
1847
- "Thúy Hường",
1848
- "Thúy Hạnh",
1849
- "Thúy Hằng",
1850
- "Thúy Kiều",
1851
- "Thúy Liên",
1852
- "Thúy Liễu",
1853
- "Thúy Loan",
1854
- "Thúy Mai",
1855
- "Thúy Minh",
1856
- "Thúy My",
1857
- "Thúy Nga",
1858
- "Thúy Ngà",
1859
- "Thúy Ngân",
1860
- "Thúy Ngọc",
1861
- "Thúy Phượng",
1862
- "Thúy Quỳnh",
1863
- "Thúy Vi",
1864
- "Thúy Vy",
1865
- "Thúy Vân",
1866
- "Thơ Thơ",
1867
- "Thư Lâm",
1868
- "Thư Sương",
1869
- "Thương Huyền",
1870
- "Thương Nga",
1871
- "Thương Thương",
1872
- "Thường Xuân",
1873
- "Thạch Thảo",
1874
- "Thảo Hương",
1875
- "Thảo Hồng",
1876
- "Thảo Linh",
1877
- "Thảo Ly",
1878
- "Thảo Mai",
1879
- "Thảo My",
1880
- "Thảo Nghi",
1881
- "Thảo Nguyên",
1882
- "Thảo Nhi",
1883
- "Thảo Quyên",
1884
- "Thảo Tiên",
1885
- "Thảo Trang",
1886
- "Thảo Uyên",
1887
- "Thảo Vy",
1888
- "Thảo Vân",
1889
- "Thục Anh",
1890
- "Thục Khuê",
1891
- "Thục Nhi",
1892
- "Thục Oanh",
1893
- "Thục Quyên",
1894
- "Thục Trang",
1895
- "Thục Trinh",
1896
- "Thục Tâm",
1897
- "Thục Uyên",
1898
- "Thục Vân",
1899
- "Thục Ðoan",
1900
- "Thục Ðào",
1901
- "Thục Ðình",
1902
- "Thụy Du",
1903
- "Thụy Khanh",
1904
- "Thụy Linh",
1905
- "Thụy Lâm",
1906
- "Thụy Miên",
1907
- "Thụy Nương",
1908
- "Thụy Trinh",
1909
- "Thụy Trâm",
1910
- "Thụy Uyên",
1911
- "Thụy Vân",
1912
- "Thụy Ðào",
1913
- "Thủy Hằng",
1914
- "Thủy Hồng",
1915
- "Thủy Linh",
1916
- "Thủy Minh",
1917
- "Thủy Nguyệt",
1918
- "Thủy Quỳnh",
1919
- "Thủy Tiên",
1920
- "Thủy Trang",
1921
- "Thủy Tâm",
1922
- "Tinh Tú",
1923
- "Tiên Phương",
1924
- "Tiểu Mi",
1925
- "Tiểu My",
1926
- "Tiểu Quỳnh",
1927
- "Trang Anh",
1928
- "Trang Linh",
1929
- "Trang Nhã",
1930
- "Trang Tâm",
1931
- "Trang Ðài",
1932
- "Triều Nguyệt",
1933
- "Triều Thanh",
1934
- "Triệu Mẫn",
1935
- "Trung Anh",
1936
- "Trà Giang",
1937
- "Trà My",
1938
- "Trâm Anh",
1939
- "Trâm Oanh",
1940
- "Trân Châu",
1941
- "Trúc Chi",
1942
- "Trúc Lam",
1943
- "Trúc Lan",
1944
- "Trúc Linh",
1945
- "Trúc Liên",
1946
- "Trúc Loan",
1947
- "Trúc Ly",
1948
- "Trúc Lâm",
1949
- "Trúc Mai",
1950
- "Trúc Phương",
1951
- "Trúc Quân",
1952
- "Trúc Quỳnh",
1953
- "Trúc Vy",
1954
- "Trúc Vân",
1955
- "Trúc Ðào",
1956
- "Trúc Đào",
1957
- "Trầm Hương",
1958
- "Tuyết Anh",
1959
- "Tuyết Băng",
1960
- "Tuyết Chi",
1961
- "Tuyết Hoa",
1962
- "Tuyết Hân",
1963
- "Tuyết Hương",
1964
- "Tuyết Hồng",
1965
- "Tuyết Lan",
1966
- "Tuyết Loan",
1967
- "Tuyết Lâm",
1968
- "Tuyết Mai",
1969
- "Tuyết Nga",
1970
- "Tuyết Nhi",
1971
- "Tuyết Nhung",
1972
- "Tuyết Oanh",
1973
- "Tuyết Thanh",
1974
- "Tuyết Trinh",
1975
- "Tuyết Trầm",
1976
- "Tuyết Tâm",
1977
- "Tuyết Vy",
1978
- "Tuyết Vân",
1979
- "Tuyết Xuân",
1980
- "Tuyền Lâm",
1981
- "Tuệ Lâm",
1982
- "Tuệ Mẫn",
1983
- "Tuệ Nhi",
1984
- "Tâm Hiền",
1985
- "Tâm Hạnh",
1986
- "Tâm Hằng",
1987
- "Tâm Khanh",
1988
- "Tâm Linh",
1989
- "Tâm Nguyên",
1990
- "Tâm Nguyệt",
1991
- "Tâm Nhi",
1992
- "Tâm Như",
1993
- "Tâm Thanh",
1994
- "Tâm Trang",
1995
- "Tâm Ðoan",
1996
- "Tâm Đan",
1997
- "Tùng Linh",
1998
- "Tùng Lâm",
1999
- "Tùng Quân",
2000
- "Tùy Anh",
2001
- "Tùy Linh",
2002
- "Tú Anh",
2003
- "Tú Ly",
2004
- "Tú Nguyệt",
2005
- "Tú Quyên",
2006
- "Tú Quỳnh",
2007
- "Tú Sương",
2008
- "Tú Trinh",
2009
- "Tú Tâm",
2010
- "Tú Uyên",
2011
- "Túy Loan",
2012
- "Tường Chinh",
2013
- "Tường Vi",
2014
- "Tường Vy",
2015
- "Tường Vân",
2016
- "Tịnh Lâm",
2017
- "Tịnh Nhi",
2018
- "Tịnh Như",
2019
- "Tịnh Tâm",
2020
- "Tịnh Yên",
2021
- "Tố Loan",
2022
- "Tố Nga",
2023
- "Tố Nhi",
2024
- "Tố Quyên",
2025
- "Tố Tâm",
2026
- "Tố Uyên",
2027
- "Từ Dung",
2028
- "Từ Ân",
2029
- "Uyên Minh",
2030
- "Uyên My",
2031
- "Uyên Nhi",
2032
- "Uyên Phương",
2033
- "Uyên Thi",
2034
- "Uyên Thy",
2035
- "Uyên Thơ",
2036
- "Uyên Trâm",
2037
- "Uyên Vi",
2038
- "Uyển Khanh",
2039
- "Uyển My",
2040
- "Uyển Nghi",
2041
- "Uyển Nhi",
2042
- "Uyển Nhã",
2043
- "Uyển Như",
2044
- "Vi Quyên",
2045
- "Vinh Diệu",
2046
- "Việt Hà",
2047
- "Việt Hương",
2048
- "Việt Khuê",
2049
- "Việt Mi",
2050
- "Việt Nga",
2051
- "Việt Nhi",
2052
- "Việt Thi",
2053
- "Việt Trinh",
2054
- "Việt Tuyết",
2055
- "Việt Yến",
2056
- "Vy Lam",
2057
- "Vy Lan",
2058
- "Vàng Anh",
2059
- "Vành Khuyên",
2060
- "Vân Anh",
2061
- "Vân Chi",
2062
- "Vân Du",
2063
- "Vân Hà",
2064
- "Vân Hương",
2065
- "Vân Khanh",
2066
- "Vân Khánh",
2067
- "Vân Linh",
2068
- "Vân Ngọc",
2069
- "Vân Nhi",
2070
- "Vân Phi",
2071
- "Vân Phương",
2072
- "Vân Quyên",
2073
- "Vân Quỳnh",
2074
- "Vân Thanh",
2075
- "Vân Thúy",
2076
- "Vân Thường",
2077
- "Vân Tiên",
2078
- "Vân Trang",
2079
- "Vân Trinh",
2080
- "Vũ Hồng",
2081
- "Xuyến Chi",
2082
- "Xuân Bảo",
2083
- "Xuân Dung",
2084
- "Xuân Hiền",
2085
- "Xuân Hoa",
2086
- "Xuân Hân",
2087
- "Xuân Hương",
2088
- "Xuân Hạnh",
2089
- "Xuân Lan",
2090
- "Xuân Linh",
2091
- "Xuân Liễu",
2092
- "Xuân Loan",
2093
- "Xuân Lâm",
2094
- "Xuân Mai",
2095
- "Xuân Nghi",
2096
- "Xuân Ngọc",
2097
- "Xuân Nhi",
2098
- "Xuân Nhiên",
2099
- "Xuân Nương",
2100
- "Xuân Phương",
2101
- "Xuân Phượng",
2102
- "Xuân Thanh",
2103
- "Xuân Thu",
2104
- "Xuân Thảo",
2105
- "Xuân Thủy",
2106
- "Xuân Trang",
2107
- "Xuân Tâm",
2108
- "Xuân Uyên",
2109
- "Xuân Vân",
2110
- "Xuân Yến",
2111
- "Xuân xanh",
2112
- "Yên Bằng",
2113
- "Yên Mai",
2114
- "Yên Nhi",
2115
- "Yên Ðan",
2116
- "Yên Đan",
2117
- "Yến Anh",
2118
- "Yến Hồng",
2119
- "Yến Loan",
2120
- "Yến Mai",
2121
- "Yến My",
2122
- "Yến Nhi",
2123
- "Yến Oanh",
2124
- "Yến Phương",
2125
- "Yến Phượng",
2126
- "Yến Thanh",
2127
- "Yến Thảo",
2128
- "Yến Trang",
2129
- "Yến Trinh",
2130
- "Yến Trâm",
2131
- "Yến Ðan",
2132
- "Ái Hồng",
2133
- "Ái Khanh",
2134
- "Ái Linh",
2135
- "Ái Nhi",
2136
- "Ái Nhân",
2137
- "Ái Thi",
2138
- "Ái Thy",
2139
- "Ái Vân",
2140
- "Ánh Dương",
2141
- "Ánh Hoa",
2142
- "Ánh Hồng",
2143
- "Ánh Linh",
2144
- "Ánh Lệ",
2145
- "Ánh Mai",
2146
- "Ánh Nguyệt",
2147
- "Ánh Ngọc",
2148
- "Ánh Thơ",
2149
- "Ánh Trang",
2150
- "Ánh Tuyết",
2151
- "Ánh Xuân",
2152
- "Ðan Khanh",
2153
- "Ðan Quỳnh",
2154
- "Ðan Thu",
2155
- "Ðinh Hương",
2156
- "Ðoan Thanh",
2157
- "Ðoan Trang",
2158
- "Ðài Trang",
2159
- "Ðông Nghi",
2160
- "Ðông Nhi",
2161
- "Ðông Trà",
2162
- "Ðông Tuyền",
2163
- "Ðông Vy",
2164
- "Ðông Ðào",
2165
- "Ðồng Dao",
2166
- "Ý Bình",
2167
- "Ý Lan",
2168
- "Ý Nhi",
2169
- "Đan Linh",
2170
- "Đan Quỳnh",
2171
- "Đan Thanh",
2172
- "Đan Thu",
2173
- "Đan Thư",
2174
- "Đan Tâm",
2175
- "Đinh Hương",
2176
- "Đoan Thanh",
2177
- "Đoan Trang",
2178
- "Đài Trang",
2179
- "Đông Nghi",
2180
- "Đông Trà",
2181
- "Đông Tuyền",
2182
- "Đông Vy",
2183
- "Đơn Thuần",
2184
- "Đức Hạnh",
2185
- "Ấu Lăng"
2186
- ]
2187
- let OtherName = [".",",","/","%", "&","*","-","+"];
2188
- try {
2189
- var Name;
2190
- if (name == " " || name == null) return "UNKNOWN";
2191
- switch (female_name.some(a => name.includes(a))) {
2192
- case true: {
2193
- if (!OtherName.includes(name)) Name = "FEMALE";
2194
- else Name = ['FEMALE','MALE'][Math.floor(Math.random() * 2)]; // just temp 🌚
2195
- }
2196
- break;
2197
- case false: {
2198
- if (female_name.some(a => name.split(' ')[name.split(' ').length - 1] == a)) Name = "FEMALE";
2199
- else if (!OtherName.includes(name) && !female_name.includes(name)) Name = "MALE";
2200
- else Name = ['FEMALE','MALE'][Math.floor(Math.random() * 2)]; // just temp 🌚
2201
- }
2202
- break;
2203
- }
2204
- }
2205
- catch (e) {
2206
- return "UNKNOWN";
2207
- }
2208
- return Name || "UNKNOWN";
2209
- }
2210
-
2211
- /**
2212
- * @param {{ [x: string]: { [x: string]: { [x: string]: any; }; }; class: any; untypedData: any; name: any; addedParticipants: any; leftParticipantFbId: any; messageMetadata: { threadKey: { threadFbId: any; otherUserFbId: any; }; adminText: any; actorFbId: any; }; participants: any; }} m
2213
- */
2214
-
2215
880
  function formatDeltaEvent(m) {
2216
- var { updateData,getData,hasData } = require('./Extra/ExtraGetThread');
2217
- var logMessageType;
2218
- var logMessageData;
2219
-
2220
- switch (m.class) {
2221
- case "AdminTextMessage":
2222
- logMessageType = getAdminTextMessageType(m);
2223
- logMessageData = m.untypedData;
2224
- break;
2225
- case "ThreadName":
2226
- logMessageType = "log:thread-name";
2227
- logMessageData = { name: m.name };
2228
- break;
2229
- case "ParticipantsAddedToGroupThread":
2230
- logMessageType = "log:subscribe";
2231
- logMessageData = { addedParticipants: m.addedParticipants };
2232
- break;
2233
- case "ParticipantLeftGroupThread":
2234
- logMessageType = "log:unsubscribe";
2235
- logMessageData = { leftParticipantFbId: m.leftParticipantFbId };
2236
- break;
2237
- case "UserLocation": {
2238
- logMessageType = "log:user-location";
2239
- logMessageData = {
2240
- Image: m.attachments[0].mercury.extensible_attachment.story_attachment.media.image,
2241
- Location: m.attachments[0].mercury.extensible_attachment.story_attachment.target.location_title,
2242
- coordinates: m.attachments[0].mercury.extensible_attachment.story_attachment.target.coordinate,
2243
- url: m.attachments[0].mercury.extensible_attachment.story_attachment.url
2244
- };
2245
- }
2246
- }
2247
- switch (hasData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()))) {
2248
- case true: {
2249
- switch (logMessageType) {
2250
- case "log:thread-color": {
2251
- let x = getData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2252
- x.emoji = (logMessageData.theme_emoji || x.emoji);
2253
- x.color = (logMessageData['theme_color'] || x.color);
2254
- updateData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),x);
2255
- }
2256
- break;
2257
- case "log:thread-icon": {
2258
- let x = getData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2259
- x.emoji = (logMessageData['thread_icon'] || x.emoji);
2260
- updateData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),x);
2261
- }
2262
- break;
2263
- case "log:user-nickname": {
2264
- let x = getData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2265
- x.nicknames[logMessageData.participant_id] = (logMessageData.nickname.length == 0 ? x.userInfo.find(i => i.id == String(logMessageData.participant_id)).name : logMessageData.nickname);
2266
- updateData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),x);
2267
- }
2268
- break;
2269
- case "log:thread-admins": {
2270
- let x = getData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2271
- switch (logMessageData.ADMIN_EVENT) {
2272
- case "add_admin": {
2273
- x.adminIDs.push({ id: logMessageData.TARGET_ID });
2274
- }
2275
- break;
2276
- case "remove_admin": {
2277
- x.adminIDs = x.adminIDs.filter(item => item.id != logMessageData.TARGET_ID);
2278
- }
2279
- break;
2280
- }
2281
- updateData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),x);
2282
- }
2283
- break;
2284
- case "log:thread-approval-mode": {
2285
- let x = getData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2286
- if (x.approvalMode == true) {
2287
- x.approvalMode = false;
2288
- }
2289
- else {
2290
- x.approvalMode = true;
2291
- }
2292
- updateData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),x);
2293
- }
2294
- break;
2295
- case "log:thread-name": {
2296
- let x = getData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2297
- x.threadName = (logMessageData.name || formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2298
- updateData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),x);
2299
- }
2300
- break;
2301
- case "log:subscribe": {
2302
- let x = getData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2303
- for (let o of logMessageData.addedParticipants) {
2304
- if (x.userInfo.some(i => i.id == o.userFbId)) continue;
2305
- else {
2306
- x.userInfo.push({
2307
- id: o.userFbId,
2308
- name: o.fullName,
2309
- gender: getGenderByPhysicalMethod(o.fullName)
2310
- });
2311
- x.participantIDs.push(o.userFbId);
2312
- }
2313
- }
2314
- updateData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),x);
2315
- }
2316
- break;
2317
- case "log:unsubscribe": {
2318
- let x = getData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()));
2319
- x.participantIDs = x.participantIDs.filter(item => item != logMessageData.leftParticipantFbId);
2320
- x.userInfo = x.userInfo.filter(item => item.id != logMessageData.leftParticipantFbId);
2321
- if (x.adminIDs.some(i => i.id == logMessageData.leftParticipantFbId)) {
2322
- x.adminIDs = x.adminIDs.filter(item => item.id != logMessageData.leftParticipantFbId);
2323
- }
2324
- updateData(formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),x);
2325
- }
2326
- break;
2327
- }
2328
- }
881
+ let logMessageType;
882
+ let logMessageData;
883
+
884
+ // log:thread-color => {theme_color}
885
+ // log:user-nickname => {participant_id, nickname}
886
+ // log:thread-icon => {thread_icon}
887
+ // log:thread-name => {name}
888
+ // log:subscribe => {addedParticipants - [Array]}
889
+ // log:unsubscribe => {leftParticipantFbId}
890
+
891
+ switch (m.class) {
892
+ case "AdminTextMessage":
893
+ logMessageData = m.untypedData;
894
+ logMessageType = getAdminTextMessageType(m.type);
895
+ break;
896
+ case "ThreadName":
897
+ logMessageType = "log:thread-name";
898
+ logMessageData = { name: m.name };
899
+ break;
900
+ case "ParticipantsAddedToGroupThread":
901
+ logMessageType = "log:subscribe";
902
+ logMessageData = { addedParticipants: m.addedParticipants };
903
+ break;
904
+ case "ParticipantLeftGroupThread":
905
+ logMessageType = "log:unsubscribe";
906
+ logMessageData = { leftParticipantFbId: m.leftParticipantFbId };
907
+ break;
908
+ case "ApprovalQueue":
909
+ logMessageType = "log:approval-queue";
910
+ logMessageData = {
911
+ approvalQueue: {
912
+ action: m.action,
913
+ recipientFbId: m.recipientFbId,
914
+ requestSource: m.requestSource,
915
+ ...m.messageMetadata
916
+ }
917
+ };
918
+ }
919
+ return {
920
+ type: "event",
921
+ threadID: formatID(
922
+ (
923
+ m.messageMetadata.threadKey.threadFbId ||
924
+ m.messageMetadata.threadKey.otherUserFbId
925
+ ).toString()
926
+ ),
927
+ messageID: m.messageMetadata.messageId.toString(),
928
+ logMessageType,
929
+ logMessageData,
930
+ logMessageBody: m.messageMetadata.adminText,
931
+ timestamp: m.messageMetadata.timestamp,
932
+ author: m.messageMetadata.actorFbId,
933
+ participantIDs: m.participants
934
+ };
2329
935
  }
2330
936
 
2331
- return {
2332
- type: "event",
2333
- threadID: formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),
2334
- logMessageType: logMessageType,
2335
- logMessageData: logMessageData,
2336
- logMessageBody: m.messageMetadata.adminText,
2337
- author: m.messageMetadata.actorFbId,
2338
- participantIDs: m.participants || []
2339
- };
2340
- }
2341
-
2342
- /**
2343
- * @param {{ st: any; from: { toString: () => any; }; to: any; thread_fbid: any; hasOwnProperty: (arg0: string) => any; from_mobile: any; realtime_viewer_fbid: any; }} event
2344
- */
2345
-
2346
937
  function formatTyp(event) {
2347
- return {
2348
- isTyping: !!event.st,
2349
- from: event.from.toString(),
2350
- threadID: formatID((event.to || event.thread_fbid || event.from).toString()),
2351
- // When receiving typ indication from mobile, `from_mobile` isn't set.
2352
- // If it is, we just use that value.
2353
- fromMobile: event.hasOwnProperty("from_mobile") ? event.from_mobile : true,
2354
- userID: (event.realtime_viewer_fbid || event.from).toString(),
2355
- type: "typ"
2356
- };
938
+ return {
939
+ isTyping: !!event.st,
940
+ from: event.from.toString(),
941
+ threadID: formatID(
942
+ (event.to || event.thread_fbid || event.from).toString()
943
+ ),
944
+ // When receiving typ indication from mobile, `from_mobile` isn't set.
945
+ // If it is, we just use that value.
946
+ fromMobile: event.hasOwnProperty("from_mobile") ? event.from_mobile : true,
947
+ userID: (event.realtime_viewer_fbid || event.from).toString(),
948
+ type: "typ"
949
+ };
2357
950
  }
2358
951
 
2359
- /**
2360
- * @param {{ threadKey: { otherUserFbId: any; threadFbId: any; }; actorFbId: any; actionTimestampMs: any; }} delta
2361
- */
2362
-
2363
952
  function formatDeltaReadReceipt(delta) {
2364
- // otherUserFbId seems to be used as both the readerID and the threadID in a 1-1 chat.
2365
- // In a group chat actorFbId is used for the reader and threadFbId for the thread.
2366
- return {
2367
- reader: (delta.threadKey.otherUserFbId || delta.actorFbId).toString(),
2368
- time: delta.actionTimestampMs,
2369
- threadID: formatID((delta.threadKey.otherUserFbId || delta.threadKey.threadFbId).toString()),
2370
- type: "read_receipt"
2371
- };
953
+ // otherUserFbId seems to be used as both the readerID and the threadID in a 1-1 chat.
954
+ // In a group chat actorFbId is used for the reader and threadFbId for the thread.
955
+ return {
956
+ reader: (delta.threadKey.otherUserFbId || delta.actorFbId).toString(),
957
+ time: delta.actionTimestampMs,
958
+ threadID: formatID(
959
+ (delta.threadKey.otherUserFbId || delta.threadKey.threadFbId).toString()
960
+ ),
961
+ type: "read_receipt"
962
+ };
2372
963
  }
2373
964
 
2374
- /**
2375
- * @param {{ reader: { toString: () => any; }; time: any; thread_fbid: any; }} event
2376
- */
2377
-
2378
965
  function formatReadReceipt(event) {
2379
- return {
2380
- reader: event.reader.toString(),
2381
- time: event.time,
2382
- threadID: formatID((event.thread_fbid || event.reader).toString()),
2383
- type: "read_receipt"
2384
- };
966
+ return {
967
+ reader: event.reader.toString(),
968
+ time: event.time,
969
+ threadID: formatID((event.thread_fbid || event.reader).toString()),
970
+ type: "read_receipt"
971
+ };
2385
972
  }
2386
973
 
2387
- /**
2388
- * @param {{ chat_ids: any[]; thread_fbids: any[]; timestamp: any; }} event
2389
- */
2390
-
2391
974
  function formatRead(event) {
2392
- return {
2393
- threadID: formatID(((event.chat_ids && event.chat_ids[0]) || (event.thread_fbids && event.thread_fbids[0])).toString()),
2394
- time: event.timestamp,
2395
- type: "read"
2396
- };
975
+ return {
976
+ threadID: formatID(
977
+ (
978
+ (event.chat_ids && event.chat_ids[0]) ||
979
+ (event.thread_fbids && event.thread_fbids[0])
980
+ ).toString()
981
+ ),
982
+ time: event.timestamp,
983
+ type: "read"
984
+ };
2397
985
  }
2398
986
 
2399
- /**
2400
- * @param {string} str
2401
- * @param {string | any[]} startToken
2402
- * @param {string} endToken
2403
- */
2404
-
2405
987
  function getFrom(str, startToken, endToken) {
2406
- var start = str.indexOf(startToken) + startToken.length;
2407
- if (start < startToken.length) return "";
2408
- var lastHalf = str.substring(start);
2409
- var end = lastHalf.indexOf(endToken);
2410
- if (end === -1) throw Error("Could not find endTime " + endToken + " in the given string.");
2411
- return lastHalf.substring(0, end);
2412
- }
2413
-
2414
-
2415
- function getFroms(str, startToken, endToken) {
2416
- //advanced search by kanzuuuuuuuuuu
2417
- let results = [];
2418
- let currentIndex = 0;
2419
-
2420
- while (true) {
2421
- let start = str.indexOf(startToken, currentIndex);
2422
- if (start === -1) break;
2423
-
2424
- start += startToken.length;
2425
-
2426
- let lastHalf = str.substring(start);
2427
- let end = lastHalf.indexOf(endToken);
2428
-
2429
- if (end === -1) {
2430
- if (results.length === 0) {
2431
- throw Error("Could not find endToken `" + endToken + "` in the given string.");
2432
- }
2433
- break;
2434
- }
2435
-
2436
- results.push(lastHalf.substring(0, end));
2437
- currentIndex = start + end + endToken.length;
2438
- }
2439
-
2440
- return results.length === 0 ? "" : results.length === 1 ? results[0] : results;
988
+ const start = str.indexOf(startToken) + startToken.length;
989
+ if (start < startToken.length) return "";
990
+
991
+ const lastHalf = str.substring(start);
992
+ const end = lastHalf.indexOf(endToken);
993
+ if (end === -1) {
994
+ throw Error(
995
+ "Could not find endTime `" + endToken + "` in the given string."
996
+ );
997
+ }
998
+ return lastHalf.substring(0, end);
2441
999
  }
2442
1000
 
2443
- /**
2444
- * @param {string} html
2445
- */
2446
-
2447
1001
  function makeParsable(html) {
2448
- let withoutForLoop = html.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/
2449
- , "");
2450
-
2451
- // (What the fuck FB, why windows style newlines?)
2452
- // So sometimes FB will send us base multiple objects in the same response.
2453
- // They're all valid JSON, one after the other, at the top level. We detect
2454
- // that and make it parse-able by JSON.parse.
2455
- // Ben - July 15th 2017
2456
- //
2457
- // It turns out that Facebook may insert random number of spaces before
2458
- // next object begins (issue #616)
2459
- // rav_kr - 2018-03-19
2460
- let maybeMultipleObjects = withoutForLoop.split(/\}\r\n *\{/);
2461
- if (maybeMultipleObjects.length === 1) return maybeMultipleObjects;
2462
-
2463
- return "[" + maybeMultipleObjects.join("},{") + "]";
1002
+ const withoutForLoop = html.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, "");
1003
+
1004
+ // (What the fuck FB, why windows style newlines?)
1005
+ // So sometimes FB will send us base multiple objects in the same response.
1006
+ // They're all valid JSON, one after the other, at the top level. We detect
1007
+ // that and make it parse-able by JSON.parse.
1008
+ // Ben - July 15th 2017
1009
+ //
1010
+ // It turns out that Facebook may insert random number of spaces before
1011
+ // next object begins (issue #616)
1012
+ // rav_kr - 2018-03-19
1013
+ const maybeMultipleObjects = withoutForLoop.split(/\}\r\n *\{/);
1014
+ if (maybeMultipleObjects.length === 1) return maybeMultipleObjects;
1015
+
1016
+ return "[" + maybeMultipleObjects.join("},{") + "]";
2464
1017
  }
2465
1018
 
2466
- /**
2467
- * @param {any} form
2468
- */
2469
-
2470
1019
  function arrToForm(form) {
2471
- return arrayToObject(form,
2472
- function(/** @type {{ name: any; }} */v) {
2473
- return v.name;
2474
- },
2475
- function(/** @type {{ val: any; }} */v) {
2476
- return v.val;
2477
- }
2478
- );
1020
+ return arrayToObject(
1021
+ form,
1022
+ function (v) {
1023
+ return v.name;
1024
+ },
1025
+ function (v) {
1026
+ return v.val;
1027
+ }
1028
+ );
2479
1029
  }
2480
1030
 
2481
- /**
2482
- * @param {any[]} arr
2483
- * @param {{ (v: any): any; (arg0: any): string | number; }} getKey
2484
- * @param {{ (v: any): any; (arg0: any): any; }} getValue
2485
- */
2486
-
2487
1031
  function arrayToObject(arr, getKey, getValue) {
2488
- return arr.reduce(function(/** @type {{ [x: string]: any; }} */
2489
- acc, /** @type {any} */val) {
2490
- acc[getKey(val)] = getValue(val);
2491
- return acc;
2492
- }, {});
1032
+ return arr.reduce(function (acc, val) {
1033
+ acc[getKey(val)] = getValue(val);
1034
+ return acc;
1035
+ }, {});
2493
1036
  }
2494
1037
 
2495
1038
  function getSignatureID() {
2496
- return Math.floor(Math.random() * 2147483648).toString(16);
1039
+ return Math.floor(Math.random() * 2147483648).toString(16);
2497
1040
  }
2498
1041
 
2499
1042
  function generateTimestampRelative() {
2500
- var d = new Date();
2501
- return d.getHours() + ":" + padZeros(d.getMinutes());
1043
+ const d = new Date();
1044
+ return d.getHours() + ":" + padZeros(d.getMinutes());
2502
1045
  }
2503
1046
 
2504
- /**
2505
- * @param {any} html
2506
- * @param {any} userID
2507
- * @param {{ fb_dtsg: any; ttstamp: any; globalOptions: any; }} ctx
2508
- */
2509
-
2510
1047
  function makeDefaults(html, userID, ctx) {
2511
- var reqCounter = 1;
2512
- var fb_dtsg = getFrom(html, 'name="fb_dtsg" value="', '"');
2513
-
2514
- // @Hack Ok we've done hacky things, this is definitely on top 5.
2515
- // We totally assume the object is flat and try parsing until a }.
2516
- // If it works though it's cool because we get a bunch of extra data things.
2517
- //
2518
- // Update: we don't need this. Leaving it in in case we ever do.
2519
- // Ben - July 15th 2017
2520
-
2521
- // var siteData = getFrom(html, "[\"SiteData\",[],", "},");
2522
- // try {
2523
- // siteData = JSON.parse(siteData + "}");
2524
- // } catch(e) {
2525
- // log.warn("makeDefaults", "Couldn't parse SiteData. Won't have access to some variables.");
2526
- // siteData = {};
2527
- // }
2528
-
2529
- var ttstamp = "2";
2530
- for (var i = 0; i < fb_dtsg.length; i++) ttstamp += fb_dtsg.charCodeAt(i);
2531
- var revision = getFrom(html, 'revision":', ",");
2532
-
2533
- /**
2534
- * @param {{ [x: string]: any; hasOwnProperty: (arg0: string) => any; }} obj
2535
- */
2536
-
2537
- function mergeWithDefaults(obj) {
2538
- // @TODO This is missing a key called __dyn.
2539
- // After some investigation it seems like __dyn is some sort of set that FB
2540
- // calls BitMap. It seems like certain responses have a "define" key in the
2541
- // res.jsmods arrays. I think the code iterates over those and calls `set`
2542
- // on the bitmap for each of those keys. Then it calls
2543
- // bitmap.toCompressedString() which returns what __dyn is.
2544
- //
2545
- // So far the API has been working without this.
2546
- //
2547
- // Ben - July 15th 2017
2548
- var newObj = {
2549
- __user: userID,
2550
- __req: (reqCounter++).toString(36),
2551
- __rev: revision,
2552
- __a: 1,
2553
- // __af: siteData.features,
2554
- fb_dtsg: ctx.fb_dtsg ? ctx.fb_dtsg : fb_dtsg,
2555
- jazoest: ctx.ttstamp ? ctx.ttstamp : ttstamp
2556
- // __spin_r: siteData.__spin_r,
2557
- // __spin_b: siteData.__spin_b,
2558
- // __spin_t: siteData.__spin_t,
2559
- };
2560
-
2561
- // @TODO this is probably not needed.
2562
- // Ben - July 15th 2017
2563
- // if (siteData.be_key) {
2564
- // newObj[siteData.be_key] = siteData.be_mode;
2565
- // }
2566
- // if (siteData.pkg_cohort_key) {
2567
- // newObj[siteData.pkg_cohort_key] = siteData.pkg_cohort;
2568
- // }
2569
-
2570
- if (!obj) return newObj;
2571
- for (var prop in obj)
2572
- if (obj.hasOwnProperty(prop))
2573
- if (!newObj[prop]) newObj[prop] = obj[prop];
2574
- return newObj;
2575
- }
2576
-
2577
- /**
2578
- * @param {any} url
2579
- * @param {any} jar
2580
- * @param {any} form
2581
- * @param {any} ctxx
2582
- */
2583
-
2584
- function postWithDefaults(url, jar, form, ctxx) {
2585
- return post(url, jar, mergeWithDefaults(form), ctx.globalOptions, ctxx || ctx);
2586
- }
2587
-
2588
- /**
2589
- * @param {any} url
2590
- * @param {any} jar
2591
- * @param {any} qs
2592
- * @param {any} ctxx
2593
- */
2594
-
2595
- function getWithDefaults(url, jar, qs, ctxx) {
2596
- return get(url, jar, mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
2597
- }
2598
-
2599
- /**
2600
- * @param {any} url
2601
- * @param {any} jar
2602
- * @param {any} form
2603
- * @param {any} qs
2604
- * @param {any} ctxx
2605
- */
2606
-
2607
- function postFormDataWithDefault(url, jar, form, qs, ctxx) {
2608
- return postFormData(url, jar, mergeWithDefaults(form), mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
2609
- }
2610
-
2611
- return {
2612
- get: getWithDefaults,
2613
- post: postWithDefaults,
2614
- postFormData: postFormDataWithDefault
2615
- };
1048
+ let reqCounter = 1;
1049
+ const fb_dtsg = getFrom(html, 'name="fb_dtsg" value="', '"');
1050
+
1051
+ let ttstamp = "2";
1052
+ for (let i = 0; i < fb_dtsg.length; i++) {
1053
+ ttstamp += fb_dtsg.charCodeAt(i);
1054
+ }
1055
+ const revision = getFrom(html, 'revision":', ",");
1056
+
1057
+ function mergeWithDefaults(obj) {
1058
+ const newObj = {
1059
+ av: userID,
1060
+ __user: userID,
1061
+ __req: (reqCounter++).toString(36),
1062
+ __rev: revision,
1063
+ __a: 1,
1064
+ fb_dtsg: ctx.fb_dtsg || fb_dtsg,
1065
+ jazoest: ctx.ttstamp || ttstamp
1066
+ }
1067
+
1068
+ if (!obj) return newObj;
1069
+
1070
+ for (var prop in obj) {
1071
+ if (obj.hasOwnProperty(prop)) {
1072
+ if (!newObj[prop])
1073
+ newObj[prop] = obj[prop];
1074
+ }
1075
+ }
1076
+
1077
+ return newObj;
1078
+ }
1079
+
1080
+ return {
1081
+ get: (url, jar, qs, ctxx, customHeader = {}) => get(url, jar, mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx, customHeader),
1082
+ post: (url, jar, form, ctxx, customHeader = {}) => post(url, jar, mergeWithDefaults(form), ctx.globalOptions, ctxx || ctx, customHeader),
1083
+ postFormData: (url, jar, form, qs, ctxx) => postFormData(url, jar, mergeWithDefaults(form), mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx)
1084
+ };
2616
1085
  }
2617
1086
 
2618
- /**
2619
- * @param {{ jar: { setCookie: (arg0: string, arg1: string) => void; }; fb_dtsg: string; ttstamp: string; }} ctx
2620
- * @param {{ postFormData: (arg0: string, arg1: any, arg2: any, arg3: {}) => any; post: (arg0: string, arg1: any, arg2: any) => any; get: (arg0: any, arg1: any) => Promise<any>; }} defaultFuncs
2621
- * @param {string | number} [retryCount]
2622
- */
2623
-
2624
- function parseAndCheckLogin(ctx, defaultFuncs, retryCount) {
2625
- if (retryCount == undefined) retryCount = 0;
2626
- return function(/** @type {{ body: string; statusCode: string | number; request: { uri: { protocol: string; hostname: string; pathname: string; }; headers: { [x: string]: string; }; formData: any; method: string; }; }} */data) {
2627
- return bluebird.try(function() {
2628
- log.verbose("parseAndCheckLogin", data.body);
2629
- if (data.statusCode >= 500 && data.statusCode < 600) {
2630
- if (retryCount >= 5) {
2631
- throw {
2632
- error: "Request retry failed. Check the `res` and `statusCode` property on this error.",
2633
- statusCode: data.statusCode,
2634
- res: data.body
2635
- };
2636
- }
2637
- retryCount++;
2638
- var retryTime = Math.floor(Math.random() * 5000);
2639
- log.warn("parseAndCheckLogin", "Got status code " + data.statusCode + " - " + retryCount + ". attempt to retry in " + retryTime + " milliseconds...");
2640
- var url = data.request.uri.protocol + "//" + data.request.uri.hostname + data.request.uri.pathname;
2641
- if (data.request.headers["Content-Type"].split(";")[0] === "multipart/form-data") {
2642
- return bluebird.delay(retryTime).then(() => defaultFuncs.postFormData(url, ctx.jar, data.request.formData, {}))
2643
- .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
2644
- } else {
2645
- return bluebird.delay(retryTime).then(() => defaultFuncs.post(url, ctx.jar, data.request.formData))
2646
- .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
2647
- }
2648
- }
2649
- if (data.statusCode !== 200) throw new Error("parseAndCheckLogin got status code: " + data.statusCode + ". Bailing out of trying to parse response.");
2650
-
2651
- var res = null;
2652
- try {
2653
- res = JSON.parse(makeParsable(data.body));
2654
- } catch (e) {
2655
- throw {
2656
- error: "JSON.parse error. Check the `detail` property on this error.",
2657
- detail: e,
2658
- res: data.body
2659
- };
2660
- }
2661
-
2662
- // In some cases the response contains only a redirect URL which should be followed
2663
- if (res.redirect && data.request.method === "GET") return defaultFuncs.get(res.redirect, ctx.jar).then(parseAndCheckLogin(ctx, defaultFuncs));
2664
-
2665
- // TODO: handle multiple cookies?
2666
- if (res.jsmods && res.jsmods.require && Array.isArray(res.jsmods.require[0]) && res.jsmods.require[0][0] === "Cookie") {
2667
- res.jsmods.require[0][3][0] = res.jsmods.require[0][3][0].replace("_js_", "");
2668
- var cookie = formatCookie(res.jsmods.require[0][3], "facebook");
2669
- var cookie2 = formatCookie(res.jsmods.require[0][3], "messenger");
2670
- ctx.jar.setCookie(cookie, "https://www.facebook.com");
2671
- ctx.jar.setCookie(cookie2, "https://www.messenger.com");
2672
- }
2673
-
2674
- // On every request we check if we got a DTSG and we mutate the context so that we use the latest
2675
- // one for the next requests.
2676
- if (res.jsmods && Array.isArray(res.jsmods.require)) {
2677
- var arr = res.jsmods.require;
2678
- for (var i in arr) {
2679
- if (arr[i][0] === "DTSG" && arr[i][1] === "setToken") {
2680
- ctx.fb_dtsg = arr[i][3][0];
2681
-
2682
- // Update ttstamp since that depends on fb_dtsg
2683
- ctx.ttstamp = "2";
2684
- for (var j = 0; j < ctx.fb_dtsg.length; j++) ctx.ttstamp += ctx.fb_dtsg.charCodeAt(j);
2685
- }
2686
- }
2687
- }
2688
-
2689
- if (res.error === 1357001) {
2690
- if (global.Fca.Require.FastConfig.AutoLogin && global.Fca.Require.FastConfig.CheckPointBypass['956'].Allow) {
2691
- return global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.Bypass_956, async function() {
2692
- const Check = () => new Promise((re) => {
2693
- defaultFuncs.get('https://facebook.com', ctx.jar).then(function(res) {
2694
- if (res.headers.location && res.headers.location.includes('https://www.facebook.com/checkpoint/')) {
2695
- if (res.headers.location.includes('828281030927956')) return global.Fca.Action('Bypass', ctx, "956", defaultFuncs)
2696
- else if (res.request.uri && res.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
2697
- if (res.request.uri.href.includes('601051028565049')) {
2698
- return global.Fca.BypassAutomationNotification(undefined, ctx.jar, ctx.globalOptions, undefined ,process.env.UID)
2699
- }
2700
- }
2701
- else return global.Fca.Require.logger.Error(global.Fca.Require.Language.Index.ErrAppState);
2702
- }
2703
- else return global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.AutoLogin, function() {
2704
- return global.Fca.Action('AutoLogin');
2705
- });
2706
- })
2707
- })
2708
- await Check();
2709
- });
2710
- }
2711
- if (res.request.uri && res.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
2712
- if (res.request.uri.href.includes('601051028565049')) {
2713
- return global.Fca.BypassAutomationNotification(undefined, ctx.jar, ctx.globalOptions, undefined ,process.env.UID)
2714
- }
2715
- }
2716
- if (global.Fca.Require.FastConfig.AutoLogin) {
2717
- return global.Fca.Require.logger.Warning(global.Fca.Require.Language.Index.AutoLogin, function() {
2718
- return global.Fca.Action('AutoLogin');
2719
- });
2720
- }
2721
- else if (!global.Fca.Require.FastConfig.AutoLogin) {
2722
- return global.Fca.Require.logger.Error(global.Fca.Require.Language.Index.ErrAppState);
2723
- }
2724
- return;
2725
- }
2726
- else return res;
2727
- });
2728
- };
1087
+ function parseAndCheckLogin(ctx, http, retryCount) {
1088
+ var delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
1089
+ var _try = (tryData) => new Promise(function (resolve, reject) {
1090
+ try {
1091
+ resolve(tryData());
1092
+ } catch (error) {
1093
+ reject(error);
1094
+ }
1095
+ });
1096
+ if (retryCount == undefined) retryCount = 0;
1097
+
1098
+ return function (data) {
1099
+ function any() {
1100
+ if (data.statusCode >= 500 && data.statusCode < 600) {
1101
+ if (retryCount >= 5) {
1102
+ const err = new Error("Request retry failed. Check the `res` and `statusCode` property on this error.");
1103
+ err.statusCode = data.statusCode;
1104
+ err.res = data.body;
1105
+ err.error = "Request retry failed. Check the `res` and `statusCode` property on this error.";
1106
+ throw err;
1107
+ }
1108
+ retryCount++;
1109
+ const retryTime = Math.floor(Math.random() * 5000);
1110
+ console.warn("parseAndCheckLogin", "Got status code " + data.statusCode + " - " + retryCount + ". attempt to retry in " + retryTime + " milliseconds...");
1111
+ const url = data.request.uri.protocol + "//" + data.request.uri.hostname + data.request.uri.pathname;
1112
+ if (data.request.headers["Content-Type"].split(";")[0] === "multipart/form-data") {
1113
+ return delay(retryTime)
1114
+ .then(function () {
1115
+ return http
1116
+ .postFormData(url, ctx.jar, data.request.formData);
1117
+ })
1118
+ .then(parseAndCheckLogin(ctx, http, retryCount));
1119
+ }
1120
+ else {
1121
+ return delay(retryTime)
1122
+ .then(function () {
1123
+ return http
1124
+ .post(url, ctx.jar, data.request.formData);
1125
+ })
1126
+ .then(parseAndCheckLogin(ctx, http, retryCount));
1127
+ }
1128
+ }
1129
+
1130
+ if (data.statusCode === 404) return;
1131
+
1132
+ if (data.statusCode !== 200)
1133
+ throw new Error("parseAndCheckLogin got status code: " + data.statusCode + ". Bailing out of trying to parse response.");
1134
+
1135
+ let res = null;
1136
+ try {
1137
+ res = JSON.parse(makeParsable(data.body));
1138
+ } catch (e) {
1139
+ const err = new Error("JSON.parse error. Check the `detail` property on this error.");
1140
+ err.error = "JSON.parse error. Check the `detail` property on this error.";
1141
+ err.detail = e;
1142
+ err.res = data.body;
1143
+ throw err;
1144
+ }
1145
+
1146
+ // In some cases the response contains only a redirect URL which should be followed
1147
+ if (res.redirect && data.request.method === "GET") {
1148
+ return http
1149
+ .get(res.redirect, ctx.jar)
1150
+ .then(parseAndCheckLogin(ctx, http));
1151
+ }
1152
+
1153
+ // TODO: handle multiple cookies?
1154
+ if (res.jsmods && res.jsmods.require && Array.isArray(res.jsmods.require[0]) && res.jsmods.require[0][0] === "Cookie") {
1155
+ res.jsmods.require[0][3][0] = res.jsmods.require[0][3][0].replace("_js_", "");
1156
+ const requireCookie = res.jsmods.require[0][3];
1157
+ ctx.jar.setCookie(formatCookie(requireCookie, "facebook"), "https://www.facebook.com");
1158
+ ctx.jar.setCookie(formatCookie(requireCookie, "messenger"), "https://www.messenger.com");
1159
+ }
1160
+
1161
+ // On every request we check if we got a DTSG and we mutate the context so that we use the latest
1162
+ // one for the next requests.
1163
+ if (res.jsmods && Array.isArray(res.jsmods.require)) {
1164
+ const arr = res.jsmods.require;
1165
+ for (const i in arr) {
1166
+ if (arr[i][0] === "DTSG" && arr[i][1] === "setToken") {
1167
+ ctx.fb_dtsg = arr[i][3][0];
1168
+
1169
+ // Update ttstamp since that depends on fb_dtsg
1170
+ ctx.ttstamp = "2";
1171
+ for (let j = 0; j < ctx.fb_dtsg.length; j++) {
1172
+ ctx.ttstamp += ctx.fb_dtsg.charCodeAt(j);
1173
+ }
1174
+ }
1175
+ }
1176
+ }
1177
+
1178
+ if (res.error === 1357001) {
1179
+ const err = new Error('Facebook blocked the login');
1180
+ err.error = "Not logged in.";
1181
+ throw err;
1182
+ }
1183
+ return res;
1184
+ }
1185
+ return _try(any);
1186
+ };
2729
1187
  }
2730
1188
 
2731
- /**
2732
- * @param {{ setCookie: (arg0: any, arg1: string) => void; }} jar
2733
- */
2734
-
2735
1189
  function saveCookies(jar) {
2736
- return function(/** @type {{ headers: { [x: string]: any[]; }; }} */res) {
2737
- var cookies = res.headers["set-cookie"] || [];
2738
- cookies.forEach(function(/** @type {string} */c) {
2739
- if (c.indexOf(".facebook.com") > -1) { // yo wtf is this?
2740
- jar.setCookie(c, "https://www.facebook.com");
2741
- jar.setCookie(c.replace(/domain=\.facebook\.com/, "domain=.messenger.com"), "https://www.messenger.com");
2742
- }
2743
- });
2744
- return res;
2745
- };
1190
+ return function (res) {
1191
+ const cookies = res.headers["set-cookie"] || [];
1192
+ cookies.forEach(function (c) {
1193
+ if (c.indexOf(".facebook.com") > -1) {
1194
+ jar.setCookie(c, "https://www.facebook.com");
1195
+ }
1196
+ const c2 = c.replace(/domain=\.facebook\.com/, "domain=.messenger.com");
1197
+ jar.setCookie(c2, "https://www.messenger.com");
1198
+ });
1199
+ return res;
1200
+ };
2746
1201
  }
2747
1202
 
2748
- var NUM_TO_MONTH = [
2749
- "Jan",
2750
- "Feb",
2751
- "Mar",
2752
- "Apr",
2753
- "May",
2754
- "Jun",
2755
- "Jul",
2756
- "Aug",
2757
- "Sep",
2758
- "Oct",
2759
- "Nov",
2760
- "Dec"
1203
+ const NUM_TO_MONTH = [
1204
+ "Jan",
1205
+ "Feb",
1206
+ "Mar",
1207
+ "Apr",
1208
+ "May",
1209
+ "Jun",
1210
+ "Jul",
1211
+ "Aug",
1212
+ "Sep",
1213
+ "Oct",
1214
+ "Nov",
1215
+ "Dec"
2761
1216
  ];
2762
- var NUM_TO_DAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
2763
-
2764
- /**
2765
- * @param {{ getUTCDate: () => any; getUTCHours: () => any; getUTCMinutes: () => any; getUTCSeconds: () => any; getUTCDay: () => string | number; getUTCMonth: () => string | number; getUTCFullYear: () => string; }} date
2766
- */
2767
-
1217
+ const NUM_TO_DAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
2768
1218
  function formatDate(date) {
2769
- var d = date.getUTCDate();
2770
- d = d >= 10 ? d : "0" + d;
2771
- var h = date.getUTCHours();
2772
- h = h >= 10 ? h : "0" + h;
2773
- var m = date.getUTCMinutes();
2774
- m = m >= 10 ? m : "0" + m;
2775
- var s = date.getUTCSeconds();
2776
- s = s >= 10 ? s : "0" + s;
2777
- return (NUM_TO_DAY[date.getUTCDay()] + ", " + d + " " + NUM_TO_MONTH[date.getUTCMonth()] + " " + date.getUTCFullYear() + " " + h + ":" + m + ":" + s + " GMT");
1219
+ let d = date.getUTCDate();
1220
+ d = d >= 10 ? d : "0" + d;
1221
+ let h = date.getUTCHours();
1222
+ h = h >= 10 ? h : "0" + h;
1223
+ let m = date.getUTCMinutes();
1224
+ m = m >= 10 ? m : "0" + m;
1225
+ let s = date.getUTCSeconds();
1226
+ s = s >= 10 ? s : "0" + s;
1227
+ return (
1228
+ NUM_TO_DAY[date.getUTCDay()] +
1229
+ ", " +
1230
+ d +
1231
+ " " +
1232
+ NUM_TO_MONTH[date.getUTCMonth()] +
1233
+ " " +
1234
+ date.getUTCFullYear() +
1235
+ " " +
1236
+ h +
1237
+ ":" +
1238
+ m +
1239
+ ":" +
1240
+ s +
1241
+ " GMT"
1242
+ );
2778
1243
  }
2779
1244
 
2780
- /**
2781
- * @param {string[]} arr
2782
- * @param {string} url
2783
- */
2784
-
2785
1245
  function formatCookie(arr, url) {
2786
- return arr[0] + "=" + arr[1] + "; Path=" + arr[3] + "; Domain=" + url + ".com";
1246
+ return (
1247
+ arr[0] + "=" + arr[1] + "; Path=" + arr[3] + "; Domain=" + url + ".com"
1248
+ );
2787
1249
  }
2788
1250
 
2789
- /**
2790
- * @param {{ thread_fbid: { toString: () => any; }; participants: any[]; name: any; custom_nickname: any; snippet: any; snippet_attachments: any; snippet_sender: any; unread_count: any; message_count: any; image_src: any; timestamp: any; mute_until: any; is_canonical_user: any; is_canonical: any; is_subscribed: any; folder: any; is_archived: any; recipients_loadable: any; has_email_participant: any; read_only: any; can_reply: any; cannot_reply_reason: any; last_message_timestamp: any; last_read_timestamp: any; last_message_type: any; custom_like_icon: any; custom_color: any; admin_ids: any; thread_type: any; }} data
2791
- */
2792
-
2793
1251
  function formatThread(data) {
2794
- return {
2795
- threadID: formatID(data.thread_fbid.toString()),
2796
- participants: data.participants.map(formatID),
2797
- participantIDs: data.participants.map(formatID),
2798
- name: data.name,
2799
- nicknames: data.custom_nickname,
2800
- snippet: data.snippet,
2801
- snippetAttachments: data.snippet_attachments,
2802
- snippetSender: formatID((data.snippet_sender || "").toString()),
2803
- unreadCount: data.unread_count,
2804
- messageCount: data.message_count,
2805
- imageSrc: data.image_src,
2806
- timestamp: data.timestamp,
2807
- muteUntil: data.mute_until,
2808
- isCanonicalUser: data.is_canonical_user,
2809
- isCanonical: data.is_canonical,
2810
- isSubscribed: data.is_subscribed,
2811
- folder: data.folder,
2812
- isArchived: data.is_archived,
2813
- recipientsLoadable: data.recipients_loadable,
2814
- hasEmailParticipant: data.has_email_participant,
2815
- readOnly: data.read_only,
2816
- canReply: data.can_reply,
2817
- cannotReplyReason: data.cannot_reply_reason,
2818
- lastMessageTimestamp: data.last_message_timestamp,
2819
- lastReadTimestamp: data.last_read_timestamp,
2820
- lastMessageType: data.last_message_type,
2821
- emoji: data.custom_like_icon,
2822
- color: data.custom_color,
2823
- adminIDs: data.admin_ids,
2824
- threadType: data.thread_type
2825
- };
1252
+ return {
1253
+ threadID: formatID(data.thread_fbid.toString()),
1254
+ participants: data.participants.map(formatID),
1255
+ participantIDs: data.participants.map(formatID),
1256
+ name: data.name,
1257
+ nicknames: data.custom_nickname,
1258
+ snippet: data.snippet,
1259
+ snippetAttachments: data.snippet_attachments,
1260
+ snippetSender: formatID((data.snippet_sender || "").toString()),
1261
+ unreadCount: data.unread_count,
1262
+ messageCount: data.message_count,
1263
+ imageSrc: data.image_src,
1264
+ timestamp: data.timestamp,
1265
+ serverTimestamp: data.server_timestamp, // what is this?
1266
+ muteUntil: data.mute_until,
1267
+ isCanonicalUser: data.is_canonical_user,
1268
+ isCanonical: data.is_canonical,
1269
+ isSubscribed: data.is_subscribed,
1270
+ folder: data.folder,
1271
+ isArchived: data.is_archived,
1272
+ recipientsLoadable: data.recipients_loadable,
1273
+ hasEmailParticipant: data.has_email_participant,
1274
+ readOnly: data.read_only,
1275
+ canReply: data.can_reply,
1276
+ cannotReplyReason: data.cannot_reply_reason,
1277
+ lastMessageTimestamp: data.last_message_timestamp,
1278
+ lastReadTimestamp: data.last_read_timestamp,
1279
+ lastMessageType: data.last_message_type,
1280
+ emoji: data.custom_like_icon,
1281
+ color: data.custom_color,
1282
+ adminIDs: data.admin_ids,
1283
+ threadType: data.thread_type
1284
+ };
2826
1285
  }
2827
1286
 
2828
- /**
2829
- * @param {any} obj
2830
- */
2831
-
2832
1287
  function getType(obj) {
2833
- return Object.prototype.toString.call(obj).slice(8, -1);
1288
+ return Object.prototype.toString.call(obj).slice(8, -1);
2834
1289
  }
2835
1290
 
2836
- /**
2837
- * @param {{ lat: number; p: any; }} presence
2838
- * @param {any} userID
2839
- */
2840
-
2841
1291
  function formatProxyPresence(presence, userID) {
2842
- if (presence.lat === undefined || presence.p === undefined) return null;
2843
- return {
2844
- type: "presence",
2845
- timestamp: presence.lat * 1000,
2846
- userID: userID || '',
2847
- statuses: presence.p
2848
- };
1292
+ if (presence.lat === undefined || presence.p === undefined) return null;
1293
+ return {
1294
+ type: "presence",
1295
+ timestamp: presence.lat * 1000,
1296
+ userID: userID,
1297
+ statuses: presence.p
1298
+ };
2849
1299
  }
2850
1300
 
2851
- /**
2852
- * @param {{ la: number; a: any; }} presence
2853
- * @param {any} userID
2854
- */
2855
-
2856
1301
  function formatPresence(presence, userID) {
2857
- return {
2858
- type: "presence",
2859
- timestamp: presence.la * 1000,
2860
- userID: userID || '',
2861
- statuses: presence.a
2862
- };
1302
+ return {
1303
+ type: "presence",
1304
+ timestamp: presence.la * 1000,
1305
+ userID: userID,
1306
+ statuses: presence.a
1307
+ };
2863
1308
  }
2864
1309
 
2865
- /**
2866
- * @param {any} payload
2867
- */
2868
-
2869
1310
  function decodeClientPayload(payload) {
2870
- /*
2871
- Special function which Client using to "encode" clients JSON payload
2872
- */
2873
-
2874
- /**
2875
- * @param {string | any[]} array
2876
- */
2877
-
2878
- function Utf8ArrayToStr(array) {
2879
- var out, i, len, c;
2880
- var char2, char3;
2881
- out = "";
2882
- len = array.length;
2883
- i = 0;
2884
- while (i < len) {
2885
- c = array[i++];
2886
- switch (c >> 4) {
2887
- case 0:
2888
- case 1:
2889
- case 2:
2890
- case 3:
2891
- case 4:
2892
- case 5:
2893
- case 6:
2894
- case 7:
2895
- out += String.fromCharCode(c);
2896
- break;
2897
- case 12:
2898
- case 13:
2899
- char2 = array[i++];
2900
- out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
2901
- break;
2902
- case 14:
2903
- char2 = array[i++];
2904
- char3 = array[i++];
2905
- out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
2906
- break;
2907
- }
2908
- }
2909
- return out;
2910
- }
2911
- return JSON.parse(Utf8ArrayToStr(payload));
1311
+ /*
1312
+ Special function which Client using to "encode" clients JSON payload
1313
+ */
1314
+ return JSON.parse(String.fromCharCode.apply(null, payload));
2912
1315
  }
2913
1316
 
2914
- /**
2915
- * @param {{ getCookies: (arg0: string) => string | any[]; }} jar
2916
- */
2917
-
2918
- function getAppState(jar, Encode) {
2919
- var prettyMilliseconds = require('pretty-ms');
2920
- var getText = globalThis.Fca.getText;
2921
- var Security = require("./Extra/Security/Base");
2922
- var appstate = jar.getCookies("https://www.facebook.com").concat(jar.getCookies("https://facebook.com")).concat(jar.getCookies("https://www.messenger.com"));
2923
- var logger = require('./logger'),languageFile = require('./Language/index.json');
2924
- var Language = languageFile.find(i => i.Language == globalThis.Fca.Require.FastConfig.Language).Folder.Index;
2925
- var data;
2926
- switch (require(process.cwd() + "/FastConfigFca.json").EncryptFeature) {
2927
- case true: {
2928
- if (Encode == undefined) Encode = true;
2929
- if (process.env['FBKEY'] != undefined && Encode) {
2930
- logger.Normal(Language.EncryptSuccess);
2931
- data = Security(JSON.stringify(appstate),process.env['FBKEY'],"Encrypt");
2932
- }
2933
- else return appstate;
2934
- }
2935
- break;
2936
- case false: {
2937
- data = appstate;
2938
- }
2939
- break;
2940
- default: {
2941
- logger.Normal(getText(Language.IsNotABoolean,require(process.cwd() + "/FastConfigFca.json").EncryptFeature));
2942
- data = appstate;
2943
- }
2944
- }
2945
- if(!globalThis.Fca.Setting.get('getAppState')) {
2946
- logger.Normal(getText(Language.ProcessDone,`${prettyMilliseconds(Date.now() - globalThis.Fca.startTime)}`),function() { globalThis.Fca.Setting.set('getAppState',true); });
2947
- }
2948
- return data;
1317
+ function getAppState(jar) {
1318
+ return jar
1319
+ .getCookies("https://www.facebook.com")
1320
+ .concat(jar.getCookies("https://www.messenger.com"));
2949
1321
  }
2950
1322
 
2951
- function getData_Path(Obj , Arr, Stt) {
2952
- //default stt = 0
2953
- if (Arr.length === 0 && Obj != undefined) {
2954
- return Obj; //object
2955
- }
2956
- else if (Obj == undefined) {
2957
- return Stt;
2958
- }
2959
- const head = Arr[0];
2960
- if (head == undefined) {
2961
- return Stt;
2962
- }
2963
- const tail = Arr.slice(1);
2964
- return getData_Path(Obj[head], tail, Stt++);
2965
- }
2966
-
2967
-
2968
- function setData_Path(obj, path, value) {
2969
- if (!path.length) {
2970
- return obj;
2971
- }
2972
- const currentKey = path[0];
2973
- let currentObj = obj[currentKey];
2974
-
2975
- if (!currentObj) {
2976
- obj[currentKey] = value;
2977
- currentObj = obj[currentKey];
2978
- }
2979
- path.shift();
2980
- if (!path.length) {
2981
- currentObj = value;
2982
- } else {
2983
- currentObj = setData_Path(currentObj, path, value);
2984
- }
2985
-
2986
- return obj;
2987
- }
2988
-
2989
- function getPaths(obj, parentPath = []) {
2990
- let paths = [];
2991
- for (let prop in obj) {
2992
- if (typeof obj[prop] === "object") {
2993
- paths = paths.concat(getPaths(obj[prop], [...parentPath, prop]));
2994
- } else {
2995
- paths.push([...parentPath, prop]);
2996
- }
2997
- }
2998
- return paths;
2999
- }
3000
-
3001
- function cleanHTML (text) {
3002
- text = text.replace(/(<br>)|(<\/?i>)|(<\/?em>)|(<\/?b>)|(!?~)|(&amp;)|(&#039;)|(&lt;)|(&gt;)|(&quot;)/g, (match) => {
3003
- switch (match) {
3004
- case "<br>":
3005
- return "\n";
3006
- case "<i>":
3007
- case "<em>":
3008
- case "</i>":
3009
- case "</em>":
3010
- return "*";
3011
- case "<b>":
3012
- case "</b>":
3013
- return "**";
3014
- case "~!":
3015
- case "!~":
3016
- return "||";
3017
- case "&amp;":
3018
- return "&";
3019
- case "&#039;":
3020
- return "'";
3021
- case "&lt;":
3022
- return "<";
3023
- case "&gt;":
3024
- return ">";
3025
- case "&quot;":
3026
- return '"';
3027
- }
3028
- });
3029
- return text;
1323
+ function getAccessFromBusiness(jar, Options) {
1324
+ return function (res) {
1325
+ var html = res ? res.body : null;
1326
+ return get('https://business.facebook.com/content_management', jar, null, Options, null, { noRef: true })
1327
+ .then(function (res) {
1328
+ var token = /"accessToken":"([^.]+)","clientID":/g.exec(res.body)[1];
1329
+ return [html, token];
1330
+ })
1331
+ .catch(function () {
1332
+ return [html, null];
1333
+ });
1334
+ }
3030
1335
  }
3031
1336
 
3032
1337
  module.exports = {
3033
- cleanHTML,
3034
- isReadableStream:isReadableStream,
3035
- get:get,
3036
- post:post,
3037
- postFormData:postFormData,
3038
- generateThreadingID:generateThreadingID,
3039
- generateOfflineThreadingID:generateOfflineThreadingID,
3040
- getGUID:getGUID,
3041
- getFrom:getFrom,
3042
- makeParsable:makeParsable,
3043
- arrToForm:arrToForm,
3044
- getSignatureID:getSignatureID,
3045
- getJar: request.jar,
3046
- generateTimestampRelative:generateTimestampRelative,
3047
- makeDefaults:makeDefaults,
3048
- parseAndCheckLogin:parseAndCheckLogin,
3049
- getGender: getGenderByPhysicalMethod,
3050
- getData_Path,
3051
- setData_Path,
3052
- getPaths,
3053
- saveCookies,
3054
- getType,
3055
- _formatAttachment,
3056
- formatHistoryMessage,
3057
- formatID,
3058
- formatMessage,
3059
- formatDeltaEvent,
3060
- formatDeltaMessage,
3061
- formatProxyPresence,
3062
- formatPresence,
3063
- formatTyp,
3064
- formatDeltaReadReceipt,
3065
- formatCookie,
3066
- formatThread,
3067
- formatReadReceipt,
3068
- formatRead,
3069
- generatePresence,
3070
- generateAccessiblityCookie,
3071
- formatDate,
3072
- decodeClientPayload,
3073
- getAppState,
3074
- getAdminTextMessageType,
3075
- setProxy,
3076
- getFroms
3077
- };
1338
+ isReadableStream,
1339
+ get,
1340
+ post,
1341
+ postFormData,
1342
+ generateThreadingID,
1343
+ generateOfflineThreadingID,
1344
+ getGUID,
1345
+ getFrom,
1346
+ makeParsable,
1347
+ arrToForm,
1348
+ getSignatureID,
1349
+ getJar: request.jar,
1350
+ generateTimestampRelative,
1351
+ makeDefaults,
1352
+ parseAndCheckLogin,
1353
+ saveCookies,
1354
+ getType,
1355
+ _formatAttachment,
1356
+ formatHistoryMessage,
1357
+ formatID,
1358
+ formatMessage,
1359
+ formatDeltaEvent,
1360
+ formatDeltaMessage,
1361
+ formatProxyPresence,
1362
+ formatPresence,
1363
+ formatTyp,
1364
+ formatDeltaReadReceipt,
1365
+ formatCookie,
1366
+ formatThread,
1367
+ formatReadReceipt,
1368
+ formatRead,
1369
+ generatePresence,
1370
+ generateAccessiblityCookie,
1371
+ formatDate,
1372
+ decodeClientPayload,
1373
+ getAppState,
1374
+ getAdminTextMessageType,
1375
+ setProxy,
1376
+ getAccessFromBusiness,
1377
+ presenceDecode,
1378
+ presenceEncode
1379
+ }