gj-boomlings-api 1.5.7 → 2.0.1

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 (55) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +31 -7
  3. package/functions/blockUser.js +29 -30
  4. package/functions/deleteAccountPost.js +22 -32
  5. package/functions/deleteComment.js +20 -20
  6. package/functions/deleteLevel.js +23 -29
  7. package/functions/dlLevel.js +157 -6
  8. package/functions/dlMessage.js +30 -36
  9. package/functions/getAccountPosts.js +23 -36
  10. package/functions/getBlockedList.js +47 -63
  11. package/functions/getCommentHistory.js +59 -39
  12. package/functions/getComments.js +46 -27
  13. package/functions/getCreatorScores.js +18 -30
  14. package/functions/getDailyLevel.js +5 -9
  15. package/functions/getFriendsList.js +48 -56
  16. package/functions/getGauntlets.js +18 -24
  17. package/functions/getLevelByID.js +9 -156
  18. package/functions/getLevelScores.js +63 -46
  19. package/functions/getMapPacks.js +40 -28
  20. package/functions/getMessages.js +36 -41
  21. package/functions/getOfficialSongInfo.js +9 -87
  22. package/functions/getProfile.js +159 -7
  23. package/functions/getSongInfo.js +22 -31
  24. package/functions/getSongsLibrary.js +80 -0
  25. package/functions/getTab.js +16 -7
  26. package/functions/getTop100.js +18 -27
  27. package/functions/getTopLists.js +14 -0
  28. package/functions/getUserLevels.js +24 -88
  29. package/functions/getWeeklyDemon.js +5 -9
  30. package/functions/reportLevel.js +9 -22
  31. package/functions/searchLevels.js +15 -84
  32. package/functions/searchLists.js +15 -0
  33. package/functions/unblockUser.js +29 -30
  34. package/functions/updateLevelDesc.js +27 -43
  35. package/functions/uploadAccountPost.js +23 -36
  36. package/functions/uploadComment.js +43 -57
  37. package/functions/uploadMessage.js +32 -41
  38. package/gjReq.js +18 -0
  39. package/index.js +36 -1
  40. package/misc/GJDecode.js +210 -1
  41. package/misc/colors.json +1 -1
  42. package/misc/gauntlets.json +1 -0
  43. package/misc/officialsongs.json +1 -1
  44. package/misc/rgbToHEX.js +1 -1
  45. package/package.json +2 -6
  46. package/.nvmrc +0 -1
  47. package/config.json +0 -1
  48. package/functions/searchUsers.js +0 -27
  49. package/misc/decB64.js +0 -4
  50. package/misc/demonlist.js +0 -1
  51. package/misc/encB64.js +0 -1
  52. package/misc/gjReq.js +0 -1
  53. package/misc/gjWReq.js +0 -1
  54. package/misc/gjp.js +0 -1
  55. /package/{misc/xor.js → xor.js} +0 -0
