rettiwt-api 5.0.0-alpha.1 → 5.0.0-alpha.2

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 (406) hide show
  1. package/dist/Rettiwt.d.ts +10 -3
  2. package/dist/Rettiwt.js +19 -7
  3. package/dist/Rettiwt.js.map +1 -1
  4. package/dist/collections/Extractors.d.ts +35 -2
  5. package/dist/collections/Extractors.js +3 -0
  6. package/dist/collections/Extractors.js.map +1 -1
  7. package/dist/collections/Groups.js +3 -0
  8. package/dist/collections/Groups.js.map +1 -1
  9. package/dist/collections/Requests.js +41 -41
  10. package/dist/collections/Requests.js.map +1 -1
  11. package/dist/commands/Tweet.js +33 -7
  12. package/dist/commands/Tweet.js.map +1 -1
  13. package/dist/commands/User.js +12 -2
  14. package/dist/commands/User.js.map +1 -1
  15. package/dist/enums/Authentication.d.ts +2 -10
  16. package/dist/enums/Authentication.js +3 -12
  17. package/dist/enums/Authentication.js.map +1 -1
  18. package/dist/enums/Data.d.ts +3 -15
  19. package/dist/enums/Data.js +4 -17
  20. package/dist/enums/Data.js.map +1 -1
  21. package/dist/enums/Media.d.ts +10 -0
  22. package/dist/enums/Media.js +15 -0
  23. package/dist/enums/Media.js.map +1 -0
  24. package/dist/enums/Notification.d.ts +12 -0
  25. package/dist/enums/Notification.js +17 -0
  26. package/dist/enums/Notification.js.map +1 -0
  27. package/dist/enums/Resource.d.ts +3 -0
  28. package/dist/enums/Resource.js +3 -0
  29. package/dist/enums/Resource.js.map +1 -1
  30. package/dist/enums/raw/Analytics.d.ts +28 -0
  31. package/dist/enums/raw/Analytics.js +34 -0
  32. package/dist/enums/raw/Analytics.js.map +1 -0
  33. package/dist/enums/raw/Media.d.ts +10 -0
  34. package/dist/enums/raw/Media.js +15 -0
  35. package/dist/enums/raw/Media.js.map +1 -0
  36. package/dist/enums/raw/Notification.d.ts +11 -0
  37. package/dist/enums/raw/Notification.js +16 -0
  38. package/dist/enums/raw/Notification.js.map +1 -0
  39. package/dist/enums/raw/Tweet.d.ts +9 -0
  40. package/dist/enums/raw/Tweet.js +14 -0
  41. package/dist/enums/raw/Tweet.js.map +1 -0
  42. package/dist/helper/TidUtils.d.ts +2 -0
  43. package/dist/helper/TidUtils.js +162 -0
  44. package/dist/helper/TidUtils.js.map +1 -0
  45. package/dist/index.d.ts +75 -4
  46. package/dist/index.js +26 -5
  47. package/dist/index.js.map +1 -1
  48. package/dist/models/RettiwtConfig.d.ts +28 -0
  49. package/dist/models/RettiwtConfig.js +55 -0
  50. package/dist/models/RettiwtConfig.js.map +1 -0
  51. package/dist/models/args/FetchArgs.d.ts +46 -3
  52. package/dist/models/args/FetchArgs.js +107 -5
  53. package/dist/models/args/FetchArgs.js.map +1 -1
  54. package/dist/models/args/PostArgs.d.ts +44 -16
  55. package/dist/models/args/PostArgs.js +61 -22
  56. package/dist/models/args/PostArgs.js.map +1 -1
  57. package/dist/models/auth/AuthCookie.d.ts +2 -0
  58. package/dist/models/auth/AuthCookie.js +2 -0
  59. package/dist/models/auth/AuthCookie.js.map +1 -1
  60. package/dist/models/auth/AuthCredential.d.ts +2 -0
  61. package/dist/models/auth/AuthCredential.js +2 -0
  62. package/dist/models/auth/AuthCredential.js.map +1 -1
  63. package/dist/models/data/CursoredData.d.ts +4 -13
  64. package/dist/models/data/CursoredData.js +16 -23
  65. package/dist/models/data/CursoredData.js.map +1 -1
  66. package/dist/models/data/List.d.ts +5 -1
  67. package/dist/models/data/List.js +14 -0
  68. package/dist/models/data/List.js.map +1 -1
  69. package/dist/models/data/Notification.d.ts +7 -5
  70. package/dist/models/data/Notification.js +19 -8
  71. package/dist/models/data/Notification.js.map +1 -1
  72. package/dist/models/data/Tweet.d.ts +29 -9
  73. package/dist/models/data/Tweet.js +103 -25
  74. package/dist/models/data/Tweet.js.map +1 -1
  75. package/dist/models/data/User.d.ts +17 -8
  76. package/dist/models/data/User.js +63 -13
  77. package/dist/models/data/User.js.map +1 -1
  78. package/dist/models/errors/RettiwtError.d.ts +3 -2
  79. package/dist/models/errors/RettiwtError.js +3 -2
  80. package/dist/models/errors/RettiwtError.js.map +1 -1
  81. package/dist/models/params/Variables.d.ts +41 -0
  82. package/dist/models/params/Variables.js +61 -0
  83. package/dist/models/params/Variables.js.map +1 -0
  84. package/dist/requests/List.d.ts +24 -0
  85. package/dist/requests/List.js +122 -0
  86. package/dist/requests/List.js.map +1 -0
  87. package/dist/requests/Media.d.ts +21 -0
  88. package/dist/requests/Media.js +70 -0
  89. package/dist/requests/Media.js.map +1 -0
  90. package/dist/requests/Tweet.d.ts +75 -0
  91. package/dist/requests/Tweet.js +480 -0
  92. package/dist/requests/Tweet.js.map +1 -0
  93. package/dist/requests/User.d.ts +111 -0
  94. package/dist/requests/User.js +762 -0
  95. package/dist/requests/User.js.map +1 -0
  96. package/dist/services/internal/AuthService.d.ts +3 -5
  97. package/dist/services/internal/AuthService.js +5 -8
  98. package/dist/services/internal/AuthService.js.map +1 -1
  99. package/dist/services/internal/TidService.d.ts +44 -0
  100. package/dist/services/internal/TidService.js +162 -0
  101. package/dist/services/internal/TidService.js.map +1 -0
  102. package/dist/services/public/FetcherService.d.ts +20 -19
  103. package/dist/services/public/FetcherService.js +67 -49
  104. package/dist/services/public/FetcherService.js.map +1 -1
  105. package/dist/services/public/ListService.d.ts +2 -2
  106. package/dist/services/public/ListService.js.map +1 -1
  107. package/dist/services/public/TweetService.d.ts +35 -7
  108. package/dist/services/public/TweetService.js +54 -8
  109. package/dist/services/public/TweetService.js.map +1 -1
  110. package/dist/services/public/UserService.d.ts +4 -4
  111. package/dist/services/public/UserService.js +25 -13
  112. package/dist/services/public/UserService.js.map +1 -1
  113. package/dist/types/RettiwtConfig.d.ts +9 -10
  114. package/dist/types/args/FetchArgs.d.ts +71 -7
  115. package/dist/types/args/PostArgs.d.ts +62 -18
  116. package/dist/types/auth/AuthCookie.d.ts +2 -0
  117. package/dist/types/auth/AuthCredential.d.ts +2 -0
  118. package/dist/types/auth/TidDynamicArgs.d.ts +10 -0
  119. package/dist/types/auth/{AccountCredential.js → TidDynamicArgs.js} +1 -1
  120. package/dist/types/auth/TidDynamicArgs.js.map +1 -0
  121. package/dist/types/auth/TidHeader.d.ts +8 -0
  122. package/dist/types/{ReturnTypes.js → auth/TidHeader.js} +1 -1
  123. package/dist/types/auth/TidHeader.js.map +1 -0
  124. package/dist/types/auth/TidParams.d.ts +27 -0
  125. package/dist/types/auth/TidParams.js +3 -0
  126. package/dist/types/auth/TidParams.js.map +1 -0
  127. package/dist/types/auth/TidProvider.d.ts +18 -0
  128. package/dist/types/auth/TidProvider.js +3 -0
  129. package/dist/types/auth/TidProvider.js.map +1 -0
  130. package/dist/types/data/CursoredData.d.ts +1 -10
  131. package/dist/types/data/Notification.d.ts +2 -2
  132. package/dist/types/data/Tweet.d.ts +2 -2
  133. package/dist/types/params/Variables.d.ts +27 -0
  134. package/dist/types/params/Variables.js +3 -0
  135. package/dist/types/params/Variables.js.map +1 -0
  136. package/dist/types/raw/base/Analytic.d.ts +21 -0
  137. package/dist/types/raw/base/Analytic.js +4 -0
  138. package/dist/types/raw/base/Analytic.js.map +1 -0
  139. package/dist/types/raw/base/Cursor.d.ts +11 -0
  140. package/dist/types/raw/base/Cursor.js +4 -0
  141. package/dist/types/raw/base/Cursor.js.map +1 -0
  142. package/dist/types/raw/base/LimitedVisibilityTweet.d.ts +32 -0
  143. package/dist/types/raw/base/LimitedVisibilityTweet.js +4 -0
  144. package/dist/types/raw/base/LimitedVisibilityTweet.js.map +1 -0
  145. package/dist/types/raw/base/List.d.ts +43 -0
  146. package/dist/types/raw/base/List.js +4 -0
  147. package/dist/types/raw/base/List.js.map +1 -0
  148. package/dist/types/raw/base/Media.d.ts +43 -0
  149. package/dist/types/raw/base/Media.js +4 -0
  150. package/dist/types/raw/base/Media.js.map +1 -0
  151. package/dist/types/raw/base/Notification.d.ts +53 -0
  152. package/dist/types/raw/base/Notification.js +4 -0
  153. package/dist/types/raw/base/Notification.js.map +1 -0
  154. package/dist/types/raw/base/Space.d.ts +32 -0
  155. package/dist/types/raw/base/Space.js +4 -0
  156. package/dist/types/raw/base/Space.js.map +1 -0
  157. package/dist/types/raw/base/Tweet.d.ts +119 -0
  158. package/dist/types/raw/base/Tweet.js +4 -0
  159. package/dist/types/raw/base/Tweet.js.map +1 -0
  160. package/dist/types/raw/base/User.d.ts +140 -0
  161. package/dist/types/raw/base/User.js +4 -0
  162. package/dist/types/raw/base/User.js.map +1 -0
  163. package/dist/types/raw/composite/DataResult.d.ts +8 -0
  164. package/dist/types/raw/composite/DataResult.js +3 -0
  165. package/dist/types/raw/composite/DataResult.js.map +1 -0
  166. package/dist/types/raw/composite/TimelineTweet.d.ts +11 -0
  167. package/dist/types/raw/composite/TimelineTweet.js +4 -0
  168. package/dist/types/raw/composite/TimelineTweet.js.map +1 -0
  169. package/dist/types/raw/composite/TimelineUser.d.ts +10 -0
  170. package/dist/types/raw/composite/TimelineUser.js +4 -0
  171. package/dist/types/raw/composite/TimelineUser.js.map +1 -0
  172. package/dist/types/raw/generic/Error.d.ts +30 -0
  173. package/dist/types/raw/generic/Error.js +3 -0
  174. package/dist/types/raw/generic/Error.js.map +1 -0
  175. package/dist/types/raw/generic/Response.d.ts +12 -0
  176. package/dist/types/raw/generic/Response.js +3 -0
  177. package/dist/types/raw/generic/Response.js.map +1 -0
  178. package/dist/types/raw/list/Details.d.ts +122 -0
  179. package/dist/types/raw/list/Details.js +4 -0
  180. package/dist/types/raw/list/Details.js.map +1 -0
  181. package/dist/types/raw/list/Members.d.ts +134 -0
  182. package/dist/types/raw/list/Members.js +4 -0
  183. package/dist/types/raw/list/Members.js.map +1 -0
  184. package/dist/types/raw/list/Tweets.d.ts +1968 -0
  185. package/dist/types/raw/list/Tweets.js +4 -0
  186. package/dist/types/raw/list/Tweets.js.map +1 -0
  187. package/dist/types/raw/media/FinalizeUpload.d.ts +18 -0
  188. package/dist/types/raw/media/FinalizeUpload.js +4 -0
  189. package/dist/types/raw/media/FinalizeUpload.js.map +1 -0
  190. package/dist/types/raw/media/InitalizeUpload.d.ts +10 -0
  191. package/dist/types/raw/media/InitalizeUpload.js +4 -0
  192. package/dist/types/raw/media/InitalizeUpload.js.map +1 -0
  193. package/dist/types/raw/media/LiveVideoStream.d.ts +19 -0
  194. package/dist/types/raw/media/LiveVideoStream.js +4 -0
  195. package/dist/types/raw/media/LiveVideoStream.js.map +1 -0
  196. package/dist/types/raw/space/Details.d.ts +315 -0
  197. package/dist/types/raw/space/Details.js +4 -0
  198. package/dist/types/raw/space/Details.js.map +1 -0
  199. package/dist/types/raw/tweet/Details.d.ts +183 -0
  200. package/dist/types/raw/tweet/Details.js +4 -0
  201. package/dist/types/raw/tweet/Details.js.map +1 -0
  202. package/dist/types/raw/tweet/Like.d.ts +12 -0
  203. package/dist/types/raw/tweet/Like.js +4 -0
  204. package/dist/types/raw/tweet/Like.js.map +1 -0
  205. package/dist/types/raw/tweet/Likers.d.ts +170 -0
  206. package/dist/types/raw/tweet/Likers.js +4 -0
  207. package/dist/types/raw/tweet/Likers.js.map +1 -0
  208. package/dist/types/raw/tweet/Post.d.ts +133 -0
  209. package/dist/types/raw/tweet/Post.js +4 -0
  210. package/dist/types/raw/tweet/Post.js.map +1 -0
  211. package/dist/types/raw/tweet/Replies.d.ts +465 -0
  212. package/dist/types/raw/tweet/Replies.js +4 -0
  213. package/dist/types/raw/tweet/Replies.js.map +1 -0
  214. package/dist/types/raw/tweet/Retweet.d.ts +25 -0
  215. package/dist/types/raw/tweet/Retweet.js +4 -0
  216. package/dist/types/raw/tweet/Retweet.js.map +1 -0
  217. package/dist/types/raw/tweet/Retweeters.d.ts +177 -0
  218. package/dist/types/raw/tweet/Retweeters.js +4 -0
  219. package/dist/types/raw/tweet/Retweeters.js.map +1 -0
  220. package/dist/types/raw/tweet/Schedule.d.ts +15 -0
  221. package/dist/types/raw/tweet/Schedule.js +4 -0
  222. package/dist/types/raw/tweet/Schedule.js.map +1 -0
  223. package/dist/types/raw/tweet/Search.d.ts +518 -0
  224. package/dist/types/raw/tweet/Search.js +4 -0
  225. package/dist/types/raw/tweet/Search.js.map +1 -0
  226. package/dist/types/raw/tweet/Unlike.d.ts +12 -0
  227. package/dist/types/raw/tweet/Unlike.js +4 -0
  228. package/dist/types/raw/tweet/Unlike.js.map +1 -0
  229. package/dist/types/raw/tweet/Unpost.d.ts +17 -0
  230. package/dist/types/raw/tweet/Unpost.js +4 -0
  231. package/dist/types/raw/tweet/Unpost.js.map +1 -0
  232. package/dist/types/raw/tweet/Unretweet.d.ts +25 -0
  233. package/dist/types/raw/tweet/Unretweet.js +4 -0
  234. package/dist/types/raw/tweet/Unretweet.js.map +1 -0
  235. package/dist/types/raw/tweet/Unschedule.d.ts +12 -0
  236. package/dist/types/raw/tweet/Unschedule.js +4 -0
  237. package/dist/types/raw/tweet/Unschedule.js.map +1 -0
  238. package/dist/types/raw/user/Affiliates.d.ts +154 -0
  239. package/dist/types/raw/user/Affiliates.js +4 -0
  240. package/dist/types/raw/user/Affiliates.js.map +1 -0
  241. package/dist/types/raw/user/Analytics.d.ts +32 -0
  242. package/dist/types/raw/user/Analytics.js +4 -0
  243. package/dist/types/raw/user/Analytics.js.map +1 -0
  244. package/dist/types/raw/user/Bookmarks.d.ts +550 -0
  245. package/dist/types/raw/user/Bookmarks.js +4 -0
  246. package/dist/types/raw/user/Bookmarks.js.map +1 -0
  247. package/dist/types/raw/user/Details.d.ts +157 -0
  248. package/dist/types/raw/user/Details.js +4 -0
  249. package/dist/types/raw/user/Details.js.map +1 -0
  250. package/dist/types/raw/user/Follow.d.ts +248 -0
  251. package/dist/types/raw/user/Follow.js +4 -0
  252. package/dist/types/raw/user/Follow.js.map +1 -0
  253. package/dist/types/raw/user/Followed.d.ts +1666 -0
  254. package/dist/types/raw/user/Followed.js +4 -0
  255. package/dist/types/raw/user/Followed.js.map +1 -0
  256. package/dist/types/raw/user/Followers.d.ts +182 -0
  257. package/dist/types/raw/user/Followers.js +4 -0
  258. package/dist/types/raw/user/Followers.js.map +1 -0
  259. package/dist/types/raw/user/Following.d.ts +182 -0
  260. package/dist/types/raw/user/Following.js +4 -0
  261. package/dist/types/raw/user/Following.js.map +1 -0
  262. package/dist/types/raw/user/Highlights.d.ts +1106 -0
  263. package/dist/types/raw/user/Highlights.js +4 -0
  264. package/dist/types/raw/user/Highlights.js.map +1 -0
  265. package/dist/types/raw/user/Likes.d.ts +1065 -0
  266. package/dist/types/raw/user/Likes.js +4 -0
  267. package/dist/types/raw/user/Likes.js.map +1 -0
  268. package/dist/types/raw/user/Media.d.ts +1492 -0
  269. package/dist/types/raw/user/Media.js +4 -0
  270. package/dist/types/raw/user/Media.js.map +1 -0
  271. package/dist/types/raw/user/Notifications.d.ts +142 -0
  272. package/dist/types/raw/user/Notifications.js +4 -0
  273. package/dist/types/raw/user/Notifications.js.map +1 -0
  274. package/dist/types/raw/user/Recommended.d.ts +1991 -0
  275. package/dist/types/raw/user/Recommended.js +4 -0
  276. package/dist/types/raw/user/Recommended.js.map +1 -0
  277. package/dist/types/raw/user/Scheduled.d.ts +31 -0
  278. package/dist/types/raw/user/Scheduled.js +4 -0
  279. package/dist/types/raw/user/Scheduled.js.map +1 -0
  280. package/dist/types/raw/user/Subscriptions.d.ts +151 -0
  281. package/dist/types/raw/user/Subscriptions.js +4 -0
  282. package/dist/types/raw/user/Subscriptions.js.map +1 -0
  283. package/dist/types/raw/user/Tweets.d.ts +1065 -0
  284. package/dist/types/raw/user/Tweets.js +4 -0
  285. package/dist/types/raw/user/Tweets.js.map +1 -0
  286. package/dist/types/raw/user/TweetsAndReplies.d.ts +1065 -0
  287. package/dist/types/raw/user/TweetsAndReplies.js +4 -0
  288. package/dist/types/raw/user/TweetsAndReplies.js.map +1 -0
  289. package/dist/types/raw/user/Unfollow.d.ts +248 -0
  290. package/dist/types/raw/user/Unfollow.js +4 -0
  291. package/dist/types/raw/user/Unfollow.js.map +1 -0
  292. package/package.json +3 -3
  293. package/src/Rettiwt.ts +22 -7
  294. package/src/collections/Extractors.ts +38 -34
  295. package/src/collections/Groups.ts +3 -0
  296. package/src/collections/Requests.ts +43 -42
  297. package/src/commands/Tweet.ts +35 -7
  298. package/src/commands/User.ts +13 -2
  299. package/src/enums/Authentication.ts +2 -11
  300. package/src/enums/Data.ts +3 -16
  301. package/src/enums/Media.ts +10 -0
  302. package/src/enums/Notification.ts +12 -0
  303. package/src/enums/Resource.ts +3 -0
  304. package/src/enums/raw/Analytics.ts +29 -0
  305. package/src/enums/raw/Media.ts +10 -0
  306. package/src/enums/raw/Notification.ts +11 -0
  307. package/src/enums/raw/Tweet.ts +9 -0
  308. package/src/helper/TidUtils.ts +189 -0
  309. package/src/index.ts +78 -43
  310. package/src/models/RettiwtConfig.ts +64 -0
  311. package/src/models/args/FetchArgs.ts +121 -5
  312. package/src/models/args/PostArgs.ts +61 -21
  313. package/src/models/auth/AuthCookie.ts +2 -0
  314. package/src/models/auth/AuthCredential.ts +2 -0
  315. package/src/models/data/CursoredData.ts +16 -24
  316. package/src/models/data/List.ts +16 -2
  317. package/src/models/data/Notification.ts +21 -12
  318. package/src/models/data/Tweet.ts +120 -39
  319. package/src/models/data/User.ts +71 -15
  320. package/src/models/errors/RettiwtError.ts +3 -2
  321. package/src/models/params/Variables.ts +62 -0
  322. package/src/requests/List.ts +121 -0
  323. package/src/requests/Media.ts +67 -0
  324. package/src/requests/Tweet.ts +496 -0
  325. package/src/requests/User.ts +783 -0
  326. package/src/services/internal/AuthService.ts +6 -11
  327. package/src/services/internal/TidService.ts +147 -0
  328. package/src/services/public/FetcherService.ts +78 -58
  329. package/src/services/public/ListService.ts +4 -4
  330. package/src/services/public/TweetService.ts +87 -40
  331. package/src/services/public/UserService.ts +47 -35
  332. package/src/types/RettiwtConfig.ts +11 -12
  333. package/src/types/args/FetchArgs.ts +92 -8
  334. package/src/types/args/PostArgs.ts +72 -22
  335. package/src/types/auth/AuthCookie.ts +2 -0
  336. package/src/types/auth/AuthCredential.ts +2 -0
  337. package/src/types/auth/TidDynamicArgs.ts +10 -0
  338. package/src/types/auth/TidHeader.ts +12 -0
  339. package/src/types/auth/TidParams.ts +36 -0
  340. package/src/types/auth/TidProvider.ts +19 -0
  341. package/src/types/data/CursoredData.ts +1 -11
  342. package/src/types/data/Notification.ts +2 -2
  343. package/src/types/data/Tweet.ts +2 -2
  344. package/src/types/params/Variables.ts +41 -0
  345. package/src/types/raw/base/Analytic.ts +26 -0
  346. package/src/types/raw/base/Cursor.ts +13 -0
  347. package/src/types/raw/base/LimitedVisibilityTweet.ts +40 -0
  348. package/src/types/raw/base/List.ts +50 -0
  349. package/src/types/raw/base/Media.ts +53 -0
  350. package/src/types/raw/base/Notification.ts +67 -0
  351. package/src/types/raw/base/Space.ts +35 -0
  352. package/src/types/raw/base/Tweet.ts +139 -0
  353. package/src/types/raw/base/User.ts +164 -0
  354. package/src/types/raw/composite/DataResult.ts +8 -0
  355. package/src/types/raw/composite/TimelineTweet.ts +14 -0
  356. package/src/types/raw/composite/TimelineUser.ts +13 -0
  357. package/src/types/raw/generic/Error.ts +35 -0
  358. package/src/types/raw/generic/Response.ts +13 -0
  359. package/src/types/raw/list/Details.ts +137 -0
  360. package/src/types/raw/list/Members.ts +154 -0
  361. package/src/types/raw/list/Tweets.ts +2296 -0
  362. package/src/types/raw/media/FinalizeUpload.ts +20 -0
  363. package/src/types/raw/media/InitalizeUpload.ts +12 -0
  364. package/src/types/raw/media/LiveVideoStream.ts +21 -0
  365. package/src/types/raw/space/Details.ts +359 -0
  366. package/src/types/raw/tweet/Details.ts +210 -0
  367. package/src/types/raw/tweet/Like.ts +14 -0
  368. package/src/types/raw/tweet/Likers.ts +200 -0
  369. package/src/types/raw/tweet/Post.ts +150 -0
  370. package/src/types/raw/tweet/Replies.ts +539 -0
  371. package/src/types/raw/tweet/Retweet.ts +31 -0
  372. package/src/types/raw/tweet/Retweeters.ts +208 -0
  373. package/src/types/raw/tweet/Schedule.ts +18 -0
  374. package/src/types/raw/tweet/Search.ts +597 -0
  375. package/src/types/raw/tweet/Unlike.ts +14 -0
  376. package/src/types/raw/tweet/Unpost.ts +20 -0
  377. package/src/types/raw/tweet/Unretweet.ts +31 -0
  378. package/src/types/raw/tweet/Unschedule.ts +14 -0
  379. package/src/types/raw/user/Affiliates.ts +179 -0
  380. package/src/types/raw/user/Analytics.ts +39 -0
  381. package/src/types/raw/user/Bookmarks.ts +637 -0
  382. package/src/types/raw/user/Details.ts +185 -0
  383. package/src/types/raw/user/Follow.ts +280 -0
  384. package/src/types/raw/user/Followed.ts +1942 -0
  385. package/src/types/raw/user/Followers.ts +215 -0
  386. package/src/types/raw/user/Following.ts +215 -0
  387. package/src/types/raw/user/Highlights.ts +1287 -0
  388. package/src/types/raw/user/Likes.ts +1254 -0
  389. package/src/types/raw/user/Media.ts +1738 -0
  390. package/src/types/raw/user/Notifications.ts +175 -0
  391. package/src/types/raw/user/Recommended.ts +2319 -0
  392. package/src/types/raw/user/Scheduled.ts +37 -0
  393. package/src/types/raw/user/Subscriptions.ts +176 -0
  394. package/src/types/raw/user/Tweets.ts +1254 -0
  395. package/src/types/raw/user/TweetsAndReplies.ts +1254 -0
  396. package/src/types/raw/user/Unfollow.ts +280 -0
  397. package/dist/models/auth/AccountCredential.d.ts +0 -13
  398. package/dist/models/auth/AccountCredential.js +0 -21
  399. package/dist/models/auth/AccountCredential.js.map +0 -1
  400. package/dist/types/ReturnTypes.d.ts +0 -21
  401. package/dist/types/ReturnTypes.js.map +0 -1
  402. package/dist/types/auth/AccountCredential.d.ts +0 -11
  403. package/dist/types/auth/AccountCredential.js.map +0 -1
  404. package/src/models/auth/AccountCredential.ts +0 -19
  405. package/src/types/ReturnTypes.ts +0 -24
  406. package/src/types/auth/AccountCredential.ts +0 -13
