noblox-asset.js 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
  3. package/.github/workflows/doc-publish.yml +33 -0
  4. package/.github/workflows/npmpublish.yml +72 -0
  5. package/.github/workflows/run-tests.yml +49 -0
  6. package/CODE_OF_CONDUCT.md +76 -0
  7. package/LICENSE +21 -0
  8. package/README.md +182 -0
  9. package/eslint.config.mjs +34 -0
  10. package/examples/cleanPlayers.js +130 -0
  11. package/examples/cleanWall.js +110 -0
  12. package/examples/revertRanks.js +100 -0
  13. package/examples/savePlayers.js +119 -0
  14. package/examples/saveWall.js +96 -0
  15. package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
  16. package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
  17. package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
  18. package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
  19. package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
  20. package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
  21. package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
  22. package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
  23. package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
  24. package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
  25. package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
  26. package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
  27. package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
  28. package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
  29. package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
  30. package/img/noblox-js-small.png +0 -0
  31. package/img/noblox-js.png +0 -0
  32. package/img/thumbnailSizes.png +0 -0
  33. package/jsDocsConfig.json +55 -0
  34. package/lib/accountinformation/getUserSocialLinks.js +40 -0
  35. package/lib/accountsettings/block.js +53 -0
  36. package/lib/accountsettings/unblock.js +53 -0
  37. package/lib/asset/deleteFromInventory.js +56 -0
  38. package/lib/asset/getGamePassProductInfo.js +50 -0
  39. package/lib/asset/getProductInfo.js +46 -0
  40. package/lib/asset/uploadAnimation.js +103 -0
  41. package/lib/asset/uploadItem.js +83 -0
  42. package/lib/asset/uploadModel.js +90 -0
  43. package/lib/avatar/avatarRules.js +39 -0
  44. package/lib/avatar/currentlyWearing.js +33 -0
  45. package/lib/avatar/getAvatar.js +36 -0
  46. package/lib/avatar/getCurrentAvatar.js +38 -0
  47. package/lib/avatar/getRecentItems.js +36 -0
  48. package/lib/avatar/outfitDetails.js +33 -0
  49. package/lib/avatar/outfits.js +38 -0
  50. package/lib/avatar/redrawAvatar.js +47 -0
  51. package/lib/avatar/removeAssetId.js +51 -0
  52. package/lib/avatar/setAvatarBodyColors.js +61 -0
  53. package/lib/avatar/setAvatarScales.js +61 -0
  54. package/lib/avatar/setPlayerAvatarType.js +51 -0
  55. package/lib/avatar/setWearingAssets.js +51 -0
  56. package/lib/avatar/wearAssetId.js +51 -0
  57. package/lib/badges/getAwardedTimestamps.js +49 -0
  58. package/lib/badges/getBadgeInfo.js +44 -0
  59. package/lib/badges/getGameBadges.js +63 -0
  60. package/lib/badges/getPlayerBadges.js +28 -0
  61. package/lib/badges/updateBadgeInfo.js +75 -0
  62. package/lib/cache/add.js +14 -0
  63. package/lib/cache/addIf.js +26 -0
  64. package/lib/cache/clear.js +8 -0
  65. package/lib/cache/get.js +28 -0
  66. package/lib/cache/index.js +17 -0
  67. package/lib/cache/new.js +12 -0
  68. package/lib/cache/wrap.js +25 -0
  69. package/lib/chat/addUsersToConversation.js +58 -0
  70. package/lib/chat/chatSettings.js +34 -0
  71. package/lib/chat/getChatMessages.js +41 -0
  72. package/lib/chat/getConversations.js +44 -0
  73. package/lib/chat/getRolloutSettings.js +36 -0
  74. package/lib/chat/getUnreadConversationCount.js +34 -0
  75. package/lib/chat/getUnreadMessages.js +39 -0
  76. package/lib/chat/getUserConversations.js +38 -0
  77. package/lib/chat/markChatAsRead.js +53 -0
  78. package/lib/chat/markChatAsSeen.js +51 -0
  79. package/lib/chat/multiGetLatestMessages.js +38 -0
  80. package/lib/chat/onNewConversation.js +50 -0
  81. package/lib/chat/onNewMessage.js +53 -0
  82. package/lib/chat/onNewMessageBySelf.js +50 -0
  83. package/lib/chat/onUserOnline.js +50 -0
  84. package/lib/chat/onUserTyping.js +54 -0
  85. package/lib/chat/removeFromGroupConversation.js +59 -0
  86. package/lib/chat/renameGroupConversation.js +58 -0
  87. package/lib/chat/sendChatMessage.js +58 -0
  88. package/lib/chat/setChatUserTyping.js +58 -0
  89. package/lib/chat/start121Conversation.js +51 -0
  90. package/lib/chat/startCloudEditConversation.js +51 -0
  91. package/lib/chat/startGroupConversation.js +59 -0
  92. package/lib/client/onNotification.js +86 -0
  93. package/lib/client/setAPIKey.js +18 -0
  94. package/lib/client/setCookie.js +38 -0
  95. package/lib/datastores/deleteDatastoreEntry.js +56 -0
  96. package/lib/datastores/getDatastoreEntry.js +88 -0
  97. package/lib/datastores/getDatastoreEntryVersions.js +73 -0
  98. package/lib/datastores/getDatastoreKeys.js +63 -0
  99. package/lib/datastores/getDatastores.js +62 -0
  100. package/lib/datastores/incrementDatastoreEntry.js +83 -0
  101. package/lib/datastores/setDatastoreEntry.js +80 -0
  102. package/lib/develop/canManage.js +42 -0
  103. package/lib/develop/configureItem.js +210 -0
  104. package/lib/develop/updateUniverse.js +52 -0
  105. package/lib/develop/updateUniverseAccess.js +54 -0
  106. package/lib/economy/getGroupFunds.js +42 -0
  107. package/lib/economy/getGroupPayoutEligibility.js +55 -0
  108. package/lib/economy/getGroupRevenueSummary.js +42 -0
  109. package/lib/economy/getGroupTransactions.js +32 -0
  110. package/lib/economy/getResaleData.js +48 -0
  111. package/lib/economy/getResellers.js +35 -0
  112. package/lib/economy/getUserFunds.js +43 -0
  113. package/lib/economy/getUserTransactions.js +34 -0
  114. package/lib/economy/onGroupTransaction.js +74 -0
  115. package/lib/friends/acceptFriendRequest.js +54 -0
  116. package/lib/friends/declineAllFriendRequests.js +52 -0
  117. package/lib/friends/declineFriendRequest.js +54 -0
  118. package/lib/friends/getFollowerCount.js +35 -0
  119. package/lib/friends/getFollowers.js +56 -0
  120. package/lib/friends/getFollowingCount.js +35 -0
  121. package/lib/friends/getFollowings.js +56 -0
  122. package/lib/friends/getFriendCount.js +35 -0
  123. package/lib/friends/getFriendRequests.js +51 -0
  124. package/lib/friends/getFriends.js +48 -0
  125. package/lib/friends/onFriendRequest.js +58 -0
  126. package/lib/friends/removeFriend.js +53 -0
  127. package/lib/friends/sendFriendRequest.js +54 -0
  128. package/lib/friends/unfollow.js +53 -0
  129. package/lib/games/addDeveloperProduct.js +53 -0
  130. package/lib/games/configureGamePass.js +126 -0
  131. package/lib/games/getDeveloperProducts.js +44 -0
  132. package/lib/games/getGameInstances.js +31 -0
  133. package/lib/games/getGamePasses.js +39 -0
  134. package/lib/games/getGameRevenue.js +48 -0
  135. package/lib/games/getGameSocialLinks.js +42 -0
  136. package/lib/games/getGroupGames.js +30 -0
  137. package/lib/games/getPlaceInfo.js +47 -0
  138. package/lib/games/getUniverseInfo.js +50 -0
  139. package/lib/games/publishToTopic.js +52 -0
  140. package/lib/games/sendUserNotification.js +65 -0
  141. package/lib/games/updateDeveloperProduct.js +56 -0
  142. package/lib/groups/banFromGroup.js +47 -0
  143. package/lib/groups/changeRank.js +59 -0
  144. package/lib/groups/deleteWallPost.js +59 -0
  145. package/lib/groups/deleteWallPostsByUser.js +55 -0
  146. package/lib/groups/demote.js +25 -0
  147. package/lib/groups/exile.js +55 -0
  148. package/lib/groups/getAuditLog.js +64 -0
  149. package/lib/groups/getGroup.js +50 -0
  150. package/lib/groups/getGroupBans.js +37 -0
  151. package/lib/groups/getGroupSocialLinks.js +41 -0
  152. package/lib/groups/getGroups.js +82 -0
  153. package/lib/groups/getJoinRequest.js +47 -0
  154. package/lib/groups/getJoinRequests.js +53 -0
  155. package/lib/groups/getPlayers.js +103 -0
  156. package/lib/groups/getRankInGroup.js +45 -0
  157. package/lib/groups/getRankNameInGroup.js +44 -0
  158. package/lib/groups/getRole.js +64 -0
  159. package/lib/groups/getRolePermissions.js +48 -0
  160. package/lib/groups/getRoles.js +53 -0
  161. package/lib/groups/getShout.js +47 -0
  162. package/lib/groups/getWall.js +56 -0
  163. package/lib/groups/groupPayout.js +103 -0
  164. package/lib/groups/handleJoinRequest.js +57 -0
  165. package/lib/groups/handleJoinRequests.js +61 -0
  166. package/lib/groups/leaveGroup.js +56 -0
  167. package/lib/groups/onAuditLog.js +62 -0
  168. package/lib/groups/onJoinRequest.js +63 -0
  169. package/lib/groups/onJoinRequestHandle.js +105 -0
  170. package/lib/groups/onShout.js +57 -0
  171. package/lib/groups/onWallPost.js +58 -0
  172. package/lib/groups/promote.js +25 -0
  173. package/lib/groups/searchGroups.js +32 -0
  174. package/lib/groups/setGroupDescription.js +58 -0
  175. package/lib/groups/setGroupName.js +59 -0
  176. package/lib/groups/setRank.js +74 -0
  177. package/lib/groups/setRoleInfo.js +84 -0
  178. package/lib/groups/shout.js +58 -0
  179. package/lib/groups/unbanFromGroup.js +41 -0
  180. package/lib/index.js +212 -0
  181. package/lib/internal/levelOneCopy.js +16 -0
  182. package/lib/internal/queue.js +61 -0
  183. package/lib/internal/timeout.js +30 -0
  184. package/lib/internal/wrap.js +78 -0
  185. package/lib/inventory/getCollectibles.js +31 -0
  186. package/lib/inventory/getInventory.js +32 -0
  187. package/lib/inventory/getInventoryById.js +31 -0
  188. package/lib/inventory/getOwnership.js +47 -0
  189. package/lib/inventory/getUAIDs.js +47 -0
  190. package/lib/itemconfiguration/getGroupAssets.js +32 -0
  191. package/lib/options.js +26 -0
  192. package/lib/party/onPartyDeleted.js +53 -0
  193. package/lib/party/onPartyInvite.js +53 -0
  194. package/lib/party/onPartyJoinedGame.js +53 -0
  195. package/lib/party/onPartyLeftGame.js +53 -0
  196. package/lib/party/onPartySelfJoined.js +53 -0
  197. package/lib/party/onPartySelfLeft.js +53 -0
  198. package/lib/party/onPartyUserJoined.js +53 -0
  199. package/lib/party/onPartyUserLeft.js +53 -0
  200. package/lib/premiumfeatures/getPremium.js +46 -0
  201. package/lib/presence/getPresences.js +60 -0
  202. package/lib/privatemessages/getMessages.js +55 -0
  203. package/lib/privatemessages/message.js +75 -0
  204. package/lib/privatemessages/onMessage.js +89 -0
  205. package/lib/thumbnails/getLogo.js +56 -0
  206. package/lib/thumbnails/getPlayerThumbnail.js +120 -0
  207. package/lib/thumbnails/getThumbnails.js +92 -0
  208. package/lib/trades/acceptTrade.js +52 -0
  209. package/lib/trades/canTradeWith.js +43 -0
  210. package/lib/trades/counterTrade.js +78 -0
  211. package/lib/trades/declineTrade.js +52 -0
  212. package/lib/trades/getTradeInfo.js +47 -0
  213. package/lib/trades/getTrades.js +37 -0
  214. package/lib/trades/sendTrade.js +76 -0
  215. package/lib/users/getBlurb.js +37 -0
  216. package/lib/users/getIdFromUsername.js +56 -0
  217. package/lib/users/getPlayerInfo.js +128 -0
  218. package/lib/users/getUserInfo.js +35 -0
  219. package/lib/users/getUsernameFromId.js +45 -0
  220. package/lib/users/getUsernameHistory.js +42 -0
  221. package/lib/users/onBlurbChange.js +46 -0
  222. package/lib/users/searchUsers.js +41 -0
  223. package/lib/util/apiError.js +50 -0
  224. package/lib/util/clearSession.js +32 -0
  225. package/lib/util/generalRequest.js +61 -0
  226. package/lib/util/getAction.js +45 -0
  227. package/lib/util/getAuthenticatedUser.js +41 -0
  228. package/lib/util/getCurrentUser.js +58 -0
  229. package/lib/util/getGeneralToken.js +52 -0
  230. package/lib/util/getHash.js +29 -0
  231. package/lib/util/getInputs.js +37 -0
  232. package/lib/util/getPageResults.js +86 -0
  233. package/lib/util/getSenderUserId.js +30 -0
  234. package/lib/util/getSession.js +38 -0
  235. package/lib/util/getVerification.js +60 -0
  236. package/lib/util/getVerificationInputs.js +31 -0
  237. package/lib/util/http.js +138 -0
  238. package/lib/util/jar.js +25 -0
  239. package/lib/util/refreshCookie.js +52 -0
  240. package/lib/util/relog.js +81 -0
  241. package/lib/util/setOptions.js +54 -0
  242. package/lib/util/shortPoll.js +102 -0
  243. package/package.json +76 -0
  244. package/postinstall.mjs +1 -0
  245. package/settings.json +115 -0
  246. package/test/accountinformation.test.js +27 -0
  247. package/test/accountsettings.test.js +27 -0
  248. package/test/asset.test.js +81 -0
  249. package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
  250. package/test/assets/KeyframeSequence.rbxm +0 -0
  251. package/test/avatar.test.js +164 -0
  252. package/test/badges.test.js +96 -0
  253. package/test/chat.test.js +104 -0
  254. package/test/datastore.test.js +105 -0
  255. package/test/develop.test.js +53 -0
  256. package/test/economy.test.js +143 -0
  257. package/test/friends.test.js +146 -0
  258. package/test/games.test.js +229 -0
  259. package/test/groups.test.js +405 -0
  260. package/test/inventory.test.js +98 -0
  261. package/test/itemconfiguration.test.js +24 -0
  262. package/test/premiumfeatures.test.js +17 -0
  263. package/test/presence.test.js +25 -0
  264. package/test/privatemessages.test.js +33 -0
  265. package/test/thumbnails.test.js +53 -0
  266. package/test/users.test.js +110 -0
  267. package/tutorials/Authentication.md +75 -0
  268. package/tutorials/Event Emitters.md +26 -0
  269. package/tutorials/Promises.md +86 -0
  270. package/tutorials/VPS Authentication.md +72 -0
  271. package/typings/index.d.ts +2639 -0
  272. package/typings/jsDocs.ts +1987 -0
