yolkbot 0.1.0-alpha.5 → 0.1.0-alpha.50

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 (60) hide show
  1. package/build/browser.js +6 -6
  2. package/package.json +27 -8
  3. package/src/api.js +44 -23
  4. package/src/bot/GamePlayer.js +3 -3
  5. package/src/bot.js +758 -391
  6. package/src/constants/index.js +23 -1
  7. package/src/constants/items.js +372 -173
  8. package/src/constants/maps.js +51 -12
  9. package/src/dispatches/BootPlayerDispatch.js +1 -1
  10. package/src/dispatches/ChatDispatch.js +1 -1
  11. package/src/dispatches/GameOptionsDispatch.js +1 -1
  12. package/src/dispatches/GoToAmmoDispatch.js +44 -0
  13. package/src/dispatches/GoToCoopDispatch.js +44 -0
  14. package/src/dispatches/GoToGrenadeDispatch.js +44 -0
  15. package/src/dispatches/GoToPlayerDispatch.js +5 -1
  16. package/src/dispatches/GoToSpatulaDispatch.js +5 -1
  17. package/src/dispatches/MeleeDispatch.js +1 -1
  18. package/src/dispatches/PauseDispatch.js +1 -1
  19. package/src/dispatches/ReloadDispatch.js +1 -1
  20. package/src/dispatches/ReportPlayerDispatch.js +1 -1
  21. package/src/dispatches/SaveLoadoutDispatch.js +11 -34
  22. package/src/dispatches/SpawnDispatch.js +1 -1
  23. package/src/dispatches/SwapWeaponDispatch.js +1 -1
  24. package/src/dispatches/SwitchTeamDispatch.js +1 -1
  25. package/src/dispatches/ThrowGrenadeDispatch.js +1 -1
  26. package/src/dispatches/index.js +14 -2
  27. package/src/matchmaker.js +11 -2
  28. package/src/pathing/mapnode.js +33 -4
  29. package/src/socket.js +1 -1
  30. package/src/types/api.d.ts +1 -16
  31. package/src/types/bot/GamePlayer.d.ts +87 -0
  32. package/src/types/bot.d.ts +117 -35
  33. package/src/types/constants/guns.d.ts +240 -0
  34. package/src/types/constants/index.d.ts +100 -0
  35. package/src/types/constants/items.d.ts +21 -0
  36. package/src/types/constants/maps.d.ts +15 -0
  37. package/src/types/dispatches/BootPlayerDispatch.d.ts +12 -0
  38. package/src/types/dispatches/ChatDispatch.d.ts +10 -0
  39. package/src/types/dispatches/FireDispatch.d.ts +10 -0
  40. package/src/types/dispatches/GameOptionsDispatch.d.ts +8 -0
  41. package/src/types/dispatches/GoToAmmoDispatch.d.ts +8 -0
  42. package/src/types/dispatches/GoToCoopDispatch.d.ts +8 -0
  43. package/src/types/dispatches/GoToGrenadeDispatch.d.ts +8 -0
  44. package/src/types/dispatches/GoToPlayerDispatch.d.ts +11 -0
  45. package/src/types/dispatches/GoToSpatulaDispatch.d.ts +8 -0
  46. package/src/types/dispatches/LookAtDispatch.d.ts +14 -0
  47. package/src/types/dispatches/LookAtPosDispatch.d.ts +19 -0
  48. package/src/types/dispatches/MeleeDispatch.d.ts +8 -0
  49. package/src/types/dispatches/MovementDispatch.d.ts +12 -0
  50. package/src/types/dispatches/PauseDispatch.d.ts +8 -0
  51. package/src/types/dispatches/ReloadDispatch.d.ts +8 -0
  52. package/src/types/dispatches/ReportPlayerDispatch.d.ts +22 -0
  53. package/src/types/dispatches/SaveLoadoutDispatch.d.ts +34 -0
  54. package/src/types/dispatches/SpawnDispatch.d.ts +8 -0
  55. package/src/types/dispatches/SwapWeaponDispatch.d.ts +8 -0
  56. package/src/types/dispatches/SwitchTeamDispatch.d.ts +8 -0
  57. package/src/types/dispatches/ThrowGrenadeDispatch.d.ts +10 -0
  58. package/src/types/dispatches/index.d.ts +174 -0
  59. package/src/types/matchmaker.d.ts +19 -14
  60. package/src/types/socket.d.ts +7 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yolkbot",