@@ -1,162 +1,15 @@
1
1
  module.exports = {
2
- /**
3
- * Gets the basic level info by its ID.
4
- *
5
- * It's the same as dlLevel(), but it works faster and doesn't provide the password, update date, upload date, the info about LDM and an accurate object counter.
6
- *
7
- * By the way, GD uses this for search results.
8
- * @param {*} id - The level ID.
9
- */
10
2
  getLevelByID: async function (id) {
11
- if (!id) throw new Error("Please provide a level ID!");
12
- if (isNaN(id)) throw new Error("The level ID should be a number!");
13
- const {
14
- gjReq
15
- } = require("../misc/gjReq.js");
16
- const {
17
- gjWReq
18
- } = require("../misc/gjWReq.js");
19
- const {
20
- secret
21
- } = require("../config.json");
22
- const {
23
- decB64
24
- } = require("../misc/decB64.js");
25
- const data = {
26
- secret: secret,
3
+ if (isNaN(id)) throw new Error("Please provide a valid level ID!");
4
+ const { gjReq } = require("../gjReq");
5
+ const GJDecode = require("../misc/GJDecode");
6
+ const { decodeSearchResults } = new GJDecode;
7
+ const res = await gjReq("getGJLevels21", {
8
+ secret: "Wmfd2893gb7",
27
9
  str: id,
28
10
  type: 0
29
- };
30
- let res = await gjReq("getGJLevels21", data);
31
- if (res.data == -1) throw new Error("-1 Not found.");
32
- if (res.data == "error code: 1005") {
33
- res = await gjWReq("getLevelByID", id);
34
- if (res.status == 403) throw new Error(res.data.error);
35
- return res.data
36
- }
37
- async function decodeLevel(l) {
38
- let spl = l.split(":");
39
- let lInfo = [];
40
- for (let i = 0; i < spl.length; i++) {
41
- if (i % 2 != 0) {
42
- lInfo.push(spl[i - 1] + `:` + spl[i])
43
- }
44
- }
45
- let id = lInfo[0].split("1:")[1];
46
- let name = lInfo[1].split("2:")[1];
47
- let version = lInfo[2].split("5:")[1];
48
- let difficulty = lInfo[5].split("9:")[1];
49
- let downloads = lInfo[6].split("10:")[1];
50
- let officialSong = lInfo[7].split("12:")[1];
51
- let gameVersion = lInfo[8].split("13:")[1];
52
- let likes = lInfo[9].split("14:")[1];
53
- let demonBool = lInfo[10].split("17:")[1];
54
- let stars = lInfo[13].split("18:")[1];
55
- let ftrd = lInfo[14].split("19:")[1];
56
- let epic = lInfo[15].split("42:")[1];
57
- let objs = lInfo[16].split("45:")[1];
58
- let desc = lInfo[17].split("3:")[1];
59
- let length = lInfo[18].split("15:")[1];
60
- let copiedID = lInfo[19].split("30:")[1];
61
- let twoPlayer = lInfo[20].split("31:")[1];
62
- let coins = lInfo[21].split("37:")[1];
63
- let verifiedCoins = lInfo[22].split("38:")[1];
64
- let starsRequested = lInfo[23].split("39:")[1];
65
- let customSong = lInfo[26].split("35:")[1].split("#")[0];
66
- let author = res.data.split("#")[1].includes(":") ? res.data.split("#")[1].split(":")[1] : "-";
67
- let disliked = likes.includes("-") ? true : false;
68
- if (desc.includes("/")) desc = desc.split("/")[0];
69
- if (decB64(desc) == "") desc = "KE5vIGRlc2NyaXB0aW9uIHByb3ZpZGVkKQ==";
70
- let featured = Boolean(Number(ftrd));
71
- let difficultyDecoding = {
72
- "-10": "Auto",
73
- 0: "Unrated",
74
- 10: "Easy",
75
- 20: "Normal",
76
- 30: "Hard",
77
- 40: "Harder",
78
- 50: "Insane"
79
- };
80
- if (Boolean(Number(demonBool))) {
81
- difficultyDecoding = {
82
- 10: "Easy Demon",
83
- 20: "Medium Demon",
84
- 30: "Hard Demon",
85
- 40: "Insane Demon",
86
- 50: "Extreme Demon"
87
- }
88
- }
89
- const lengthDecoding = {
90
- 0: "Tiny",
91
- 1: "Short",
92
- 2: "Medium",
93
- 3: "Long",
94
- 4: "XL"
95
- };
96
- const decodeGameVersion = {
97
- 10: "1.7",
98
- 18: "1.8",
99
- 19: "1.9",
100
- 20: "2.0",
101
- 21: "2.1",
102
- undefined: "Pre-1.7"
103
- };
104
- const {
105
- getOfficialSongInfo
106
- } = require("../functions/getOfficialSongInfo.js");
107
- let song;
108
- if (Number(officialSong) > 0) song = getOfficialSongInfo(Number(officialSong) + 1);
109
- if (Number(officialSong) == 0 && Number(customSong) == 0) song = getOfficialSongInfo(1);
110
- if (Number(customSong) > 0) {
111
- let songName = l.split("~|~2~|~")[1].split("~|~3~|~")[0];
112
- let songId = Number(l.split("#1~|~")[1].split("~|~2~|~")[0]);
113
- let artist = l.split("~|~4~|~")[1].split("~|~5~|~")[0];
114
- let artistId = Number(l.split("~|~3~|~")[1].split("~|~4~|~")[0]);
115
- let size = `${l.split("~|~5~|~")[1].split("~|~6~|~")[0]} MB`;
116
- let link = decodeURIComponent(l.split("~|~10~|~")[1].split("~|~7~|~")[0]);
117
- song = {
118
- name: songName,
119
- id: songId,
120
- artist: artist,
121
- artistId: artistId,
122
- fileSize: size,
123
- link: link
124
- }
125
- }
126
- let result = {
127
- id: Number(id),
128
- name: name,
129
- description: decB64(desc),
130
- creator: author,
131
- level_version: Number(version),
132
- difficulty: difficultyDecoding[difficulty],
133
- stars: Number(stars),
134
- downloads: Number(downloads),
135
- likes: Number(likes),
136
- disliked: disliked,
137
- length: lengthDecoding[length],
138
- demon: Boolean(Number(demonBool)),
139
- featured: featured,
140
- epic: Boolean(Number(epic)),
141
- objects: Number(objs),
142
- stars_requested: Number(starsRequested),
143
- game_version: decodeGameVersion[gameVersion],
144
- copied: Number(copiedID),
145
- large: Number(objs) > 4e4 ? true : false,
146
- two_p: Boolean(Number(twoPlayer)),
147
- coins: Number(coins),
148
- verified_coins: Boolean(Number(verifiedCoins)),
149
- song: song
150
- };
151
- if (["Extreme Demon", "Insane Demon"].includes(difficultyDecoding[difficulty])) {
152
- const {
153
- demonlist
154
- } = require("../misc/demonlist.js");
155
- const dlist = await demonlist(name.trim());
156
- if (dlist != null) result.pointercrate = dlist
157
- }
158
- return result
159
- }
160
- return await decodeLevel(res.data)
11
+ });
12
+ if (res.data == -1) return {};
13
+ return decodeSearchResults(res.data)[0];
161
14
  }
162
15
  }