@@ -1,12 +1,9 @@
1
- import https, { Agent } from 'https';
1
+ import { Agent } from 'https';
2
2
 
3
3
  import axios from 'axios';
4
4
 
5
- import { HttpsProxyAgent } from 'https-proxy-agent';
6
-
7
5
  import { EApiErrors } from '../../enums/Api';
8
6
  import { AuthCredential } from '../../models/auth/AuthCredential';
9
- import { IRettiwtConfig } from '../../types/RettiwtConfig';
10
7
 
11
8
  /**
12
9
  * The services that handles authentication.
@@ -18,12 +15,10 @@ export class AuthService {
18
15
  private readonly _httpsAgent: Agent;
19
16
 
20
17
  /**
21
- * @param config - The config object for configuring the `Rettiwt` instance.
22
- *
23
- * @internal
18
+ * @param httpsAgent - The HTTPS agent to use. If none is provided, default is used.
24
19
  */
25
- public constructor(config?: IRettiwtConfig) {
26
- this._httpsAgent = config?.proxyUrl ? new HttpsProxyAgent(config.proxyUrl) : new https.Agent();
20
+ public constructor(httpsAgent?: Agent) {
21
+ this._httpsAgent = httpsAgent ?? new Agent();
27
22
  }
28
23
 
29
24
  /**
@@ -106,11 +101,11 @@ export class AuthService {
106
101
 
107
102
  // Getting the guest token
108
103
  await axios
109
- .get<{
104
+ .post<{
110
105
  /* eslint-disable @typescript-eslint/naming-convention */
111
106
  guest_token: string;
112
107
  /* eslint-enable @typescript-eslint/naming-convention */
113
- }>('https://api.twitter.com/1.1/guest/activate.json', {
108
+ }>('https://api.twitter.com/1.1/guest/activate.json', undefined, {
114
109
  headers: cred.toHeader(),
115
110
  httpsAgent: this._httpsAgent,
116
111
  })
@@ -0,0 +1,147 @@
1
+ import { Agent } from 'http';
2
+
3
+ import axios from 'axios';
4
+ import * as htmlParser from 'node-html-parser';
5
+
6
+ import { ELogActions } from '../../enums/Logging';
7
+
8
+ import { calculateClientTransactionIdHeader } from '../../helper/TidUtils';
9
+
10
+ import { ITidDynamicArgs } from '../../types/auth/TidDynamicArgs';
11
+ import { ITidProvider } from '../../types/auth/TidProvider';
12
+
13
+ import { LogService } from './LogService';
14
+
15
+ /**
16
+ * Handles transaction ID generation for requests to Twitter.
17
+ *
18
+ * @internal
19
+ */
20
+ export class TidService implements ITidProvider {
21
+ private readonly _cdnUrl: string;
22
+ private readonly _httpsAgent: Agent;
23
+ private readonly _requestHeaders: NonNullable<unknown>;
24
+ private _dynamicArgs?: ITidDynamicArgs;
25
+
26
+ /**
27
+ * @param httpsAgent - The HTTPS agent to use. If none is provided, default is used.
28
+ */
29
+ public constructor(httpsAgent?: Agent) {
30
+ this._cdnUrl = 'https://abs.twimg.com/responsive-web/client-web';
31
+ this._httpsAgent = httpsAgent ?? new Agent();
32
+ this._requestHeaders = {
33
+ /* eslint-disable @typescript-eslint/naming-convention */
34
+
35
+ Authority: 'x.com',
36
+ 'Accept-Language': 'en-US,en;q=0.9',
37
+ 'Cache-Control': 'no-cache',
38
+ Referer: 'https://x.com',
39
+ 'User-Agent':
40
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
41
+ 'X-Twitter-Active-User': 'yes',
42
+ 'X-Twitter-Client-Language': 'en',
43
+
44
+ /* eslint-enable @typescript-eslint/naming-convention */
45
+ };
46
+ }
47
+
48
+ /**
49
+ * Fetches the dynamic args embedded in the homepage.
50
+ *
51
+ * @returns The new dynamic args.
52
+ */
53
+ private async getDynamicArgs(): Promise<ITidDynamicArgs> {
54
+ const html = await this.getHomepageHtml();
55
+ const root = htmlParser.parse(html);
56
+ const keyElement = root.querySelector("[name='twitter-site-verification']");
57
+ const frameElements = root.querySelectorAll("[id^='loading-x-anim']");
58
+
59
+ return {
60
+ verificationKey: keyElement?.getAttribute('content') ?? '',
61
+ frames: frameElements.map((el) => this.parseFrameElement(el)),
62
+ indices: await this.getKeyBytesIndices(html),
63
+ };
64
+ }
65
+
66
+ /**
67
+ * Fetches the HTML content of Twitter's homepage.
68
+ *
69
+ * @returns The stringified HTML content of the homepage.
70
+ */
71
+ private async getHomepageHtml(): Promise<string> {
72
+ const response = await axios.get<string>('https://x.com', {
73
+ headers: this._requestHeaders,
74
+ httpAgent: this._httpsAgent,
75
+ httpsAgent: this._httpsAgent,
76
+ });
77
+
78
+ return response.data;
79
+ }
80
+
81
+ private async getKeyBytesIndices(html: string): Promise<number[]> {
82
+ const ondemandFileMatch = html.match(/ondemand\.s":"([^"]+)"/);
83
+ if (!ondemandFileMatch || !ondemandFileMatch[1]) {
84
+ LogService.log(ELogActions.WARNING, { message: 'ondemand.s file not found' });
85
+
86
+ return [0, 0, 0, 0];
87
+ }
88
+
89
+ const onDemandFileHash = ondemandFileMatch ? ondemandFileMatch[1] : '';
90
+ const response = await axios.get<string>(`${this._cdnUrl}/ondemand.s.${onDemandFileHash}a.js`, {
91
+ httpAgent: this._httpsAgent,
92
+ httpsAgent: this._httpsAgent,
93
+ });
94
+ const match = response.data.matchAll(/(\(\w\[(\d{1,2})],\s*16\))+?/gm);
95
+
96
+ return Array.from(match).map((m) => Number(m[2]));
97
+ }
98
+
99
+ private parseFrameElement(element: htmlParser.HTMLElement): number[][] {
100
+ const pathElement = element.children[0].children[1];
101
+ const value = pathElement.getAttribute('d');
102
+ if (!value) {
103
+ return [[]];
104
+ }
105
+
106
+ const rawFrames = value.substring(9).split('C');
107
+
108
+ return rawFrames.map((str) => str.replaceAll(/\D+/g, ' ').trim().split(' ')).map((arr) => arr.map(Number));
109
+ }
110
+
111
+ /**
112
+ * Generate an `x-client-transaction-id` for the specific URL method and path.
113
+ *
114
+ * @param method - The target method.
115
+ * @param path - The target path.
116
+ *
117
+ * @returns The specific `x-client-transaction-id` token.
118
+ */
119
+ public async generate(method: string, path: string): Promise<string | undefined> {
120
+ try {
121
+ if (!this._dynamicArgs) {
122
+ this._dynamicArgs = await this.getDynamicArgs();
123
+ }
124
+
125
+ const { verificationKey, frames, indices } = this._dynamicArgs;
126
+
127
+ return calculateClientTransactionIdHeader({
128
+ keyword: 'obfiowerehiring',
129
+ method: method,
130
+ path: path,
131
+ verificationKey: verificationKey,
132
+ frames: frames,
133
+ indices: indices,
134
+ extraByte: 3,
135
+ });
136
+ } catch {
137
+ return;
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Refreshes the dynamic args from the homepage.
143
+ */
144
+ public async refreshDynamicArgs(): Promise<void> {
145
+ this._dynamicArgs = await this.getDynamicArgs();
146
+ }
147
+ }
@@ -1,8 +1,5 @@
1
- import https, { Agent } from 'https';
2
-
3
1
  import axios from 'axios';
4
2
  import { Cookie } from 'cookiejar';
5
- import { HttpsProxyAgent } from 'https-proxy-agent';
6
3
 
7
4
  import { allowGuestAuthentication, fetchResources, postResources } from '../../collections/Groups';
8
5
  import { requests } from '../../collections/Requests';
@@ -12,14 +9,17 @@ import { EResourceType } from '../../enums/Resource';
12
9
  import { FetchArgs } from '../../models/args/FetchArgs';
13
10
  import { PostArgs } from '../../models/args/PostArgs';
14
11
  import { AuthCredential } from '../../models/auth/AuthCredential';
12
+ import { RettiwtConfig } from '../../models/RettiwtConfig';
15
13
  import { IFetchArgs } from '../../types/args/FetchArgs';
16
14
  import { IPostArgs } from '../../types/args/PostArgs';
15
+ import { ITidHeader } from '../../types/auth/TidHeader';
16
+ import { ITidProvider } from '../../types/auth/TidProvider';
17
17
  import { IErrorHandler } from '../../types/ErrorHandler';
18
- import { IRettiwtConfig } from '../../types/RettiwtConfig';
19
18
 
20
19
  import { AuthService } from '../internal/AuthService';
21
20
  import { ErrorService } from '../internal/ErrorService';
22
21
  import { LogService } from '../internal/LogService';
22
+ import { TidService } from '../internal/TidService';
23
23
 
24
24
  /**
25
25
  * The base service that handles all HTTP requests.
@@ -27,43 +27,35 @@ import { LogService } from '../internal/LogService';
27
27
  * @public
28
28
  */
29
29
  export class FetcherService {
30
- /** The api key to use for authenticating against Twitter API as user. */
31
- private readonly _apiKey?: string;
30
+ /** The AuthService instance to use. */
31
+ private readonly _auth: AuthService;
32
32
 
33
- /** Custom headers to use for all requests */
34
- private readonly _customHeaders?: { [key: string]: string };
33
+ /** The delay/delay function to use (ms). */
34
+ private readonly _delay?: number | (() => number | Promise<number>);
35
35
 
36
36
  /** The service used to handle HTTP and API errors */
37
37
  private readonly _errorHandler: IErrorHandler;
38
38
 
39
- /** The guest key to use for authenticating against Twitter API as guest. */
40
- private readonly _guestKey?: string;
41
-
42
- /** The URL To the proxy server to use for all others. */
43
- private readonly _proxyUrl?: URL;
39
+ /** Service responsible for generating the `x-client-transaction-id` header. */
40
+ private readonly _tidProvider: ITidProvider;
44
41
 
45
42
  /** The max wait time for a response. */
46
43
  private readonly _timeout: number;
47
44
 
48
- /** The URL to the proxy server to use only for authentication. */
49
- protected readonly authProxyUrl?: URL;
50
-
51
- /** The id of the authenticated user (if any). */
52
- protected readonly userId?: string;
45
+ /** The config object. */
46
+ protected readonly config: RettiwtConfig;
53
47
 
54
48
  /**
55
49
  * @param config - The config object for configuring the Rettiwt instance.
56
50
  */
57
- public constructor(config?: IRettiwtConfig) {
58
- LogService.enabled = config?.logging ?? false;
59
- this._apiKey = config?.apiKey;
60
- this._guestKey = config?.guestKey;
61
- this.userId = config?.apiKey ? AuthService.getUserId(config.apiKey) : undefined;
62
- this.authProxyUrl = config?.authProxyUrl ?? config?.proxyUrl;
63
- this._proxyUrl = config?.proxyUrl;
64
- this._timeout = config?.timeout ?? 0;
65
- this._errorHandler = config?.errorHandler ?? new ErrorService();
66
- this._customHeaders = config?.headers;
51
+ public constructor(config: RettiwtConfig) {
52
+ LogService.enabled = config.logging ?? false;
53
+ this.config = config;
54
+ this._delay = config.delay;
55
+ this._errorHandler = config.errorHandler ?? new ErrorService();
56
+ this._tidProvider = config.tidProvider ?? new TidService(config.httpsAgent);
57
+ this._timeout = config.timeout ?? 0;
58
+ this._auth = new AuthService(config.httpsAgent);
67
59
  }
68
60
 
69
61
  /**
@@ -75,10 +67,10 @@ export class FetcherService {
75
67
  */
76
68
  private checkAuthorization(resource: EResourceType): void {
77
69
  // Logging
78
- LogService.log(ELogActions.AUTHORIZATION, { authenticated: this.userId != undefined });
70
+ LogService.log(ELogActions.AUTHORIZATION, { authenticated: this.config.userId != undefined });
79
71
 
80
72
  // Checking authorization status
81
- if (!allowGuestAuthentication.includes(resource) && this.userId == undefined) {
73
+ if (!allowGuestAuthentication.includes(resource) && this.config.userId == undefined) {
82
74
  throw new Error(EApiErrors.RESOURCE_NOT_ALLOWED);
83
75
  }
84
76
  }
@@ -89,46 +81,46 @@ export class FetcherService {
89
81
  * @returns The generated AuthCredential
90
82
  */
91
83
  private async getCredential(): Promise<AuthCredential> {
92
- if (this._apiKey) {
84
+ if (this.config.apiKey) {
93
85
  // Logging
94
86
  LogService.log(ELogActions.GET, { target: 'USER_CREDENTIAL' });
95
87
 
96
88
  return new AuthCredential(
97
- AuthService.decodeCookie(this._apiKey)
89
+ AuthService.decodeCookie(this.config.apiKey)
98
90
  .split(';')
99
91
  .map((item) => new Cookie(item)),
100
92
  );
101
- } else if (this._guestKey) {
102
- // Logging
103
- LogService.log(ELogActions.GET, { target: 'GUEST_CREDENTIAL' });
104
-
105
- return new AuthCredential(undefined, this._guestKey);
106
93
  } else {
107
94
  // Logging
108
95
  LogService.log(ELogActions.GET, { target: 'NEW_GUEST_CREDENTIAL' });
109
96
 
110
- return await new AuthService({ proxyUrl: this.authProxyUrl }).guest();
97
+ return this._auth.guest();
111
98
  }
112
99
  }
113
100
 
114
101
  /**
115
- * Gets the https agent based on whether a proxy is used or not.
102
+ * Generates the header for the transaction ID.
116
103
  *
117
- * @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
104
+ * @param method - The target method.
105
+ * @param url - The target URL.
118
106
  *
119
- * @returns The https agent to use.
107
+ * @returns The header containing the transaction ID.
120
108
  */
121
- private getHttpsAgent(proxyUrl?: URL): Agent {
122
- if (proxyUrl) {
123
- // Logging
124
- LogService.log(ELogActions.GET, { target: 'HTTPS_PROXY_AGENT' });
125
-
126
- return new HttpsProxyAgent(proxyUrl);
109
+ private async getTransactionHeader(method: string, url: string): Promise<ITidHeader | undefined> {
110
+ // Getting the URL path excluding all params
111
+ const path = new URL(url).pathname.split('?')[0].trim();
112
+
113
+ // Generating the transaction ID
114
+ const tid = await this._tidProvider.generate(method.toUpperCase(), path);
115
+
116
+ if (tid) {
117
+ return {
118
+ /* eslint-disable @typescript-eslint/naming-convention */
119
+ 'x-client-transaction-id': tid,
120
+ /* eslint-enable @typescript-eslint/naming-convention */
121
+ };
127
122
  } else {
128
- // Logging
129
- LogService.log(ELogActions.GET, { target: 'HTTPS_AGENT' });
130
-
131
- return new https.Agent();
123
+ return undefined;
132
124
  }
133
125
  }
134
126
 
@@ -154,6 +146,29 @@ export class FetcherService {
154
146
  }
155
147
  }
156
148
 
149
+ /**
150
+ * Introduces a delay using the configured delay/delay function.
151
+ */
152
+ private async wait(): Promise<void> {
153
+ // If no delay is set, skip
154
+ if (this._delay == undefined) {
155
+ return;
156
+ }
157
+
158
+ /** The delay (in ms) to use. */
159
+ let delay = 0;
160
+
161
+ // Getting the delay
162
+ if (this._delay && typeof this._delay == 'number') {
163
+ delay = this._delay;
164
+ } else if (this._delay && typeof this._delay == 'function') {
165
+ delay = await this._delay();
166
+ }
167
+
168
+ // Awaiting for the delay time
169
+ await new Promise((resolve) => setTimeout(resolve, delay));
170
+ }
171
+
157
172
  /**
158
173
  * Makes an HTTP request according to the given parameters.
159
174
  *
@@ -182,7 +197,7 @@ export class FetcherService {
182
197
  * })
183
198
  * ```
184
199
  */
185
- public async request<T>(resource: EResourceType, args: IFetchArgs | IPostArgs): Promise<T> {
200
+ public async request<T = unknown>(resource: EResourceType, args: IFetchArgs | IPostArgs): Promise<T> {
186
201
  // Logging
187
202
  LogService.log(ELogActions.REQUEST, { resource: resource, args: args });
188
203
 
@@ -192,9 +207,6 @@ export class FetcherService {
192
207
  // Validating args
193
208
  args = this.validateArgs(resource, args)!;
194
209
 
195
- // Getting HTTPS agent
196
- const httpsAgent: Agent = this.getHttpsAgent(this._proxyUrl);
197
-
198
210
  // Getting credentials from key
199
211
  const cred: AuthCredential = await this.getCredential();
200
212
 
@@ -202,13 +214,21 @@ export class FetcherService {
202
214
  const config = requests[resource](args);
203
215
 
204
216
  // Setting additional request parameters
205
- config.headers = { ...config.headers, ...cred.toHeader(), ...(this._customHeaders || {}) };
206
- config.httpAgent = httpsAgent;
207
- config.httpsAgent = httpsAgent;
217
+ config.headers = {
218
+ ...config.headers,
219
+ ...cred.toHeader(),
220
+ ...(await this.getTransactionHeader(config.method ?? '', config.url ?? '')),
221
+ ...this.config.headers,
222
+ };
223
+ config.httpAgent = this.config.httpsAgent;
224
+ config.httpsAgent = this.config.httpsAgent;
208
225
  config.timeout = this._timeout;
209
226
 
210
227
  // Sending the request
211
228
  try {
229
+ // Introducing a delay
230
+ await this.wait();
231
+
212
232
  // Returning the reponse body
213
233
  return (await axios<T>(config)).data;
214
234
  } catch (error) {
@@ -1,11 +1,11 @@
1
- import { IListMembersResponse, IListTweetsResponse } from 'rettiwt-core';
2
-
3
1
  import { extractors } from '../../collections/Extractors';
4
2
  import { EResourceType } from '../../enums/Resource';
5
3
  import { CursoredData } from '../../models/data/CursoredData';
6
4
  import { Tweet } from '../../models/data/Tweet';
7
5
  import { User } from '../../models/data/User';
8
- import { IRettiwtConfig } from '../../types/RettiwtConfig';
6
+ import { RettiwtConfig } from '../../models/RettiwtConfig';
7
+ import { IListMembersResponse } from '../../types/raw/list/Members';
8
+ import { IListTweetsResponse } from '../../types/raw/list/Tweets';
9
9
 
10
10
  import { FetcherService } from './FetcherService';
11
11
 
@@ -15,7 +15,7 @@ export class ListService extends FetcherService {
15
15
  *
16
16
  * @internal
17
17
  */
18
- public constructor(config?: IRettiwtConfig) {
18
+ public constructor(config: RettiwtConfig) {
19
19
  super(config);
20
20
  }
21
21
 
@@ -1,31 +1,30 @@
1
1
  import { statSync } from 'fs';
2
2
 
3
- import {
4
- ESearchResultType,
5
- IInitializeMediaUploadResponse,
6
- IListTweetsResponse,
7
- INewTweet,
8
- ITweetDetailsResponse,
9
- ITweetLikeResponse,
10
- ITweetPostResponse,
11
- ITweetRepliesResponse,
12
- ITweetRetweetersResponse,
13
- ITweetRetweetResponse,
14
- ITweetScheduleResponse,
15
- ITweetSearchResponse,
16
- ITweetUnlikeResponse,
17
- ITweetUnpostResponse,
18
- ITweetUnretweetResponse,
19
- ITweetUnscheduleResponse,
20
- TweetFilter,
21
- } from 'rettiwt-core';
22
-
23
3
  import { extractors } from '../../collections/Extractors';
24
4
  import { EResourceType } from '../../enums/Resource';
25
5
  import { CursoredData } from '../../models/data/CursoredData';
26
6
  import { Tweet } from '../../models/data/Tweet';
27
7
  import { User } from '../../models/data/User';
28
- import { IRettiwtConfig } from '../../types/RettiwtConfig';
8
+
9
+ import { RettiwtConfig } from '../../models/RettiwtConfig';
10
+ import { ITweetFilter } from '../../types/args/FetchArgs';
11
+ import { INewTweet } from '../../types/args/PostArgs';
12
+ import { IListTweetsResponse } from '../../types/raw/list/Tweets';
13
+ import { IMediaInitializeUploadResponse } from '../../types/raw/media/InitalizeUpload';
14
+ import { ITweetDetailsResponse } from '../../types/raw/tweet/Details';
15
+
16
+ import { ITweetLikeResponse } from '../../types/raw/tweet/Like';
17
+ import { ITweetLikersResponse } from '../../types/raw/tweet/Likers';
18
+ import { ITweetPostResponse } from '../../types/raw/tweet/Post';
19
+ import { ITweetRepliesResponse } from '../../types/raw/tweet/Replies';
20
+ import { ITweetRetweetResponse } from '../../types/raw/tweet/Retweet';
21
+ import { ITweetRetweetersResponse } from '../../types/raw/tweet/Retweeters';
22
+ import { ITweetScheduleResponse } from '../../types/raw/tweet/Schedule';
23
+ import { ITweetSearchResponse } from '../../types/raw/tweet/Search';
24
+ import { ITweetUnlikeResponse } from '../../types/raw/tweet/Unlike';
25
+ import { ITweetUnpostResponse } from '../../types/raw/tweet/Unpost';
26
+ import { ITweetUnretweetResponse } from '../../types/raw/tweet/Unretweet';
27
+ import { ITweetUnscheduleResponse } from '../../types/raw/tweet/Unschedule';
29
28
 
30
29
  import { FetcherService } from './FetcherService';
31
30
 
@@ -40,14 +39,14 @@ export class TweetService extends FetcherService {
40
39
  *
41
40
  * @internal
42
41
  */
43
- public constructor(config?: IRettiwtConfig) {
42
+ public constructor(config: RettiwtConfig) {
44
43
  super(config);
45
44
  }
46
45
 
47
46
  /**
48
47
  * Get the details of a tweet.
49
48
  *
50
- * @param id - The id of the target tweet.
49
+ * @param id - The id(s) of the target tweet/tweets.
51
50
  *
52
51
  * @returns
53
52
  * The details of the tweet with the given id.
@@ -70,11 +69,11 @@ export class TweetService extends FetcherService {
70
69
  * });
71
70
  * ```
72
71
  */
73
- public async details(id: string): Promise<Tweet | undefined> {
72
+ public async details<T extends string | string[]>(id: T): Promise<T extends string ? Tweet | undefined : Tweet[]> {
74
73
  let resource: EResourceType;
75
74
 
76
- // If user is authenticated
77
- if (this.userId != undefined) {
75
+ // If user is authenticated and details of single tweet required
76
+ if (this.config.userId != undefined && typeof id == 'string') {
78
77
  resource = EResourceType.TWEET_DETAILS_ALT;
79
78
 
80
79
  // Fetching raw tweet details
@@ -83,19 +82,31 @@ export class TweetService extends FetcherService {
83
82
  // Deserializing response
84
83
  const data = extractors[resource](response, id);
85
84
 
86
- return data;
85
+ return data as T extends string ? Tweet | undefined : Tweet[];
86
+ }
87
+ // If user is authenticated and details of multiple tweets required
88
+ else if (this.config.userId != undefined && Array.isArray(id)) {
89
+ resource = EResourceType.TWEET_DETAILS_BULK;
90
+
91
+ // Fetching raw tweet details
92
+ const response = await this.request<ITweetRepliesResponse>(resource, { ids: id });
93
+
94
+ // Deserializing response
95
+ const data = extractors[resource](response, id);
96
+
97
+ return data as T extends string ? Tweet | undefined : Tweet[];
87
98
  }
88
99
  // If user is not authenticated
89
100
  else {
90
101
  resource = EResourceType.TWEET_DETAILS;
91
102
 
92
103
  // Fetching raw tweet details
93
- const response = await this.request<ITweetDetailsResponse>(resource, { id: id });
104
+ const response = await this.request<ITweetDetailsResponse>(resource, { id: String(id) });
94
105
 
95
106
  // Deserializing response
96
- const data = extractors[resource](response, id);
107
+ const data = extractors[resource](response, String(id));
97
108
 
98
- return data;
109
+ return data as T extends string ? Tweet | undefined : Tweet[];
99
110
  }
100
111
  }
101
112
 
@@ -137,6 +148,48 @@ export class TweetService extends FetcherService {
137
148
  return data;
138
149
  }
139
150
 
151
+ /**
152
+ * Get the list of users who liked a tweet. Only works for your own tweets.
153
+ *
154
+ * @param id - The id of the target tweet.
155
+ * @param count - The number of likers to fetch, must be \<= 100.
156
+ * @param cursor - The cursor to the batch of likers to fetch.
157
+ *
158
+ * @returns The list of users who liked the given tweet.
159
+ *
160
+ * @example
161
+ * ```
162
+ * import { Rettiwt } from 'rettiwt-api';
163
+ *
164
+ * // Creating a new Rettiwt instance using the given 'API_KEY'
165
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
166
+ *
167
+ * // Fetching the most recent 100 likers of the Tweet with id '1234567890'
168
+ * rettiwt.tweet.likers('1234567890')
169
+ * .then(res => {
170
+ * console.log(res);
171
+ * })
172
+ * .catch(err => {
173
+ * console.log(err);
174
+ * });
175
+ * ```
176
+ */
177
+ public async likers(id: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
178
+ const resource = EResourceType.TWEET_LIKERS;
179
+
180
+ // Fetching raw likers
181
+ const response = await this.request<ITweetLikersResponse>(resource, {
182
+ id: id,
183
+ count: count,
184
+ cursor: cursor,
185
+ });
186
+
187
+ // Deserializing response
188
+ const data = extractors[resource](response);
189
+
190
+ return data;
191
+ }
192
+
140
193
  /**
141
194
  * Get the list of tweets from a tweet list.
142
195
  *
@@ -462,12 +515,7 @@ export class TweetService extends FetcherService {
462
515
  *
463
516
  * @remarks For details about available filters, refer to {@link TweetFilter}
464
517
  */
465
- public async search(
466
- filter: TweetFilter,
467
- count?: number,
468
- cursor?: string,
469
- results?: ESearchResultType,
470
- ): Promise<CursoredData<Tweet>> {
518
+ public async search(filter: ITweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
471
519
  const resource = EResourceType.TWEET_SEARCH;
472
520
 
473
521
  // Fetching raw list of filtered tweets
@@ -475,7 +523,6 @@ export class TweetService extends FetcherService {
475
523
  filter: filter,
476
524
  count: count,
477
525
  cursor: cursor,
478
- results: results,
479
526
  });
480
527
 
481
528
  // Deserializing response
@@ -519,7 +566,7 @@ export class TweetService extends FetcherService {
519
566
  * streamTweets();
520
567
  * ```
521
568
  */
522
- public async *stream(filter: TweetFilter, pollingInterval = 60000): AsyncGenerator<Tweet> {
569
+ public async *stream(filter: ITweetFilter, pollingInterval = 60000): AsyncGenerator<Tweet> {
523
570
  const startDate = new Date();
524
571
 
525
572
  let cursor: string | undefined = undefined;
@@ -545,7 +592,7 @@ export class TweetService extends FetcherService {
545
592
 
546
593
  // If there are more tweets to fetch, adjust the cursor value
547
594
  if (tweets.list.length > 0 && tweets.next) {
548
- cursor = tweets.next.value;
595
+ cursor = tweets.next;
549
596
  }
550
597
  // Else, start the next iteration from this batch's most recent tweet
551
598
  else {
@@ -732,7 +779,7 @@ export class TweetService extends FetcherService {
732
779
  // INITIALIZE
733
780
  const size = typeof media == 'string' ? statSync(media).size : media.byteLength;
734
781
  const id: string = (
735
- await this.request<IInitializeMediaUploadResponse>(EResourceType.MEDIA_UPLOAD_INITIALIZE, {
782
+ await this.request<IMediaInitializeUploadResponse>(EResourceType.MEDIA_UPLOAD_INITIALIZE, {
736
783
  upload: { size: size },
737
784
  })
738
785
  ).media_id_string;