@@ -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 you send a new message.
10
+ * @category Chat
11
+ * @alias onNewMessageBySelf
12
+ * @returns An EventEmitter that emits when you send a new message.
13
+ * @example const noblox = require("noblox.js")
14
+ * // Login using your cookie
15
+ * const messageSent = noblox.onNewMessageBySelf()
16
+ * messageSent.on("data", function(data) {
17
+ * console.log("Sent chat message! ", data)
18
+ * })
19
+ * messageSent.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 newEvent = new events.EventEmitter()
28
+ const notifications = onNotification({ jar })
29
+
30
+ notifications.on('data', (name, message) => {
31
+ if (name === 'ChatNotifications' && message.Type === 'NewMessageBySelf') {
32
+ newEvent.emit('data', message.ConversationId)
33
+ }
34
+ })
35
+
36
+ notifications.on('error', (err) => {
37
+ newEvent.emit('error', err)
38
+ })
39
+
40
+ notifications.on('connect', () => {
41
+ newEvent.emit('connect')
42
+ })
43
+
44
+ notifications.on('close', (internal) => {
45
+ if (internal) return
46
+ notifications.emit('close', true)
47
+ })
48
+
49
+ return newEvent
50
+ }
@@ -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 someone comes online.
10
+ * @category Chat
11
+ * @alias onUserOnline
12
+ * @returns An EventEmitter that emits when someone comes online.
13
+ * @example const noblox = require("noblox.js")
14
+ * // Login using your cookie
15
+ * const userOnlineEvent = noblox.onUserOnline()
16
+ * userOnlineEvent.on("data", function(data) {
17
+ * console.log("User online! ", data)
18
+ * })
19
+ * userOnlineEvent.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 newEvent = new events.EventEmitter()
28
+ const notifications = onNotification({ jar })
29
+
30
+ notifications.on('data', (name, message) => {
31
+ if (name === 'PresenceNotifications' && message.Type === 'UserOnline') {
32
+ newEvent.emit('data', message.UserId)
33
+ }
34
+ })
35
+
36
+ notifications.on('error', (err) => {
37
+ newEvent.emit('error', err)
38
+ })
39
+
40
+ notifications.on('connect', () => {
41
+ newEvent.emit('connect')
42
+ })
43
+
44
+ notifications.on('close', (internal) => {
45
+ if (internal) return
46
+ notifications.emit('close', true)
47
+ })
48
+
49
+ return newEvent
50
+ }
@@ -0,0 +1,54 @@
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 someone starts typing in a chat.
10
+ * @category Chat
11
+ * @alias onUserTyping
12
+ * @returns An EventEmitter that emits when someone starts typing in a chat.
13
+ * @example const noblox = require("noblox.js")
14
+ * // Login using your cookie
15
+ * const userTyping = noblox.onUserTyping()
16
+ * userTyping.on("data", function(data) {
17
+ * console.log("User typing! ", data)
18
+ * })
19
+ * userTyping.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 newEvent = new events.EventEmitter()
28
+ const notifications = onNotification({ jar })
29
+
30
+ notifications.on('data', (name, message) => {
31
+ if (name === 'ChatNotifications' && message.Type === 'ParticipantTyping') {
32
+ newEvent.emit('data', {
33
+ UserId: message.UserId,
34
+ ConversationId: message.ConversationId,
35
+ IsTyping: message.IsTyping
36
+ })
37
+ }
38
+ })
39
+
40
+ notifications.on('error', (err) => {
41
+ newEvent.emit('error', err)
42
+ })
43
+
44
+ notifications.on('connect', () => {
45
+ newEvent.emit('connect')
46
+ })
47
+
48
+ notifications.on('close', (internal) => {
49
+ if (internal) return
50
+ notifications.emit('close', true)
51
+ })
52
+
53
+ return newEvent
54
+ }
@@ -0,0 +1,59 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['conversationId', 'userId']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Remove a user from the group conversation.
11
+ * @category Chat
12
+ * @alias removeFromGroupConversation
13
+ * @param {number} conversationId - The id of the conversation.
14
+ * @param {number} userId - The id of the user.
15
+ * @returns {Promise<ConversationRemoveResponse>}
16
+ * @example const noblox = require("noblox.js")
17
+ * // Login using your cookie
18
+ * noblox.removeFromGroupConversation(1, 2)
19
+ **/
20
+
21
+ function removeFromGroupConversation (conversationId, userId, jar, token) {
22
+ return new Promise((resolve, reject) => {
23
+ const httpOpt = {
24
+ url: '//chat.roblox.com/v2/remove-from-conversation',
25
+ options: {
26
+ method: 'POST',
27
+ jar,
28
+ headers: {
29
+ 'X-CSRF-TOKEN': token
30
+ },
31
+ json: {
32
+ conversationId,
33
+ participantUserId: userId
34
+ },
35
+ resolveWithFullResponse: true
36
+ }
37
+ }
38
+
39
+ return http(httpOpt).then((res) => {
40
+ if (res.statusCode === 200) {
41
+ if (!res.body.resultType === 'Success') {
42
+ reject(new RobloxAPIError(res))
43
+ } else {
44
+ resolve(res.body)
45
+ }
46
+ } else {
47
+ reject(new RobloxAPIError(res))
48
+ }
49
+ }).catch(error => reject(error))
50
+ })
51
+ }
52
+
53
+ exports.func = (args) => {
54
+ const jar = args.jar
55
+
56
+ return getGeneralToken({ jar }).then((xcsrf) => {
57
+ return removeFromGroupConversation(args.conversationId, args.userId, jar, xcsrf)
58
+ })
59
+ }
@@ -0,0 +1,58 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['conversationId', 'title']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Rename a group conversation.
11
+ * @category Chat
12
+ * @alias renameGroupConversation
13
+ * @param {number} conversationId - The id of the conversation.
14
+ * @param {string} title - The new title of the group.
15
+ * @returns {Promise<ConversationRenameResponse>}
16
+ * @example const noblox = require("noblox.js")
17
+ * // Login using your cookie
18
+ * noblox.renameGroupConversation(1, "A cool group.")
19
+ **/
20
+
21
+ function renameGroupConversation (conversationId, newTitle, jar, token) {
22
+ return new Promise((resolve, reject) => {
23
+ const httpOpt = {
24
+ url: '//chat.roblox.com/v2/rename-group-conversation',
25
+ options: {
26
+ method: 'POST',
27
+ jar,
28
+ headers: {
29
+ 'X-CSRF-TOKEN': token
30
+ },
31
+ json: {
32
+ conversationId,
33
+ newTitle
34
+ },
35
+ resolveWithFullResponse: true
36
+ }
37
+ }
38
+ return http(httpOpt).then((res) => {
39
+ if (res.statusCode === 200) {
40
+ if (!res.body.resultType === 'Success') {
41
+ reject(new RobloxAPIError(res))
42
+ } else {
43
+ resolve(res.body)
44
+ }
45
+ } else {
46
+ reject(new RobloxAPIError(res))
47
+ }
48
+ }).catch(error => reject(error))
49
+ })
50
+ }
51
+
52
+ exports.func = (args) => {
53
+ const jar = args.jar
54
+
55
+ return getGeneralToken({ jar }).then((xcsrf) => {
56
+ return renameGroupConversation(args.conversationId, args.title, jar, xcsrf)
57
+ })
58
+ }
@@ -0,0 +1,58 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['conversationId', 'message']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Send a message in a chat.
11
+ * @category Chat
12
+ * @alias sendChatMessage
13
+ * @param {number} conversationId - The id of the conversation.
14
+ * @param {string} message - The message to send.
15
+ * @returns {Promise<SendChatResponse>}
16
+ * @example const noblox = require("noblox.js")
17
+ * // Login using your cookie
18
+ * noblox.sendChatMessage(1, "Hello world!")
19
+ **/
20
+
21
+ function sendChatMessage (conversationId, messageText, jar, token) {
22
+ return new Promise((resolve, reject) => {
23
+ const httpOpt = {
24
+ url: '//chat.roblox.com/v2/send-message',
25
+ options: {
26
+ method: 'POST',
27
+ jar,
28
+ headers: {
29
+ 'X-CSRF-TOKEN': token
30
+ },
31
+ json: {
32
+ conversationId,
33
+ message: messageText
34
+ },
35
+ resolveWithFullResponse: true
36
+ }
37
+ }
38
+ return http(httpOpt).then((res) => {
39
+ if (res.statusCode === 200) {
40
+ if (!res.body.resultType === 'Success') {
41
+ reject(new RobloxAPIError(res))
42
+ } else {
43
+ resolve(res.body)
44
+ }
45
+ } else {
46
+ reject(new RobloxAPIError(res))
47
+ }
48
+ }).catch(error => reject(error))
49
+ })
50
+ }
51
+
52
+ exports.func = (args) => {
53
+ const jar = args.jar
54
+
55
+ return getGeneralToken({ jar }).then((xcsrf) => {
56
+ return sendChatMessage(args.conversationId, args.message, jar, xcsrf)
57
+ })
58
+ }
@@ -0,0 +1,58 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['conversationId', 'isTyping']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Trigger the typing action in a conversation.
11
+ * @category Chat
12
+ * @alias setChatUserTyping
13
+ * @param {number} conversationId - The id of the conversation.
14
+ * @param {boolean} isTyping - If the user is typing.
15
+ * @returns {Promise<UpdateTypingResponse>}
16
+ * @example const noblox = require("noblox.js")
17
+ * // Login using your cookie
18
+ * noblox.setChatUserTyping(1, true)
19
+ **/
20
+
21
+ function setChatUserTyping (conversationId, isTyping, jar, token) {
22
+ return new Promise((resolve, reject) => {
23
+ const httpOpt = {
24
+ url: '//chat.roblox.com/v2/update-user-typing-status',
25
+ options: {
26
+ method: 'POST',
27
+ jar,
28
+ headers: {
29
+ 'X-CSRF-TOKEN': token
30
+ },
31
+ json: {
32
+ conversationId,
33
+ isTyping
34
+ },
35
+ resolveWithFullResponse: true
36
+ }
37
+ }
38
+ return http(httpOpt).then((res) => {
39
+ if (res.statusCode === 200) {
40
+ if (!res.body.resultType === 'Success') {
41
+ reject(new RobloxAPIError(res))
42
+ } else {
43
+ resolve(res.body)
44
+ }
45
+ } else {
46
+ reject(new RobloxAPIError(res))
47
+ }
48
+ }).catch(error => reject(error))
49
+ })
50
+ }
51
+
52
+ exports.func = (args) => {
53
+ const jar = args.jar
54
+
55
+ return getGeneralToken({ jar }).then((xcsrf) => {
56
+ return setChatUserTyping(args.conversationId, args.isTyping, jar, xcsrf)
57
+ })
58
+ }
@@ -0,0 +1,51 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['userId']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Start a conversation with another user.
11
+ * @category Chat
12
+ * @alias start121Conversation
13
+ * @param {number} userId - The id of the user.
14
+ * @returns {Promise<void>}
15
+ * @example const noblox = require("noblox.js")
16
+ * // Login using your cookie
17
+ * noblox.start121Conversation(1)
18
+ **/
19
+
20
+ const nextFunction = (jar, token, userId) => {
21
+ return http({
22
+ url: '//chat.roblox.com/v2/start-one-to-one-conversation',
23
+ options: {
24
+ method: 'POST',
25
+ jar,
26
+ headers: {
27
+ 'X-CSRF-TOKEN': token
28
+ },
29
+ json: {
30
+ participantUserId: userId
31
+ },
32
+ resolveWithFullResponse: true
33
+ }
34
+ }).then((res) => {
35
+ if (res.statusCode === 200) {
36
+ if (!res.body.resultType === 'Success') {
37
+ throw new RobloxAPIError(res)
38
+ }
39
+ } else {
40
+ throw new RobloxAPIError(res)
41
+ }
42
+ })
43
+ }
44
+
45
+ exports.func = (args) => {
46
+ const jar = args.jar
47
+
48
+ return getGeneralToken({ jar }).then((xcsrf) => {
49
+ return nextFunction(jar, xcsrf, args.userId)
50
+ })
51
+ }
@@ -0,0 +1,51 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['placeId']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Start a Cloud Edit/Team Create conversation.
11
+ * @category Chat
12
+ * @alias startCloudEditConversation
13
+ * @param {number} placeId - The id of the place.
14
+ * @returns {Promise<void>}
15
+ * @example const noblox = require("noblox.js")
16
+ * // Login using your cookie
17
+ * noblox.startCloudEditConversation(1117747196)
18
+ **/
19
+
20
+ const nextFunction = (jar, token, placeId) => {
21
+ return http({
22
+ url: '//chat.roblox.com/v2/start-cloud-edit-conversation',
23
+ options: {
24
+ method: 'POST',
25
+ jar,
26
+ headers: {
27
+ 'X-CSRF-TOKEN': token
28
+ },
29
+ json: {
30
+ placeId
31
+ },
32
+ resolveWithFullResponse: true
33
+ }
34
+ }).then((res) => {
35
+ if (res.statusCode === 200) {
36
+ if (!res.body.resultType === 'Success') {
37
+ throw new RobloxAPIError(res)
38
+ }
39
+ } else {
40
+ throw new RobloxAPIError(res)
41
+ }
42
+ })
43
+ }
44
+
45
+ exports.func = (args) => {
46
+ const jar = args.jar
47
+
48
+ return getGeneralToken({ jar }).then((xcsrf) => {
49
+ return nextFunction(jar, xcsrf, args.placeId)
50
+ })
51
+ }
@@ -0,0 +1,59 @@
1
+ const http = require('../util/http.js').func
2
+ const getGeneralToken = require('../util/getGeneralToken.js').func
3
+ const RobloxAPIError = require('../util/apiError.js')
4
+
5
+ exports.required = ['userIds', 'title']
6
+ exports.optional = ['jar']
7
+
8
+ // Docs
9
+ /**
10
+ * 🔐 Start a group conversation.
11
+ * @category Chat
12
+ * @alias startGroupConversation
13
+ * @param {Array<number>} userIds - An array of userIds to add.
14
+ * @param {string} title - The title of the group.
15
+ * @returns {Promise<StartGroupConversationResponse>}
16
+ * @example const noblox = require("noblox.js")
17
+ * // Login using your cookie
18
+ * noblox.startGroupConversation([1, 2, 3], "A group conversation.")
19
+ **/
20
+
21
+ function startGroupConversation (userIds, chatTitle, jar, token) {
22
+ return new Promise((resolve, reject) => {
23
+ const httpOpt = {
24
+ url: '//chat.roblox.com/v2/start-group-conversation',
25
+ options: {
26
+ method: 'POST',
27
+ jar,
28
+ headers: {
29
+ 'X-CSRF-TOKEN': token
30
+ },
31
+ json: {
32
+ participantUserIds: userIds,
33
+ title: chatTitle
34
+ },
35
+ resolveWithFullResponse: true
36
+ }
37
+ }
38
+
39
+ return http(httpOpt).then((res) => {
40
+ if (res.statusCode === 200) {
41
+ if (!res.body.resultType === 'Success') {
42
+ reject(new RobloxAPIError(res))
43
+ } else {
44
+ resolve(res.body)
45
+ }
46
+ } else {
47
+ reject(new RobloxAPIError(res))
48
+ }
49
+ }).catch(error => reject(error))
50
+ })
51
+ }
52
+
53
+ exports.func = (args) => {
54
+ const jar = args.jar
55
+
56
+ return getGeneralToken({ jar }).then((xcsrf) => {
57
+ return startGroupConversation(args.userIds, args.title, jar, xcsrf)
58
+ })
59
+ }
@@ -0,0 +1,86 @@
1
+ // Dependencies
2
+ const signalR = require('@microsoft/signalr')
3
+ const events = require('events')
4
+
5
+ // Includes
6
+ const getSession = require('../util/getSession.js').func
7
+ const settings = require('../../settings.json')
8
+
9
+ // Args
10
+ exports.optional = ['jar']
11
+
12
+ // Docs
13
+ /**
14
+ * 🔐 An event for when you get a notification.
15
+ * @category Client
16
+ * @alias onNotification
17
+ * @returns An EventEmitter that emits when you get a notification.
18
+ * @example const noblox = require("noblox.js")
19
+ * // Login using your cookie
20
+ * const notification = noblox.onNotification()
21
+ * notification.on("data", function(data) {
22
+ * console.log("New notification! ", data)
23
+ * })
24
+ * notification.on("error", function(err) {
25
+ * console.error("Something went wrong: ", err)
26
+ * // Handle error as needed
27
+ * })
28
+ **/
29
+
30
+ // Define
31
+ exports.func = function (args) {
32
+ const max = settings.event.maxRetries
33
+ const notifications = new events.EventEmitter()
34
+ function connect (retries) {
35
+ if (typeof args.jar === 'string') {
36
+ args.jar = { session: args.jar }
37
+ }
38
+ const session = getSession({ jar: args.jar })
39
+ let userNotificationConnection = null
40
+
41
+ userNotificationConnection = new signalR.HubConnectionBuilder()
42
+ .withUrl('https://realtime-signalr.roblox.com/userhub', {
43
+ transport: signalR.HttpTransportType.WebSockets,
44
+ skipNegotiation: true,
45
+ headers: {
46
+ Cookie: '.ROBLOSECURITY=' + session + ';'
47
+ }
48
+ })
49
+ .build()
50
+
51
+ userNotificationConnection.on('notification', function (name, message) {
52
+ notifications.emit('data', name, JSON.parse(message))
53
+ })
54
+
55
+ notifications.on('close', userNotificationConnection.stop)
56
+
57
+ userNotificationConnection.disconnected = function (err) {
58
+ notifications.emit('error', new Error('Connection failed: ' + err.message))
59
+ if (retries !== -1) {
60
+ if (retries > max) {
61
+ notifications.emit('close', new Error('Max retries reached'))
62
+ } else {
63
+ setTimeout(connect, 5000, retries + 1)
64
+ }
65
+ }
66
+ }
67
+
68
+ userNotificationConnection.error = function (err) {
69
+ notifications.emit('error', err)
70
+ }
71
+
72
+ userNotificationConnection.connected = function (connection) {
73
+ notifications.emit('connect', connection)
74
+ }
75
+
76
+ userNotificationConnection.reconnecting = function () {
77
+ setTimeout(connect, 5000, 0)
78
+ notifications.emit('error', new Error('Lost connection, reconnecting'))
79
+ return true // Abort reconnection
80
+ }
81
+
82
+ userNotificationConnection.start()
83
+ }
84
+ connect(-1)
85
+ return notifications
86
+ }
@@ -0,0 +1,18 @@
1
+ const options = require('../options.js')
2
+
3
+ exports.required = ['apiKey']
4
+
5
+ // Docs
6
+ /**
7
+ * 🔑 Sign in with an API key.
8
+ * @category Client
9
+ * @alias setAPIKey
10
+ * @param {string} apiKey - The api key to sign in with.
11
+ * @returns {Promise<boolean>}
12
+ * @example const noblox = require("noblox.js")
13
+ * noblox.setAPIKey("A3H+1rfQj0Kwz0CsSO2ciuT/e/ZHekahvehGG3PPmFOASZx1")
14
+ **/
15
+
16
+ exports.func = function (args) {
17
+ options.jar.apiKey = args.apiKey
18
+ }
@@ -0,0 +1,38 @@
1
+ const options = require('../options.js')
2
+ const getAuthenticatedUser = require('../util/getAuthenticatedUser.js').func
3
+
4
+ exports.required = ['cookie']
5
+ exports.optional = ['validate']
6
+
7
+ // Docs
8
+ /**
9
+ * 🔑 Sign in with a cookie.
10
+ * @category Client
11
+ * @alias setCookie
12
+ * @param {string} cookie - The cookie to sign in with.
13
+ * @param {boolean=} [validate=true] - Whether to validate the cookie or not.
14
+ * @returns {Promise<AuthenticatedUserData>}
15
+ * @example const noblox = require("noblox.js")
16
+ * noblox.setCookie("cookie").then(function() {
17
+ * //your code here
18
+ * })
19
+ **/
20
+
21
+ exports.func = async function (args) {
22
+ // verify it
23
+ if (!args.cookie.toLowerCase().includes('warning:-')) {
24
+ console.error('Warning: No Roblox warning detected in provided cookie. Ensure you include the entire .ROBLOSECURITY warning.')
25
+ }
26
+ if (args.validate === false) {
27
+ options.jar.session = args.cookie
28
+ return false
29
+ }
30
+ try {
31
+ const res = await getAuthenticatedUser({ jar: { session: args.cookie } })
32
+ options.jar.session = args.cookie
33
+ return res
34
+ } catch (error) {
35
+ console.error('Failed to validate cookie: Are you sure the cookie is valid?\nEnsure you include the full cookie, including warning text.')
36
+ throw new Error(error)
37
+ }
38
+ }