roblox-ts-core 0.0.1-security.1 → 4.6.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of roblox-ts-core might be problematic. Click here for more details.
- package/.eslintrc.js +21 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- package/.github/workflows/doc-publish.yml +33 -0
- package/.github/workflows/npmpublish.yml +70 -0
- package/.travis.yml +13 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/LICENSE +21 -0
- package/README.md +166 -3
- package/examples/cleanPlayers.js +130 -0
- package/examples/cleanWall.js +110 -0
- package/examples/revertRanks.js +100 -0
- package/examples/savePlayers.js +119 -0
- package/examples/saveWall.js +96 -0
- package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
- package/img/noblox-js-small.png +0 -0
- package/img/noblox-js.png +0 -0
- package/img/thumbnailSizes.png +0 -0
- package/jsDocsConfig.json +55 -0
- package/lib/accountinformation/getUserSocialLinks.js +42 -0
- package/lib/accountsettings/block.js +58 -0
- package/lib/accountsettings/unblock.js +58 -0
- package/lib/asset/deleteFromInventory.js +69 -0
- package/lib/asset/getGamePassProductInfo.js +51 -0
- package/lib/asset/getProductInfo.js +56 -0
- package/lib/asset/uploadAnimation.js +103 -0
- package/lib/asset/uploadItem.js +83 -0
- package/lib/asset/uploadModel.js +90 -0
- package/lib/avatar/avatarRules.js +38 -0
- package/lib/avatar/currentlyWearing.js +32 -0
- package/lib/avatar/getAvatar.js +35 -0
- package/lib/avatar/getCurrentAvatar.js +37 -0
- package/lib/avatar/getRecentItems.js +37 -0
- package/lib/avatar/outfitDetails.js +32 -0
- package/lib/avatar/outfits.js +37 -0
- package/lib/avatar/redrawAvatar.js +48 -0
- package/lib/avatar/removeAssetId.js +55 -0
- package/lib/avatar/setAvatarBodyColors.js +60 -0
- package/lib/avatar/setAvatarScales.js +60 -0
- package/lib/avatar/setPlayerAvatarType.js +50 -0
- package/lib/avatar/setWearingAssets.js +50 -0
- package/lib/avatar/wearAssetId.js +55 -0
- package/lib/badges/getAwardedTimestamps.js +52 -0
- package/lib/badges/getBadgeInfo.js +43 -0
- package/lib/badges/getGameBadges.js +62 -0
- package/lib/badges/getPlayerBadges.js +28 -0
- package/lib/badges/updateBadgeInfo.js +80 -0
- package/lib/cache/add.js +14 -0
- package/lib/cache/addIf.js +26 -0
- package/lib/cache/clear.js +8 -0
- package/lib/cache/get.js +28 -0
- package/lib/cache/index.js +17 -0
- package/lib/cache/new.js +12 -0
- package/lib/cache/wrap.js +25 -0
- package/lib/chat/addUsersToConversation.js +61 -0
- package/lib/chat/chatSettings.js +33 -0
- package/lib/chat/getChatMessages.js +40 -0
- package/lib/chat/getConversations.js +43 -0
- package/lib/chat/getRolloutSettings.js +35 -0
- package/lib/chat/getUnreadConversationCount.js +33 -0
- package/lib/chat/getUnreadMessages.js +38 -0
- package/lib/chat/getUserConversations.js +37 -0
- package/lib/chat/markChatAsRead.js +52 -0
- package/lib/chat/markChatAsSeen.js +50 -0
- package/lib/chat/multiGetLatestMessages.js +37 -0
- package/lib/chat/onNewConversation.js +50 -0
- package/lib/chat/onNewMessage.js +53 -0
- package/lib/chat/onNewMessageBySelf.js +50 -0
- package/lib/chat/onUserOnline.js +50 -0
- package/lib/chat/onUserTyping.js +54 -0
- package/lib/chat/removeFromGroupConversation.js +62 -0
- package/lib/chat/renameGroupConversation.js +57 -0
- package/lib/chat/sendChatMessage.js +57 -0
- package/lib/chat/setChatUserTyping.js +61 -0
- package/lib/chat/start121Conversation.js +50 -0
- package/lib/chat/startCloudEditConversation.js +50 -0
- package/lib/chat/startGroupConversation.js +62 -0
- package/lib/client/onNotification.js +70 -0
- package/lib/client/setAPIKey.js +18 -0
- package/lib/client/setCookie.js +38 -0
- package/lib/datastores/deleteDatastoreEntry.js +66 -0
- package/lib/datastores/getDatastoreEntry.js +98 -0
- package/lib/datastores/getDatastoreEntryVersions.js +83 -0
- package/lib/datastores/getDatastoreKeys.js +73 -0
- package/lib/datastores/getDatastores.js +72 -0
- package/lib/datastores/incrementDatastoreEntry.js +93 -0
- package/lib/datastores/setDatastoreEntry.js +90 -0
- package/lib/develop/canManage.js +44 -0
- package/lib/develop/configureItem.js +142 -0
- package/lib/develop/updateUniverse.js +53 -0
- package/lib/develop/updateUniverseAccess.js +55 -0
- package/lib/economy/buy.js +99 -0
- package/lib/economy/getGroupFunds.js +43 -0
- package/lib/economy/getGroupRevenueSummary.js +48 -0
- package/lib/economy/getGroupTransactions.js +32 -0
- package/lib/economy/getResaleData.js +54 -0
- package/lib/economy/getResellers.js +35 -0
- package/lib/economy/getUserTransactions.js +34 -0
- package/lib/economy/onGroupTransaction.js +74 -0
- package/lib/friends/acceptFriendRequest.js +59 -0
- package/lib/friends/declineAllFriendRequests.js +57 -0
- package/lib/friends/declineFriendRequest.js +59 -0
- package/lib/friends/getFollowers.js +61 -0
- package/lib/friends/getFollowings.js +61 -0
- package/lib/friends/getFriendRequests.js +56 -0
- package/lib/friends/getFriends.js +53 -0
- package/lib/friends/onFriendRequest.js +58 -0
- package/lib/friends/removeFriend.js +58 -0
- package/lib/friends/sendFriendRequest.js +59 -0
- package/lib/friends/unfollow.js +58 -0
- package/lib/games/addDeveloperProduct.js +65 -0
- package/lib/games/checkDeveloperProductName.js +39 -0
- package/lib/games/configureGamePass.js +146 -0
- package/lib/games/getDeveloperProducts.js +51 -0
- package/lib/games/getGameInstances.js +31 -0
- package/lib/games/getGamePasses.js +39 -0
- package/lib/games/getGameRevenue.js +49 -0
- package/lib/games/getGameSocialLinks.js +45 -0
- package/lib/games/getGroupGames.js +30 -0
- package/lib/games/getPlaceInfo.js +48 -0
- package/lib/games/getUniverseInfo.js +51 -0
- package/lib/games/updateDeveloperProduct.js +69 -0
- package/lib/groups/changeRank.js +59 -0
- package/lib/groups/deleteWallPost.js +64 -0
- package/lib/groups/deleteWallPostsByUser.js +59 -0
- package/lib/groups/demote.js +25 -0
- package/lib/groups/exile.js +59 -0
- package/lib/groups/getAuditLog.js +67 -0
- package/lib/groups/getGroup.js +57 -0
- package/lib/groups/getGroupSocialLinks.js +44 -0
- package/lib/groups/getGroups.js +88 -0
- package/lib/groups/getJoinRequest.js +52 -0
- package/lib/groups/getJoinRequests.js +58 -0
- package/lib/groups/getPlayers.js +108 -0
- package/lib/groups/getRankInGroup.js +52 -0
- package/lib/groups/getRankNameInGroup.js +52 -0
- package/lib/groups/getRole.js +64 -0
- package/lib/groups/getRolePermissions.js +51 -0
- package/lib/groups/getRoles.js +56 -0
- package/lib/groups/getShout.js +49 -0
- package/lib/groups/getWall.js +59 -0
- package/lib/groups/groupPayout.js +103 -0
- package/lib/groups/handleJoinRequest.js +60 -0
- package/lib/groups/leaveGroup.js +60 -0
- package/lib/groups/onAuditLog.js +62 -0
- package/lib/groups/onJoinRequest.js +63 -0
- package/lib/groups/onJoinRequestHandle.js +105 -0
- package/lib/groups/onShout.js +57 -0
- package/lib/groups/onWallPost.js +58 -0
- package/lib/groups/promote.js +25 -0
- package/lib/groups/searchGroups.js +32 -0
- package/lib/groups/setGroupDescription.js +65 -0
- package/lib/groups/setGroupName.js +66 -0
- package/lib/groups/setRank.js +79 -0
- package/lib/groups/shout.js +65 -0
- package/lib/index.js +30 -0
- package/lib/internal/levelOneCopy.js +16 -0
- package/lib/internal/queue.js +61 -0
- package/lib/internal/timeout.js +30 -0
- package/lib/internal/wrap.js +78 -0
- package/lib/inventory/getCollectibles.js +31 -0
- package/lib/inventory/getInventory.js +32 -0
- package/lib/inventory/getInventoryById.js +31 -0
- package/lib/inventory/getOwnership.js +54 -0
- package/lib/inventory/getUAIDs.js +47 -0
- package/lib/itemconfiguration/getGroupAssets.js +32 -0
- package/lib/options.js +26 -0
- package/lib/party/onPartyDeleted.js +53 -0
- package/lib/party/onPartyInvite.js +53 -0
- package/lib/party/onPartyJoinedGame.js +53 -0
- package/lib/party/onPartyLeftGame.js +53 -0
- package/lib/party/onPartySelfJoined.js +53 -0
- package/lib/party/onPartySelfLeft.js +53 -0
- package/lib/party/onPartyUserJoined.js +53 -0
- package/lib/party/onPartyUserLeft.js +53 -0
- package/lib/premiumfeatures/getPremium.js +51 -0
- package/lib/presence/getPresences.js +63 -0
- package/lib/privatemessages/getMessages.js +60 -0
- package/lib/privatemessages/message.js +80 -0
- package/lib/privatemessages/onMessage.js +88 -0
- package/lib/thumbnails/getLogo.js +60 -0
- package/lib/thumbnails/getPlayerThumbnail.js +121 -0
- package/lib/thumbnails/getThumbnails.js +93 -0
- package/lib/trades/acceptTrade.js +58 -0
- package/lib/trades/canTradeWith.js +48 -0
- package/lib/trades/counterTrade.js +84 -0
- package/lib/trades/declineTrade.js +58 -0
- package/lib/trades/getTradeInfo.js +52 -0
- package/lib/trades/getTrades.js +37 -0
- package/lib/trades/sendTrade.js +82 -0
- package/lib/users/getBlurb.js +36 -0
- package/lib/users/getIdFromUsername.js +53 -0
- package/lib/users/getPlayerInfo.js +100 -0
- package/lib/users/getUsernameFromId.js +44 -0
- package/lib/users/onBlurbChange.js +46 -0
- package/lib/util/clearSession.js +32 -0
- package/lib/util/generalRequest.js +61 -0
- package/lib/util/getAction.js +45 -0
- package/lib/util/getCurrentUser.js +44 -0
- package/lib/util/getGeneralToken.js +52 -0
- package/lib/util/getHash.js +29 -0
- package/lib/util/getInputs.js +37 -0
- package/lib/util/getPageResults.js +89 -0
- package/lib/util/getSenderUserId.js +30 -0
- package/lib/util/getSession.js +38 -0
- package/lib/util/getVerification.js +60 -0
- package/lib/util/getVerificationInputs.js +31 -0
- package/lib/util/http.js +110 -0
- package/lib/util/jar.js +24 -0
- package/lib/util/refreshCookie.js +52 -0
- package/lib/util/relog.js +81 -0
- package/lib/util/setOptions.js +54 -0
- package/lib/util/shortPoll.js +102 -0
- package/lib/util/threaded.js +80 -0
- package/package.json +91 -3
- package/postinstall.js +1 -0
- package/settings.json +107 -0
- package/test/accountinformation.test.js +27 -0
- package/test/accountsettings.test.js +27 -0
- package/test/asset.test.js +81 -0
- package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
- package/test/assets/KeyframeSequence.rbxm +0 -0
- package/test/avatar.test.js +164 -0
- package/test/badges.test.js +96 -0
- package/test/chat.test.js +104 -0
- package/test/datastore.test.js +105 -0
- package/test/develop.test.js +53 -0
- package/test/economy.test.js +137 -0
- package/test/friends.test.js +128 -0
- package/test/games.test.js +212 -0
- package/test/groups.test.js +311 -0
- package/test/inventory.test.js +98 -0
- package/test/itemconfiguration.test.js +24 -0
- package/test/premiumfeatures.test.js +17 -0
- package/test/presence.test.js +25 -0
- package/test/privatemessages.test.js +33 -0
- package/test/thumbnails.test.js +53 -0
- package/test/users.test.js +68 -0
- package/tutorials/Authentication.md +75 -0
- package/tutorials/Event Emitters.md +26 -0
- package/tutorials/Promises.md +86 -0
- package/tutorials/VPS Authentication.md +72 -0
- package/typings/index.d.ts +2525 -0
- package/typings/jsDocs.ts +1927 -0
@@ -0,0 +1,142 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
4
|
+
|
5
|
+
// Args
|
6
|
+
exports.required = ['id', 'name', 'description']
|
7
|
+
exports.optional = ['enableComments', 'sellForRobux', 'genreSelection', 'jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Configure an asset.
|
12
|
+
* @category Develop
|
13
|
+
* @alias configureItem
|
14
|
+
* @param {number} assetId - The id of the asset.
|
15
|
+
* @param {string} name - The new name of the asset.
|
16
|
+
* @param {string} description - The new description of the asset.
|
17
|
+
* @param {boolean=} enableComments - Enable comments on your asset.
|
18
|
+
* @param {number|boolean=} [sellForRobux=false] - The amount of robux to sell for; use a number for sellable assets, boolean for copyable assets
|
19
|
+
* @param {string=} [genreSelection="All"] - The genre of your asset.
|
20
|
+
* @returns {Promise<ConfigureItemResponse>}
|
21
|
+
* @example const noblox = require("noblox.js")
|
22
|
+
* // Login using your cookie
|
23
|
+
* noblox.configureItem(1117747196, "Item", "A cool item.", false, 100)
|
24
|
+
**/
|
25
|
+
|
26
|
+
// Define
|
27
|
+
function configure (jar, token, id, name, description, enableComments, sellForRobux, genreSelection, sellingPrice) {
|
28
|
+
return http({
|
29
|
+
url: '//develop.roblox.com/v1/assets/' + id,
|
30
|
+
options: {
|
31
|
+
method: 'PATCH',
|
32
|
+
jar: jar,
|
33
|
+
headers: {
|
34
|
+
'X-CSRF-TOKEN': token
|
35
|
+
},
|
36
|
+
json: {
|
37
|
+
name: name,
|
38
|
+
description: description,
|
39
|
+
enableComments: enableComments,
|
40
|
+
genres: genreSelection || ['All'],
|
41
|
+
isCopyingAllowed: typeof (sellForRobux) === 'boolean' ? sellForRobux : null
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}).then(function (json) {
|
45
|
+
if (!json.errors) {
|
46
|
+
const response = {
|
47
|
+
name,
|
48
|
+
description,
|
49
|
+
assetId: id
|
50
|
+
}
|
51
|
+
if (typeof sellForRobux === 'boolean') {
|
52
|
+
response.isCopyingAllowed = sellForRobux
|
53
|
+
} else {
|
54
|
+
response.price = sellingPrice || 0
|
55
|
+
}
|
56
|
+
return response
|
57
|
+
} else {
|
58
|
+
if (json.errors[0].code === 13) { // "Only a marketplace asset can be updated with IsCopyingAllowed."
|
59
|
+
throw new Error('Attempting to make a sellable asset copyable; it must be sold for robux. (Use a number for sellForRobux.)')
|
60
|
+
}
|
61
|
+
throw new Error(json.errors[0].message)
|
62
|
+
}
|
63
|
+
})
|
64
|
+
}
|
65
|
+
|
66
|
+
function configureRobux (args) {
|
67
|
+
return http({
|
68
|
+
url: '//itemconfiguration.roblox.com/v1/assets/' + args.id + '/release',
|
69
|
+
options: {
|
70
|
+
method: 'POST',
|
71
|
+
jar: args.jar,
|
72
|
+
headers: {
|
73
|
+
'X-CSRF-TOKEN': args.token
|
74
|
+
},
|
75
|
+
json: {
|
76
|
+
saleStatus: args.sellForRobux ? 'OnSale' : 'OffSale',
|
77
|
+
priceConfiguration: {
|
78
|
+
priceInRobux: args.sellForRobux || 0
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
})
|
83
|
+
.then(function (json) {
|
84
|
+
if (!json.errors) {
|
85
|
+
return configure(args.jar, args.token, args.id, args.name, args.description, args.enableComments, args.sellForRobux, args.genreSelection, args.sellForRobux)
|
86
|
+
} else {
|
87
|
+
// Code 6: "Asset is released"; caused when changing the price of an on-sale asset from non-zero to non-zero
|
88
|
+
if (json.errors[0].code === 6) {
|
89
|
+
return http({
|
90
|
+
url: '//itemconfiguration.roblox.com/v1/assets/' + args.id + '/update-price',
|
91
|
+
options: {
|
92
|
+
method: 'POST',
|
93
|
+
jar: args.jar,
|
94
|
+
headers: {
|
95
|
+
'X-CSRF-TOKEN': args.token
|
96
|
+
},
|
97
|
+
json: {
|
98
|
+
priceConfiguration: {
|
99
|
+
priceInRobux: args.sellForRobux
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}).then((err) => {
|
104
|
+
if (!err.errors) {
|
105
|
+
return configure(args.jar, args.token, args.id, args.name, args.description, args.enableComments, args.sellForRobux, args.genreSelection, args.sellForRobux)
|
106
|
+
} else {
|
107
|
+
throw new Error(json.errors[0].message)
|
108
|
+
}
|
109
|
+
})
|
110
|
+
} else if (json.errors[0].code === 3) { // "Cannot release the associated asset type" - caused by copyable asset using sellForRobux: 2 or greater
|
111
|
+
// Throw an error as the developer may have intended to sell the asset for robux instead of making it free.
|
112
|
+
throw new Error('Attempting to sell a copyable asset for robux; it can only be made free. (Use true for sellForRobux.)')
|
113
|
+
} else if (json.errors[0].code === 20) { // "Cannot set the associated asset type to remove-from-release" - caused by copyable asset using sellForRobux: 0
|
114
|
+
// Continue and ignore the error as the intended outcome makes the asset private; set sellForRobux from 0 to false
|
115
|
+
return configure(args.jar, args.token, args.id, args.name, args.description, args.enableComments, args.sellForRobux, args.genreSelection, !!args.sellForRobux)
|
116
|
+
}
|
117
|
+
throw new Error(`An unknown error occurred: [${json.errors[0].code}] ${json.errors[0].message}`)
|
118
|
+
}
|
119
|
+
})
|
120
|
+
}
|
121
|
+
|
122
|
+
function runWithToken (args) {
|
123
|
+
const jar = args.jar
|
124
|
+
return getGeneralToken({
|
125
|
+
jar: jar
|
126
|
+
})
|
127
|
+
.then(function (token) {
|
128
|
+
if (typeof (args.sellForRobux) === 'number') {
|
129
|
+
if (args.sellForRobux < 2 && args.sellForRobux !== 0) {
|
130
|
+
throw new Error('Assets cannot be sold for less than 2R.')
|
131
|
+
}
|
132
|
+
args.token = token
|
133
|
+
return configureRobux(args)
|
134
|
+
} else {
|
135
|
+
return configure(args.jar, token, args.id, args.name, args.description, args.enableComments, args.sellForRobux, args.genreSelection)
|
136
|
+
}
|
137
|
+
})
|
138
|
+
}
|
139
|
+
|
140
|
+
exports.func = function (args) {
|
141
|
+
return runWithToken(args)
|
142
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
4
|
+
|
5
|
+
// Args
|
6
|
+
exports.required = ['universeId', 'settings']
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Modifies a universe's settings
|
12
|
+
* @category Develop
|
13
|
+
* @alias updateUniverse
|
14
|
+
* @param {number} universeId - The universeId of the experience
|
15
|
+
* @param {UniverseSettings} settings - The settings to update
|
16
|
+
* @returns {Promise<UpdateUniverseResponse>}
|
17
|
+
* @example const noblox = require("noblox.js")
|
18
|
+
* // Login using your cookie
|
19
|
+
* noblox.updateUniverse(2421261122, { name: "The best game ever!" })
|
20
|
+
**/
|
21
|
+
|
22
|
+
// Define
|
23
|
+
function updateUniverse (universeId, settings, jar, token) {
|
24
|
+
return new Promise((resolve, reject) => {
|
25
|
+
return http({
|
26
|
+
url: `//develop.roblox.com/v1/universes/${universeId}/configuration`,
|
27
|
+
options: {
|
28
|
+
method: 'PATCH',
|
29
|
+
jar,
|
30
|
+
headers: {
|
31
|
+
'X-CSRF-TOKEN': token
|
32
|
+
},
|
33
|
+
json: settings,
|
34
|
+
resolveWithFullResponse: true
|
35
|
+
}
|
36
|
+
}).then(({ statusCode, body }) => {
|
37
|
+
if (statusCode === 200) {
|
38
|
+
resolve(body)
|
39
|
+
} else if (body && body.errors) {
|
40
|
+
reject(new Error(`[${statusCode}] ${body.errors[0].message} | universeId: ${universeId}, settings: ${JSON.stringify(settings)} ${body.errors.field ? ` | ${body.errors.field} is incorrect` : ''}`))
|
41
|
+
} else {
|
42
|
+
reject(new Error(`An unknown error occurred with updateUniverse() | [${statusCode}] universeId: ${universeId}, settings: ${JSON.stringify(settings)}`))
|
43
|
+
}
|
44
|
+
}).catch(reject)
|
45
|
+
})
|
46
|
+
}
|
47
|
+
|
48
|
+
exports.func = function ({ universeId, settings, jar }) {
|
49
|
+
return getGeneralToken({ jar })
|
50
|
+
.then((token) => {
|
51
|
+
return updateUniverse(universeId, settings, jar, token)
|
52
|
+
})
|
53
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
4
|
+
|
5
|
+
// Args
|
6
|
+
exports.required = ['universeId', 'isPublic']
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 Modifies a universe's public access setting
|
12
|
+
* @category Develop
|
13
|
+
* @alias updateUniverseAccess
|
14
|
+
* @param {number} universeId - The universeId of the experience
|
15
|
+
* @param {boolean=} isPublic - The visibility and access of the universe; shuts down all running instances if set to false
|
16
|
+
* @returns {Promise<void>}
|
17
|
+
* @example const noblox = require("noblox.js")
|
18
|
+
* // Login using your cookie
|
19
|
+
* noblox.updateUniverseAccess(2421261122, true)
|
20
|
+
**/
|
21
|
+
|
22
|
+
// Define
|
23
|
+
function updateUniverseAccess (universeId, isPublic, jar, token) {
|
24
|
+
return new Promise((resolve, reject) => {
|
25
|
+
return http({
|
26
|
+
url: `//develop.roblox.com/v1/universes/${universeId}/${isPublic ? 'activate' : 'deactivate'}`,
|
27
|
+
options: {
|
28
|
+
method: 'POST',
|
29
|
+
jar,
|
30
|
+
headers: {
|
31
|
+
'X-CSRF-TOKEN': token
|
32
|
+
},
|
33
|
+
json: {
|
34
|
+
universeId
|
35
|
+
},
|
36
|
+
resolveWithFullResponse: true
|
37
|
+
}
|
38
|
+
}).then(({ statusCode, body }) => {
|
39
|
+
if (statusCode === 200) {
|
40
|
+
resolve()
|
41
|
+
} else if (body && body.errors) {
|
42
|
+
reject(new Error(`[${statusCode}] ${body.errors[0].message} | universeId: ${universeId}, isPublic: ${isPublic} ${body.errors.field ? ` | ${body.errors.field} is incorrect` : ''}`))
|
43
|
+
} else {
|
44
|
+
reject(new Error(`An unknown error occurred with updateUniverseAccess() | [${statusCode}] universeId: ${universeId}, isPublic: ${isPublic}`))
|
45
|
+
}
|
46
|
+
}).catch(error => reject(error))
|
47
|
+
})
|
48
|
+
}
|
49
|
+
|
50
|
+
exports.func = function ({ universeId, isPublic, jar }) {
|
51
|
+
return getGeneralToken({ jar })
|
52
|
+
.then((token) => {
|
53
|
+
return updateUniverseAccess(universeId, isPublic, jar, token)
|
54
|
+
})
|
55
|
+
}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
const getProductInfo = require('../asset/getProductInfo.js').func
|
4
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
5
|
+
|
6
|
+
// Args
|
7
|
+
exports.required = [['asset', 'product']]
|
8
|
+
exports.optional = ['price', 'jar']
|
9
|
+
|
10
|
+
// Docs
|
11
|
+
/**
|
12
|
+
* 🔐 Buy an asset from the marketplace.
|
13
|
+
* @category Assets
|
14
|
+
* @param {number} asset - The ID of the product.
|
15
|
+
* @param {number=} price - The price of the product.
|
16
|
+
* @returns {Promise<BuyAssetResponse>}
|
17
|
+
* @example const noblox = require("noblox.js")
|
18
|
+
* // Login using your cookie
|
19
|
+
* noblox.buy(1117747196)
|
20
|
+
**/
|
21
|
+
|
22
|
+
// Define
|
23
|
+
function buy (jar, token, product, price) {
|
24
|
+
const robux = product.PriceInRobux || 0
|
25
|
+
const productId = product.ProductId
|
26
|
+
if (price) {
|
27
|
+
if (typeof price === 'number') {
|
28
|
+
if (robux !== price) {
|
29
|
+
throw new Error('Price requirement not met. Requested price: ' + price + ' Actual price: ' + robux)
|
30
|
+
}
|
31
|
+
} else if (typeof price === 'object') {
|
32
|
+
const high = price.high
|
33
|
+
const low = price.low
|
34
|
+
if (high) {
|
35
|
+
if (robux > high) {
|
36
|
+
throw new Error('Price requirement not met. Requested price: <=' + high + ' Actual price: ' + robux)
|
37
|
+
}
|
38
|
+
}
|
39
|
+
if (low) {
|
40
|
+
if (robux < low) {
|
41
|
+
throw new Error('Price requirement not met. Requested price: >=' + low + ' Actual price: ' + robux)
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
const httpOpt = {
|
47
|
+
url: '//economy.roblox.com/v1/purchases/products/' + productId,
|
48
|
+
options: {
|
49
|
+
method: 'POST',
|
50
|
+
jar: jar,
|
51
|
+
headers: {
|
52
|
+
'X-CSRF-TOKEN': token
|
53
|
+
},
|
54
|
+
json: {
|
55
|
+
expectedCurrency: 1,
|
56
|
+
expectedPrice: robux,
|
57
|
+
expectedSellerId: product.Creator.Id
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
return http(httpOpt)
|
62
|
+
.then(function (json) {
|
63
|
+
let err = json.errorMsg
|
64
|
+
if (json.reason === 'InsufficientFunds') {
|
65
|
+
err = 'You need ' + json.shortfallPrice + ' more robux to purchase this item.'
|
66
|
+
} else if (json.errorMsg) {
|
67
|
+
err = json.errorMsg
|
68
|
+
}
|
69
|
+
if (!err) {
|
70
|
+
return { productId, price: robux }
|
71
|
+
} else {
|
72
|
+
throw new Error(err)
|
73
|
+
}
|
74
|
+
})
|
75
|
+
}
|
76
|
+
|
77
|
+
function runWithToken (args) {
|
78
|
+
const jar = args.jar
|
79
|
+
return getGeneralToken({
|
80
|
+
jar: jar
|
81
|
+
})
|
82
|
+
.then(function (token) {
|
83
|
+
return buy(jar, token, args.product, args.price)
|
84
|
+
})
|
85
|
+
}
|
86
|
+
|
87
|
+
exports.func = function (args) {
|
88
|
+
if (!args.product) {
|
89
|
+
return getProductInfo({
|
90
|
+
asset: args.asset
|
91
|
+
})
|
92
|
+
.then(function (product) {
|
93
|
+
args.product = product
|
94
|
+
return runWithToken(args)
|
95
|
+
})
|
96
|
+
} else {
|
97
|
+
return runWithToken(args)
|
98
|
+
}
|
99
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['group']
|
6
|
+
exports.optional = ['jar']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* 🔓 Gets the amount of robux in a group.
|
11
|
+
* @category Group
|
12
|
+
* @alias getGroupFunds
|
13
|
+
* @param {number} group - The id of the group
|
14
|
+
* @returns {Promise<number>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* // Login using your cookie (optional if group funds are public)
|
17
|
+
* let robux = await noblox.getGroupFunds(9997719)
|
18
|
+
**/
|
19
|
+
|
20
|
+
// Define
|
21
|
+
function getGroupFunds (group, jar) {
|
22
|
+
return http({
|
23
|
+
url: `//economy.roblox.com/v1/groups/${group}/currency`,
|
24
|
+
options: {
|
25
|
+
jar: jar,
|
26
|
+
resolveWithFullResponse: true
|
27
|
+
}
|
28
|
+
})
|
29
|
+
.then(({ statusCode, body }) => {
|
30
|
+
const { robux, errors } = JSON.parse(body)
|
31
|
+
if (statusCode === 200) {
|
32
|
+
return robux
|
33
|
+
} else if (statusCode === 400 || statusCode === 403) {
|
34
|
+
throw new Error(`${errors[0].message} | groupId: ${group}`)
|
35
|
+
} else {
|
36
|
+
throw new Error(`An unknown error occurred with getGroupFunds() | [${statusCode}] groupId: ${group}`)
|
37
|
+
}
|
38
|
+
})
|
39
|
+
}
|
40
|
+
|
41
|
+
exports.func = function ({ group, jar }) {
|
42
|
+
return getGroupFunds(group, jar)
|
43
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http.js').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['groupId']
|
6
|
+
exports.optional = ['timeFrame', 'jar']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* 🔐 Gets recent Robux revenue summary for a group; shows pending Robux. | Requires "Spend group funds" permissions.
|
11
|
+
* @category Group
|
12
|
+
* @alias getGroupRevenueSummary
|
13
|
+
* @param {number} groupId - The group id to get Robux summary for.
|
14
|
+
* @param {("Day" | "Week" | "Month" | "Year")=} [timeFrame="Month"] - The time frame to get for.
|
15
|
+
* @returns {Promise<RevenueSummaryResponse>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* let revenueSummary = await noblox.getGroupRevenueSummary(9997719, "Year")
|
19
|
+
**/
|
20
|
+
|
21
|
+
// Define
|
22
|
+
function getGroupRevenueSummary (group, timeFrame, jar) {
|
23
|
+
return http({
|
24
|
+
url: `//economy.roblox.com/v1/groups/${group}/revenue/summary/${timeFrame}`,
|
25
|
+
options: {
|
26
|
+
jar: jar,
|
27
|
+
resolveWithFullResponse: true
|
28
|
+
}
|
29
|
+
})
|
30
|
+
.then(({ statusCode, body }) => {
|
31
|
+
const { errors } = JSON.parse(body)
|
32
|
+
if (statusCode === 200) {
|
33
|
+
return JSON.parse(body)
|
34
|
+
} else if (statusCode === 400) {
|
35
|
+
throw new Error(`${errors[0].message} | group: ${group}, timeFrame: ${timeFrame}`)
|
36
|
+
} else if (statusCode === 401) {
|
37
|
+
throw new Error(`${errors[0].message} (Are you logged in?) | group: ${group}, timeFrame: ${timeFrame}`)
|
38
|
+
} else if (statusCode === 403) {
|
39
|
+
throw new Error('Insufficient permissions: "Spend group funds" role permissions required')
|
40
|
+
} else {
|
41
|
+
throw new Error(`An unknown error occurred with getGroupRevenueSummary() | [${statusCode}] group: ${group}, timeFrame: ${timeFrame}`)
|
42
|
+
}
|
43
|
+
})
|
44
|
+
}
|
45
|
+
|
46
|
+
exports.func = function ({ groupId, timeFrame = 'Month', jar }) {
|
47
|
+
return getGroupRevenueSummary(groupId, timeFrame, jar)
|
48
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
const getPageResults = require('../util/getPageResults.js').func
|
2
|
+
|
3
|
+
exports.required = ['group']
|
4
|
+
exports.optional = ['transactionType', 'limit', 'sortOrder', 'jar']
|
5
|
+
|
6
|
+
// Docs
|
7
|
+
/**
|
8
|
+
* 🔐 Get a group's transactions.
|
9
|
+
* @category Group
|
10
|
+
* @alias getGroupTransactions
|
11
|
+
* @param {number} group - The id of the group.
|
12
|
+
* @param {("Sale" | "Purchase" | "AffiliateSale" | "DevEx" | "GroupPayout" | "AdImpressionPayout")} [transactionType=Sale] - The transaction type.
|
13
|
+
* @param {number} limit - The number of transactions being fetched in total.
|
14
|
+
* @param {SortOrder=} [sortOrder=Asc] - The cursor for the next page.
|
15
|
+
* @returns {Promise<TransactionItem[]>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* const transactions = await noblox.getGroupTransactions(1, "Sale")
|
19
|
+
**/
|
20
|
+
|
21
|
+
// Define
|
22
|
+
exports.func = function (args) {
|
23
|
+
return getPageResults({
|
24
|
+
jar: args.jar,
|
25
|
+
url: `//economy.roblox.com/v2/groups/${args.group}/transactions`,
|
26
|
+
query: {
|
27
|
+
transactionType: args.transactionType || 'Sale'
|
28
|
+
},
|
29
|
+
sortOrder: args.sortOrder || 'Asc',
|
30
|
+
limit: args.limit
|
31
|
+
})
|
32
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// Includes
|
2
|
+
const http = require('../util/http').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['assetId']
|
6
|
+
exports.optional = ['jar']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* ✅ Get the recent sale history (price and volume per day for 180 days) of a limited asset.
|
11
|
+
* @category Assets
|
12
|
+
* @alias getResaleData
|
13
|
+
* @param {number} assetId - The id of the asset.
|
14
|
+
* @returns {Promise<ResaleDataResponse>}
|
15
|
+
* @example const noblox = require("noblox.js")
|
16
|
+
* const resaleData = await noblox.getResaleData(20573078)
|
17
|
+
**/
|
18
|
+
|
19
|
+
// Define
|
20
|
+
const getResaleData = async (assetId) => {
|
21
|
+
return http({
|
22
|
+
url: `//economy.roblox.com/v1/assets/${assetId}/resale-data`,
|
23
|
+
options: {
|
24
|
+
resolveWithFullResponse: true
|
25
|
+
}
|
26
|
+
}).then(({ body, statusCode }) => {
|
27
|
+
const { errors } = JSON.parse(body)
|
28
|
+
if (statusCode === 200) {
|
29
|
+
try {
|
30
|
+
const resaleData = JSON.parse(body)
|
31
|
+
for (const priceDataPoint of resaleData.priceDataPoints) {
|
32
|
+
priceDataPoint.date = new Date(priceDataPoint.date)
|
33
|
+
}
|
34
|
+
for (const volumeDataPoint of resaleData.volumeDataPoints) {
|
35
|
+
volumeDataPoint.date = new Date(volumeDataPoint.date)
|
36
|
+
}
|
37
|
+
return resaleData
|
38
|
+
} catch (err) {
|
39
|
+
throw new Error(`An unknown error occurred with getResaleData() | [${statusCode}] assetId: ${assetId}`)
|
40
|
+
}
|
41
|
+
} else if (statusCode === 400) {
|
42
|
+
throw new Error(`${errors[0].message} | assetId: ${assetId}`)
|
43
|
+
} else {
|
44
|
+
throw new Error(`An unknown error occurred with getResaleData() | [${statusCode}] assetId: ${assetId}`)
|
45
|
+
}
|
46
|
+
})
|
47
|
+
}
|
48
|
+
|
49
|
+
exports.func = function ({ assetId }) {
|
50
|
+
if (isNaN(assetId)) {
|
51
|
+
throw new Error('The provided assetId is not a number.')
|
52
|
+
}
|
53
|
+
return getResaleData(assetId)
|
54
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
// Includes
|
2
|
+
const getPageResults = require('../util/getPageResults.js').func
|
3
|
+
|
4
|
+
// Args
|
5
|
+
exports.required = ['assetId']
|
6
|
+
exports.optional = ['limit', 'jar']
|
7
|
+
|
8
|
+
// Docs
|
9
|
+
/**
|
10
|
+
* 🔐 Gets available resale copies of a limited asset.
|
11
|
+
* @category Assets
|
12
|
+
* @alias getResellers
|
13
|
+
* @param {number} assetId - The id of the asset.
|
14
|
+
* @param {Limit=} limit - The max number of resellers to return.
|
15
|
+
* @returns {Promise<ResellerData[]>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* const resellers = await noblox.getResellers(20573078)
|
19
|
+
**/
|
20
|
+
|
21
|
+
// Define
|
22
|
+
const getResellers = async (assetId, limit, jar) => {
|
23
|
+
return getPageResults({
|
24
|
+
url: `//economy.roblox.com/v1/assets/${assetId}/resellers`,
|
25
|
+
limit,
|
26
|
+
jar
|
27
|
+
})
|
28
|
+
}
|
29
|
+
|
30
|
+
exports.func = function ({ assetId, limit, jar }) {
|
31
|
+
if (isNaN(assetId)) {
|
32
|
+
throw new Error('The provided assetId ID is not a number.')
|
33
|
+
}
|
34
|
+
return getResellers(assetId, limit, jar)
|
35
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
const getPageResults = require('../util/getPageResults.js').func
|
2
|
+
const getCurrentUser = require('../util/getCurrentUser.js').func
|
3
|
+
|
4
|
+
exports.required = []
|
5
|
+
exports.optional = ['transactionType', 'limit', 'sortOrder', 'jar']
|
6
|
+
|
7
|
+
// Docs
|
8
|
+
/**
|
9
|
+
* 🔐 Get a user's transactions.
|
10
|
+
* @category User
|
11
|
+
* @alias getUserTransactions
|
12
|
+
* @param {("Sale" | "Purchase" | "AffiliateSale" | "DevEx" | "GroupPayout" | "AdImpressionPayout")} [transactionType=Sale] - The type of transactions being fetched.
|
13
|
+
* @param {number} limit - The number of transactions being fetched in total.
|
14
|
+
* @param {SortOrder=} [sortOrder=Asc] - The cursor for the next page.
|
15
|
+
* @returns {Promise<TransactionItem[]>}
|
16
|
+
* @example const noblox = require("noblox.js")
|
17
|
+
* // Login using your cookie
|
18
|
+
* let transactions = await noblox.getUserTransactions("Sale", 10)
|
19
|
+
**/
|
20
|
+
|
21
|
+
exports.func = async function (args) {
|
22
|
+
const jar = args.jar
|
23
|
+
const currentUser = await getCurrentUser({ jar: jar })
|
24
|
+
// return getTransactions(currentUser.UserID, transactionType, limit, cursor)
|
25
|
+
return getPageResults({
|
26
|
+
jar: args.jar,
|
27
|
+
url: `//economy.roblox.com/v2/users/${currentUser.UserID}/transactions`,
|
28
|
+
query: {
|
29
|
+
transactionType: args.transactionType || 'Sale'
|
30
|
+
},
|
31
|
+
sortOrder: args.sortOrder || 'Asc',
|
32
|
+
limit: args.limit
|
33
|
+
})
|
34
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
// Includes
|
2
|
+
const shortPoll = require('../util/shortPoll.js').func
|
3
|
+
const getGroupTransactions = require('./getGroupTransactions.js').func
|
4
|
+
|
5
|
+
// Args
|
6
|
+
exports.required = ['groupId', 'transactionType']
|
7
|
+
exports.optional = ['jar']
|
8
|
+
|
9
|
+
// Docs
|
10
|
+
/**
|
11
|
+
* 🔐 An event for when a group transaction is made, for example a purchase. This event has a rate of one request per 60
|
12
|
+
* sec, which is more than the typical 10 seconds. This is due to the unusually low rate limit on the transactions
|
13
|
+
* endpoint.
|
14
|
+
*
|
15
|
+
* Note: The `created` field returned by this event will always have 0 milliseconds. This is due to a quirk on Roblox's side:
|
16
|
+
* These millisecond values fluctuate, meaning the event can misfire. Removing them avoids this problem.
|
17
|
+
* @category Group
|
18
|
+
* @alias onGroupTransaction
|
19
|
+
* @param {number} groupId - The id of the group.
|
20
|
+
* @param {("Sale" | "Purchase" | "AffiliateSale" | "DevEx" | "GroupPayout" | "AdImpressionPayout")} transactionType - The transaction type.
|
21
|
+
* @returns An EventEmitter that emits when a transaction is made.
|
22
|
+
* @example const noblox = require("noblox.js")
|
23
|
+
* // Login using your cookie
|
24
|
+
* const transactionEvent = noblox.onGroupTransaction(1)
|
25
|
+
* transactionEvent.on("data", function(data) {
|
26
|
+
* console.log("New Transaction!", data)
|
27
|
+
* })
|
28
|
+
* transactionEvent.on("error", function(err) {
|
29
|
+
* console.error("Something went wrong: ", err)
|
30
|
+
* // Handle error as needed
|
31
|
+
* })
|
32
|
+
**/
|
33
|
+
|
34
|
+
// Define
|
35
|
+
exports.func = function (args) {
|
36
|
+
let empty = true
|
37
|
+
return shortPoll({
|
38
|
+
getLatest: function (latest) {
|
39
|
+
return getGroupTransactions({ group: args.groupId, jar: args.jar, transactionType: args.transactionType })
|
40
|
+
.then(function (transactions) {
|
41
|
+
const given = []
|
42
|
+
// This method works much in the same way as onAuditLog. We remove some of the precision from transaction dates
|
43
|
+
// Because Roblox has a habit of being imprecise and varying the milliseconds of a given transaction/log item
|
44
|
+
// across different requests - and this causes duplicate fires.
|
45
|
+
if (transactions) {
|
46
|
+
for (const key in transactions) {
|
47
|
+
if (Object.prototype.hasOwnProperty.call(transactions, key)) {
|
48
|
+
const date = transactions[key].created
|
49
|
+
date.setMilliseconds(0)
|
50
|
+
|
51
|
+
if (date > latest) {
|
52
|
+
latest = date
|
53
|
+
given.push(transactions[key])
|
54
|
+
}
|
55
|
+
empty = false
|
56
|
+
} else if (!empty) {
|
57
|
+
const date = new Date()
|
58
|
+
date.setMilliseconds(0)
|
59
|
+
|
60
|
+
given.push({ date: date })
|
61
|
+
latest = date
|
62
|
+
empty = true
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return {
|
66
|
+
latest: latest,
|
67
|
+
data: given
|
68
|
+
}
|
69
|
+
}
|
70
|
+
})
|
71
|
+
},
|
72
|
+
delay: 'onGroupTransaction'
|
73
|
+
})
|
74
|
+
}
|