noblox.js-proxy-agent 4.10.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. package/.eslintrc.js +21 -0
  2. package/.github/FUNDING.yml +3 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
  5. package/.github/workflows/doc-publish.yml +33 -0
  6. package/.github/workflows/npmpublish.yml +70 -0
  7. package/.travis.yml +13 -0
  8. package/CODE_OF_CONDUCT.md +76 -0
  9. package/LICENSE +21 -0
  10. package/README.md +168 -0
  11. package/examples/cleanPlayers.js +130 -0
  12. package/examples/cleanWall.js +110 -0
  13. package/examples/revertRanks.js +100 -0
  14. package/examples/savePlayers.js +119 -0
  15. package/examples/saveWall.js +96 -0
  16. package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
  17. package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
  18. package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
  19. package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
  20. package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
  21. package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
  22. package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
  23. package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
  24. package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
  25. package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
  26. package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
  27. package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
  28. package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
  29. package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
  30. package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
  31. package/img/noblox-js-small.png +0 -0
  32. package/img/noblox-js.png +0 -0
  33. package/img/thumbnailSizes.png +0 -0
  34. package/jsDocsConfig.json +55 -0
  35. package/lib/accountinformation/getUserSocialLinks.js +42 -0
  36. package/lib/accountsettings/block.js +58 -0
  37. package/lib/accountsettings/unblock.js +58 -0
  38. package/lib/asset/deleteFromInventory.js +69 -0
  39. package/lib/asset/getGamePassProductInfo.js +51 -0
  40. package/lib/asset/getProductInfo.js +56 -0
  41. package/lib/asset/uploadAnimation.js +103 -0
  42. package/lib/asset/uploadItem.js +83 -0
  43. package/lib/asset/uploadModel.js +90 -0
  44. package/lib/avatar/avatarRules.js +38 -0
  45. package/lib/avatar/currentlyWearing.js +32 -0
  46. package/lib/avatar/getAvatar.js +35 -0
  47. package/lib/avatar/getCurrentAvatar.js +37 -0
  48. package/lib/avatar/getRecentItems.js +37 -0
  49. package/lib/avatar/outfitDetails.js +32 -0
  50. package/lib/avatar/outfits.js +37 -0
  51. package/lib/avatar/redrawAvatar.js +48 -0
  52. package/lib/avatar/removeAssetId.js +55 -0
  53. package/lib/avatar/setAvatarBodyColors.js +60 -0
  54. package/lib/avatar/setAvatarScales.js +60 -0
  55. package/lib/avatar/setPlayerAvatarType.js +50 -0
  56. package/lib/avatar/setWearingAssets.js +50 -0
  57. package/lib/avatar/wearAssetId.js +55 -0
  58. package/lib/badges/getAwardedTimestamps.js +52 -0
  59. package/lib/badges/getBadgeInfo.js +43 -0
  60. package/lib/badges/getGameBadges.js +62 -0
  61. package/lib/badges/getPlayerBadges.js +28 -0
  62. package/lib/badges/updateBadgeInfo.js +80 -0
  63. package/lib/cache/add.js +14 -0
  64. package/lib/cache/addIf.js +26 -0
  65. package/lib/cache/clear.js +8 -0
  66. package/lib/cache/get.js +28 -0
  67. package/lib/cache/index.js +17 -0
  68. package/lib/cache/new.js +12 -0
  69. package/lib/cache/wrap.js +25 -0
  70. package/lib/chat/addUsersToConversation.js +61 -0
  71. package/lib/chat/chatSettings.js +33 -0
  72. package/lib/chat/getChatMessages.js +40 -0
  73. package/lib/chat/getConversations.js +43 -0
  74. package/lib/chat/getRolloutSettings.js +35 -0
  75. package/lib/chat/getUnreadConversationCount.js +33 -0
  76. package/lib/chat/getUnreadMessages.js +38 -0
  77. package/lib/chat/getUserConversations.js +37 -0
  78. package/lib/chat/markChatAsRead.js +52 -0
  79. package/lib/chat/markChatAsSeen.js +50 -0
  80. package/lib/chat/multiGetLatestMessages.js +37 -0
  81. package/lib/chat/onNewConversation.js +50 -0
  82. package/lib/chat/onNewMessage.js +53 -0
  83. package/lib/chat/onNewMessageBySelf.js +50 -0
  84. package/lib/chat/onUserOnline.js +50 -0
  85. package/lib/chat/onUserTyping.js +54 -0
  86. package/lib/chat/removeFromGroupConversation.js +62 -0
  87. package/lib/chat/renameGroupConversation.js +57 -0
  88. package/lib/chat/sendChatMessage.js +57 -0
  89. package/lib/chat/setChatUserTyping.js +61 -0
  90. package/lib/chat/start121Conversation.js +50 -0
  91. package/lib/chat/startCloudEditConversation.js +50 -0
  92. package/lib/chat/startGroupConversation.js +62 -0
  93. package/lib/client/onNotification.js +70 -0
  94. package/lib/client/setAPIKey.js +18 -0
  95. package/lib/client/setCookie.js +38 -0
  96. package/lib/datastores/deleteDatastoreEntry.js +66 -0
  97. package/lib/datastores/getDatastoreEntry.js +98 -0
  98. package/lib/datastores/getDatastoreEntryVersions.js +83 -0
  99. package/lib/datastores/getDatastoreKeys.js +73 -0
  100. package/lib/datastores/getDatastores.js +72 -0
  101. package/lib/datastores/incrementDatastoreEntry.js +93 -0
  102. package/lib/datastores/setDatastoreEntry.js +90 -0
  103. package/lib/develop/canManage.js +44 -0
  104. package/lib/develop/configureItem.js +142 -0
  105. package/lib/develop/updateUniverse.js +53 -0
  106. package/lib/develop/updateUniverseAccess.js +55 -0
  107. package/lib/economy/buy.js +99 -0
  108. package/lib/economy/getGroupFunds.js +43 -0
  109. package/lib/economy/getGroupRevenueSummary.js +48 -0
  110. package/lib/economy/getGroupTransactions.js +32 -0
  111. package/lib/economy/getResaleData.js +54 -0
  112. package/lib/economy/getResellers.js +35 -0
  113. package/lib/economy/getUserTransactions.js +34 -0
  114. package/lib/economy/onGroupTransaction.js +74 -0
  115. package/lib/friends/acceptFriendRequest.js +59 -0
  116. package/lib/friends/declineAllFriendRequests.js +57 -0
  117. package/lib/friends/declineFriendRequest.js +59 -0
  118. package/lib/friends/getFollowers.js +61 -0
  119. package/lib/friends/getFollowings.js +61 -0
  120. package/lib/friends/getFriendRequests.js +56 -0
  121. package/lib/friends/getFriends.js +53 -0
  122. package/lib/friends/onFriendRequest.js +58 -0
  123. package/lib/friends/removeFriend.js +58 -0
  124. package/lib/friends/sendFriendRequest.js +59 -0
  125. package/lib/friends/unfollow.js +58 -0
  126. package/lib/games/addDeveloperProduct.js +65 -0
  127. package/lib/games/checkDeveloperProductName.js +39 -0
  128. package/lib/games/configureGamePass.js +146 -0
  129. package/lib/games/getDeveloperProducts.js +51 -0
  130. package/lib/games/getGameInstances.js +31 -0
  131. package/lib/games/getGamePasses.js +39 -0
  132. package/lib/games/getGameRevenue.js +49 -0
  133. package/lib/games/getGameSocialLinks.js +45 -0
  134. package/lib/games/getGroupGames.js +30 -0
  135. package/lib/games/getPlaceInfo.js +48 -0
  136. package/lib/games/getUniverseInfo.js +51 -0
  137. package/lib/games/updateDeveloperProduct.js +69 -0
  138. package/lib/groups/changeRank.js +59 -0
  139. package/lib/groups/deleteWallPost.js +64 -0
  140. package/lib/groups/deleteWallPostsByUser.js +59 -0
  141. package/lib/groups/demote.js +25 -0
  142. package/lib/groups/exile.js +59 -0
  143. package/lib/groups/getAuditLog.js +67 -0
  144. package/lib/groups/getGroup.js +57 -0
  145. package/lib/groups/getGroupSocialLinks.js +44 -0
  146. package/lib/groups/getGroups.js +88 -0
  147. package/lib/groups/getJoinRequest.js +52 -0
  148. package/lib/groups/getJoinRequests.js +58 -0
  149. package/lib/groups/getPlayers.js +108 -0
  150. package/lib/groups/getRankInGroup.js +52 -0
  151. package/lib/groups/getRankNameInGroup.js +52 -0
  152. package/lib/groups/getRole.js +64 -0
  153. package/lib/groups/getRolePermissions.js +51 -0
  154. package/lib/groups/getRoles.js +56 -0
  155. package/lib/groups/getShout.js +49 -0
  156. package/lib/groups/getWall.js +59 -0
  157. package/lib/groups/groupPayout.js +103 -0
  158. package/lib/groups/handleJoinRequest.js +60 -0
  159. package/lib/groups/leaveGroup.js +60 -0
  160. package/lib/groups/onAuditLog.js +62 -0
  161. package/lib/groups/onJoinRequest.js +63 -0
  162. package/lib/groups/onJoinRequestHandle.js +105 -0
  163. package/lib/groups/onShout.js +57 -0
  164. package/lib/groups/onWallPost.js +58 -0
  165. package/lib/groups/promote.js +25 -0
  166. package/lib/groups/searchGroups.js +32 -0
  167. package/lib/groups/setGroupDescription.js +65 -0
  168. package/lib/groups/setGroupName.js +66 -0
  169. package/lib/groups/setRank.js +79 -0
  170. package/lib/groups/shout.js +65 -0
  171. package/lib/index.js +30 -0
  172. package/lib/internal/levelOneCopy.js +16 -0
  173. package/lib/internal/queue.js +61 -0
  174. package/lib/internal/timeout.js +30 -0
  175. package/lib/internal/wrap.js +78 -0
  176. package/lib/inventory/getCollectibles.js +31 -0
  177. package/lib/inventory/getInventory.js +32 -0
  178. package/lib/inventory/getInventoryById.js +31 -0
  179. package/lib/inventory/getOwnership.js +54 -0
  180. package/lib/inventory/getUAIDs.js +47 -0
  181. package/lib/itemconfiguration/getGroupAssets.js +32 -0
  182. package/lib/options.js +26 -0
  183. package/lib/party/onPartyDeleted.js +53 -0
  184. package/lib/party/onPartyInvite.js +53 -0
  185. package/lib/party/onPartyJoinedGame.js +53 -0
  186. package/lib/party/onPartyLeftGame.js +53 -0
  187. package/lib/party/onPartySelfJoined.js +53 -0
  188. package/lib/party/onPartySelfLeft.js +53 -0
  189. package/lib/party/onPartyUserJoined.js +53 -0
  190. package/lib/party/onPartyUserLeft.js +53 -0
  191. package/lib/premiumfeatures/getPremium.js +51 -0
  192. package/lib/presence/getPresences.js +63 -0
  193. package/lib/privatemessages/getMessages.js +60 -0
  194. package/lib/privatemessages/message.js +80 -0
  195. package/lib/privatemessages/onMessage.js +88 -0
  196. package/lib/thumbnails/getLogo.js +60 -0
  197. package/lib/thumbnails/getPlayerThumbnail.js +121 -0
  198. package/lib/thumbnails/getThumbnails.js +93 -0
  199. package/lib/trades/acceptTrade.js +58 -0
  200. package/lib/trades/canTradeWith.js +48 -0
  201. package/lib/trades/counterTrade.js +84 -0
  202. package/lib/trades/declineTrade.js +58 -0
  203. package/lib/trades/getTradeInfo.js +52 -0
  204. package/lib/trades/getTrades.js +37 -0
  205. package/lib/trades/sendTrade.js +82 -0
  206. package/lib/users/getBlurb.js +36 -0
  207. package/lib/users/getIdFromUsername.js +53 -0
  208. package/lib/users/getPlayerInfo.js +100 -0
  209. package/lib/users/getUsernameFromId.js +44 -0
  210. package/lib/users/onBlurbChange.js +46 -0
  211. package/lib/util/clearSession.js +32 -0
  212. package/lib/util/generalRequest.js +61 -0
  213. package/lib/util/getAction.js +45 -0
  214. package/lib/util/getCurrentUser.js +44 -0
  215. package/lib/util/getGeneralToken.js +52 -0
  216. package/lib/util/getHash.js +29 -0
  217. package/lib/util/getInputs.js +37 -0
  218. package/lib/util/getPageResults.js +89 -0
  219. package/lib/util/getSenderUserId.js +30 -0
  220. package/lib/util/getSession.js +38 -0
  221. package/lib/util/getVerification.js +60 -0
  222. package/lib/util/getVerificationInputs.js +31 -0
  223. package/lib/util/http.js +110 -0
  224. package/lib/util/jar.js +24 -0
  225. package/lib/util/refreshCookie.js +52 -0
  226. package/lib/util/relog.js +81 -0
  227. package/lib/util/setOptions.js +54 -0
  228. package/lib/util/shortPoll.js +102 -0
  229. package/lib/util/threaded.js +80 -0
  230. package/package.json +94 -0
  231. package/postinstall.js +1 -0
  232. package/settings.json +107 -0
  233. package/test/accountinformation.test.js +27 -0
  234. package/test/accountsettings.test.js +27 -0
  235. package/test/asset.test.js +81 -0
  236. package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
  237. package/test/assets/KeyframeSequence.rbxm +0 -0
  238. package/test/avatar.test.js +164 -0
  239. package/test/badges.test.js +96 -0
  240. package/test/chat.test.js +104 -0
  241. package/test/datastore.test.js +105 -0
  242. package/test/develop.test.js +53 -0
  243. package/test/economy.test.js +137 -0
  244. package/test/friends.test.js +128 -0
  245. package/test/games.test.js +212 -0
  246. package/test/groups.test.js +311 -0
  247. package/test/inventory.test.js +98 -0
  248. package/test/itemconfiguration.test.js +24 -0
  249. package/test/premiumfeatures.test.js +17 -0
  250. package/test/presence.test.js +25 -0
  251. package/test/privatemessages.test.js +33 -0
  252. package/test/thumbnails.test.js +53 -0
  253. package/test/users.test.js +68 -0
  254. package/tutorials/Authentication.md +75 -0
  255. package/tutorials/Event Emitters.md +26 -0
  256. package/tutorials/Promises.md +86 -0
  257. package/tutorials/VPS Authentication.md +72 -0
  258. package/typings/index.d.ts +2525 -0
  259. package/typings/jsDocs.ts +1927 -0