3
3
  "description": "create a shell shockers (self) bot in under 10 lines.",
4
- "version": "0.1.0-alpha.5",
4
+ "version": "0.1.0-alpha.50",
5
5
  "keywords": [
6
6
  "shell shockers",
7
7
  "shellshock.io",
@@ -46,15 +46,34 @@
46
46
  "types": "./src/types/matchmaker.d.ts"
47
47
  },
48
48
  "./packets": "./src/packet.js",
49
- "./constants": "./src/constants/index.js",
50
- "./constants/*": "./src/constants/*.js",
51
- "./constants/*.js": "./src/constants/*.js",
52
- "./dispatch": "./src/dispatches/index.js",
53
- "./dispatch/*": "./src/dispatches/*.js",
54
- "./dispatch/*.js": "./src/dispatches/*.js"
49
+ "./constants": {
50
+ "import": "./src/constants/index.js",
51
+ "types": "./src/types/constants/index.d.ts"
52
+ },
53
+ "./constants/*": {
54
+ "import": "./src/constants/*.js",
55
+ "types": "./src/types/constants/*.d.ts"
56
+ },
57
+ "./constants/*.js": {
58
+ "import": "./src/constants/*.js",
59
+ "types": "./src/types/constants/*.d.ts"
60
+ },
61
+ "./dispatch": {
62
+ "import": "./src/dispatches/index.js",
63
+ "types": "./src/types/dispatches.d.ts"
64
+ },
65
+ "./dispatch/*": {
66
+ "import": "./src/dispatches/*.js",
67
+ "types": "./src/types/dispatches/*.d.ts"
68
+ },
69
+ "./dispatch/*.js": {
70
+ "import": "./src/dispatches/*.js",
71
+ "types": "./src/types/dispatches/*.d.ts"
72
+ }
55
73
  },
56
74
  "dependencies": {
57
- "socks-proxy-agent": "^8.0.5",
75
+ "axios": "^1.8.3",
76
+ "smallsocks": "^1.0.0",
58
77
  "ws": "^8.18.0"
59
78
  },
