daiki-fca 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of daiki-fca might be problematic. Click here for more details.

Files changed (296) hide show
  1. package/.cache/nix/binary-cache-v6.sqlite +0 -0
  2. package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
  3. package/.cache/replit/env/latest +121 -0
  4. package/.cache/replit/env/latest.json +1 -0
  5. package/.cache/replit/modules/nix.res +1 -0
  6. package/.cache/replit/modules/nodejs-20.res +1 -0
  7. package/.cache/replit/modules/replit.res +1 -0
  8. package/.cache/replit/modules.stamp +0 -0
  9. package/.cache/replit/nix/env.json +1 -0
  10. package/.cache/typescript/5.6/node_modules/.package-lock.json +188 -0
  11. package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +21 -0
  12. package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +15 -0
  13. package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +1365 -0
  14. package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +25 -0
  15. package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +21 -0
  16. package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +48 -0
  17. package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +29 -0
  18. package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +35 -0
  19. package/.cache/typescript/5.6/node_modules/@types/cheerio/LICENSE +21 -0
  20. package/.cache/typescript/5.6/node_modules/@types/cheerio/README.md +15 -0
  21. package/.cache/typescript/5.6/node_modules/@types/cheerio/index.d.ts +318 -0
  22. package/.cache/typescript/5.6/node_modules/@types/cheerio/package.json +71 -0
  23. package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +21 -0
  24. package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +15 -0
  25. package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +2929 -0
  26. package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +56 -0
  27. package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +21 -0
  28. package/.cache/typescript/5.6/node_modules/@types/node/README.md +15 -0
  29. package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +8 -0
  30. package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +1040 -0
  31. package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +541 -0
  32. package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +385 -0
  33. package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +1933 -0
  34. package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +1549 -0
  35. package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +579 -0
  36. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
  37. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +9 -0
  38. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
  39. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  40. package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +452 -0
  41. package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +19 -0
  42. package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +4475 -0
  43. package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +597 -0
  44. package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
  45. package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +476 -0
  46. package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +865 -0
  47. package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +124 -0
  48. package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +170 -0
  49. package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +931 -0
  50. package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +1275 -0
  51. package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +4343 -0
  52. package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +511 -0
  53. package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +21 -0
  54. package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +1958 -0
  55. package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +2558 -0
  56. package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +543 -0
  57. package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +92 -0
  58. package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +3966 -0
  59. package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +621 -0
  60. package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +1005 -0
  61. package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +495 -0
  62. package/.cache/typescript/5.6/node_modules/@types/node/package.json +220 -0
  63. package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +200 -0
  64. package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +965 -0
  65. package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +1996 -0
  66. package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +117 -0
  67. package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +153 -0
  68. package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +162 -0
  69. package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +589 -0
  70. package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +430 -0
  71. package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +153 -0
  72. package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +349 -0
  73. package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +12 -0
  74. package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +90 -0
  75. package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +609 -0
  76. package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +1726 -0
  77. package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +67 -0
  78. package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +2248 -0
  79. package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +97 -0
  80. package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +240 -0
  81. package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +1226 -0
  82. package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +197 -0
  83. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
  84. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
  85. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +92 -0
  86. package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +208 -0
  87. package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +972 -0
  88. package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +2397 -0
  89. package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +808 -0
  90. package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +976 -0
  91. package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +181 -0
  92. package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +745 -0
  93. package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +539 -0
  94. package/.cache/typescript/5.6/node_modules/@types/node-cron/LICENSE +21 -0
  95. package/.cache/typescript/5.6/node_modules/@types/node-cron/README.md +76 -0
  96. package/.cache/typescript/5.6/node_modules/@types/node-cron/index.d.ts +57 -0
  97. package/.cache/typescript/5.6/node_modules/@types/node-cron/package.json +50 -0
  98. package/.cache/typescript/5.6/node_modules/@types/npmlog/LICENSE +21 -0
  99. package/.cache/typescript/5.6/node_modules/@types/npmlog/README.md +15 -0
  100. package/.cache/typescript/5.6/node_modules/@types/npmlog/index.d.ts +84 -0
  101. package/.cache/typescript/5.6/node_modules/@types/npmlog/package.json +32 -0
  102. package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +21 -0
  103. package/.cache/typescript/5.6/node_modules/@types/request/README.md +15 -0
  104. package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +395 -0
  105. package/.cache/typescript/5.6/node_modules/@types/request/package.json +70 -0
  106. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +21 -0
  107. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +15 -0
  108. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +321 -0
  109. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +35 -0
  110. package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +21 -0
  111. package/.cache/typescript/5.6/node_modules/asynckit/README.md +233 -0
  112. package/.cache/typescript/5.6/node_modules/asynckit/bench.js +76 -0
  113. package/.cache/typescript/5.6/node_modules/asynckit/index.js +6 -0
  114. package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +29 -0
  115. package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +34 -0
  116. package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +26 -0
  117. package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +75 -0
  118. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  119. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +25 -0
  120. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +25 -0
  121. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  122. package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +37 -0
  123. package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +141 -0
  124. package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +29 -0
  125. package/.cache/typescript/5.6/node_modules/asynckit/package.json +63 -0
  126. package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +43 -0
  127. package/.cache/typescript/5.6/node_modules/asynckit/serial.js +17 -0
  128. package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +75 -0
  129. package/.cache/typescript/5.6/node_modules/asynckit/stream.js +21 -0
  130. package/.cache/typescript/5.6/node_modules/combined-stream/License +19 -0
  131. package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +138 -0
  132. package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +208 -0
  133. package/.cache/typescript/5.6/node_modules/combined-stream/package.json +25 -0
  134. package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +17 -0
  135. package/.cache/typescript/5.6/node_modules/delayed-stream/License +19 -0
  136. package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +7 -0
  137. package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +141 -0
  138. package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  139. package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +27 -0
  140. package/.cache/typescript/5.6/node_modules/form-data/License +19 -0
  141. package/.cache/typescript/5.6/node_modules/form-data/Readme.md +350 -0
  142. package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +51 -0
  143. package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +2 -0
  144. package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +484 -0
  145. package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +10 -0
  146. package/.cache/typescript/5.6/node_modules/form-data/package.json +72 -0
  147. package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +507 -0
  148. package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +23 -0
  149. package/.cache/typescript/5.6/node_modules/mime-db/README.md +100 -0
  150. package/.cache/typescript/5.6/node_modules/mime-db/db.json +8519 -0
  151. package/.cache/typescript/5.6/node_modules/mime-db/index.js +12 -0
  152. package/.cache/typescript/5.6/node_modules/mime-db/package.json +60 -0
  153. package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +397 -0
  154. package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +23 -0
  155. package/.cache/typescript/5.6/node_modules/mime-types/README.md +113 -0
  156. package/.cache/typescript/5.6/node_modules/mime-types/index.js +188 -0
  157. package/.cache/typescript/5.6/node_modules/mime-types/package.json +44 -0
  158. package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +21 -0
  159. package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +584 -0
  160. package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +187 -0
  161. package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +65 -0
  162. package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +51 -0
  163. package/.cache/typescript/5.6/node_modules/types-registry/README.md +2 -0
  164. package/.cache/typescript/5.6/node_modules/types-registry/index.json +1 -0
  165. package/.cache/typescript/5.6/node_modules/types-registry/package.json +20 -0
  166. package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +21 -0
  167. package/.cache/typescript/5.6/node_modules/undici-types/README.md +6 -0
  168. package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +31 -0
  169. package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +43 -0
  170. package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +29 -0
  171. package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +36 -0
  172. package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +108 -0
  173. package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +34 -0
  174. package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +21 -0
  175. package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +28 -0
  176. package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
  177. package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +255 -0
  178. package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
  179. package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +149 -0
  180. package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +61 -0
  181. package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +209 -0
  182. package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +39 -0
  183. package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +54 -0
  184. package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +108 -0
  185. package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  186. package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +7 -0
  187. package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +15 -0
  188. package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +4 -0
  189. package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +71 -0
  190. package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +17 -0
  191. package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +50 -0
  192. package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +25 -0
  193. package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +12 -0
  194. package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  195. package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +25 -0
  196. package/.cache/typescript/5.6/node_modules/undici-types/package.json +55 -0
  197. package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +33 -0
  198. package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +19 -0
  199. package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +39 -0
  200. package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +28 -0
  201. package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +60 -0
  202. package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +8 -0
  203. package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +116 -0
  204. package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +18 -0
  205. package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +222 -0
  206. package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +150 -0
  207. package/.cache/typescript/5.6/package-lock.json +202 -0
  208. package/.cache/typescript/5.6/package.json +1 -0
  209. package/.replit +8 -0
  210. package/LICENSE +21 -0
  211. package/index.js +460 -0
  212. package/package.json +46 -0
  213. package/replit.nix +3 -0
  214. package/src/Screenshot.js +83 -0
  215. package/src/addExternalModule.js +25 -0
  216. package/src/addUserToGroup.js +115 -0
  217. package/src/changeAdminStatus.js +103 -0
  218. package/src/changeArchivedStatus.js +55 -0
  219. package/src/changeAvatar.js +136 -0
  220. package/src/changeAvatarV2.js +86 -0
  221. package/src/changeAvt.js +85 -0
  222. package/src/changeBio.js +76 -0
  223. package/src/changeBlockedStatus.js +49 -0
  224. package/src/changeBlockedStatusMqtt.js +80 -0
  225. package/src/changeCover.js +72 -0
  226. package/src/changeGroupImage.js +135 -0
  227. package/src/changeName.js +79 -0
  228. package/src/changeNickname.js +59 -0
  229. package/src/changeThreadColor.js +65 -0
  230. package/src/changeThreadEmoji.js +55 -0
  231. package/src/changeUsername.js +59 -0
  232. package/src/createCommentPost.js +230 -0
  233. package/src/createNewGroup.js +88 -0
  234. package/src/createPoll.js +71 -0
  235. package/src/createPost.js +276 -0
  236. package/src/deleteMessage.js +56 -0
  237. package/src/deleteThread.js +56 -0
  238. package/src/editMessage.js +68 -0
  239. package/src/editMessageOld.js +67 -0
  240. package/src/follow.js +74 -0
  241. package/src/forwardAttachment.js +60 -0
  242. package/src/getAccess.js +112 -0
  243. package/src/getAvatarUser.js +78 -0
  244. package/src/getCurrentUserID.js +7 -0
  245. package/src/getEmojiUrl.js +29 -0
  246. package/src/getFriendsList.js +83 -0
  247. package/src/getMessage.js +835 -0
  248. package/src/getRegion.js +7 -0
  249. package/src/getThreadHistory.js +680 -0
  250. package/src/getThreadHistoryDeprecated.js +71 -0
  251. package/src/getThreadInfo.js +232 -0
  252. package/src/getThreadInfoDeprecated.js +56 -0
  253. package/src/getThreadList.js +213 -0
  254. package/src/getThreadListDeprecated.js +46 -0
  255. package/src/getThreadPictures.js +59 -0
  256. package/src/getUID.js +119 -0
  257. package/src/getUserID.js +61 -0
  258. package/src/getUserInfo.js +66 -0
  259. package/src/handleFriendRequest.js +46 -0
  260. package/src/handleMessageRequest.js +47 -0
  261. package/src/httpGet.js +49 -0
  262. package/src/httpPost.js +48 -0
  263. package/src/listenMqtt.js +827 -0
  264. package/src/listenMqtt.txt +827 -0
  265. package/src/logout.js +75 -0
  266. package/src/markAsDelivered.js +47 -0
  267. package/src/markAsRead.js +70 -0
  268. package/src/markAsReadAll.js +40 -0
  269. package/src/markAsSeen.js +48 -0
  270. package/src/muteThread.js +45 -0
  271. package/src/postFormData.txt +46 -0
  272. package/src/refreshFb_dtsg.js +89 -0
  273. package/src/removeUserFromGroup.js +79 -0
  274. package/src/resolvePhotoUrl.js +45 -0
  275. package/src/searchForThread.js +53 -0
  276. package/src/searchStickers.js +53 -0
  277. package/src/sendMessage.js +329 -0
  278. package/src/sendMessageMqtt.js +322 -0
  279. package/src/sendTypingIndicator.js +101 -0
  280. package/src/sendTypingIndicatorV2.js +28 -0
  281. package/src/setMessageReaction.js +122 -0
  282. package/src/setMessageReactionMqtt.js +62 -0
  283. package/src/setPostReaction.js +112 -0
  284. package/src/setStoryReaction.js +64 -0
  285. package/src/setTitle.js +90 -0
  286. package/src/shareContact.js +110 -0
  287. package/src/shareLink.js +59 -0
  288. package/src/stopListenMqtt.js +23 -0
  289. package/src/threadColors.js +131 -0
  290. package/src/unfriend.js +52 -0
  291. package/src/unsendMessage.js +45 -0
  292. package/src/uploadAttachment.js +94 -0
  293. package/test/example-config.json +18 -0
  294. package/test/test-page.js +140 -0
  295. package/test/test.js +385 -0
  296. package/utils.js +2876 -0
