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,33 @@
1
+ const { getMessages, setCookie } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ return new Promise(resolve => {
5
+ setCookie(process.env.COOKIE).then(() => {
6
+ resolve()
7
+ })
8
+ })
9
+ })
10
+
11
+ describe('Private Messages Methods', () => {
12
+ it('getMessages() returns the logged in user\'s messages', () => {
13
+ return getMessages().then((res) => {
14
+ return expect(res).toMatchObject({
15
+ totalCollectionSize: expect.any(Number),
16
+ totalPages: expect.any(Number),
17
+ pageNumber: expect.any(Number),
18
+ collection: expect.arrayContaining([
19
+ expect.objectContaining({
20
+ id: expect.any(Number),
21
+ sender: expect.any(Object),
22
+ recipient: expect.any(Object),
23
+ subject: expect.any(String),
24
+ body: expect.any(String),
25
+ created: expect.any(String),
26
+ updated: expect.any(String),
27
+ isRead: expect.any(Boolean)
28
+ })
29
+ ])
30
+ })
31
+ })
32
+ })
33
+ })
@@ -0,0 +1,53 @@
1
+ const { getLogo, getPlayerThumbnail, getThumbnails, setCookie } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ return new Promise(resolve => {
5
+ setCookie(process.env.COOKIE).then(() => {
6
+ resolve()
7
+ })
8
+ })
9
+ })
10
+
11
+ describe('Thumbnails Methods', () => {
12
+ it('getLogo() returns a image URL for a group', () => {
13
+ return getLogo(4591072).then(() => {
14
+ return expect.any(String)
15
+ })
16
+ })
17
+
18
+ it('getPlayerThumbnail() returns a player\'s thumbnail', () => {
19
+ return getPlayerThumbnail(55549140, 60).then((res) => {
20
+ return expect(res).toEqual(
21
+ expect.arrayContaining([
22
+ expect.objectContaining({
23
+ targetId: expect.any(Number),
24
+ state: expect.any(String),
25
+ imageUrl: expect.any(String)
26
+ })
27
+ ])
28
+ )
29
+ })
30
+ })
31
+
32
+ it('getThumbnails() returns player/asset thumbnails', () => {
33
+ return getThumbnails([
34
+ {
35
+ type: 'AvatarHeadShot',
36
+ token: '4C32C300ABC60ABD344ABCFB3841E778',
37
+ size: '150x150'
38
+ }
39
+ ]).then((res) => {
40
+ return expect(res).toEqual(
41
+ expect.arrayContaining([
42
+ expect.objectContaining({
43
+ errorCode: expect.any(Number),
44
+ errorMessage: expect.any(String),
45
+ targetId: expect.any(Number),
46
+ state: expect.any(String),
47
+ imageUrl: expect.any(String)
48
+ })
49
+ ])
50
+ )
51
+ })
52
+ })
53
+ })
@@ -0,0 +1,68 @@
1
+ const { getBlurb, getIdFromUsername, getPlayerInfo, getUsernameFromId, setCookie } = require('../lib')
2
+
3
+ beforeAll(() => {
4
+ return new Promise(resolve => {
5
+ setCookie(process.env.COOKIE).then(() => {
6
+ resolve()
7
+ })
8
+ })
9
+ })
10
+
11
+ describe('Users Methods', () => {
12
+ it('getBlurb() returns a user\'s blurb', () => {
13
+ return getBlurb(55549140).then((res) => {
14
+ return expect(res).toEqual(expect.any(String))
15
+ })
16
+ })
17
+
18
+ it('getIdFromUsername() returns a user\'s ID given their username', () => {
19
+ return getIdFromUsername('ROBLOX').then((res) => {
20
+ return expect(res).toEqual(expect.any(Number))
21
+ })
22
+ })
23
+
24
+ it('getIdFromUsername() returns several IDs given several usernames', () => {
25
+ return getIdFromUsername(['qxest', 'builderman']).then((res) => {
26
+ return expect(res).toEqual(
27
+ expect.arrayContaining([expect.toBeOneOf([expect.any(Number), null])])
28
+ )
29
+ })
30
+ })
31
+
32
+ it('getIdFromUsername() returns null when given username that doesn\'t exist', () => {
33
+ return getIdFromUsername('x').then((res) => {
34
+ return expect(res).toBeNull()
35
+ })
36
+ })
37
+
38
+ it('getIdFromUsername() returns null when given usernames that don\'t exist', () => {
39
+ return getIdFromUsername(['p', 'a']).then((res) => {
40
+ return expect(res).toEqual(
41
+ expect.arrayContaining([null])
42
+ )
43
+ })
44
+ })
45
+
46
+ it('getPlayerInfo() returns information on the specified user', () => {
47
+ return getPlayerInfo(55549140).then((res) => {
48
+ return expect(res).toMatchObject({
49
+ username: expect.any(String),
50
+ blurb: expect.any(String),
51
+ joinDate: expect.any(Date),
52
+ age: expect.any(Number),
53
+ friendCount: expect.any(Number),
54
+ followerCount: expect.any(Number),
55
+ followingCount: expect.any(Number),
56
+ oldNames: expect.any(Array),
57
+ isBanned: expect.any(Boolean),
58
+ displayName: expect.any(String)
59
+ })
60
+ })
61
+ })
62
+
63
+ it('getUsernameFromId() returns a player\'s username given an ID', () => {
64
+ return getUsernameFromId(1).then((res) => {
65
+ return expect(res).toEqual(expect.any(String))
66
+ })
67
+ })
68
+ })
@@ -0,0 +1,75 @@
1
+ ### What is Authentication on Roblox?
2
+ Authentication is pretty simple, it's how Roblox knows who you are and what account you're using. To identify your account, Roblox uses [**authentication sessions**](https://medium.com/@sherryhsu/session-vs-token-based-authentication-11a6c5ac45e4) which are stored on their servers and linked to your account. Your authentication session will expire when you log out of an account or press sign out of all other sessions. You can keep your session active by obtaining your cookie in an incognito window using the instructions below and closing the window when you're done, rather than signing out manually. Since Roblox uses FunCaptcha and have no official bot system, developers are forced to use these sessions, which are stored in [**cookies.**](https://support.mozilla.org/en-US/kb/cookies-information-websites-store-on-your-computer) This will allow Roblox to easily identify your bot's account and execute actions on it's behalf.
3
+
4
+ ### What's a cookie?
5
+ A cookie (not the ones you eat) is a small quantity of data containing data sent by a website. Cookies are stored by the user's web browser while browsing. Cookies are standard practice across the web and as such, a large part of Roblox's security are based around cookies. Sharing is not caring. Never share your cookie.
6
+
7
+ ### How do I obtain my cookie?
8
+ There are many different ways to obtain your cookie depending on your browser. First of all, open an [Incognito window](https://support.google.com/chrome/answer/95464?co=GENIE.Platform%3DDesktop&hl=en) on your browser and sign into your bot account.
9
+
10
+ > [Are you hosting your bot remotely? Due to recent security improvements, cookies are now locked by IP region. Learn connect to your VPS and generate the cookie remotely here.](https://noblox.js.org/tutorial-VPS%20Authentication.html)
11
+
12
+ #### **Chrome**
13
+ 1. Click the arrow icon on the right-hand side of the toolbar.
14
+ 2. Go to More Tools.
15
+ 3. Click the Developer Tools button.
16
+ 4. Click the Application tab and Cookies button on the menu to the left.
17
+ 5. Click the dropdown until you find www.roblox.com.
18
+ 6. Your cookie is the value assigned to the key named .ROBLOSECURITY. Copy it.
19
+ #### **Firefox**
20
+ 1. Click the hamburger icon on the right-hand side of the toolbar.
21
+ 2. Go to Web Developer.
22
+ 3. Click Storage Inspector and the Cookies button on the menu to the left.
23
+ 4. Click the dropdown until you find www.roblox.com.
24
+ 5. Your cookie is the value assigned to the key named .ROBLOSECURITY. Copy it.
25
+ #### **Safari**
26
+ 1. Go to Preferences, Advanced and select Show Develop menu in menu bar.
27
+ 2. Click the Develop tab.
28
+ 3. Click Show Web Inspector.
29
+ 4. Click the Storage tab and then click Cookies.
30
+ 5. Click the dropdown until you find www.roblox.com.
31
+ 6. Your cookie is the value assigned to the key named .ROBLOSECURITY. Copy it.
32
+ #### **Edge**
33
+ 1. Click the elipsis (...) on the right-hand side of the toolbar.
34
+ 2. Go to More tools.
35
+ 3. Click the Developer Tools button.
36
+ 4. Click the More Tools button (icon next to Console).
37
+ 5. Click Storage.
38
+ 6. Click the dropdown until you find www.roblox.com.
39
+ 7. Your cookie is the value assigned to the key named .ROBLOSECURITY. Copy it.
40
+
41
+ ### How do I use my cookie?
42
+ Once you have obtained and copied your cookie, close the incognito window without signing out. To use your cookie with noblox, you will have to use the **setCookie method**. This will use your cookie in all requests sent to Roblox to perform actions on your bot's behalf. You should store your cookie somewhere secure, such as a [**.env file**](https://medium.com/the-node-js-collection/making-your-node-js-work-everywhere-with-environment-variables-2da8cdf6e786).
43
+
44
+ ### Example:
45
+ ```javascript
46
+ const noblox = require("noblox.js");
47
+
48
+ noblox.setCookie(process.env.COOKIE).then(function() { //Use COOKIE from our .env file.
49
+ console.log("Logged in!")
50
+ }).catch(function(err) {
51
+ console.log("Unable to log in!", err)
52
+ })
53
+ ```
54
+
55
+ ### ⚠️ Usage warning
56
+
57
+ An authentication error which is often seen is `Cannot get CSRF: You are not logged in.`.
58
+ This is an error caused by trying to use an authenticated method, while not having set a cookie.
59
+ This is usually for one of two reasons:
60
+ #### Reason 1: Not used method
61
+ You haven't set the cookie. This should be pretty self-explanatory, and can also appear as "Authorization has been denied for this request".
62
+ To solve this case, use the [setCookie](./global.html#setCookie) method.
63
+
64
+
65
+ #### Reason 2: Promises
66
+ More often than not, this error is caused by misuse of promises.
67
+ The setCookie method, like most of our methods, returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
68
+
69
+ Ensure you use either `async await` or the `.then` and `.catch` methods. If using Async await, you must put any
70
+ authenticated code either WITHIN the same async function, or in another function which is called after your setCookie
71
+ completes. The cookie will **not** be set until setCookie is complete.
72
+
73
+ If using `then` and `catch`, likewise it should be within the `then` block or a function called by it.
74
+
75
+ You can read more about Promises [here](./tutorial-Promises.html).
@@ -0,0 +1,26 @@
1
+ ### What is an EventEmitter?
2
+ An Event Emitter is a way in JavaScript to recieve data in real time until the emitter is closed. It's an easy way to handle events that occur in your application and execute functions. In noblox, they are used for handling events such as when someone shouts or Roblox notifications.
3
+
4
+ ### How can I use an EventEmitter?
5
+ You can use an EventEmitter created by noblox by calling a function that returns an EventEmitter, and calling **.on(event, callback)**. 3 events used by noblox are "data", "connect", and "close". Data is when noblox detects a change on Roblox and informs you of the change, which it will provide as a parameter in the callback function. Connect is when noblox connects to Roblox successfully and starts the emitter. Finally, close is when noblox disconnects from Roblox and stops the emitter.
6
+
7
+ ### Example:
8
+ ```javascript
9
+ const noblox = require("noblox.js");
10
+ const Emitter = noblox.onShout(1);
11
+
12
+ Emitter.on("connect", function() {
13
+ console.log("noblox is listening for a shout change!");
14
+ })
15
+
16
+ Emitter.on("data", function(newStatus) {
17
+ console.log("The group status has been updated! New status:", newStatus);
18
+ })
19
+
20
+ Emitter.on("close", function() {
21
+ console.log("noblox has closed the emitter!");
22
+ })
23
+ ```
24
+
25
+ ### Resources:
26
+ [**DigitalOcean**](https://www.digitalocean.com/community/tutorials/using-event-emitters-in-node-js)
@@ -0,0 +1,86 @@
1
+ ### What are Promises?
2
+ Promises allow you to easily make your code asynchronous. They will allow your code to yield/stop and wait for a function to return a value. If a value is unknown, they will allow us to wait for the value to become known or for an error to be thrown. For example, if we want to get a user's rank, we want to wait for Roblox to reply with their rank before continuing the execution of our code.
3
+
4
+ ### How do you use Promises?
5
+
6
+ You can use promises in 2 different ways. The first one is using **await/async**, in which you can set a variable to the result of the Promise, but **only** in an **async** function. This is done using await before calling the function, which will return a Promise.
7
+
8
+ Another way you can use promises is by using **.then**(function). The function wrapped in .then() will execute when the Promise resolves, and the variables will be passed through the function.
9
+
10
+ However, sometimes Promises throw errors. You will need to handle any errors from promises or else you will get an **[Unhandled Promise Rejection Error.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#Promise_rejection_events)** These errors are fatal and should always be handled accordingly. To do this, you can use **.catch**, which will allow you to handle the error correctly. When using **async/await**, you can use .catch by attaching it after the function is called. With **.then()**, you can attach it after **.then**. Both cases are shown in the examples below.
11
+
12
+ ### Examples:
13
+
14
+ #### async/await
15
+ ```javascript
16
+ const noblox = require("noblox.js");
17
+
18
+ //await can only be used in async functions!
19
+ async function DemoteUser (groupId, username) {
20
+ //await will yield the code until a value is returned.
21
+ const userId = await noblox.getIdFromUsername(username).catch(function(error) {
22
+ console.log("There was an error getting the id!", error)
23
+ }); //Handle the rejection accordingly.
24
+
25
+ if (!userId) return console.log("No id was returned.");
26
+ noblox.demote(groupId, userId); //Use the value returned to demote the user.
27
+ }
28
+
29
+ DemoteUser(1, "popeeyy");
30
+ ```
31
+
32
+ #### .then(function)
33
+ ```javascript
34
+ const noblox = require("noblox.js");
35
+
36
+ //When the promise is resolved, the function runs with the provided variable.
37
+ noblox.getIdFromUsername("popeeyy").then(function(userId) {
38
+ noblox.demote(1, userId)
39
+ }).catch(function(error) { //Handle the rejection accordingly.
40
+ console.log("There was an error getting the id!", error)
41
+ })
42
+ ```
43
+
44
+ ### Additional Info:
45
+
46
+ When you use an **async** function, a Promise is returned, not a function. They should be treated as if they are Promises when returning values by using await or .then with proper error handling as well.
47
+
48
+ There are different ways to create a Promise, but we'll discuss two of the easiest ways. The first way is to create an **async function**, as explained above. The other way is to use **new Promise(function)**, with the function having 2 parameters. The 2 parameters are resolve and reject respectively, which will resolve the Promise or throw an error.
49
+
50
+ You should always read the docs, isn't that what you're here for? There are plenty of examples showing when you use Promises and what values are returned by the function. Promises are your friend in this library and many others, so take the time to learn them first and practice using them. If you have any questions, you can always ask the community in the [Roblox API Discord](https://discord.gg/EDXNdAT) via our designated channel "nodejs_nobloxjs".
51
+
52
+ ### Example:
53
+
54
+ ```javascript
55
+ const isCool = false;
56
+
57
+ function amICool() {
58
+ //Create a new Promise
59
+ return new Promise(function(resolve, reject) {
60
+ if (isCool) {
61
+ //Resolve that isCool is true.
62
+ resolve(true)
63
+ } else {
64
+ //Reject the Promise because only cool people can call this.
65
+ reject("You aren't cool, don't call this function!")
66
+ }
67
+ })
68
+ }
69
+
70
+ amICool().then(function(cool) {
71
+ console.log("Am I cool?", cool)
72
+ }).catch(function(err) {
73
+ console.log("There was an error while checking if I'm cool", err)
74
+ })
75
+ ```
76
+
77
+ ### Resources:
78
+
79
+ If you are still having trouble with Promises or want to learn more, here are a few helpful resources:
80
+
81
+
82
+ [**MDN**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
83
+ <br />
84
+ [**DigitalOcean**](https://www.digitalocean.com/community/tutorials/javascript-promises-for-dummies)
85
+ <br />
86
+ [**JavaScript.info**](https://javascript.info/promise-basics)
@@ -0,0 +1,72 @@
1
+ # Retrieving a .ROBLOSECURITY cookie on a headless VPS:
2
+
3
+ > You must have a **static IP** on a dedicated VPS that you can SSH into; <ins>free hosts like Repl.it and Glitch **are not compatible.**</ins>
4
+
5
+ [Adapted from a DigitalOcean tutorial.](https://www.digitalocean.com/community/tutorials/how-to-route-web-traffic-securely-without-a-vpn-using-a-socks-tunnel)
6
+
7
+ ---
8
+
9
+ As of March 8th, 2022, Roblox began rolling out a mandatory security feature that locks an account's `.ROBLOSECURITY` cookie to an IP region.
10
+
11
+ Learn more here: [https://devforum.roblox.com/t/ip-changes-invalidate-cookie/1700515](https://devforum.roblox.com/t/ip-changes-invalidate-cookie/1700515)
12
+
13
+ To bypass this, you must create the token from your VPS; the easiest way of which is through an SSH tunnel. When using this solution, the VPS must be the **only IP** accessing the account. Relogging without the proxy, or using a free coding workspace like Repl.it, Glitch, or Heroku, that assign dynamic IPs **will not work.**
14
+
15
+ ---
16
+
17
+ **Step 0)** Make sure you are signed out of the target account, and have SSH access to your VPS.
18
+
19
+ **Step 1)** Connect to your VPS over SSH:
20
+
21
+ ```console
22
+ ssh your_user@your_server_ip
23
+ ```
24
+
25
+ **Step 2)** Whitelist a port in your firewall (any value between 1024 and 65535), we will use `1234`:
26
+
27
+ ```console
28
+ sudo ufw allow 1234
29
+ ```
30
+
31
+ > [If you have never set up a firewall, I strongly recommend reading this article to harden your server](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-20-04); make sure to allow your SSH port too!
32
+
33
+ **Step 3)** Reconnect and start an SSH tunnel on the whitelisted port:
34
+
35
+ ```console
36
+ ssh -D 1234 your_user@your_server_ip
37
+ ```
38
+
39
+ You will be prompted for a password, and then there will be no sign for success for failure, **this is expected**.
40
+
41
+ **Step 4)** From a <ins>new terminal instance</ins>, connect your web browser to the proxy in incognito, and log in:
42
+
43
+ > These commands should be run outside of WSL, either use Git Bash or cmd.
44
+
45
+ **Google Chrome:**
46
+ ```
47
+ start chrome --incognito --proxy-server="socks5://localhost:1234" https://www.roblox.com/login
48
+ ```
49
+
50
+ **Microsoft Edge:**
51
+ ```
52
+ start msedge --inprivate --proxy-server="socks5://localhost:1234" https://www.roblox.com/login
53
+ ```
54
+
55
+ [**Mozilla Firefox**](https://www.digitalocean.com/community/tutorials/how-to-route-web-traffic-securely-without-a-vpn-using-a-socks-tunnel#step-2-mdash-configuring-firefox-to-use-the-tunnel) (Less recommended; must be manually configured.)
56
+
57
+ **Step 5)** [Retrieve your cookie as normal](https://noblox.js.org/tutorial-Authentication.html); this is nothing new.
58
+
59
+ **Step 6)** Copy the cookie to your VPS, write to a `.env` file, etc, your pick.
60
+
61
+ **Step 7)** Close the incognito proxied window; **do not** press log out.
62
+
63
+ **Step 8)** [Clean-Up]: Remove the whitelisted port from your firewall rules:
64
+ ```console
65
+ sudo ufw delete allow 1234
66
+ ```
67
+
68
+ **Step 9)** You may now close the SSH tunnel by closing your terminal; you are done- as far as Roblox can tell, you logged in from your VPS's IP.
69
+
70
+ ---
71
+
72
+ > From now on, you **MUST** be connected through the SSH Tunnel to access the Roblox account. Failing to do so will violate the IP check and invalidate your cookie.