@@ -1,50 +1,67 @@
1
1
  module.exports = {
2
- /**
3
- * Gets the leaderboard on a level.
4
- *
5
- * For some reason, Geometry Dash API requires the login information.
6
- * @param {*} lvl - The level ID.
7
- * @param {*} type - The leaderboard type. Possible types: `"week"`, `"top"`, `"friends"`.
8
- * @param {*} str - The username or a player ID.
9
- * @param {*} pass - The password.
10
- */
11
- getLevelScores:
12
- async function(lvl, type, str, pass){
13
- let types = {"week":"2","top":"1","friends":"0"}
14
- if(!lvl) throw new Error("Please provide a level ID!");
15
- if(!types[type.toLowerCase()]) throw new Error("Please provide a valid leaderboard type! Possible types: \"week\", \"top\", \"friends\".")
16
- if(!str) throw new Error("Please provide a username or a Player ID!");
17
- if(!pass) throw new Error("Please provide a password!");
18
-
19
- const {gjReq} = require("../misc/gjReq.js");
20
- const {gjWReq} = require("../misc/gjWReq.js");
21
- const { secret } = require("../config.json");
22
-
23
- const { searchUsers } = require("./searchUsers.js");
24
- let user = await searchUsers(str);
25
-
26
- let GJDecode = require("../misc/GJDecode.js");
27
- const {gjp} = require("../misc/gjp.js");
28
-
29
- let {decodeScore} = new GJDecode();
30
-
31
- const data = {
32
- accountID: user.accountID,
33
- gjp: gjp(pass),
34
- levelID: lvl,
35
- secret: secret,
36
- type: types[type.toLowerCase()]
37
- }
38
-
39
- let res = await gjReq("getGJLevelScores211", data);
40
-
41
- let scores = res.data.split("|");
42
- let result = [];
43
-
44
- scores.forEach(s =>{
45
- result.push(decodeScore(s));
46
- })
2
+ getLevelScores: async function (lvl, type, user, pass) {
3
+ let types = { week: "2", top: "1", friends: "0" }
4
+ if (!lvl) throw new Error("Please provide a level ID!");
5
+ if (!types[type.toLowerCase()]) throw new Error("Please provide a valid leaderboard type! Possible types: \"week\", \"top\", \"friends\".")
6
+ if (!user) throw new Error("Please provide a username or a Player ID!");
7
+ if (!pass) throw new Error("Please provide a password!");
8
+
9
+ const { gjReq } = require("../gjReq.js");
10
+ const { rgbToHEX } = require("../misc/rgbToHEX");
11
+ const colors = require("../misc/colors.json");
12
+ let search = await gjReq("getGJUsers20", {
13
+ str: user,
14
+ secret: "Wmfd2893gb7"
15
+ });
16
+ if (search.data == -1) return [];
17
+ let accID = search.data.split(":")[21];
18
+
19
+ const XOR = require("../xor.js");
20
+ const xor = new XOR;
21
+
22
+ const data = {
23
+ accountID: accID,
24
+ gjp: xor.encrypt(pass, 37526),
25
+ levelID: lvl,
26
+ secret: "Wmfd2893gb7",
27
+ type: types[type.toLowerCase()]
28
+ }
47
29
 
48
- return result;
30
+ let res = await gjReq("getGJLevelScores211", data);
31
+
32
+ let scores = res.data.split("|");
33
+ let result = [];
34
+
35
+ let iconObj = {
36
+ 0: "cube",
37
+ 1: "ship",
38
+ 2: "ball",
39
+ 3: "ufo",
40
+ 4: "wave",
41
+ 5: "robot",
42
+ 6: "spider",
43
+ 7: "swing",
44
+ 8: "jetpack"
49
45
  }
46
+
47
+ scores.forEach(sc => {
48
+ let s = sc.split(":");
49
+ result.push({
50
+ username: s[1],
51
+ playerID: Number(s[3]),
52
+ accountID: Number(s[15]),
53
+ rank: Number(s[19]),
54
+ c1: rgbToHEX(colors[user[7]]),
55
+ c2: rgbToHEX(colors[user[9]]),
56
+ iconID: Number(s[5]),
57
+ iconType: iconObj[s[11]],
58
+ glow: s[13] == "2" ? true : false,
59
+ percent: Number(s[17]),
60
+ coins: Number(s[21]),
61
+ age: s[23]
62
+ })
63
+ })
64
+
65
+ return result;
66
+ }
50
67
  }
@@ -1,35 +1,47 @@
1
1
  module.exports = {
2
- /**
3
- * Gets the map pack list.
4
- * @param {*} page - The page.
5
- */
6
- getMapPacks:
7
- async function(page = 1) {
8
- let GJDecode = require("../misc/GJDecode.js");
9
- const { decodeMapPack } = new GJDecode();
10
-
11
- const {gjReq} = require("../misc/gjReq.js");
12
- const {gjWReq} = require("../misc/gjWReq.js");
13
- const data = {
14
- secret: "Wmfd2893gb7",
15
- page: Number(page) - 1
16
- }
2
+ getMapPacks: async function (page = 1) {
3
+ const { gjReq } = require("../gjReq");
4
+ const data = {
5
+ secret: "Wmfd2893gb7",
6
+ page: Number(page) - 1
7
+ }
17
8
 
18
- let res = await gjReq("getGJMapPacks21", data);
19
- if(res.data.startsWith("#")) throw new Error("-1 Not found.");
9
+ let res = await gjReq("getGJMapPacks21", data);
10
+ if (res.data.startsWith("#")) throw new Error("-1 Not found.");
20
11
 
21
- if(res.data == "error code: 1005") {
22
- res = await gjWReq("getMapPacks", page);
23
- if(res.status == 403) throw new Error(res.data.error);
24
- return res.data;
12
+ let packs = res.data.split("#")[0].split("|");
13
+ let result = [];
14
+ packs.forEach(p => {
15
+ const { rgbToHEX } = require("../misc/rgbToHEX");
16
+ let diffObj = {
17
+ 0: "Auto",
18
+ 1: "Easy",
19
+ 2: "Normal",
20
+ 3: "Hard",
21
+ 4: "Harder",
22
+ 5: "Insane",
23
+ 6: "Hard Demon",
24
+ 7: "Easy Demon",
25
+ 8: "Medium Demon",
26
+ 9: "Insane Demon",
27
+ 10: "Extreme Demon"
25
28
  }
26
-
27
- let packs = res.data.split("|");
28
- let result = [];
29
- packs.forEach(p => {
30
- result.push(decodeMapPack(p));
29
+ let lvls = [];
30
+ for (let lvl of p.split(":")[5].split(",")) {
31
+ lvls.push(Number(lvl));
32
+ }
33
+ result.push({
34
+ name: p.split(":")[3],
35
+ id: Number(p.split(":")[1]),
36
+ levels: lvls,
37
+ stars: Number(p.split(":")[7]),
38
+ coins: Number(p.split(":")[9]),
39
+ difficulty: diffObj[p.split(":")[11]],
40
+ textColor: rgbToHEX(p.split(":")[13]),
41
+ barColor: rgbToHEX(p.split(":")[15])
31
42
  })
43
+ })
32
44
 
33
- return result;
34
- }
45
+ return result;
46
+ }
35
47
  }
@@ -1,48 +1,43 @@
1
1
  module.exports = {
2
- /**
3
- * Gets user's messages.
4
- * @param {*} user - The player ID or username.
5
- * @param {*} pass - The password.
6
- * @param {*} page - The page.
7
- */
8
- getMessages:
9
- async function(user, pass, page = 1) {
10
- if(!user) throw new Error("Please provide your player ID or username!");
11
- if(!pass) throw new Error("Please provide your password!");
12
- if(Number(page) == NaN) throw new Error("The page should be a number!");
13
-
14
- const {gjReq} = require("../misc/gjReq.js");
15
- const {gjWReq} = require("../misc/gjWReq.js");
16
- const {secret} = require("../config.json");
17
- const {gjp} = require("../misc/gjp.js");
18
- let GJDecode = require("../misc/GJDecode.js");
19
- const {decMsg} = new GJDecode();
20
- const { searchUsers } = require("./searchUsers.js");
2
+ getMessages: async function (user, pass, page = 1) {
3
+ if (!user) throw new Error("Please provide a player ID or username!");
4
+ if (!pass) throw new Error("Please provide a password!");
5
+ if (isNaN(page)) throw new Error("The page should be a number!");
21
6
 
22
- let userObj = await searchUsers(user);
7
+ const { gjReq } = require("../gjReq");
8
+ const XOR = require("../xor");
9
+ const xor = new XOR;
23
10
 
24
- const data = {
25
- accountID: userObj.accountID,
26
- gjp: gjp(pass),
27
- secret: secret,
28
- page: Number(page) - 1
29
- }
11
+ let search = await gjReq("getGJUsers20", {
12
+ str: user,
13
+ secret: "Wmfd2893gb7"
14
+ });
15
+ if (search.data == -1) return [];
16
+ let accID = search.data.split(":")[21];
30
17
 
31
- let res = await gjReq("getGJMessages20", data);
32
- if(res.data == -1) throw new Error(-1);
18
+ let res = await gjReq("getGJMessages20", {
19
+ accountID: accID,
20
+ gjp: xor.encrypt(pass, 37526),
21
+ secret: "Wmfd2893gb7",
22
+ page: page - 1
23
+ });
24
+ if (res.data == -1 || res.data.startsWith("#")) return [];
33
25
 
34
- if(res.data == "error code: 1005") {
35
- res = await gjWReq("getMessages", `${user}?password=${pass}&page=${page}`);
36
- if(res.status == 403) throw new Error(res.data.error);
37
- return res.data;
38
- }
26
+ let msgs = res.data.split("#")[0].split("|");
27
+ let result = [];
28
+ msgs.forEach(m => {
29
+ let s = m.split(":");
30
+ result.push({
31
+ username: s[1],
32
+ title: Buffer.from(s[9], "base64").toString(),
33
+ playerID: Number(s[3]),
34
+ accountID: Number(s[5]),
35
+ messageID: Number(s[7]),
36
+ age: s[15],
37
+ read: Boolean(Number(s[11]))
38
+ });
39
+ })
39
40
 
40
- let msgs = res.data.split("|");
41
- let result = [];
42
- msgs.forEach(m => {
43
- result.push(decMsg(m));
44
- })
45
-
46
- return result;
47
- }
41
+ return result;
42
+ }
48
43
  }
@@ -1,89 +1,11 @@
1
1
  module.exports = {
2
- /**
3
- * Gets the info about an official song by its ID.
4
- * @param {*} song - The song ID. 1-21 is main GD, 22-24 is GD Meltdown, 25 is Random Song 06 (The Challenge), 26-35 is GD World.
5
- */
6
- getOfficialSongInfo:
7
- function(song) {
8
- if(!song) throw new Error("Please provide a song ID.");
9
- if(isNaN(song)) throw new Error("A song ID must be a number.");
10
- const {
11
- sm,
12
- bot,
13
- pg,
14
- dout,
15
- bab,
16
- clg,
17
- j,
18
- tm,
19
- c,
20
- xs,
21
- cf,
22
- toe,
23
- ea,
24
- cs,
25
- ed,
26
- hf,
27
- bp,
28
- toeii,
29
- gd,
30
- d,
31
- fd,
32
- tss,
33
- va,
34
- ar,
35
- tc,
36
- p,
37
- bm,
38
- m,
39
- y,
40
- f,
41
- sp,
42
- s,
43
- e,
44
- round,
45
- mdo,
46
- unknown
47
- } = require("../misc/officialsongs.json");
48
- const jsons = {
49
- 1: sm,
50
- 2: bot,
51
- 3: pg,
52
- 4: dout,
53
- 5: bab,
54
- 6: clg,
55
- 7: j,
56
- 8: tm,
57
- 9: c,
58
- 10: xs,
59
- 11: cf,
60
- 12: toe,
61
- 13: ea,
62
- 14: cs,
63
- 15: ed,
64
- 16: hf,
65
- 17: bp,
66
- 18: toeii,
67
- 19: gd,
68
- 20: d,
69
- 21: fd,
70
- 22: tss,
71
- 23: va,
72
- 24: ar,
73
- 25: tc,
74
- 26: p,
75
- 27: bm,
76
- 28: m,
77
- 29: y,
78
- 30: f,
79
- 31: sp,
80
- 32: s,
81
- 33: e,
82
- 34: round,
83
- 35: mdo
84
- }
85
- let result = jsons[Number(song)];
86
- if(result == undefined) result = unknown;
87
- return result;
88
- }
2
+ getOfficialSongInfo: function (song) {
3
+ if (isNaN(song)) throw new Error("Please provide a valid official song ID.");
4
+ const { sm, bot, pg, dout, bab, clg, j, tm, c, xs, cf, toe, ea, cs, ed, hf, bp, toeii, gd, d, fd, dash, exp, tss, va, ar, tc, p, bm, m, y, f, sp, s, e, round, mdo, ps, ne, pt, unknown } = require("../misc/officialsongs.json");
5
+ const jsons = { 1: sm, 2: bot, 3: pg, 4: dout, 5: bab, 6: clg, 7: j, 8: tm, 9: c, 10: xs, 11: cf, 12: toe, 13: ea, 14: cs, 15: ed, 16: hf, 17: bp, 18: toeii, 19: gd, 20: d, 21: fd, 22: dash, 23: exp, 24: tss, 25: va, 26: ar, 27: tc, 28: p, 29: bm, 30: m, 31: y, 32: f, 33: sp, 34: s, 35: e, 36: round, 37: mdo, 38: ps, 39: ne, 40: pt };
6
+
7
+ let result = jsons[Number(song)];
8
+ if (!result) result = unknown;
9
+ return result;
10
+ }
89
11
  }