package/test/test.js ADDED
@@ -0,0 +1,385 @@
1
+ var login = require('../index.js');
2
+ var fs = require('fs');
3
+ var assert = require('assert');
4
+
5
+ var conf = JSON.parse(process.env.testconfig || fs.readFileSync('test/test-config.json', 'utf8'));
6
+ var credentials = {
7
+ email: conf.user.email,
8
+ password: conf.user.password,
9
+ };
10
+
11
+ var userIDs = conf.userIDs;
12
+
13
+ var options = { selfListen: true, listenEvents: true, logLevel: "silent"};
14
+ var pageOptions = {logLevel: 'silent', pageID: conf.pageID};
15
+ var getType = require('../utils').getType;
16
+ var formatDeltaMessage = require('../utils').formatDeltaMessage;
17
+ var shareAttachmentFixture = require('./data/shareAttach');
18
+
19
+ var userID = conf.user.id;
20
+
21
+ var groupChatID;
22
+ var groupChatName;
23
+
24
+ function checkErr(done){
25
+ return function(err) {
26
+ if (err) done(err);
27
+ };
28
+ }
29
+
30
+ describe('Login:', function() {
31
+ var api = null;
32
+ process.on('SIGINT', () => api && !api.logout() && console.log("Logged out :)"));
33
+ var tests = [];
34
+ var stopListening;
35
+ this.timeout(20000);
36
+
37
+ function listen(done, matcher) {
38
+ tests.push({matcher:matcher, done:done});
39
+ }
40
+
41
+ before(function(done) {
42
+ login(credentials, options, function (err, localAPI) {
43
+ if(err) return done(err);
44
+
45
+ assert(localAPI);
46
+ api = localAPI;
47
+ stopListening = api.listen(function (err, msg) {
48
+ if (err) throw err;
49
+ if (msg.type === "message") {
50
+ assert(msg.senderID && !isNaN(msg.senderID));
51
+ assert(msg.threadID && !isNaN(msg.threadID));
52
+ assert(msg.timestamp && !isNaN(msg.timestamp));
53
+ assert(msg.messageID != null && msg.messageID.length > 0);
54
+ assert(msg.body != null || msg.attachments.length > 0);
55
+ }
56
+ // Removes matching function and calls corresponding done
57
+ tests = tests.filter(function(test) {
58
+ return !(test.matcher(msg) && (test.done() || true));
59
+ });
60
+ });
61
+
62
+ done();
63
+ });
64
+ });
65
+
66
+ it('should login without error', function (){
67
+ assert(api);
68
+ });
69
+
70
+ it('should get the current user ID', function (){
71
+ assert(userID === api.getCurrentUserID());
72
+ });
73
+
74
+ it('should send text message object (user)', function (done){
75
+ var body = "text-msg-obj-" + Date.now();
76
+ listen(done, msg =>
77
+ msg.type === 'message' &&
78
+ msg.body === body &&
79
+ msg.isGroup === false
80
+ );
81
+ api.sendMessage({body: body}, userID, checkErr(done));
82
+ });
83
+
84
+ it('should send sticker message object (user)', function (done){
85
+ var stickerID = '767334526626290';
86
+ listen(done, msg =>
87
+ msg.type === 'message' &&
88
+ msg.attachments.length > 0 &&
89
+ msg.attachments[0].type === 'sticker' &&
90
+ msg.attachments[0].stickerID === stickerID &&
91
+ msg.isGroup === false
92
+ );
93
+ api.sendMessage({sticker: stickerID}, userID, checkErr(done));
94
+ });
95
+
96
+ it('should send basic string (user)', function (done){
97
+ var body = "basic-str-" + Date.now();
98
+ listen(done, msg =>
99
+ msg.type === 'message' &&
100
+ msg.body === body &&
101
+ msg.isGroup === false
102
+ );
103
+ api.sendMessage(body, userID, checkErr(done));
104
+ });
105
+
106
+ it('should get thread info (user)', function (done){
107
+ api.getThreadInfo(userID, (err, info) => {
108
+ if (err) done(err);
109
+
110
+ assert(info.participantIDs != null && info.participantIDs.length > 0);
111
+ assert(!info.participantIDs.some(isNaN));
112
+ assert(!info.participantIDs.some(v => v.length == 0));
113
+ assert(info.name != null);
114
+ assert(info.messageCount != null && !isNaN(info.messageCount));
115
+ assert(info.hasOwnProperty('emoji'));
116
+ assert(info.hasOwnProperty('nicknames'));
117
+ assert(info.hasOwnProperty('color'));
118
+ done();
119
+ });
120
+ });
121
+
122
+
123
+ it('should get the history of the chat (user)', function (done) {
124
+ api.getThreadHistory(userID, 5, null, function(err, data) {
125
+ checkErr(done)(err);
126
+ assert(getType(data) === "Array");
127
+ assert(data.every(function(v) {return getType(v) == "Object";}));
128
+ done();
129
+ });
130
+ });
131
+
132
+ it('should get the history of the chat (user) (graphql)', function (done) {
133
+ api.getThreadHistoryGraphQL(userID, 5, null, function(err, data) {
134
+ checkErr(done)(err);
135
+ assert(getType(data) === "Array");
136
+ assert(data.every(function(v) {return getType(v) == "Object";}));
137
+ done();
138
+ });
139
+ });
140
+
141
+ it('should create a chat', function (done){
142
+ var body = "new-chat-" + Date.now();
143
+ var inc = 0;
144
+
145
+ function doneHack(){
146
+ if (inc === 1) return done();
147
+ inc++;
148
+ }
149
+
150
+ listen(doneHack, msg =>
151
+ msg.type === 'message' && msg.body === body
152
+ );
153
+ api.sendMessage(body, userIDs, function(err, info){
154
+ checkErr(done)(err);
155
+ groupChatID = info.threadID;
156
+ doneHack();
157
+ });
158
+ });
159
+
160
+ it('should send text message object (group)', function (done){
161
+ var body = "text-msg-obj-" + Date.now();
162
+ listen(done, msg =>
163
+ msg.type === 'message' &&
164
+ msg.body === body &&
165
+ msg.isGroup === true
166
+ );
167
+ api.sendMessage({body: body}, groupChatID, function(err, info){
168
+ checkErr(done)(err);
169
+ assert(groupChatID === info.threadID);
170
+ });
171
+ });
172
+
173
+ it('should send basic string (group)', function (done){
174
+ var body = "basic-str-" + Date.now();
175
+ listen(done, msg =>
176
+ msg.type === 'message' &&
177
+ msg.body === body &&
178
+ msg.isGroup === true
179
+ );
180
+ api.sendMessage(body, groupChatID, function(err, info) {
181
+ checkErr(done)(err);
182
+ assert(groupChatID === info.threadID);
183
+ });
184
+ });
185
+
186
+ it('should send sticker message object (group)', function (done){
187
+ var stickerID = '767334526626290';
188
+ listen(done, function (msg) {
189
+ return msg.type === 'message' &&
190
+ msg.attachments.length > 0 &&
191
+ msg.attachments[0].type === 'sticker' &&
192
+ msg.attachments[0].stickerID === stickerID;
193
+ });
194
+ api.sendMessage({sticker: stickerID}, groupChatID, function (err, info) {
195
+ assert(groupChatID === info.threadID);
196
+ checkErr(done)(err);
197
+ });
198
+ });
199
+
200
+ it('should send an attachment with a body (group)', function (done){
201
+ var body = "attach-" + Date.now();
202
+ var attach = [];
203
+ attach.push(fs.createReadStream("test/data/test.txt"));
204
+ attach.push(fs.createReadStream("test/data/test.png"));
205
+ listen(done, function (msg) {
206
+ return msg.type === 'message' && msg.body === body;
207
+ });
208
+ api.sendMessage({attachment: attach, body: body}, groupChatID, function(err, info){
209
+ checkErr(done)(err);
210
+ assert(groupChatID === info.threadID);
211
+ });
212
+ });
213
+
214
+ it('should get the history of the chat (group)', function (done) {
215
+ api.getThreadHistory(groupChatID, 5, null, function(err, data) {
216
+ checkErr(done)(err);
217
+ assert(getType(data) === "Array");
218
+ assert(data.every(function(v) {return getType(v) == "Object";}));
219
+ done();
220
+ });
221
+ });
222
+
223
+ it('should get the history of the chat (group) (graphql)', function (done) {
224
+ api.getThreadHistoryGraphQL(groupChatID, 5, null, function(err, data) {
225
+ checkErr(done)(err);
226
+ assert(getType(data) === "Array");
227
+ assert(data.every(function(v) {return getType(v) == "Object";}));
228
+ done();
229
+ });
230
+ });
231
+
232
+
233
+ it('should change chat title', function (done){
234
+ var title = 'test-chat-title-' + Date.now();
235
+ listen(done, function (msg) {
236
+ return msg.type === 'event' &&
237
+ msg.logMessageType === 'log:thread-name' &&
238
+ msg.logMessageData.name === title;
239
+ });
240
+ groupChatName = title;
241
+ api.setTitle(title, groupChatID, checkErr(done));
242
+ });
243
+
244
+ it('should kick user', function (done) {
245
+ var id = userIDs[0];
246
+ listen(done, function (msg) {
247
+ return msg.type === 'event' &&
248
+ msg.logMessageType === 'log:unsubscribe' &&
249
+ msg.logMessageData.leftParticipantFbId === id;
250
+ });
251
+ api.removeUserFromGroup(id, groupChatID, checkErr(done));
252
+ });
253
+
254
+ it('should add user', function (done) {
255
+ var id = userIDs[0];
256
+ listen(done, function (msg) {
257
+ return (msg.type === 'event' &&
258
+ msg.logMessageType === 'log:subscribe' &&
259
+ msg.logMessageData.addedParticipants.length > 0 &&
260
+ msg.logMessageData.addedParticipants[0].userFbId === id);
261
+ });
262
+ // TODO: we don't check for errors inside this because FB changed and
263
+ // returns an error, even though we receive the event that the user was
264
+ // added
265
+ api.addUserToGroup(id, groupChatID, function() {});
266
+ });
267
+
268
+ xit('should get thread info (group)', function (done){
269
+ api.getThreadInfo(groupChatID, (err, info) => {
270
+ if (err) done(err);
271
+
272
+ assert(info.participantIDs != null && info.participantIDs.length > 0);
273
+ assert(!info.participantIDs.some(isNaN));
274
+ assert(!info.participantIDs.some(v => v.length == 0));
275
+ assert(info.name != null);
276
+ assert(info.messageCount != null && !isNaN(info.messageCount));
277
+ assert(info.hasOwnProperty('emoji'));
278
+ assert(info.hasOwnProperty('nicknames'));
279
+ assert(info.hasOwnProperty('color'));
280
+ done();
281
+ });
282
+ });
283
+
284
+ it('should retrieve a list of threads', function (done) {
285
+ api.getThreadList(0, 20, function(err, res) {
286
+ checkErr(done)(err);
287
+
288
+ // This checks to see if the group chat we just made
289
+ // is in the list... it should be.
290
+ assert(res.some(function (v) {
291
+ return (
292
+ v.threadID === groupChatID &&
293
+ userIDs.every(function (val) {
294
+ return v.participants.indexOf(val) > -1;
295
+ }) &&
296
+ v.name === groupChatName
297
+ );
298
+ }));
299
+ done();
300
+ });
301
+ });
302
+
303
+ it('should mark as read', function (done){
304
+ api.markAsRead(groupChatID, done);
305
+ });
306
+
307
+ it('should send typing indicator', function (done) {
308
+ var stopType = api.sendTypingIndicator(groupChatID, function(err) {
309
+ checkErr(done)(err);
310
+ stopType();
311
+ done();
312
+ });
313
+ });
314
+
315
+
316
+ it('should get the right user info', function (done) {
317
+ api.getUserInfo(userID, function(err, data) {
318
+ checkErr(done)(err);
319
+ var user = data[userID];
320
+ assert(user.name);
321
+ assert(user.firstName);
322
+ assert(user.vanity !== null);
323
+ assert(user.profileUrl);
324
+ assert(user.gender);
325
+ assert(user.type);
326
+ assert(!user.isFriend);
327
+ done();
328
+ });
329
+ });
330
+
331
+ it('should get the user ID', function(done) {
332
+ api.getUserInfo(userIDs[0], function(err, data) {
333
+ checkErr(done)(err);
334
+ var user = data[userIDs[0]];
335
+ api.getUserID(user.name, function(err, data) {
336
+ checkErr(done)(err);
337
+ assert(getType(data) === "Array");
338
+ assert(data.some(function(val) {
339
+ return val.userID === userIDs[0];
340
+ }));
341
+ done();
342
+ });
343
+ });
344
+ });
345
+
346
+ it('should get the list of friends', function (done) {
347
+ api.getFriendsList(function(err, data) {
348
+ try {
349
+ checkErr(done)(err);
350
+ assert(getType(data) === "Array");
351
+ data.map(v => {
352
+ assert(getType(v.firstName) === "String");
353
+ assert(getType(v.gender) === "String");
354
+ assert(getType(v.userID) === "String");
355
+ assert(getType(v.isFriend) === "Boolean");
356
+ assert(getType(v.fullName) === "String");
357
+ assert(getType(v.profilePicture) === "String");
358
+ assert(getType(v.type) === "String");
359
+ assert(v.hasOwnProperty("profileUrl")); // This can be null if the account is disabled
360
+ assert(getType(v.isBirthday) === "Boolean");
361
+ })
362
+ done();
363
+ } catch(e){
364
+ done(e);
365
+ }
366
+ });
367
+ });
368
+
369
+ it('should parse share attachment correctly', function () {
370
+ var formatted = formatDeltaMessage(shareAttachmentFixture);
371
+ assert(formatted.attachments[0].type === "share");
372
+ assert(formatted.attachments[0].title === "search engines");
373
+ assert(formatted.attachments[0].target.items[0].name === "search engines");
374
+ assert(formatted.attachments[0].target.items[0].call_to_actions.length === 3);
375
+ assert(formatted.attachments[0].target.items[0].call_to_actions[0].title === "Google");
376
+ });
377
+
378
+ it('should log out', function (done) {
379
+ api.logout(done);
380
+ });
381
+
382
+ after(function (){
383
+ if (stopListening) stopListening();
384
+ });
385
+ });