@@ -0,0 +1,14 @@
1
+ // Includes
2
+ const levelOneCopy = require('../internal/levelOneCopy.js')
3
+
4
+ // Define
5
+ module.exports = function (cache, type, index, element) {
6
+ if (cache[type]) {
7
+ if (element instanceof Object) {
8
+ element = levelOneCopy(element)
9
+ }
10
+ cache[type].items[index] = { item: element, time: Date.now() / 1000 }
11
+ } else {
12
+ return 'Invalid type'
13
+ }
14
+ }
@@ -0,0 +1,26 @@
1
+ // Includes
2
+ const add = require('./add.js')
3
+ const get = require('./get.js')
4
+
5
+ // Define
6
+ module.exports = function (cache, type, index, callbacks) {
7
+ const got = get(cache, type, index)
8
+ const item = got[0]
9
+ const refresh = got[1]
10
+ if (item) {
11
+ callbacks.done(item)
12
+ if (refresh) {
13
+ const group = cache[type]
14
+ group.refresh = false
15
+ callbacks.add(function (element) {
16
+ group.refresh = true
17
+ add(cache, type, index, element)
18
+ })
19
+ }
20
+ } else {
21
+ callbacks.add(function (element) {
22
+ add(cache, type, index, element)
23
+ callbacks.done(element)
24
+ })
25
+ }
26
+ }
@@ -0,0 +1,8 @@
1
+ // Define
2
+ module.exports = function (cache, type, index) {
3
+ if (cache[type]) {
4
+ cache[type].items[index].time = null
5
+ } else {
6
+ return 'Invalid type'
7
+ }
8
+ }
@@ -0,0 +1,28 @@
1
+ // Includes
2
+ const levelOneCopy = require('../internal/levelOneCopy.js')
3
+
4
+ // Define
5
+ module.exports = function (cache, type, index) {
6
+ if (cache[type]) {
7
+ const group = cache[type]
8
+ const cached = group.items[index]
9
+ if (cached && cached.time) {
10
+ let passed
11
+ if (!group.permanent) {
12
+ passed = Date.now() / 1000 - cached.time
13
+ if (passed > group.expire) {
14
+ return false
15
+ }
16
+ }
17
+ let item = cached.item
18
+ if (item instanceof Object) {
19
+ item = levelOneCopy(item)
20
+ }
21
+ return [item, (group.refresh && ((group.refresh === true && true) || passed > group.refresh))]
22
+ } else {
23
+ return false
24
+ }
25
+ } else {
26
+ return 'Invalid type'
27
+ }
28
+ }
@@ -0,0 +1,17 @@
1
+ // Includes
2
+ const newCache = require('./new.js')
3
+ const add = require('./add.js')
4
+ const addIf = require('./addIf.js')
5
+ const get = require('./get.js')
6
+ const clear = require('./clear.js')
7
+ const wrap = require('./wrap.js')
8
+
9
+ // Define
10
+ module.exports = {
11
+ new: newCache,
12
+ add: add,
13
+ clear: clear,
14
+ addIf: addIf,
15
+ get: get,
16
+ wrap: wrap
17
+ }
@@ -0,0 +1,12 @@
1
+ // Define
2
+ module.exports = function (types) {
3
+ const cache = {}
4
+ for (let i = 0; i < types.length; i++) {
5
+ const type = types[i]
6
+ const expireValue = type.expire
7
+ const permanent = expireValue === true
8
+ const expire = (permanent || expireValue === false ? 0 : expireValue)
9
+ cache[type.name] = { items: {}, expire: expire, refresh: type.refresh, permanent: permanent }
10
+ }
11
+ return cache
12
+ }
@@ -0,0 +1,25 @@
1
+ // Includes
2
+ const addIf = require('./addIf.js')
3
+ const options = require('../options.js')
4
+
5
+ // Define
6
+ function wrap (type, index, func) {
7
+ const cache = options.cache
8
+ const group = cache[type]
9
+ if (group.expire > 0 || group.permanent) {
10
+ return new Promise(function (resolve, reject) {
11
+ addIf(cache, type, index, {
12
+ done: resolve,
13
+ add: function (done) {
14
+ return func().then(done).catch(reject)
15
+ }
16
+ })
17
+ })
18
+ } else {
19
+ return func()
20
+ }
21
+ }
22
+
23
+ module.exports = function (type, index, func) {
24
+ return wrap(type, index, func)
25
+ }
@@ -0,0 +1,61 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+
4
+ exports.required = ['conversationId', 'userIds']
5
+ exports.optional = ['jar']
6
+
7
+ // Docs
8
+ /**
9
+ * 🔐 Add users to a conversation.
10
+ * @category Chat
11
+ * @alias addUsersToConversation
12
+ * @param {number} conversationId - The id of the conversation.
13
+ * @param {Array<number>} userIds - The userIds of the users to add.
14
+ * @returns {Promise<ConversationAddResponse>}
15
+ * @example const noblox = require("noblox.js")
16
+ * // Login using your cookie
17
+ * noblox.addUsersToConversation(1, [1, 2, 3])
18
+ **/
19
+
20
+ function addUsersToConversation (conversationId, userIds, jar, token) {
21
+ return new Promise((resolve, reject) => {
22
+ const httpOpt = {
23
+ url: '//chat.roblox.com/v2/add-to-conversation',
24
+ options: {
25
+ method: 'POST',
26
+ jar: jar,
27
+ headers: {
28
+ 'X-CSRF-TOKEN': token
29
+ },
30
+ json: {
31
+ conversationId: conversationId,
32
+ participantUserIds: userIds
33
+ },
34
+ resolveWithFullResponse: true
35
+ }
36
+ }
37
+ return http(httpOpt).then((res) => {
38
+ if (res.statusCode === 200) {
39
+ if (!res.body.resultType === 'Success') {
40
+ reject(new Error(res.body.statusMessage))
41
+ } else {
42
+ resolve(res.body)
43
+ }
44
+ } else {
45
+ let error = 'An unknown error has occurred.'
46
+ if (res.body && res.body.errors) {
47
+ error = res.body.errors.map((e) => e.message).join('\n')
48
+ }
49
+ reject(new Error(error))
50
+ }
51
+ }).catch(error => reject(error))
52
+ })
53
+ }
54
+
55
+ exports.func = (args) => {
56
+ const jar = args.jar
57
+
58
+ return getGeneralToken({ jar: jar }).then((xcsrf) => {
59
+ return addUsersToConversation(args.conversationId, args.userIds, jar, xcsrf)
60
+ })
61
+ }
@@ -0,0 +1,33 @@
1
+ const http = require('../util/http.js').func
2
+
3
+ exports.optional = ['jar']
4
+
5
+ // Docs
6
+ /**
7
+ * 🔐 Get the chat settings.
8
+ * @category Chat
9
+ * @alias chatSettings
10
+ * @returns {Promise<ChatSettings>}
11
+ * @example const noblox = require("noblox.js")
12
+ * // Login using your cookie
13
+ * const settings = await noblox.chatSettings()
14
+ **/
15
+
16
+ exports.func = (args) => {
17
+ const jar = args.jar
18
+
19
+ return http({
20
+ url: '//chat.roblox.com/v2/chat-settings',
21
+ options: {
22
+ method: 'GET',
23
+ jar: jar,
24
+ resolveWithFullResponse: true
25
+ }
26
+ }).then((res) => {
27
+ if (res.statusCode !== 200) {
28
+ throw new Error('You are not logged in')
29
+ } else {
30
+ return JSON.parse(res.body)
31
+ }
32
+ })
33
+ }
@@ -0,0 +1,40 @@
1
+ const http = require('../util/http.js').func
2
+
3
+ exports.required = ['conversationId']
4
+ exports.optional = ['pageSize', 'exclusiveStartMessageId', 'jar']
5
+
6
+ // Docs
7
+ /**
8
+ * 🔐 Get the chat messages for a conversation.
9
+ * @category Chat
10
+ * @alias getChatMessages
11
+ * @param {number} conversationId - The id of the conversation.
12
+ * @param {number=} [pageSize=100] - The size of the page.
13
+ * @param {string=} exclusiveStartMessageId - The messageId to start at.
14
+ * @returns {Promise<ChatMessage[]>}
15
+ * @example const noblox = require("noblox.js")
16
+ * // Login using your cookie
17
+ * const messages = await noblox.getChatMessages(1, 25)
18
+ **/
19
+
20
+ exports.func = (args) => {
21
+ const jar = args.jar
22
+ const conversationId = parseInt(args.conversationId) ? parseInt(args.conversationId) : 0
23
+ const pageSize = parseInt(args.pageSize) ? parseInt(args.pageSize) : 100
24
+ const startMessageId = typeof (args.exclusiveStartMessageId) === 'string' ? args.exclusiveStartMessageId : ''
25
+
26
+ return http({
27
+ url: '//chat.roblox.com/v2/get-messages?conversationId=' + conversationId + '&pageSize=' + pageSize + '&exclusiveStartMessageId=' + startMessageId,
28
+ options: {
29
+ method: 'GET',
30
+ jar: jar,
31
+ resolveWithFullResponse: true
32
+ }
33
+ }).then((res) => {
34
+ if (res.statusCode !== 200) {
35
+ throw new Error('You are not logged in')
36
+ } else {
37
+ return JSON.parse(res.body)
38
+ }
39
+ })
40
+ }
@@ -0,0 +1,43 @@
1
+ const http = require('../util/http.js').func
2
+
3
+ exports.required = ['conversationIds']
4
+ exports.optional = ['jar']
5
+
6
+ // Docs
7
+ /**
8
+ * 🔐 Get conversation details for the conversationIds specified in the parameters
9
+ * @category Chat
10
+ * @alias getConversations
11
+ * @param {Array<number>} conversationIds - An array with the ids of the conversations.
12
+ * @returns {Promise<ChatConversation[]>}
13
+ * @example const noblox = require("noblox.js")
14
+ * // Login using your cookie
15
+ * const conversations = await noblox.getConversations([1, 2, 3])
16
+ **/
17
+
18
+ exports.func = (args) => {
19
+ const jar = args.jar
20
+ const conversationIds = typeof (args.conversationIds) === 'object' ? args.conversationIds : []
21
+
22
+ return http({
23
+ url: '//chat.roblox.com/v2/get-conversations?conversationIds=' + conversationIds.join('&conversationIds='),
24
+ options: {
25
+ method: 'GET',
26
+ jar: jar,
27
+ resolveWithFullResponse: true
28
+ }
29
+ }).then((res) => {
30
+ if (res.statusCode !== 200) {
31
+ throw new Error('You are not logged in')
32
+ } else {
33
+ let response = JSON.parse(res.body)
34
+
35
+ response = response.map((entry) => {
36
+ entry.lastUpdated = new Date(entry.lastUpdated)
37
+ return entry
38
+ })
39
+
40
+ return response
41
+ }
42
+ })
43
+ }
@@ -0,0 +1,35 @@
1
+ const http = require('../util/http.js').func
2
+
3
+ exports.optional = ['featureNames', 'jar']
4
+
5
+ // Docs
6
+ /**
7
+ * 🔐 Get the rollout settings.
8
+ * @category Chat
9
+ * @alias getRolloutSettings
10
+ * @param {Array<string>=} featureNames - The names of the features rolling out.
11
+ * @returns {Promise<GetRolloutSettingsResult>}
12
+ * @example const noblox = require("noblox.js")
13
+ * // Login using your cookie
14
+ * const settings = await noblox.getRolloutSettings(['LuaChat', 'Party'])
15
+ **/
16
+
17
+ exports.func = (args) => {
18
+ const jar = args.jar
19
+ const featureNames = typeof (args.featureNames) === 'object' ? args.featureNames : []
20
+
21
+ return http({
22
+ url: '//chat.roblox.com/v2/get-rollout-settings?featureNames=' + featureNames.join('&featureNames='),
23
+ options: {
24
+ method: 'GET',
25
+ jar: jar,
26
+ resolveWithFullResponse: true
27
+ }
28
+ }).then((res) => {
29
+ if (res.statusCode !== 200) {
30
+ throw new Error('You are not logged in')
31
+ } else {
32
+ return JSON.parse(res.body)
33
+ }
34
+ })
35
+ }
@@ -0,0 +1,33 @@
1
+ const http = require('../util/http.js').func
2
+
3
+ exports.optional = ['jar']
4
+
5
+ // Docs
6
+ /**
7
+ * 🔐 Get the number of unread conversations.
8
+ * @category Chat
9
+ * @alias getUnreadConversationCount
10
+ * @returns {Promise<GetUnreadConversationCountResult>}
11
+ * @example const noblox = require("noblox.js")
12
+ * // Login using your cookie
13
+ * const unreadConversationCount = noblox.getUnreadConversationCount()
14
+ **/
15
+
16
+ exports.func = (args) => {
17
+ const jar = args.jar
18
+
19
+ return http({
20
+ url: '//chat.roblox.com/v2/get-unread-conversation-count',
21
+ options: {
22
+ method: 'GET',
23
+ jar: jar,
24
+ resolveWithFullResponse: true
25
+ }
26
+ }).then((res) => {
27
+ if (res.statusCode !== 200) {
28
+ throw new Error('You are not logged in')
29
+ } else {
30
+ return JSON.parse(res.body)
31
+ }
32
+ })
33
+ }
@@ -0,0 +1,38 @@
1
+ const http = require('../util/http.js').func
2
+
3
+ exports.required = ['conversationIds']
4
+ exports.optional = ['pageSize', 'jar']
5
+
6
+ // Docs
7
+ /**
8
+ * 🔐 Returns unread messages in the given conversations
9
+ * @category Chat
10
+ * @alias getUnreadMessages
11
+ * @param {Array<number>} conversationIds - The IDs of the conversations you want unread messages from.
12
+ * @param {number} pageSize - Number of messages to return on each page.
13
+ * @returns {Promise<ChatConversationWithMessages[]>}
14
+ * @example const noblox = require("noblox.js")
15
+ * // Login using your cookie
16
+ * noblox.getUnreadMessages([8212952828])
17
+ **/
18
+
19
+ exports.func = (args) => {
20
+ const jar = args.jar
21
+ const conversationIds = typeof (args.conversationIds) === 'object' ? args.conversationIds : []
22
+ const pageSize = parseInt(args.pageSize) ? parseInt(args.pageSize) : 30
23
+
24
+ return http({
25
+ url: '//chat.roblox.com/v2/get-unread-messages?pageSize=' + pageSize + '&conversationIds=' + conversationIds.join('&conversationIds='),
26
+ options: {
27
+ method: 'GET',
28
+ jar: jar,
29
+ resolveWithFullResponse: true
30
+ }
31
+ }).then((res) => {
32
+ if (res.statusCode !== 200) {
33
+ throw new Error('You are not logged in')
34
+ } else {
35
+ return JSON.parse(res.body)
36
+ }
37
+ })
38
+ }
@@ -0,0 +1,37 @@
1
+ const http = require('../util/http.js').func
2
+
3
+ exports.optional = ['pageNumber', 'pageSize', 'jar']
4
+
5
+ // Docs
6
+ /**
7
+ * 🔐 Get your conversations.
8
+ * @category Chat
9
+ * @alias getUserConversations
10
+ * @param {number=} pageNumber - The page index.
11
+ * @param {number=} pageSize - The size of each page.
12
+ * @returns {Promise<ChatConversation[]>}
13
+ * @example const noblox = require("noblox.js")
14
+ * // Login using your cookie
15
+ * const conversations = await noblox.getUserConversations()
16
+ **/
17
+
18
+ exports.func = (args) => {
19
+ const jar = args.jar
20
+ const pageNumber = parseInt(args.pageNumber) ? parseInt(args.pageNumber) : 1
21
+ const pageSize = parseInt(args.pageSize) ? parseInt(args.pageSize) : 30
22
+
23
+ return http({
24
+ url: '//chat.roblox.com/v2/get-user-conversations?pageNumber=' + pageNumber + '&pageSize=' + pageSize,
25
+ options: {
26
+ method: 'GET',
27
+ jar: jar,
28
+ resolveWithFullResponse: true
29
+ }
30
+ }).then((res) => {
31
+ if (res.statusCode !== 200) {
32
+ throw new Error('You are not logged in')
33
+ } else {
34
+ return JSON.parse(res.body)
35
+ }
36
+ })
37
+ }
@@ -0,0 +1,52 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+
4
+ exports.required = ['conversationId', 'endMessageId']
5
+ exports.optional = ['jar']
6
+
7
+ // Docs
8
+ /**
9
+ * 🔐 Mark a chat as read.
10
+ * @category Chat
11
+ * @alias markChatAsRead
12
+ * @param {number} conversationId - The id of the conversation.
13
+ * @param {string} endMessageId - The last message to read.
14
+ * @returns {Promise<void>}
15
+ * @example const noblox = require("noblox.js")
16
+ * // Login using your cookie
17
+ * noblox.markChatAsRead(8212952828, 'e775e103-876f-4332-84ab-1ea14f326d39')
18
+ **/
19
+
20
+ const nextFunction = (jar, token, conversationId, endMessageId) => {
21
+ return http({
22
+ url: '//chat.roblox.com/v2/mark-as-read',
23
+ options: {
24
+ method: 'POST',
25
+ jar: jar,
26
+ headers: {
27
+ 'X-CSRF-TOKEN': token
28
+ },
29
+ json: {
30
+ conversationId: conversationId,
31
+ endMessageId: endMessageId
32
+ },
33
+ resolveWithFullResponse: true
34
+ }
35
+ }).then((res) => {
36
+ if (res.statusCode === 200) {
37
+ if (!res.body.resultType === 'Success') {
38
+ throw new Error(res.body.statusMessage)
39
+ }
40
+ } else {
41
+ throw new Error('Mark as read failed')
42
+ }
43
+ })
44
+ }
45
+
46
+ exports.func = (args) => {
47
+ const jar = args.jar
48
+
49
+ return getGeneralToken({ jar: jar }).then((xcsrf) => {
50
+ return nextFunction(jar, xcsrf, args.conversationId, args.endMessageId)
51
+ })
52
+ }
@@ -0,0 +1,50 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+
4
+ exports.required = ['conversationIds']
5
+ exports.optional = ['jar']
6
+
7
+ // Docs
8
+ /**
9
+ * 🔐 Mark chats as seen.
10
+ * @category Chat
11
+ * @alias markChatAsSeen
12
+ * @param {Array<number>} conversationIds - An array with conversationIds.
13
+ * @returns {Promise<void>}
14
+ * @example const noblox = require("noblox.js")
15
+ * // Login using your cookie
16
+ * noblox.markChatAsSeen([1, 2, 3])
17
+ **/
18
+
19
+ const nextFunction = (jar, token, conversationIds) => {
20
+ return http({
21
+ url: '//chat.roblox.com/v2/mark-as-seen',
22
+ options: {
23
+ method: 'POST',
24
+ jar: jar,
25
+ headers: {
26
+ 'X-CSRF-TOKEN': token
27
+ },
28
+ json: {
29
+ conversationsToMarkSeen: conversationIds
30
+ },
31
+ resolveWithFullResponse: true
32
+ }
33
+ }).then((res) => {
34
+ if (res.statusCode === 200) {
35
+ if (!res.body.resultType === 'Success') {
36
+ throw new Error(res.body.statusMessage)
37
+ }
38
+ } else {
39
+ throw new Error('Mark as seen failed')
40
+ }
41
+ })
42
+ }
43
+
44
+ exports.func = (args) => {
45
+ const jar = args.jar
46
+
47
+ return getGeneralToken({ jar: jar }).then((xcsrf) => {
48
+ return nextFunction(jar, xcsrf, args.conversationIds)
49
+ })
50
+ }
@@ -0,0 +1,37 @@
1
+ const http = require('../util/http.js').func
2
+
3
+ exports.required = ['conversationIds']
4
+ exports.optional = ['pageSize', 'jar']
5
+
6
+ // Docs
7
+ /**
8
+ * 🔐 Get multiple of the latest messages.
9
+ * @category Chat
10
+ * @alias multiGetLatestMessages
11
+ * @param {Array<number>} conversationIds - An array with the conversationIds.
12
+ * @returns {Promise<ChatConversationWithMessages[]>}
13
+ * @example const noblox = require("noblox.js")
14
+ * // Login using your cookie
15
+ * const recentMessages = await noblox.multiGetLatestMessages([1, 2, 3])
16
+ **/
17
+
18
+ exports.func = (args) => {
19
+ const jar = args.jar
20
+ const conversationIds = typeof (args.conversationIds) === 'object' ? args.conversationIds : []
21
+ const pageSize = parseInt(args.pageSize) ? parseInt(args.pageSize) : 30
22
+
23
+ return http({
24
+ url: '//chat.roblox.com/v2/multi-get-latest-messages?pageSize=' + pageSize + '&conversationIds=' + conversationIds.join('&conversationIds='),
25
+ options: {
26
+ method: 'GET',
27
+ jar: jar,
28
+ resolveWithFullResponse: true
29
+ }
30
+ }).then((res) => {
31
+ if (res.statusCode !== 200) {
32
+ throw new Error('You are not logged in')
33
+ } else {
34
+ return JSON.parse(res.body)
35
+ }
36
+ })
37
+ }
@@ -0,0 +1,50 @@
1
+ const events = require('events')
2
+
3
+ const onNotification = require('../client/onNotification.js').func
4
+
5
+ exports.optional = ['jar']
6
+
7
+ // Docs
8
+ /**
9
+ * 🔐 An event for when a conversation is created.
10
+ * @category Chat
11
+ * @alias onNewConversation
12
+ * @returns An EventEmitter that emits when a conversation is created.
13
+ * @example const noblox = require("noblox.js")
14
+ * // Login using your cookie
15
+ * const conversationEvent = noblox.onNewConversation()
16
+ * conversationEvent.on("data", function(data) {
17
+ * console.log("New conversation! ", data)
18
+ * })
19
+ * conversationEvent.on("error", function(err) {
20
+ * console.error("Something went wrong: ", err)
21
+ * // Handle error as needed
22
+ * })
23
+ **/
24
+
25
+ exports.func = (args) => {
26
+ const jar = args.jar
27
+ const onChatEvent = new events.EventEmitter()
28
+ const notifications = onNotification({ jar: jar })
29
+
30
+ notifications.on('data', (name, message) => {
31
+ if (name === 'ChatNotifications' && message.Type === 'NewConversation') {
32
+ onChatEvent.emit('data', message.ConversationId)
33
+ }
34
+ })
35
+
36
+ notifications.on('error', (err) => {
37
+ onChatEvent.emit('error', err)
38
+ })
39
+
40
+ notifications.on('connect', () => {
41
+ onChatEvent.emit('connect')
42
+ })
43
+
44
+ notifications.on('close', (internal) => {
45
+ if (internal) return
46
+ notifications.emit('close', true)
47
+ })
48
+
49
+ return onChatEvent
50
+ }