yolkbot 1.5.7 → 1.5.9
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 +1 -244
- package/dist/bot/GamePlayer.js +1 -84
- package/dist/bot.js +1 -1226
- package/dist/comm/CommIn.js +1 -76
- package/dist/comm/CommOut.js +1 -60
- package/dist/constants/CloseCode.js +1 -27
- package/dist/constants/CommCode.js +1 -53
- package/dist/constants/challenges.js +1 -1821
- package/dist/constants/findItemById.js +1 -3
- package/dist/constants/guns.js +1 -155
- package/dist/constants/index.js +1 -141
- package/dist/constants/items.js +1 -45979
- package/dist/constants/maps.js +1 -1289
- package/dist/constants/regions.js +1 -30
- package/dist/dispatches/BanPlayerDispatch.js +1 -32
- package/dist/dispatches/BootPlayerDispatch.js +1 -21
- package/dist/dispatches/ChatDispatch.js +1 -32
- package/dist/dispatches/FireDispatch.js +1 -15
- package/dist/dispatches/GameOptionsDispatch.js +1 -66
- package/dist/dispatches/GoToAmmoDispatch.js +1 -37
- package/dist/dispatches/GoToCoopDispatch.js +1 -37
- package/dist/dispatches/GoToGrenadeDispatch.js +1 -37
- package/dist/dispatches/GoToPlayerDispatch.js +1 -34
- package/dist/dispatches/GoToSpatulaDispatch.js +1 -23
- package/dist/dispatches/LookAtDispatch.js +1 -37
- package/dist/dispatches/LookAtPosDispatch.js +1 -29
- package/dist/dispatches/MeleeDispatch.js +1 -26
- package/dist/dispatches/MovementDispatch.js +1 -26
- package/dist/dispatches/PauseDispatch.js +1 -18
- package/dist/dispatches/ReloadDispatch.js +1 -35
- package/dist/dispatches/ReportPlayerDispatch.js +1 -44
- package/dist/dispatches/ResetGameDispatch.js +1 -19
- package/dist/dispatches/SaveLoadoutDispatch.js +1 -106
- package/dist/dispatches/SpawnDispatch.js +1 -26
- package/dist/dispatches/SwapWeaponDispatch.js +1 -25
- package/dist/dispatches/SwitchTeamDispatch.js +1 -34
- package/dist/dispatches/ThrowGrenadeDispatch.js +1 -21
- package/dist/dispatches/index.js +1 -73
- package/dist/enums.js +1 -114
- package/dist/env/fetch.js +8 -129
- package/dist/env/globals.js +1 -17
- package/dist/index.js +1 -22
- package/dist/packets/addPlayer.js +1 -63
- package/dist/packets/beginShellStreak.js +1 -44
- package/dist/packets/challengeCompleted.js +1 -16
- package/dist/packets/changeCharacter.js +1 -46
- package/dist/packets/chat.js +1 -10
- package/dist/packets/collectItem.js +1 -26
- package/dist/packets/die.js +1 -40
- package/dist/packets/endShellStreak.js +1 -21
- package/dist/packets/eventModifier.js +1 -8
- package/dist/packets/explode.js +1 -19
- package/dist/packets/fire.js +1 -21
- package/dist/packets/gameAction.js +1 -33
- package/dist/packets/gameJoined.js +1 -64
- package/dist/packets/gameOptions.js +1 -27
- package/dist/packets/hitMe.js +1 -12
- package/dist/packets/hitMeHardBoiled.js +1 -18
- package/dist/packets/hitThem.js +1 -12
- package/dist/packets/melee.js +1 -8
- package/dist/packets/metaGameState.js +1 -62
- package/dist/packets/pause.js +1 -17
- package/dist/packets/ping.js +1 -19
- package/dist/packets/playerInfo.js +1 -15
- package/dist/packets/reload.js +1 -17
- package/dist/packets/removePlayer.js +1 -10
- package/dist/packets/respawn.js +1 -31
- package/dist/packets/socketReady.js +1 -16
- package/dist/packets/spawnItem.js +1 -11
- package/dist/packets/swapWeapon.js +1 -11
- package/dist/packets/switchTeam.js +1 -13
- package/dist/packets/syncMe.js +1 -25
- package/dist/packets/syncThem.js +1 -63
- package/dist/packets/throwGrenade.js +1 -17
- package/dist/packets/updateBalance.js +1 -8
- package/dist/pathing/astar.js +1 -68
- package/dist/pathing/mapnode.js +1 -284
- package/dist/socket.js +1 -107
- package/dist/util.js +1 -128
- package/dist/wasm/bytes.js +1 -8
- package/dist/wasm/direct.js +1 -84
- package/dist/wasm/legacy.js +1 -176
- package/package.json +2 -7
package/dist/api.js
CHANGED
|
@@ -1,244 +1 @@
|
|
|
1
|
-
import globals from
|
|
2
|
-
import yolkws from "./socket.js";
|
|
3
|
-
import { APIError } from "./enums.js";
|
|
4
|
-
import { createError } from "./util.js";
|
|
5
|
-
import { FirebaseKey, UserAgent } from "./constants/index.js";
|
|
6
|
-
const baseHeaders = {
|
|
7
|
-
origin: "https://shellshock.io",
|
|
8
|
-
"user-agent": typeof process === "undefined" ? null : UserAgent,
|
|
9
|
-
"x-client-version": "Chrome/JsCore/9.17.2/FirebaseCore-web",
|
|
10
|
-
"x-firebase-locale": "en"
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export class API {
|
|
14
|
-
errorLogger = (...args) => console.error(...args);
|
|
15
|
-
idToken = null;
|
|
16
|
-
constructor(params = {}) {
|
|
17
|
-
this.proxy = params.proxy;
|
|
18
|
-
this.instance = params.instance || "shellshock.io";
|
|
19
|
-
this.protocol = params.protocol || "wss";
|
|
20
|
-
this.customKey = params.customKey || null;
|
|
21
|
-
this.connectionTimeout = params.connectionTimeout || 5000;
|
|
22
|
-
if (typeof params.errorLogger === "function")
|
|
23
|
-
this.errorLogger = params.errorLogger;
|
|
24
|
-
}
|
|
25
|
-
queryServices = async (request) => {
|
|
26
|
-
const ws = new yolkws(`${this.protocol}://${this.instance}/services/`, { proxy: this.proxy, errorLogger: this.errorLogger });
|
|
27
|
-
ws.connectionTimeout = this.connectionTimeout;
|
|
28
|
-
const didConnect = await ws.tryConnect();
|
|
29
|
-
if (!didConnect || ws.socket.readyState !== 1)
|
|
30
|
-
return createError(APIError.WebSocketConnectFail);
|
|
31
|
-
return new Promise((resolve) => {
|
|
32
|
-
let resolved = false;
|
|
33
|
-
ws.onmessage = (mes) => {
|
|
34
|
-
resolved = true;
|
|
35
|
-
try {
|
|
36
|
-
const resp = JSON.parse(mes.data);
|
|
37
|
-
resolve({ ok: true, ...resp });
|
|
38
|
-
} catch (e) {
|
|
39
|
-
this.errorLogger("queryServices: error! command:", request.cmd, "and data:", request, e);
|
|
40
|
-
resolve(createError(APIError.InternalError));
|
|
41
|
-
}
|
|
42
|
-
ws.close();
|
|
43
|
-
};
|
|
44
|
-
ws.onerror = (error) => {
|
|
45
|
-
if (resolved)
|
|
46
|
-
return;
|
|
47
|
-
resolved = true;
|
|
48
|
-
this.errorLogger("queryServices: websocket error! command:", request.cmd, "and data:", request, "error:", error);
|
|
49
|
-
resolve(createError(APIError.InternalError));
|
|
50
|
-
};
|
|
51
|
-
ws.onclose = () => {
|
|
52
|
-
if (resolved)
|
|
53
|
-
return;
|
|
54
|
-
resolved = true;
|
|
55
|
-
this.errorLogger("queryServices: services closed before sending back message");
|
|
56
|
-
this.errorLogger("queryServices: command:", request.cmd, "and data:", request);
|
|
57
|
-
resolve(createError(APIError.ServicesClosedEarly));
|
|
58
|
-
};
|
|
59
|
-
ws.send(JSON.stringify(request));
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
#authWithEmailPass = async (email, password, customServicesParams, endpoint) => {
|
|
63
|
-
if (!email || !password)
|
|
64
|
-
return createError(APIError.MissingParams);
|
|
65
|
-
let body;
|
|
66
|
-
try {
|
|
67
|
-
const request = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${endpoint}?key=${this.customKey || FirebaseKey}`, {
|
|
68
|
-
method: "POST",
|
|
69
|
-
body: JSON.stringify({ email, password, returnSecureToken: true }),
|
|
70
|
-
headers: {
|
|
71
|
-
...baseHeaders,
|
|
72
|
-
"content-type": "application/json"
|
|
73
|
-
},
|
|
74
|
-
proxy: this.proxy
|
|
75
|
-
});
|
|
76
|
-
body = await request.json();
|
|
77
|
-
} catch (error) {
|
|
78
|
-
if (error.code === "auth/too-many-requests")
|
|
79
|
-
return createError(APIError.FirebaseRateLimited);
|
|
80
|
-
else if (error.code === "auth/network-request-failed") {
|
|
81
|
-
this.errorLogger("authWithEmailPass: network error", body || error);
|
|
82
|
-
return createError(APIError.NetworkFail);
|
|
83
|
-
} else if (error.code === "ERR_BAD_REQUEST") {
|
|
84
|
-
this.errorLogger("authWithEmailPass: bad request", body || error);
|
|
85
|
-
return createError(APIError.InternalError);
|
|
86
|
-
} else if (error.code === "ECONNREFUSED") {
|
|
87
|
-
this.errorLogger("authWithEmailPass: connection refused", body || error);
|
|
88
|
-
return createError(APIError.NetworkFail);
|
|
89
|
-
}
|
|
90
|
-
this.errorLogger("authWithEmailPass: unknown error:", email, error);
|
|
91
|
-
return createError(APIError.InternalError);
|
|
92
|
-
}
|
|
93
|
-
if (!body.idToken) {
|
|
94
|
-
this.errorLogger("authWithEmailPass: missing idToken", body);
|
|
95
|
-
return createError(APIError.InternalError);
|
|
96
|
-
}
|
|
97
|
-
this.idToken = body.idToken;
|
|
98
|
-
const servicesQuery = await this.queryServices({ cmd: "auth", firebaseToken: body.idToken, ...customServicesParams });
|
|
99
|
-
return servicesQuery.ok ? { firebase: body, ...servicesQuery } : servicesQuery;
|
|
100
|
-
};
|
|
101
|
-
createAccount = (email, password, customServicesParams) => this.#authWithEmailPass(email, password, customServicesParams, "signUp");
|
|
102
|
-
loginWithCredentials = (email, password, customServicesParams) => this.#authWithEmailPass(email, password, customServicesParams, "signInWithPassword");
|
|
103
|
-
loginWithRefreshToken = async (refreshToken, customServicesParams) => {
|
|
104
|
-
if (!refreshToken)
|
|
105
|
-
return createError(APIError.MissingParams);
|
|
106
|
-
const formData = new URLSearchParams;
|
|
107
|
-
formData.append("grant_type", "refresh_token");
|
|
108
|
-
formData.append("refresh_token", refreshToken);
|
|
109
|
-
let body;
|
|
110
|
-
try {
|
|
111
|
-
const request = await globals.fetch(`https://securetoken.googleapis.com/v1/token?key=${this.customKey || FirebaseKey}`, {
|
|
112
|
-
method: "POST",
|
|
113
|
-
body: formData.toString(),
|
|
114
|
-
headers: {
|
|
115
|
-
...baseHeaders,
|
|
116
|
-
"content-type": "application/x-www-form-urlencoded"
|
|
117
|
-
},
|
|
118
|
-
proxy: this.proxy
|
|
119
|
-
});
|
|
120
|
-
body = await request.json();
|
|
121
|
-
} catch (error) {
|
|
122
|
-
if (error.code === "auth/too-many-requests")
|
|
123
|
-
return createError(APIError.FirebaseRateLimited);
|
|
124
|
-
else if (error.code === "auth/network-request-failed") {
|
|
125
|
-
this.errorLogger("loginWithRefreshToken: network error", body || error);
|
|
126
|
-
return createError(APIError.NetworkFail);
|
|
127
|
-
} else if (error.code === "ECONNREFUSED") {
|
|
128
|
-
this.errorLogger("loginWithRefreshToken: connection refused", body || error);
|
|
129
|
-
return createError(APIError.NetworkFail);
|
|
130
|
-
}
|
|
131
|
-
this.errorLogger("loginWithRefreshToken: unknown error:", body, error);
|
|
132
|
-
return createError(APIError.InternalError);
|
|
133
|
-
}
|
|
134
|
-
if (!body.id_token) {
|
|
135
|
-
this.errorLogger("loginWithRefreshToken: missing idToken", body);
|
|
136
|
-
return createError(APIError.InternalError);
|
|
137
|
-
}
|
|
138
|
-
this.idToken = body.id_token;
|
|
139
|
-
const response = await this.queryServices({ cmd: "auth", firebaseToken: body.id_token, ...customServicesParams });
|
|
140
|
-
return response.ok ? { firebase: body, ...response } : response;
|
|
141
|
-
};
|
|
142
|
-
loginAnonymously = async (customServicesParams) => {
|
|
143
|
-
let body;
|
|
144
|
-
try {
|
|
145
|
-
const req = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${this.customKey || FirebaseKey}`, {
|
|
146
|
-
method: "POST",
|
|
147
|
-
body: JSON.stringify({ returnSecureToken: true }),
|
|
148
|
-
headers: {
|
|
149
|
-
...baseHeaders,
|
|
150
|
-
"content-type": "application/json"
|
|
151
|
-
},
|
|
152
|
-
proxy: this.proxy
|
|
153
|
-
});
|
|
154
|
-
body = await req.json();
|
|
155
|
-
} catch (error) {
|
|
156
|
-
if (error.code === "auth/too-many-requests")
|
|
157
|
-
return createError(APIError.FirebaseRateLimited);
|
|
158
|
-
else if (error.code === "ECONNREFUSED") {
|
|
159
|
-
this.errorLogger("loginAnonymously: connection refused", body || error);
|
|
160
|
-
return createError(APIError.NetworkFail);
|
|
161
|
-
}
|
|
162
|
-
this.errorLogger("loginAnonymously: unknown error:", body, error);
|
|
163
|
-
return createError(APIError.InternalError);
|
|
164
|
-
}
|
|
165
|
-
if (!body.idToken) {
|
|
166
|
-
this.errorLogger("loginAnonymously: missing idToken", body);
|
|
167
|
-
return createError(APIError.InternalError);
|
|
168
|
-
}
|
|
169
|
-
this.idToken = body.idToken;
|
|
170
|
-
const query = await this.queryServices({ cmd: "auth", firebaseToken: body.idToken, ...customServicesParams });
|
|
171
|
-
return query.ok ? { firebase: body, ...query } : query;
|
|
172
|
-
};
|
|
173
|
-
sendEmailVerification = async (idToken = this.idToken) => {
|
|
174
|
-
if (!idToken)
|
|
175
|
-
return createError(APIError.MissingParams);
|
|
176
|
-
let body;
|
|
177
|
-
try {
|
|
178
|
-
const req = await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${this.customKey || FirebaseKey}`, {
|
|
179
|
-
method: "POST",
|
|
180
|
-
body: JSON.stringify({ requestType: "VERIFY_EMAIL", idToken }),
|
|
181
|
-
headers: {
|
|
182
|
-
...baseHeaders,
|
|
183
|
-
"content-type": "application/json"
|
|
184
|
-
},
|
|
185
|
-
proxy: this.proxy
|
|
186
|
-
});
|
|
187
|
-
body = await req.json();
|
|
188
|
-
} catch (error) {
|
|
189
|
-
if (error.code === "auth/too-many-requests")
|
|
190
|
-
return createError(APIError.FirebaseRateLimited);
|
|
191
|
-
else if (error.code === "auth/network-request-failed") {
|
|
192
|
-
this.errorLogger("sendEmailVerification: network error", body || error);
|
|
193
|
-
return createError(APIError.NetworkFail);
|
|
194
|
-
} else if (error.code === "ECONNREFUSED") {
|
|
195
|
-
this.errorLogger("sendEmailVerification: connection refused", body || error);
|
|
196
|
-
return createError(APIError.NetworkFail);
|
|
197
|
-
}
|
|
198
|
-
this.errorLogger("sendEmailVerification: unknown error:", idToken, error);
|
|
199
|
-
return createError(APIError.InternalError);
|
|
200
|
-
}
|
|
201
|
-
if (body.kind !== "identitytoolkit#GetOobConfirmationCodeResponse") {
|
|
202
|
-
this.errorLogger("sendEmailVerification: the game sent an invalid response", body);
|
|
203
|
-
return createError(APIError.InternalError);
|
|
204
|
-
}
|
|
205
|
-
return { ok: true, email: body.email };
|
|
206
|
-
};
|
|
207
|
-
verifyOobCode = async (oobCode) => {
|
|
208
|
-
if (!oobCode)
|
|
209
|
-
return createError(APIError.MissingParams);
|
|
210
|
-
let body;
|
|
211
|
-
try {
|
|
212
|
-
const req = await globals.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${this.customKey || FirebaseKey}`, {
|
|
213
|
-
method: "POST",
|
|
214
|
-
body: JSON.stringify({ oobCode }),
|
|
215
|
-
headers: {
|
|
216
|
-
...baseHeaders,
|
|
217
|
-
"x-client-version": "Chrome/JsCore/3.7.5/FirebaseCore-web",
|
|
218
|
-
referer: "https://shellshockio-181719.firebaseapp.com/",
|
|
219
|
-
"content-type": "application/json"
|
|
220
|
-
},
|
|
221
|
-
proxy: this.proxy
|
|
222
|
-
});
|
|
223
|
-
body = await req.json();
|
|
224
|
-
} catch (error) {
|
|
225
|
-
if (error.code === "auth/too-many-requests")
|
|
226
|
-
return createError(APIError.FirebaseRateLimited);
|
|
227
|
-
else if (error.code === "auth/network-request-failed") {
|
|
228
|
-
this.errorLogger("verifyOobCode: network error", body || error);
|
|
229
|
-
return createError(APIError.NetworkFail);
|
|
230
|
-
} else if (error.code === "ECONNREFUSED") {
|
|
231
|
-
this.errorLogger("verifyOobCode: connection refused", body || error);
|
|
232
|
-
return createError(APIError.NetworkFail);
|
|
233
|
-
}
|
|
234
|
-
this.errorLogger("verifyOobCode: unknown error:", oobCode, error);
|
|
235
|
-
return createError(APIError.InternalError);
|
|
236
|
-
}
|
|
237
|
-
if (!body.emailVerified) {
|
|
238
|
-
this.errorLogger("verifyOobCode: the game sent an invalid response", body);
|
|
239
|
-
return createError(APIError.InternalError);
|
|
240
|
-
}
|
|
241
|
-
return { ok: true, email: body.email };
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
export default API;
|
|
1
|
+
import globals from"./env/globals.js";import yolkws from"./socket.js";import{APIError}from"./enums.js";import{createError}from"./util.js";import{FirebaseKey,UserAgent}from"./constants/index.js";const baseHeaders={origin:"https://shellshock.io","user-agent":typeof process==="undefined"?null:UserAgent,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};export class API{errorLogger=(...args)=>console.error(...args);idToken=null;constructor(params={}){this.proxy=params.proxy;this.instance=params.instance||"shellshock.io";this.protocol=params.protocol||"wss";this.customKey=params.customKey||null;this.connectionTimeout=params.connectionTimeout||5000;if(typeof params.errorLogger==="function")this.errorLogger=params.errorLogger}queryServices=async(request)=>{const ws=new yolkws(`${this.protocol}://${this.instance}/services/`,{proxy:this.proxy,errorLogger:this.errorLogger});ws.connectionTimeout=this.connectionTimeout;const didConnect=await ws.tryConnect();if(!didConnect||ws.socket.readyState!==1)return createError(APIError.WebSocketConnectFail);return new Promise((resolve)=>{let resolved=false;ws.onmessage=(mes)=>{resolved=true;try{const resp=JSON.parse(mes.data);resolve({ok:true,...resp})}catch(e){this.errorLogger("queryServices: error! command:",request.cmd,"and data:",request,e);resolve(createError(APIError.InternalError))}ws.close()};ws.onerror=(error)=>{if(resolved)return;resolved=true;this.errorLogger("queryServices: websocket error! command:",request.cmd,"and data:",request,"error:",error);resolve(createError(APIError.InternalError))};ws.onclose=()=>{if(resolved)return;resolved=true;this.errorLogger("queryServices: services closed before sending back message");this.errorLogger("queryServices: command:",request.cmd,"and data:",request);resolve(createError(APIError.ServicesClosedEarly))};ws.send(JSON.stringify(request))})};#authWithEmailPass=async(email,password,customServicesParams,endpoint)=>{if(!email||!password)return createError(APIError.MissingParams);let body;try{const request=await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${endpoint}?key=${this.customKey||FirebaseKey}`,{method:"POST",body:JSON.stringify({email,password,returnSecureToken:true}),headers:{...baseHeaders,"content-type":"application/json"},proxy:this.proxy});body=await request.json()}catch(error){if(error.code==="auth/too-many-requests")return createError(APIError.FirebaseRateLimited);else if(error.code==="auth/network-request-failed"){this.errorLogger("authWithEmailPass: network error",body||error);return createError(APIError.NetworkFail)}else if(error.code==="ERR_BAD_REQUEST"){this.errorLogger("authWithEmailPass: bad request",body||error);return createError(APIError.InternalError)}else if(error.code==="ECONNREFUSED"){this.errorLogger("authWithEmailPass: connection refused",body||error);return createError(APIError.NetworkFail)}this.errorLogger("authWithEmailPass: unknown error:",email,error);return createError(APIError.InternalError)}if(!body.idToken){this.errorLogger("authWithEmailPass: missing idToken",body);return createError(APIError.InternalError)}this.idToken=body.idToken;const servicesQuery=await this.queryServices({cmd:"auth",firebaseToken:body.idToken,...customServicesParams});return servicesQuery.ok?{firebase:body,...servicesQuery}:servicesQuery};createAccount=(email,password,customServicesParams)=>this.#authWithEmailPass(email,password,customServicesParams,"signUp");loginWithCredentials=(email,password,customServicesParams)=>this.#authWithEmailPass(email,password,customServicesParams,"signInWithPassword");loginWithRefreshToken=async(refreshToken,customServicesParams)=>{if(!refreshToken)return createError(APIError.MissingParams);const formData=new URLSearchParams;formData.append("grant_type","refresh_token");formData.append("refresh_token",refreshToken);let body;try{const request=await globals.fetch(`https://securetoken.googleapis.com/v1/token?key=${this.customKey||FirebaseKey}`,{method:"POST",body:formData.toString(),headers:{...baseHeaders,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy});body=await request.json()}catch(error){if(error.code==="auth/too-many-requests")return createError(APIError.FirebaseRateLimited);else if(error.code==="auth/network-request-failed"){this.errorLogger("loginWithRefreshToken: network error",body||error);return createError(APIError.NetworkFail)}else if(error.code==="ECONNREFUSED"){this.errorLogger("loginWithRefreshToken: connection refused",body||error);return createError(APIError.NetworkFail)}this.errorLogger("loginWithRefreshToken: unknown error:",body,error);return createError(APIError.InternalError)}if(!body.id_token){this.errorLogger("loginWithRefreshToken: missing idToken",body);return createError(APIError.InternalError)}this.idToken=body.id_token;const response=await this.queryServices({cmd:"auth",firebaseToken:body.id_token,...customServicesParams});return response.ok?{firebase:body,...response}:response};loginAnonymously=async(customServicesParams)=>{let body;try{const req=await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${this.customKey||FirebaseKey}`,{method:"POST",body:JSON.stringify({returnSecureToken:true}),headers:{...baseHeaders,"content-type":"application/json"},proxy:this.proxy});body=await req.json()}catch(error){if(error.code==="auth/too-many-requests")return createError(APIError.FirebaseRateLimited);else if(error.code==="ECONNREFUSED"){this.errorLogger("loginAnonymously: connection refused",body||error);return createError(APIError.NetworkFail)}this.errorLogger("loginAnonymously: unknown error:",body,error);return createError(APIError.InternalError)}if(!body.idToken){this.errorLogger("loginAnonymously: missing idToken",body);return createError(APIError.InternalError)}this.idToken=body.idToken;const query=await this.queryServices({cmd:"auth",firebaseToken:body.idToken,...customServicesParams});return query.ok?{firebase:body,...query}:query};sendEmailVerification=async(idToken=this.idToken)=>{if(!idToken)return createError(APIError.MissingParams);let body;try{const req=await globals.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${this.customKey||FirebaseKey}`,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken}),headers:{...baseHeaders,"content-type":"application/json"},proxy:this.proxy});body=await req.json()}catch(error){if(error.code==="auth/too-many-requests")return createError(APIError.FirebaseRateLimited);else if(error.code==="auth/network-request-failed"){this.errorLogger("sendEmailVerification: network error",body||error);return createError(APIError.NetworkFail)}else if(error.code==="ECONNREFUSED"){this.errorLogger("sendEmailVerification: connection refused",body||error);return createError(APIError.NetworkFail)}this.errorLogger("sendEmailVerification: unknown error:",idToken,error);return createError(APIError.InternalError)}if(body.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"){this.errorLogger("sendEmailVerification: the game sent an invalid response",body);return createError(APIError.InternalError)}return{ok:true,email:body.email}};verifyOobCode=async(oobCode)=>{if(!oobCode)return createError(APIError.MissingParams);let body;try{const req=await globals.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${this.customKey||FirebaseKey}`,{method:"POST",body:JSON.stringify({oobCode}),headers:{...baseHeaders,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy});body=await req.json()}catch(error){if(error.code==="auth/too-many-requests")return createError(APIError.FirebaseRateLimited);else if(error.code==="auth/network-request-failed"){this.errorLogger("verifyOobCode: network error",body||error);return createError(APIError.NetworkFail)}else if(error.code==="ECONNREFUSED"){this.errorLogger("verifyOobCode: connection refused",body||error);return createError(APIError.NetworkFail)}this.errorLogger("verifyOobCode: unknown error:",oobCode,error);return createError(APIError.InternalError)}if(!body.emailVerified){this.errorLogger("verifyOobCode: the game sent an invalid response",body);return createError(APIError.InternalError)}return{ok:true,email:body.email}}}export default API;
|
package/dist/bot/GamePlayer.js
CHANGED
|
@@ -1,84 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Cluck9mm } from "../constants/guns.js";
|
|
3
|
-
import { createGun } from "../util.js";
|
|
4
|
-
const RSocialMedia = Object.fromEntries(Object.entries(SocialMedia).map(([key, value]) => [value, key.toLowerCase()]));
|
|
5
|
-
|
|
6
|
-
export class GamePlayer {
|
|
7
|
-
constructor(playerData, activeZone = null) {
|
|
8
|
-
this.id = playerData.id;
|
|
9
|
-
this.uniqueId = playerData.uniqueId;
|
|
10
|
-
this.name = playerData.name;
|
|
11
|
-
this.safeName = playerData.safeName;
|
|
12
|
-
this.team = playerData.team;
|
|
13
|
-
this.playing = playerData.playing;
|
|
14
|
-
this.socials = [];
|
|
15
|
-
if (typeof playerData.social === "string" && playerData.social.length) {
|
|
16
|
-
try {
|
|
17
|
-
const parsed = JSON.parse(playerData.social);
|
|
18
|
-
if (Array.isArray(parsed))
|
|
19
|
-
this.socials = parsed;
|
|
20
|
-
} catch (e) {
|
|
21
|
-
console.error("Error parsing socials:", e);
|
|
22
|
-
console.error("Report this on Github!");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
this.socials.forEach((social) => social.type = RSocialMedia[social.id]);
|
|
26
|
-
this.isVip = playerData.upgradeProductId > 0;
|
|
27
|
-
this.showBadge = !playerData.hideBadge || false;
|
|
28
|
-
this.streak = playerData.score;
|
|
29
|
-
this.streakRewards = Object.values(ShellStreak).filter((streak) => playerData.activeShellStreaks & streak);
|
|
30
|
-
this.scale = this.streakRewards.includes(ShellStreak.MiniEgg) ? 0.5 : 1;
|
|
31
|
-
this.position = {
|
|
32
|
-
x: playerData.x,
|
|
33
|
-
y: playerData.y,
|
|
34
|
-
z: playerData.z
|
|
35
|
-
};
|
|
36
|
-
this.jumping = playerData.$controlKeys & Movement.Jump;
|
|
37
|
-
this.scoping = playerData.$controlKeys & Movement.Scope;
|
|
38
|
-
this.climbing = false;
|
|
39
|
-
this.view = {
|
|
40
|
-
yaw: playerData.yaw,
|
|
41
|
-
pitch: playerData.pitch
|
|
42
|
-
};
|
|
43
|
-
this.updateKotcZone(activeZone);
|
|
44
|
-
this.character = {
|
|
45
|
-
eggColor: playerData.shellColor,
|
|
46
|
-
primaryGun: playerData.primaryWeaponItem,
|
|
47
|
-
secondaryGun: playerData.secondaryWeaponItem,
|
|
48
|
-
stamp: playerData.stampItem,
|
|
49
|
-
hat: playerData.hatItem,
|
|
50
|
-
grenade: playerData.grenadeItem,
|
|
51
|
-
melee: playerData.meleeItem,
|
|
52
|
-
stampPos: {
|
|
53
|
-
x: playerData.stampPosX,
|
|
54
|
-
y: playerData.stampPosY
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this.stats = {
|
|
58
|
-
totalKills: playerData.totalKills,
|
|
59
|
-
totalDeaths: playerData.totalDeaths,
|
|
60
|
-
bestStreak: playerData.bestStreak
|
|
61
|
-
};
|
|
62
|
-
this.activeGun = playerData.weaponIdx;
|
|
63
|
-
this.selectedGun = playerData.charClass;
|
|
64
|
-
this.weapons = [];
|
|
65
|
-
if (this.character.primaryGun) {
|
|
66
|
-
this.weapons[0] = createGun(GunList[this.selectedGun]);
|
|
67
|
-
this.weapons[1] = createGun(Cluck9mm);
|
|
68
|
-
}
|
|
69
|
-
this.grenades = 1;
|
|
70
|
-
this.hp = playerData.hp;
|
|
71
|
-
this.hpShield = 0;
|
|
72
|
-
this.spawnShield = playerData.shield;
|
|
73
|
-
this.randomSeed = 0;
|
|
74
|
-
}
|
|
75
|
-
updateKotcZone(activeZone) {
|
|
76
|
-
if (!activeZone)
|
|
77
|
-
return this.inKotcZone = false;
|
|
78
|
-
const fx = Math.floor(this.position.x);
|
|
79
|
-
const fy = Math.floor(this.position.y);
|
|
80
|
-
const fz = Math.floor(this.position.z);
|
|
81
|
-
this.inKotcZone = activeZone.some((coordSets) => coordSets.x === fx && coordSets.y === fy && coordSets.z === fz) && this.playing;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
export default GamePlayer;
|
|
1
|
+
import{GunList,Movement,ShellStreak,SocialMedia}from"../constants/index.js";import{Cluck9mm}from"../constants/guns.js";import{createGun}from"../util.js";const RSocialMedia=Object.fromEntries(Object.entries(SocialMedia).map(([key,value])=>[value,key.toLowerCase()]));export class GamePlayer{constructor(playerData,activeZone=null){this.id=playerData.id;this.uniqueId=playerData.uniqueId;this.name=playerData.name;this.safeName=playerData.safeName;this.team=playerData.team;this.playing=playerData.playing;this.socials=[];if(typeof playerData.social==="string"&&playerData.social.length){try{const parsed=JSON.parse(playerData.social);if(Array.isArray(parsed))this.socials=parsed}catch(e){console.error("error parsing socials:",e);console.error("report this issue at https://yolkbot.xyz/community")}}this.socials.forEach((social)=>social.type=RSocialMedia[social.id]);this.isVip=playerData.upgradeProductId>0;this.showBadge=!playerData.hideBadge||false;this.streak=playerData.score;this.streakRewards=Object.values(ShellStreak).filter((streak)=>playerData.activeShellStreaks&streak);this.scale=this.streakRewards.includes(ShellStreak.MiniEgg)?0.5:1;this.position={x:playerData.x,y:playerData.y,z:playerData.z};this.jumping=playerData.$controlKeys&Movement.Jump;this.scoping=playerData.$controlKeys&Movement.Scope;this.climbing=false;this.view={yaw:playerData.yaw,pitch:playerData.pitch};this.updateKotcZone(activeZone);this.character={eggColor:playerData.shellColor,primaryGun:playerData.primaryWeaponItem,secondaryGun:playerData.secondaryWeaponItem,stamp:playerData.stampItem,hat:playerData.hatItem,grenade:playerData.grenadeItem,melee:playerData.meleeItem,stampPos:{x:playerData.stampPosX,y:playerData.stampPosY}};this.stats={totalKills:playerData.totalKills,totalDeaths:playerData.totalDeaths,bestStreak:playerData.bestStreak};this.activeGun=playerData.weaponIdx;this.selectedGun=playerData.charClass;this.weapons=[];if(this.character.primaryGun){this.weapons[0]=createGun(GunList[this.selectedGun]);this.weapons[1]=createGun(Cluck9mm)}this.grenades=1;this.hp=playerData.hp;this.hpShield=0;this.spawnShield=playerData.shield;this.randomSeed=0}updateKotcZone(activeZone){if(!activeZone)return this.inKotcZone=false;const fx=Math.floor(this.position.x);const fy=Math.floor(this.position.y);const fz=Math.floor(this.position.z);this.inKotcZone=activeZone.some((coordSets)=>coordSets.x===fx&&coordSets.y===fy&&coordSets.z===fz)&&this.playing}}export default GamePlayer;
|