yolkbot 1.4.4 → 1.4.6
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.
- package/browser/build/global.js +1 -1
- package/browser/build/module.js +1 -1
- package/dist/api.js +200 -1
- package/dist/bot/GamePlayer.js +74 -1
- package/dist/bot.js +1679 -1
- package/dist/comm/CommIn.js +79 -1
- package/dist/comm/CommOut.js +60 -1
- package/dist/comm/index.js +11 -1
- package/dist/constants/CloseCode.js +27 -1
- package/dist/constants/CommCode.js +53 -1
- package/dist/constants/challenges.js +1821 -1
- package/dist/constants/findItemById.js +2 -3
- package/dist/constants/guns.js +277 -1
- package/dist/constants/index.js +139 -1
- package/dist/constants/items.js +45042 -1
- package/dist/constants/maps.js +1263 -1
- package/dist/constants/regions.js +30 -1
- package/dist/dispatches/BanPlayerDispatch.js +32 -1
- package/dist/dispatches/BootPlayerDispatch.js +21 -1
- package/dist/dispatches/ChatDispatch.js +32 -1
- package/dist/dispatches/FireDispatch.js +15 -1
- package/dist/dispatches/GameOptionsDispatch.js +66 -1
- package/dist/dispatches/GoToAmmoDispatch.js +38 -1
- package/dist/dispatches/GoToCoopDispatch.js +38 -1
- package/dist/dispatches/GoToGrenadeDispatch.js +38 -1
- package/dist/dispatches/GoToPlayerDispatch.js +39 -1
- package/dist/dispatches/GoToSpatulaDispatch.js +26 -1
- package/dist/dispatches/LookAtDispatch.js +35 -1
- package/dist/dispatches/LookAtPosDispatch.js +29 -1
- package/dist/dispatches/MeleeDispatch.js +26 -1
- package/dist/dispatches/MovementDispatch.js +26 -1
- package/dist/dispatches/PauseDispatch.js +18 -1
- package/dist/dispatches/ReloadDispatch.js +28 -1
- package/dist/dispatches/ReportPlayerDispatch.js +42 -1
- package/dist/dispatches/ResetGameDispatch.js +19 -1
- package/dist/dispatches/SaveLoadoutDispatch.js +105 -1
- package/dist/dispatches/SpawnDispatch.js +22 -1
- package/dist/dispatches/SwapWeaponDispatch.js +25 -1
- package/dist/dispatches/SwitchTeamDispatch.js +33 -1
- package/dist/dispatches/ThrowGrenadeDispatch.js +21 -1
- package/dist/dispatches/index.js +74 -1
- package/dist/env/fetch.js +97 -10
- package/dist/env/globals.js +15 -1
- package/dist/index.js +14 -2
- package/dist/matchmaker.js +141 -1
- package/dist/pathing/astar.js +55 -1
- package/dist/pathing/binaryheap.js +79 -1
- package/dist/pathing/mapnode.js +179 -1
- package/dist/socket.js +97 -1
- package/dist/util.js +68 -1
- package/dist/wasm/bytes.js +8 -1
- package/dist/wasm/direct.js +84 -1
- package/dist/wasm/legacy.js +170 -1
- package/dist/wasm/util.js +19 -1
- package/package.json +38 -39
- /package/dist/{types/api.d.ts → api.d.ts} +0 -0
- /package/dist/{types/bot → bot}/GamePlayer.d.ts +0 -0
- /package/dist/{types/bot.d.ts → bot.d.ts} +0 -0
- /package/dist/{types/comm → comm}/CommIn.d.ts +0 -0
- /package/dist/{types/comm → comm}/CommOut.d.ts +0 -0
- /package/dist/{types/comm → comm}/index.d.ts +0 -0
- /package/dist/{types/constants → constants}/CloseCode.d.ts +0 -0
- /package/dist/{types/constants → constants}/CommCode.d.ts +0 -0
- /package/dist/{types/constants → constants}/challenges.d.ts +0 -0
- /package/dist/{types/constants → constants}/changelog.d.ts +0 -0
- /package/dist/{types/constants → constants}/findItemById.d.ts +0 -0
- /package/dist/{types/constants → constants}/guns.d.ts +0 -0
- /package/dist/{types/constants → constants}/housePromo.d.ts +0 -0
- /package/dist/{types/constants → constants}/index.d.ts +0 -0
- /package/dist/{types/constants → constants}/items.d.ts +0 -0
- /package/dist/{types/constants → constants}/language.d.ts +0 -0
- /package/dist/{types/constants → constants}/maps.d.ts +0 -0
- /package/dist/{types/constants → constants}/notices.d.ts +0 -0
- /package/dist/{types/constants → constants}/regions.d.ts +0 -0
- /package/dist/{types/constants → constants}/shellNews.d.ts +0 -0
- /package/dist/{types/constants → constants}/shellYoutube.d.ts +0 -0
- /package/dist/{types/constants → constants}/shopItems.d.ts +0 -0
- /package/dist/{types/constants → constants}/sounds.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/BanPlayerDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/BootPlayerDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ChatDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/FireDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GameOptionsDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToAmmoDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToCoopDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToGrenadeDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToPlayerDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/GoToSpatulaDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/LookAtDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/LookAtPosDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/MeleeDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/MovementDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/PauseDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ReloadDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ReportPlayerDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ResetGameDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/SaveLoadoutDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/SpawnDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/SwapWeaponDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/SwitchTeamDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/ThrowGrenadeDispatch.d.ts +0 -0
- /package/dist/{types/dispatches → dispatches}/index.d.ts +0 -0
- /package/dist/{types/matchmaker.d.ts → matchmaker.d.ts} +0 -0
- /package/dist/{types/pathing → pathing}/astar.d.ts +0 -0
- /package/dist/{types/pathing → pathing}/binaryheap.d.ts +0 -0
- /package/dist/{types/pathing → pathing}/mapnode.d.ts +0 -0
- /package/dist/{types/socket.d.ts → socket.d.ts} +0 -0
- /package/dist/{types/util.d.ts → util.d.ts} +0 -0
- /package/dist/{types/wasm → wasm}/bytes.d.ts +0 -0
- /package/dist/{types/wasm → wasm}/direct.d.ts +0 -0
- /package/dist/{types/wasm → wasm}/legacy.d.ts +0 -0
- /package/dist/{types/wasm → wasm}/util.d.ts +0 -0
package/dist/api.js
CHANGED
|
@@ -1 +1,200 @@
|
|
|
1
|
-
import
|
|
1
|
+
import globals from "./env/globals.js";
|
|
2
|
+
import yolkws from "./socket.js";
|
|
3
|
+
import { FirebaseKey, UserAgent } from "./constants/index.js";
|
|
4
|
+
const baseHeaders = {
|
|
5
|
+
origin: "https://shellshock.io",
|
|
6
|
+
"user-agent": UserAgent,
|
|
7
|
+
"x-client-version": "Chrome/JsCore/9.17.2/FirebaseCore-web",
|
|
8
|
+
"x-firebase-locale": "en"
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export class API {
|
|
12
|
+
constructor(params = {}) {
|
|
13
|
+
this.proxy = params.proxy;
|
|
14
|
+
this.instance = params.instance || "shellshock.io";
|
|
15
|
+
this.protocol = params.protocol || "wss";
|
|
16
|
+
this.maxRetries = params.maxRetries || 5;
|
|
17
|
+
this.suppressErrors = params.suppressErrors || false;
|
|
18
|
+
this.connectionTimeout = params.connectionTimeout || 5000;
|
|
19
|
+
}
|
|
20
|
+
queryServices = async (request) => {
|
|
21
|
+
const ws = new yolkws(`${this.protocol}://${this.instance}/services/`, this.proxy);
|
|
22
|
+
ws.connectionTimeout = this.connectionTimeout;
|
|
23
|
+
const didConnect = await ws.tryConnect(-2);
|
|
24
|
+
if (!didConnect || ws.socket.readyState !== 1)
|
|
25
|
+
return "websocket_connect_fail";
|
|
26
|
+
return new Promise((resolve) => {
|
|
27
|
+
let resolved = false;
|
|
28
|
+
ws.onmessage = (mes) => {
|
|
29
|
+
resolved = true;
|
|
30
|
+
try {
|
|
31
|
+
const resp = JSON.parse(mes.data);
|
|
32
|
+
resolve(resp);
|
|
33
|
+
} catch {
|
|
34
|
+
if (!this.suppressErrors) {
|
|
35
|
+
console.error("queryServices: Bad API JSON response with call:", request.cmd, "and data:", JSON.stringify(request));
|
|
36
|
+
console.error("queryServices: Full data sent:", JSON.stringify(request));
|
|
37
|
+
}
|
|
38
|
+
resolve("bad_json");
|
|
39
|
+
}
|
|
40
|
+
ws.close();
|
|
41
|
+
};
|
|
42
|
+
ws.onerror = () => !resolved && resolve("unknown_socket_error");
|
|
43
|
+
ws.onclose = () => !resolved && resolve("services_closed_early");
|
|
44
|
+
ws.send(JSON.stringify(request));
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
#authWithEmailPass = async (email, password, endpoint) => {
|
|
48
|
+
if (!email || !password)
|
|
49
|
+
return "firebase_no_credentials";
|
|
50
|
+
let body, firebaseToken;
|
|
51
|
+
try {
|
|
52
|
+
const request = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${endpoint}?key=${FirebaseKey}`, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: JSON.stringify({
|
|
55
|
+
email,
|
|
56
|
+
password,
|
|
57
|
+
returnSecureToken: true
|
|
58
|
+
}),
|
|
59
|
+
headers: {
|
|
60
|
+
...baseHeaders,
|
|
61
|
+
"content-type": "application/json"
|
|
62
|
+
},
|
|
63
|
+
proxy: this.proxy
|
|
64
|
+
});
|
|
65
|
+
body = await request.json();
|
|
66
|
+
firebaseToken = body.idToken;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (error.code === "auth/network-request-failed") {
|
|
69
|
+
if (!this.suppressErrors)
|
|
70
|
+
console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");
|
|
71
|
+
return "firebase_network_failed";
|
|
72
|
+
} else if (error.code === "auth/missing-email") {
|
|
73
|
+
return "firebase_no_credentials";
|
|
74
|
+
} else if (error.code === "ERR_BAD_REQUEST") {
|
|
75
|
+
if (!this.suppressErrors)
|
|
76
|
+
console.error("loginWithCredentials: Error:", email, password);
|
|
77
|
+
if (!this.suppressErrors)
|
|
78
|
+
console.error("loginWithCredentials: Error:", body || error);
|
|
79
|
+
return "firebase_bad_request";
|
|
80
|
+
}
|
|
81
|
+
if (!this.suppressErrors)
|
|
82
|
+
console.error("loginWithCredentials: Error:", email, password, error);
|
|
83
|
+
return "firebase_unknown_error";
|
|
84
|
+
}
|
|
85
|
+
if (!firebaseToken) {
|
|
86
|
+
if (!this.suppressErrors)
|
|
87
|
+
console.error("loginWithCredentials: the game sent no idToken", body);
|
|
88
|
+
return "firebase_no_token";
|
|
89
|
+
}
|
|
90
|
+
this.idToken = firebaseToken;
|
|
91
|
+
const servicesQuery = await this.queryServices({ cmd: "auth", firebaseToken });
|
|
92
|
+
return typeof servicesQuery === "object" ? { firebase: body, ...servicesQuery } : servicesQuery;
|
|
93
|
+
};
|
|
94
|
+
createAccount = async (email, password) => await this.#authWithEmailPass(email, password, "signUp");
|
|
95
|
+
loginWithCredentials = async (email, password) => await this.#authWithEmailPass(email, password, "signInWithPassword");
|
|
96
|
+
loginWithRefreshToken = async (refreshToken) => {
|
|
97
|
+
if (!refreshToken)
|
|
98
|
+
return "firebase_no_credentials";
|
|
99
|
+
const formData = new URLSearchParams;
|
|
100
|
+
formData.append("grant_type", "refresh_token");
|
|
101
|
+
formData.append("refresh_token", refreshToken);
|
|
102
|
+
let body, token;
|
|
103
|
+
try {
|
|
104
|
+
const request = await globals.fetch(`https://securetoken.googleapis.com/v1/token?key=${FirebaseKey}`, {
|
|
105
|
+
method: "POST",
|
|
106
|
+
body: formData,
|
|
107
|
+
headers: {
|
|
108
|
+
...baseHeaders,
|
|
109
|
+
"content-type": "application/x-www-form-urlencoded"
|
|
110
|
+
},
|
|
111
|
+
proxy: this.proxy
|
|
112
|
+
});
|
|
113
|
+
body = await request.json();
|
|
114
|
+
token = body.id_token;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (error.code === "auth/network-request-failed") {
|
|
117
|
+
if (!this.suppressErrors)
|
|
118
|
+
console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");
|
|
119
|
+
return "firebase_network_failed";
|
|
120
|
+
} else if (error.code === "auth/missing-email") {
|
|
121
|
+
return "firebase_no_credentials";
|
|
122
|
+
}
|
|
123
|
+
if (!this.suppressErrors)
|
|
124
|
+
console.error("loginWithRefreshToken: Error:", error, refreshToken);
|
|
125
|
+
return "firebase_unknown_error";
|
|
126
|
+
}
|
|
127
|
+
if (!token) {
|
|
128
|
+
if (!this.suppressErrors)
|
|
129
|
+
console.error("loginWithRefreshToken: the game sent no idToken", body);
|
|
130
|
+
return "firebase_no_token";
|
|
131
|
+
}
|
|
132
|
+
this.idToken = token;
|
|
133
|
+
const response = await this.queryServices({ cmd: "auth", firebaseToken: token });
|
|
134
|
+
return typeof response === "object" ? { firebase: body, ...response } : response;
|
|
135
|
+
};
|
|
136
|
+
loginAnonymously = async () => {
|
|
137
|
+
const req = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${FirebaseKey}`, {
|
|
138
|
+
method: "POST",
|
|
139
|
+
body: JSON.stringify({ returnSecureToken: true }),
|
|
140
|
+
headers: {
|
|
141
|
+
...baseHeaders,
|
|
142
|
+
"content-type": "application/json"
|
|
143
|
+
},
|
|
144
|
+
proxy: this.proxy
|
|
145
|
+
});
|
|
146
|
+
const body = await req.json();
|
|
147
|
+
const firebaseToken = body.idToken;
|
|
148
|
+
if (!firebaseToken) {
|
|
149
|
+
if (!this.suppressErrors)
|
|
150
|
+
console.error("loginAnonymously: the game sent no idToken", body);
|
|
151
|
+
return "firebase_no_token";
|
|
152
|
+
}
|
|
153
|
+
this.idToken = firebaseToken;
|
|
154
|
+
const query = await this.queryServices({ cmd: "auth", firebaseToken });
|
|
155
|
+
return typeof query === "object" ? { firebase: body, ...query } : query;
|
|
156
|
+
};
|
|
157
|
+
sendEmailVerification = async (idToken = this.idToken) => {
|
|
158
|
+
if (!idToken)
|
|
159
|
+
return "no_idtoken_passed";
|
|
160
|
+
const req = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${FirebaseKey}`, {
|
|
161
|
+
method: "POST",
|
|
162
|
+
body: JSON.stringify({ requestType: "VERIFY_EMAIL", idToken }),
|
|
163
|
+
headers: {
|
|
164
|
+
...baseHeaders,
|
|
165
|
+
"content-type": "application/json"
|
|
166
|
+
},
|
|
167
|
+
proxy: this.proxy
|
|
168
|
+
});
|
|
169
|
+
const body = await req.json();
|
|
170
|
+
if (body.kind !== "identitytoolkit#GetOobConfirmationCodeResponse") {
|
|
171
|
+
if (!this.suppressErrors)
|
|
172
|
+
console.error("sendEmailVerification: the game sent an invalid response", body);
|
|
173
|
+
return "firebase_invalid_response";
|
|
174
|
+
}
|
|
175
|
+
return { email: body.email };
|
|
176
|
+
};
|
|
177
|
+
verifyOobCode = async (oobCode) => {
|
|
178
|
+
if (!oobCode)
|
|
179
|
+
return "no_oob_code_passed";
|
|
180
|
+
const req = await globals.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${FirebaseKey}`, {
|
|
181
|
+
method: "POST",
|
|
182
|
+
body: JSON.stringify({ oobCode }),
|
|
183
|
+
headers: {
|
|
184
|
+
...baseHeaders,
|
|
185
|
+
"x-client-version": "Chrome/JsCore/3.7.5/FirebaseCore-web",
|
|
186
|
+
referer: "https://shellshockio-181719.firebaseapp.com/",
|
|
187
|
+
"content-type": "application/json"
|
|
188
|
+
},
|
|
189
|
+
proxy: this.proxy
|
|
190
|
+
});
|
|
191
|
+
const body = await req.json();
|
|
192
|
+
if (!body.emailVerified) {
|
|
193
|
+
if (!this.suppressErrors)
|
|
194
|
+
console.error("verifyOobCode: the game sent an invalid response", body);
|
|
195
|
+
return "firebase_invalid_response";
|
|
196
|
+
}
|
|
197
|
+
return body.email;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
export default API;
|
package/dist/bot/GamePlayer.js
CHANGED
|
@@ -1 +1,74 @@
|
|
|
1
|
-
import{GunList
|
|
1
|
+
import { GunList, Movement, ShellStreak, SocialMedia } from "../constants/index.js";
|
|
2
|
+
import { Cluck9mm } from "../constants/guns.js";
|
|
3
|
+
const RSocialMedia = Object.fromEntries(Object.entries(SocialMedia).map(([key, value]) => [value, key.toLowerCase()]));
|
|
4
|
+
|
|
5
|
+
export class GamePlayer {
|
|
6
|
+
constructor(playerData, activeZone = null) {
|
|
7
|
+
this.id = playerData.id;
|
|
8
|
+
this.uniqueId = playerData.uniqueId;
|
|
9
|
+
this.name = playerData.name;
|
|
10
|
+
this.safeName = playerData.safeName;
|
|
11
|
+
this.team = playerData.team;
|
|
12
|
+
this.playing = playerData.playing;
|
|
13
|
+
this.socials = playerData.social && JSON.parse(playerData.social);
|
|
14
|
+
if (this.socials)
|
|
15
|
+
this.socials.forEach((social) => social.type = RSocialMedia[social.id]);
|
|
16
|
+
this.isVip = playerData.upgradeProductId > 0;
|
|
17
|
+
this.showBadge = !playerData.hideBadge || false;
|
|
18
|
+
this.streak = playerData.score;
|
|
19
|
+
this.streakRewards = Object.values(ShellStreak).filter((streak) => playerData.activeShellStreaks & streak);
|
|
20
|
+
this.scale = this.streakRewards.includes(ShellStreak.MiniEgg) ? 0.5 : 1;
|
|
21
|
+
this.position = {
|
|
22
|
+
x: playerData.x,
|
|
23
|
+
y: playerData.y,
|
|
24
|
+
z: playerData.z
|
|
25
|
+
};
|
|
26
|
+
this.jumping = playerData.$controlKeys & Movement.Jump;
|
|
27
|
+
this.scoping = playerData.$controlKeys & Movement.Scope;
|
|
28
|
+
this.climbing = false;
|
|
29
|
+
this.view = {
|
|
30
|
+
yaw: playerData.yaw,
|
|
31
|
+
pitch: playerData.pitch
|
|
32
|
+
};
|
|
33
|
+
this.updateKotcZone(activeZone);
|
|
34
|
+
this.character = {
|
|
35
|
+
eggColor: playerData.shellColor,
|
|
36
|
+
primaryGun: playerData.primaryWeaponItem,
|
|
37
|
+
secondaryGun: playerData.secondaryWeaponItem,
|
|
38
|
+
stamp: playerData.stampItem,
|
|
39
|
+
hat: playerData.hatItem,
|
|
40
|
+
grenade: playerData.grenadeItem,
|
|
41
|
+
melee: playerData.meleeItem,
|
|
42
|
+
stampPos: {
|
|
43
|
+
x: playerData.stampPosX,
|
|
44
|
+
y: playerData.stampPosY
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
this.stats = {
|
|
48
|
+
totalKills: playerData.totalKills,
|
|
49
|
+
totalDeaths: playerData.totalDeaths,
|
|
50
|
+
bestStreak: playerData.bestStreak
|
|
51
|
+
};
|
|
52
|
+
this.activeGun = playerData.weaponIdx;
|
|
53
|
+
this.selectedGun = playerData.charClass;
|
|
54
|
+
this.weapons = [];
|
|
55
|
+
if (this.character.primaryGun) {
|
|
56
|
+
this.weapons[0] = new GunList[this.selectedGun];
|
|
57
|
+
this.weapons[1] = new Cluck9mm;
|
|
58
|
+
}
|
|
59
|
+
this.grenades = 1;
|
|
60
|
+
this.hp = playerData.hp;
|
|
61
|
+
this.hpShield = 0;
|
|
62
|
+
this.spawnShield = playerData.shield;
|
|
63
|
+
this.randomSeed = 0;
|
|
64
|
+
}
|
|
65
|
+
updateKotcZone(activeZone) {
|
|
66
|
+
if (!activeZone)
|
|
67
|
+
return this.inKotcZone = false;
|
|
68
|
+
const fx = Math.floor(this.position.x);
|
|
69
|
+
const fy = Math.floor(this.position.y);
|
|
70
|
+
const fz = Math.floor(this.position.z);
|
|
71
|
+
this.inKotcZone = activeZone.some((coordSets) => coordSets.x === fx && coordSets.y === fy && coordSets.z === fz) && this.playing;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export default GamePlayer;
|