funcraft-api-v3 0.0.1-security → 3.0.2

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.

Potentially problematic release.


This version of funcraft-api-v3 might be problematic. Click here for more details.

package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 gauthier-th
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,322 @@
1
- # Security holding package
2
-
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=funcraft-api-v3 for more information.
1
+ # API Funcraft
2
+
3
+ Une API pour récupérer les statistiques de FunCraft.net ! - modified by molo (discord : molofdb)
4
+
5
+ ## Sommaire
6
+
7
+ [Utilisation :](#utilisation)
8
+ - [Initialisation](#initialisation)
9
+ - [FuncraftApi.stats](#funcraftapi-stats)
10
+ - [FuncraftApi.allstats](#funcraftapi-allstats)
11
+ - [FuncraftApi.infos](#funcraftapi-infos)
12
+ - [FuncraftApi.friends](#funcraftapi-friends)
13
+ - [FuncraftApi.head](#funcraftapi-head)
14
+ - [FuncraftApi.table](#funcraftapi-table)
15
+
16
+ [Autre informations :](#autre-informations)
17
+ - [Codes d'erreur](#codes-derreur)
18
+ - [Périodes](#periodes)
19
+ - [Jeux](#jeux)
20
+
21
+ <a name="utilisation" />
22
+
23
+ ## Utilisation
24
+
25
+ L'API est documenté avec JSDoc. Elle est également compatible avec TypeScript.
26
+
27
+ <a name="initialisation" />
28
+
29
+ ### Initialisation :
30
+
31
+ Installez le paquet avec NPM : `npm install funcraft-api-v3` ou Yarn : `yarn add funcraft-api-v3`.
32
+
33
+ ```js
34
+ const FuncraftApi = require('funcraft-api-v3');
35
+ ```
36
+
37
+ <a name="funcraftapi-stats" />
38
+
39
+ ### FuncraftApi.stats(period, game, username): Promise\<StatsResponse\>
40
+
41
+ Renvoie une [promesse](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Promise) contenant les statistiques d'un mode de jeu et d'une période spécifique.
42
+
43
+ ```js
44
+ FuncraftApi.stats('toujours', 'shootcraft', 'jujoh').then(console.log).catch(console.error);
45
+ ```
46
+
47
+ ```js
48
+ {
49
+ code: 0,
50
+ error: null,
51
+ userId: '177',
52
+ username: 'jujoh',
53
+ month: 0,
54
+ monthName: 'always',
55
+ game: 'shootcraft',
56
+ rank: 22,
57
+ data: {
58
+ points: 229557,
59
+ gameCount: 5029,
60
+ winCount: 4901,
61
+ defeatCount: 128,
62
+ gameTime: 15467,
63
+ kills: 234252,
64
+ deathCount: 30149
65
+ },
66
+ stats: {
67
+ winrate: 97.455,
68
+ kd: 7.77,
69
+ ragequit: 38.489,
70
+ killsPerGame: 46.58,
71
+ deathsPerGame: 5.995,
72
+ pointsPerGame: 45.647,
73
+ killsPerMinute: 15.145,
74
+ secondsPerKill: 3.962
75
+ },
76
+ skin: 'https://d31zb6ev5hmn3f.cloudfront.net/_u/avatar/head/jujoh/m2/f3cc7aa5869ddab02eafcfa37cc667209d34f3ca'
77
+ }
78
+ ```
79
+
80
+ <a name="funcraftapi-allstats" />
81
+
82
+ ### FuncraftApi.allStats(username): Promise\<object\>
83
+
84
+ Renvoie une [promesse](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Promise) contenant les statistiques de tous les modes de jeux dans toutes les périodes disponibles.
85
+
86
+ ```js
87
+ FuncraftApi.allStats('jujoh').then(console.log).catch(console.error);
88
+ ```
89
+
90
+ ```js
91
+ {
92
+ code: 0,
93
+ error: null,
94
+ infos: {
95
+ username: 'jujoh',
96
+ skin: 'https://d31zb6ev5hmn3f.cloudfront.net/_u/avatar/head/jujoh/m2/f3cc7aa5869ddab02eafcfa37cc667209d34f3ca',
97
+ userId: '177'
98
+ },
99
+ rush_retro: {
100
+ always: null,
101
+ march: null,
102
+ february: null,
103
+ january: null,
104
+ december: null
105
+ },
106
+ rush_mdt: {
107
+ always: {
108
+ code: 0,
109
+ error: null,
110
+ username: 'jujoh',
111
+ month: 0,
112
+ monthName: 'always',
113
+ game: 'rush_mdt',
114
+ rank: 19605,
115
+ data: [Object],
116
+ stats: [Object],
117
+ skin: 'https://d31zb6ev5hmn3f.cloudfront.net/_u/avatar/head/jujoh/m2/f3cc7aa5869ddab02eafcfa37cc667209d34f3ca',
118
+ userId: '177'
119
+ },
120
+ march: null,
121
+ february: null,
122
+ january: null,
123
+ december: null
124
+ },
125
+ ...
126
+ }
127
+ ```
128
+
129
+ <a name="funcraftapi-infos" />
130
+
131
+ ### FuncraftApi.infos(username, fetchFriends? = true): Promise\<InfosResponse\>
132
+
133
+ Renvoie une [promesse](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Promise) contenant les informations d'un joueur. `fetchFriends` est un booléen spéicifiant si une autre requête pour récupérer les amis doit être faite.
134
+
135
+ La valeur de `ban` peut être : `NONE`, `TEMP` ou `DEF`.
136
+
137
+ ```js
138
+ FuncraftApi.infos('jujoh').then(console.log);
139
+ ```
140
+
141
+ ```js
142
+ {
143
+ code: 0,
144
+ error: null,
145
+ grade: 'Shootcraft',
146
+ username: 'jujoh',
147
+ userId: '177',
148
+ skin: 'https://d31zb6ev5hmn3f.cloudfront.net/_u/avatar/head/jujoh/m2/f3cc7aa5869ddab02eafcfa37cc667209d34f3ca',
149
+ inscription: Date('2016-01-14T17:28:00.000Z'),
150
+ lastConnection: Date('2021-03-29T21:06:00.000Z'),
151
+ gloires: 1178354,
152
+ gameCount: 14072,
153
+ points: 596411,
154
+ winCount: 12765,
155
+ defeatCount: 1307,
156
+ gameTime: 52529,
157
+ kills: 276657,
158
+ deathCount: 46711,
159
+ ban: 'NONE',
160
+ friends: [
161
+ {
162
+ nom: 'AcyD_',
163
+ skin: 'https://d31zb6ev5hmn3f.cloudfront.net/_u/avatar/head/AcyD_/s/fa4652a59a640d3bde1aca803f6a27ed81107f94'
164
+ },
165
+ ...
166
+ ]
167
+ }
168
+ ```
169
+
170
+ <a name="funcraftapi-friends" />
171
+
172
+ ### FuncraftApi.friends(userId): Promise\<object\>
173
+
174
+ Renvoie une [promesse](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Promise) contenant la liste des amis d'un joueur.
175
+
176
+ ```js
177
+ FuncraftApi.friends('177').then(console.log);
178
+ ```
179
+
180
+ ```js
181
+ {
182
+ code: 0,
183
+ error: null,
184
+ friends: [
185
+ {
186
+ nom: 'AcyD_',
187
+ skin: 'https://d31zb6ev5hmn3f.cloudfront.net/_u/avatar/head/AcyD_/s/fa4652a59a640d3bde1aca803f6a27ed81107f94'
188
+ },
189
+ ...
190
+ ]
191
+ }
192
+ ```
193
+
194
+ <a name="funcraftapi-head" />
195
+
196
+ ### FuncraftApi.head(username): Promise\<string\>
197
+
198
+ Renvoie une [promesse](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Promise) contenant l'URL du skin de la tête d'un joueur.
199
+
200
+ ```js
201
+ FuncraftApi.head('jujoh').then(console.log);
202
+ ```
203
+
204
+ ```js
205
+ 'https://d31zb6ev5hmn3f.cloudfront.net/_u/avatar/head/jujoh/m2/f3cc7aa5869ddab02eafcfa37cc667209d34f3ca'
206
+ ```
207
+
208
+ <a name="funcraftapi-table" />
209
+
210
+ ### FuncraftApi.table(period, game): Promise\<StatsResponse[]\>
211
+
212
+ Renvoie une [promesse](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Promise) contenant les stats du top 100 d'un jeu. Les skins ne sont disponible que pour les 3 premiers joueurs.
213
+
214
+ ```js
215
+ FuncraftApi.table('always', 'shootcraft').then(console.log);
216
+ ```
217
+
218
+ ```js
219
+ [
220
+ {
221
+ code: 0,
222
+ error: null,
223
+ userId: '393176',
224
+ username: 'CptnKILL',
225
+ month: 0,
226
+ monthName: 'always',
227
+ game: 'shootcraft',
228
+ rank: 1,
229
+ data: {
230
+ points: 1402275,
231
+ gameCount: 13440,
232
+ winCount: 9462,
233
+ defeatCount: 3978,
234
+ gameTime: 50883,
235
+ kills: 640543,
236
+ deathCount: 207115
237
+ },
238
+ stats: {
239
+ winrate: 70.402,
240
+ kd: 3.093,
241
+ ragequit: 24.281,
242
+ killsPerGame: 47.659,
243
+ deathsPerGame: 15.41,
244
+ pointsPerGame: 104.336,
245
+ killsPerMinute: 12.589,
246
+ secondsPerKill: 4.766
247
+ },
248
+ skin: 'https://d31zb6ev5hmn3f.cloudfront.net/_u/avatar/head/CptnKILL/s/cc9d545b3ccc7b9789cb902aed70e8bfe276317b'
249
+ },
250
+ ...
251
+ ]
252
+ ```
253
+
254
+ <a name="autres-informations" />
255
+
256
+ ## Autres informations
257
+
258
+ <a name="codes-derreur" />
259
+
260
+ ### Codes d'erreur
261
+
262
+ Lorsqu'une requête échoue, la promesse retourn une erreur sous la forme d'un objet de la forme suivante :
263
+
264
+ ```js
265
+ { code: 1, error: 'Specified game is incorrect.' }
266
+ ```
267
+
268
+ Voici les différents codes d'erreur :
269
+
270
+ | Code | Description |
271
+ |:----:| ------------------------------------- |
272
+ | 0 | Aucune erreur |
273
+ | 1 | Jeu incorrect |
274
+ | 2 | Période incorrecte |
275
+ | 3 | Joueur inconnu |
276
+ | 4 | Aucune données pour cette période |
277
+ | 5 | Erreur de connexion avec funcraft.net |
278
+
279
+ <a name="periodes" />
280
+
281
+ ### Périodes
282
+
283
+ Pour les statistiques global, vous pouvez utiliser :
284
+ - toujours
285
+ - always
286
+ - 0
287
+
288
+ Pour les statistiques mensuels :
289
+ - le nom du mois en français (janvier, février, fevrier, etc.)
290
+ - le nom du mois en anglais (january, february, etc.)
291
+ - le chiffre le représentant (1 = janvier, 2 = février, etc.)
292
+
293
+ Pour les tableaux du top 100, vous devez spécifier soit `always`, soit la période sous la forme `YYYY-MM`.
294
+
295
+ Note : vous ne pouvez pas récupérer via la méthode `stats` les statistiques datant de plus de 3 mois.
296
+ Note 2 : les accents ne sont pas pris en compte.
297
+
298
+ <a name="jeux" />
299
+
300
+ ### Jeux
301
+
302
+ Les noms et alias des jeux sont :
303
+
304
+ | Noms | rush_retro | rush_mdt | hikabrain | skywars | octogone | shootcraft | infected | survival | blitz | pvpsmash | landrush |
305
+ |-------|------------|----------|-----------|---------|----------|------------|----------|----------|-------|----------|----------|
306
+ | Alias | | rush | hika | sky | mma | shoot | infecte | | | pvp | land |
307
+
308
+ Note : les accents ne sont pas pris en compte.
309
+
310
+ ### Outils
311
+
312
+ Vous pouvez récupérer les liste des noms et alias des jeux dans `FuncraftApi.utils.data`.
313
+
314
+ Les fonction `FuncraftApi.utils.vGetPeriod` et `FuncraftApi.utils.vGetGame` servent à déterminer si une période ou un mode de jeu est valide.
315
+
316
+ Se référer à la JSDoc ou voir le code source pour plus de détails.
317
+
318
+ ## Licence
319
+
320
+ Licence MIT
321
+
322
+ Copyright (c) 2021 gauthier-th
package/errors.js ADDED
@@ -0,0 +1,20 @@
1
+ const none = () => ({ code: 0, error: null });
2
+ const incorrectGame = () => ({ code: 1, error: "Specified game is incorrect." });
3
+ const incorrectPeriod = () => ({ code: 2, error: "Specified period is incorrect." });
4
+ /** @param {string} username */
5
+ const unknownPlayer = (username) => ({ code: 3, error: `Player ${username ? username + ' ' : ''}doesn't exists.` });
6
+ const noStatistics = () => ({ code: 4, error: "No statistics for this period." });
7
+ const connectionError = () => ({ code: 5, error: "Unable to connect to funcraft.net." });
8
+
9
+ const errors = {
10
+ stats: { none, incorrectGame, incorrectPeriod, unknownPlayer, noStatistics, connectionError },
11
+ allStats: { none, unknownPlayer, connectionError },
12
+ infos: { none, unknownPlayer, connectionError },
13
+ friends: { none, unknownPlayer, connectionError },
14
+ table: { none, incorrectGame, noStatistics, connectionError },
15
+ head: { none, unknownPlayer, connectionError },
16
+ getMonthsDispo: { none, unknownPlayer, connectionError },
17
+ statsOfAllMonths: { none, incorrectPeriod, unknownPlayer, connectionError }
18
+ };
19
+
20
+ module.exports = errors;