60
79
  "devDependencies": {
package/src/api.js CHANGED
@@ -1,18 +1,34 @@
1
+ import axios from 'axios';
2
+
1
3
  import yolkws from './socket.js';
2
4
 
3
- import { FirebaseKey, UserAgent } from '#constants';
5
+ import { FirebaseKey, IsBrowser, UserAgent } from '#constants';
6
+
7
+ let SocksProxyAgent;
8
+ if (!IsBrowser) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
4
9
 
5
10
  const queryServices = async (request, proxy = '', instance = 'shellshock.io') => {
6
- return new Promise((resolve) => {
7
- const ws = new yolkws(`wss://${instance}/services/`, proxy);
11
+ let ws;
12
+
13
+ const attempt = async () => {
14
+ try {
15
+ ws = new yolkws(`wss://${instance}/services/`, proxy);
16
+ } catch {
17
+ await new Promise((resolve) => setTimeout(resolve, 100));
18
+ await attempt();
19
+ }
20
+ }
8
21
 
22
+ await attempt();
23
+
24
+ return new Promise((resolve) => {
9
25
  ws.onopen = () => {
10
26
  // console.log('opened')
11
27
  ws.send(JSON.stringify(request));
12
28
  }
13
-
29
+
14
30
  let resolved = false;
15
-
31
+
16
32
  ws.onmessage = (mes) => {
17
33
  try {
18
34
  const resp = JSON.parse(mes.data);
@@ -35,7 +51,11 @@ const queryServices = async (request, proxy = '', instance = 'shellshock.io') =>
35
51
  });
36
52
  }
37
53
 
38
- async function loginWithCredentials(email, password, prox = '', instance = 'shellshock.io') {
54
+ async function createAccount(email, password, prox = '', instance = 'shellshock.io') {
55
+ return await loginWithCredentials(email, password, prox, instance, true);
56
+ }
57
+
58
+ async function loginWithCredentials(email, password, prox = '', instance = 'shellshock.io', _useRegisterEndpoint) {
39
59
  if (!email || !password) return 'firebase_no_credentials';
40
60
 
41
61
  /*
@@ -54,25 +74,26 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
54
74
  }
55
75
  */
56
76
 
77
+ const endpoint = _useRegisterEndpoint ? 'signUp' : 'signInWithPassword';
78
+
57
79
  let SUCCESS = false;
58
80
  let request, body, token;
59
81
  let k = 0;
60
82
 
61
83
  while (!SUCCESS) {
62
84
  try {
63
- request = await fetch('https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=' + FirebaseKey, {
64
- method: 'POST',
65
- body: JSON.stringify({
66
- email: email,
67
- password: password,
68
- returnSecureToken: true
69
- }),
85
+ request = await axios.post(`https://identitytoolkit.googleapis.com/v1/accounts:${endpoint}?key=${FirebaseKey}`, {
86
+ email: email,
87
+ password: password,
88
+ returnSecureToken: true
89
+ }, {
70
90
  headers: {
71
91
  'user-agent': UserAgent,
72
92
  'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
73
- }
93
+ },
94
+ httpsAgent: (!IsBrowser && prox) ? new SocksProxyAgent(prox) : false
74
95
  })
75
- body = await request.json();
96
+ body = request.data
76
97
  token = body.idToken;
77
98
  SUCCESS = true;
78
99
  } catch (error) {
@@ -87,8 +108,7 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
87
108
  }
88
109
 
89
110
  if (k > 5) return 'firebase_too_many_retries';
90
-
91
- await new Promise((resolve) => setTimeout(resolve, 100));
111
+ else await new Promise((resolve) => setTimeout(resolve, 100));
92
112
  }
93
113
  }
94
114
 
@@ -106,16 +126,16 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
106
126
  }
107
127
 
108
128
  async function loginAnonymously(prox = '', instance = 'shellshock.io') {
109
- const request = await fetch('https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=' + FirebaseKey, {
110
- method: 'POST',
111
- body: JSON.stringify({ returnSecureToken: true }),
129
+ const { data: body } = await axios.post('https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=' + FirebaseKey, {
130
+ returnSecureToken: true
131
+ }, {
112
132
  headers: {
113
133
  'user-agent': UserAgent,
114
134
  'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
115
- }
116
- })
135
+ },
136
+ httpsAgent: (!IsBrowser && prox) ? new SocksProxyAgent(prox) : false
137
+ });
117
138
 
118
- const body = await request.json();
119
139
  const token = body.idToken;
120
140
 
121
141
  if (!token) {
@@ -132,6 +152,7 @@ async function loginAnonymously(prox = '', instance = 'shellshock.io') {
132
152
  }
133
153
 
134
154
  export {
155
+ createAccount,
135
156
  loginAnonymously,
136
157
  loginWithCredentials,
137
158
  queryServices
@@ -2,7 +2,7 @@ import { GunList } from '#constants';
2
2
  import { Cluck9mm } from '../constants/guns.js';
3
3
 
4
4
  export class GamePlayer {
5
- constructor(id, team, playerData) {
5
+ constructor(id = -1, team = 0, playerData) {
6
6
  this.id = id;
7
7
  this.team = team;
8
8
 
@@ -13,7 +13,7 @@ export class GamePlayer {
13
13
 
14
14
  this.playing = playerData.playing_;
15
15
 
16
- this.social = playerData.social && JSON.parse(playerData.social_);
16
+ this.social = playerData.social_ && JSON.parse(playerData.social_);
17
17
  this.showBadge = !playerData.hideBadge_ || false;
18
18
 
19
19
  this.position = {
@@ -52,7 +52,7 @@ export class GamePlayer {
52
52
  this.weapons[1] = new Cluck9mm();
53
53
  }
54
54
 
55
- this.grenades = 0;
55
+ this.grenades = 1;
56
56
 
57
57
  this.buffer = {
58
58
  0: {},