tiny-essentials 1.3.0 → 1.3.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.
- package/dist/TinyEssentials.js +16 -8
- package/dist/TinyLevelUp.js +16 -8
- package/dist/legacy/firebase/cookieSession.cjs +1 -1
- package/dist/legacy/firebase/cookieSession.d.mts +2 -2
- package/dist/legacy/firebase/cookieSession.mjs +1 -1
- package/dist/legacy/firebase/databaseLogger.cjs +5 -5
- package/dist/legacy/firebase/databaseLogger.d.mts +2 -2
- package/dist/legacy/firebase/databaseLogger.mjs +5 -5
- package/dist/legacy/firebase/discord/api/addGuildMember.cjs +2 -2
- package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/addGuildMember.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getGuildWidget.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getGuildWidget.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getToken.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getToken.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getToken.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getUser.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getUser.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getUser.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getUserConnections.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getUserConnections.mjs +2 -2
- package/dist/legacy/firebase/discord/api/getUserGuilds.cjs +2 -2
- package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/getUserGuilds.mjs +2 -2
- package/dist/legacy/firebase/discord/api/refreshToken.cjs +2 -2
- package/dist/legacy/firebase/discord/api/refreshToken.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/refreshToken.mjs +2 -2
- package/dist/legacy/firebase/discord/api/revokeToken.cjs +2 -2
- package/dist/legacy/firebase/discord/api/revokeToken.d.mts +3 -3
- package/dist/legacy/firebase/discord/api/revokeToken.mjs +2 -2
- package/dist/legacy/firebase/discord/get/authURLGenerator.cjs +3 -3
- package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +4 -4
- package/dist/legacy/firebase/discord/get/authURLGenerator.mjs +3 -3
- package/dist/legacy/firebase/discord/get/cookie-session.cjs +1 -1
- package/dist/legacy/firebase/discord/get/cookie-session.d.mts +2 -2
- package/dist/legacy/firebase/discord/get/cookie-session.mjs +1 -1
- package/dist/legacy/firebase/discord/get/errorValidator.cjs +1 -1
- package/dist/legacy/firebase/discord/get/errorValidator.d.mts +2 -2
- package/dist/legacy/firebase/discord/get/errorValidator.mjs +1 -1
- package/dist/legacy/firebase/discord/http/login.cjs +3 -3
- package/dist/legacy/firebase/discord/http/login.d.mts +4 -4
- package/dist/legacy/firebase/discord/http/login.mjs +3 -3
- package/dist/legacy/firebase/discord/http/logout.cjs +4 -4
- package/dist/legacy/firebase/discord/http/logout.d.mts +5 -5
- package/dist/legacy/firebase/discord/http/logout.mjs +4 -4
- package/dist/legacy/firebase/discord/http/redirect.cjs +4 -4
- package/dist/legacy/firebase/discord/http/redirect.d.mts +5 -5
- package/dist/legacy/firebase/discord/http/redirect.mjs +4 -4
- package/dist/legacy/firebase/discord/http/refreshToken.cjs +4 -4
- package/dist/legacy/firebase/discord/http/refreshToken.d.mts +5 -5
- package/dist/legacy/firebase/discord/http/refreshToken.mjs +4 -4
- package/dist/legacy/firebase/discord/template/cookie-session.cjs +2 -2
- package/dist/legacy/firebase/discord/template/cookie-session.d.mts +5 -5
- package/dist/legacy/firebase/discord/template/cookie-session.mjs +2 -2
- package/dist/legacy/firebase/escape.cjs +1 -1
- package/dist/legacy/firebase/escape.d.mts +2 -2
- package/dist/legacy/firebase/escape.mjs +1 -1
- package/dist/legacy/firebase/index.cjs +6 -6
- package/dist/legacy/firebase/index.d.mts +7 -7
- package/dist/legacy/firebase/index.mjs +6 -6
- package/dist/legacy/firebase/logger.cjs +5 -5
- package/dist/legacy/firebase/logger.d.mts +4 -4
- package/dist/legacy/firebase/logger.mjs +5 -5
- package/dist/legacy/firebase/mySQL.cjs +2 -2
- package/dist/legacy/firebase/mySQL.d.mts +3 -3
- package/dist/legacy/firebase/mySQL.mjs +2 -2
- package/dist/legacy/firebase/mysqlConnector/create.cjs +4 -4
- package/dist/legacy/firebase/mysqlConnector/create.d.mts +5 -5
- package/dist/legacy/firebase/mysqlConnector/create.mjs +4 -4
- package/dist/legacy/firebase/mysqlConnector/nextPrev.cjs +2 -2
- package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +4 -4
- package/dist/legacy/firebase/mysqlConnector/nextPrev.mjs +2 -2
- package/dist/legacy/firebase/mysqlConnector/pagination.cjs +4 -4
- package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +6 -6
- package/dist/legacy/firebase/mysqlConnector/pagination.mjs +4 -4
- package/dist/legacy/firebase/transactionDBAsync.cjs +1 -1
- package/dist/legacy/firebase/transactionDBAsync.d.mts +2 -2
- package/dist/legacy/firebase/transactionDBAsync.mjs +1 -1
- package/dist/legacy/get/pagination.cjs +1 -1
- package/dist/legacy/get/pagination.d.mts +2 -2
- package/dist/legacy/get/pagination.mjs +1 -1
- package/dist/legacy/get/versionCheck.cjs +1 -1
- package/dist/legacy/get/versionCheck.d.mts +2 -2
- package/dist/legacy/get/versionCheck.mjs +1 -1
- package/dist/legacy/http/check_domain.cjs +2 -2
- package/dist/legacy/http/check_domain.d.mts +2 -2
- package/dist/legacy/http/check_domain.mjs +2 -2
- package/dist/legacy/http/csrfTokenAnalyze.cjs +2 -2
- package/dist/legacy/http/csrfTokenAnalyze.d.mts +3 -3
- package/dist/legacy/http/csrfTokenAnalyze.mjs +2 -2
- package/dist/legacy/http/domainValidator.cjs +3 -3
- package/dist/legacy/http/domainValidator.d.mts +4 -4
- package/dist/legacy/http/domainValidator.mjs +3 -3
- package/dist/legacy/http/userIP.cjs +1 -1
- package/dist/legacy/http/userIP.d.mts +2 -4
- package/dist/legacy/http/userIP.mjs +1 -1
- package/dist/legacy/index.d.mts +4 -4
- package/dist/legacy/libs/custom_module_loader.cjs +2 -2
- package/dist/legacy/libs/custom_module_loader.d.mts +2 -2
- package/dist/legacy/libs/custom_module_loader.mjs +2 -2
- package/dist/legacy/libs/userLevel.cjs +16 -8
- package/dist/legacy/libs/userLevel.d.mts +34 -12
- package/dist/legacy/libs/userLevel.mjs +14 -8
- package/dist/legacy/socket.io/antiFlood/install.cjs +3 -3
- package/dist/legacy/socket.io/antiFlood/install.d.mts +4 -6
- package/dist/legacy/socket.io/antiFlood/install.mjs +3 -3
- package/dist/legacy/socket.io/antiFlood/verify.cjs +4 -4
- package/dist/legacy/socket.io/antiFlood/verify.d.mts +5 -7
- package/dist/legacy/socket.io/antiFlood/verify.mjs +4 -4
- package/dist/legacy/socket.io/cookie-session.cjs +2 -2
- package/dist/legacy/socket.io/cookie-session.d.mts +3 -3
- package/dist/legacy/socket.io/cookie-session.mjs +2 -2
- package/dist/legacy/socket.io/discord.cjs +3 -3
- package/dist/legacy/socket.io/discord.d.mts +4 -4
- package/dist/legacy/socket.io/discord.mjs +3 -3
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import _ from 'lodash';
|
|
|
5
5
|
* supporting detection for Firebase/Cloud Functions, proxies, and direct connections.
|
|
6
6
|
*
|
|
7
7
|
* @param {import('express').Request} req - The Express request object.
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {Record<string, any>} [options] - Optional configuration.
|
|
9
9
|
* @param {boolean} [options.isFirebase=false] - Enable detection for Firebase environments (e.g., Fastly).
|
|
10
10
|
*
|
|
11
11
|
* @returns {{ value: string[] | null, type: string | null }} An object containing the list of IP addresses and the detection source type.
|
package/dist/legacy/index.d.mts
CHANGED
|
@@ -20,8 +20,8 @@ declare const legacyModules: {
|
|
|
20
20
|
callback: (arg0: req) => Object;
|
|
21
21
|
the_domain?: string;
|
|
22
22
|
}>;
|
|
23
|
-
validator: (req:
|
|
24
|
-
get: (req:
|
|
23
|
+
validator: (req: Record<string, any>, the_domain: string) => boolean;
|
|
24
|
+
get: (req: Record<string, any>) => string | null;
|
|
25
25
|
};
|
|
26
26
|
getObjType: typeof objType;
|
|
27
27
|
countObj: typeof countObj;
|
|
@@ -30,8 +30,8 @@ declare const legacyModules: {
|
|
|
30
30
|
getUserIP: typeof userIp;
|
|
31
31
|
superStringFilter: typeof super_string_filter;
|
|
32
32
|
customModuleManager: {
|
|
33
|
-
validator: (custom_modules:
|
|
34
|
-
run: (custom_modules: Object | Function[], db_prepare: any, hookType: string, options?:
|
|
33
|
+
validator: (custom_modules: Record<string, any>, type: string) => boolean;
|
|
34
|
+
run: (custom_modules: Object | Function[], db_prepare: any, hookType: string, options?: Record<string, any>) => Promise<void>;
|
|
35
35
|
};
|
|
36
36
|
errorsCallback: typeof errorsCallback;
|
|
37
37
|
domainValidator: typeof domainValidator;
|
|
@@ -13,7 +13,7 @@ var objType = require('../get/objType.cjs');
|
|
|
13
13
|
const custom_module_manager = {
|
|
14
14
|
/**
|
|
15
15
|
* Validates if the given object has valid custom or default module arrays.
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {Record<string, any>} custom_modules - The object containing module definitions.
|
|
17
17
|
* @param {string} type - The specific type of module to validate.
|
|
18
18
|
* @returns {boolean} Whether the module is valid.
|
|
19
19
|
*
|
|
@@ -37,7 +37,7 @@ const custom_module_manager = {
|
|
|
37
37
|
* @param {Object|Function[]} custom_modules - The modules or functions to run.
|
|
38
38
|
* @param {*} db_prepare - A value to pass to each module when called.
|
|
39
39
|
* @param {string} hookType - A string representing the hook (e.g., 'before', 'after').
|
|
40
|
-
* @param {
|
|
40
|
+
* @param {Record<string, any>} [options] - Optional. Object with keys matching types in `custom_modules`.
|
|
41
41
|
*
|
|
42
42
|
* @returns {Promise<void>}
|
|
43
43
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default custom_module_manager;
|
|
2
2
|
declare namespace custom_module_manager {
|
|
3
|
-
function validator(custom_modules:
|
|
4
|
-
function run(custom_modules: Object | Function[], db_prepare: any, hookType: string, options?:
|
|
3
|
+
function validator(custom_modules: Record<string, any>, type: string): boolean;
|
|
4
|
+
function run(custom_modules: Object | Function[], db_prepare: any, hookType: string, options?: Record<string, any>): Promise<void>;
|
|
5
5
|
}
|
|
@@ -8,7 +8,7 @@ import objType from '../get/objType.mjs';
|
|
|
8
8
|
const custom_module_manager = {
|
|
9
9
|
/**
|
|
10
10
|
* Validates if the given object has valid custom or default module arrays.
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Record<string, any>} custom_modules - The object containing module definitions.
|
|
12
12
|
* @param {string} type - The specific type of module to validate.
|
|
13
13
|
* @returns {boolean} Whether the module is valid.
|
|
14
14
|
*
|
|
@@ -30,7 +30,7 @@ const custom_module_manager = {
|
|
|
30
30
|
* @param {Object|Function[]} custom_modules - The modules or functions to run.
|
|
31
31
|
* @param {*} db_prepare - A value to pass to each module when called.
|
|
32
32
|
* @param {string} hookType - A string representing the hook (e.g., 'before', 'after').
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {Record<string, any>} [options] - Optional. Object with keys matching types in `custom_modules`.
|
|
34
34
|
*
|
|
35
35
|
* @returns {Promise<void>}
|
|
36
36
|
*
|
|
@@ -14,10 +14,18 @@ class TinyLevelUp {
|
|
|
14
14
|
this.expLevel = expLevel;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {{ exp: number, level: number, totalExp: number }} UserResult
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{ exp: number, level: number, totalExp: any }} UserEditor
|
|
23
|
+
*/
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* Validates and adjusts the user's level based on their current experience.
|
|
19
|
-
* @param {
|
|
20
|
-
* @returns {
|
|
27
|
+
* @param {UserEditor} user - The user object containing experience and level properties.
|
|
28
|
+
* @returns {UserResult} The updated user object.
|
|
21
29
|
*/
|
|
22
30
|
expValidator(user) {
|
|
23
31
|
let extraValue = 0;
|
|
@@ -85,9 +93,9 @@ class TinyLevelUp {
|
|
|
85
93
|
|
|
86
94
|
/**
|
|
87
95
|
* Sets the experience value for the user, adjusting their level if necessary.
|
|
88
|
-
* @param {
|
|
96
|
+
* @param {UserEditor} user - The user object.
|
|
89
97
|
* @param {number} value - The new experience value to set.
|
|
90
|
-
* @returns {
|
|
98
|
+
* @returns {UserResult} The updated user object.
|
|
91
99
|
*/
|
|
92
100
|
set(user, value) {
|
|
93
101
|
user.exp = value;
|
|
@@ -98,11 +106,11 @@ class TinyLevelUp {
|
|
|
98
106
|
|
|
99
107
|
/**
|
|
100
108
|
* Adds experience to the user, adjusting their level if necessary.
|
|
101
|
-
* @param {
|
|
109
|
+
* @param {UserEditor} user - The user object.
|
|
102
110
|
* @param {number} extraExp - Additional experience to be added.
|
|
103
111
|
* @param {'add' | 'extra'} type - Type of addition ('add' or 'extra').
|
|
104
112
|
* @param {number} multi - Multiplier for experience generation.
|
|
105
|
-
* @returns {
|
|
113
|
+
* @returns {UserResult} The updated user object.
|
|
106
114
|
*/
|
|
107
115
|
give(user, extraExp = 0, type = 'add', multi = 1) {
|
|
108
116
|
if (type === 'add') user.exp += this.expGenerator(multi) + extraExp;
|
|
@@ -115,11 +123,11 @@ class TinyLevelUp {
|
|
|
115
123
|
|
|
116
124
|
/**
|
|
117
125
|
* Removes experience from the user, adjusting their level if necessary.
|
|
118
|
-
* @param {
|
|
126
|
+
* @param {UserEditor} user - The user object.
|
|
119
127
|
* @param {number} extraExp - Experience to remove.
|
|
120
128
|
* @param {'add' | 'extra'} type - Type of removal ('add' or 'extra').
|
|
121
129
|
* @param {number} multi - Multiplier for experience generation.
|
|
122
|
-
* @returns {
|
|
130
|
+
* @returns {UserResult} The updated user object.
|
|
123
131
|
*/
|
|
124
132
|
remove(user, extraExp = 0, type = 'add', multi = 1) {
|
|
125
133
|
if (type === 'add') user.exp -= this.expGenerator(multi) + extraExp;
|
|
@@ -11,16 +11,26 @@ declare class TinyLevelUp {
|
|
|
11
11
|
constructor(giveExp: number, expLevel: number);
|
|
12
12
|
giveExp: number;
|
|
13
13
|
expLevel: number;
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{ exp: number, level: number, totalExp: number }} UserResult
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {{ exp: number, level: number, totalExp: any }} UserEditor
|
|
19
|
+
*/
|
|
14
20
|
/**
|
|
15
21
|
* Validates and adjusts the user's level based on their current experience.
|
|
16
|
-
* @param {
|
|
17
|
-
* @returns {
|
|
22
|
+
* @param {UserEditor} user - The user object containing experience and level properties.
|
|
23
|
+
* @returns {UserResult} The updated user object.
|
|
18
24
|
*/
|
|
19
25
|
expValidator(user: {
|
|
20
26
|
exp: number;
|
|
21
27
|
level: number;
|
|
22
28
|
totalExp: any;
|
|
23
|
-
}):
|
|
29
|
+
}): {
|
|
30
|
+
exp: number;
|
|
31
|
+
level: number;
|
|
32
|
+
totalExp: number;
|
|
33
|
+
};
|
|
24
34
|
/**
|
|
25
35
|
* Calculates the total experience based on the user's level.
|
|
26
36
|
* @param {{ exp: number, level: number }} user - The user object containing experience and level properties.
|
|
@@ -54,39 +64,51 @@ declare class TinyLevelUp {
|
|
|
54
64
|
}): number;
|
|
55
65
|
/**
|
|
56
66
|
* Sets the experience value for the user, adjusting their level if necessary.
|
|
57
|
-
* @param {
|
|
67
|
+
* @param {UserEditor} user - The user object.
|
|
58
68
|
* @param {number} value - The new experience value to set.
|
|
59
|
-
* @returns {
|
|
69
|
+
* @returns {UserResult} The updated user object.
|
|
60
70
|
*/
|
|
61
71
|
set(user: {
|
|
62
72
|
exp: number;
|
|
63
73
|
level: number;
|
|
64
74
|
totalExp: any;
|
|
65
|
-
}, value: number):
|
|
75
|
+
}, value: number): {
|
|
76
|
+
exp: number;
|
|
77
|
+
level: number;
|
|
78
|
+
totalExp: number;
|
|
79
|
+
};
|
|
66
80
|
/**
|
|
67
81
|
* Adds experience to the user, adjusting their level if necessary.
|
|
68
|
-
* @param {
|
|
82
|
+
* @param {UserEditor} user - The user object.
|
|
69
83
|
* @param {number} extraExp - Additional experience to be added.
|
|
70
84
|
* @param {'add' | 'extra'} type - Type of addition ('add' or 'extra').
|
|
71
85
|
* @param {number} multi - Multiplier for experience generation.
|
|
72
|
-
* @returns {
|
|
86
|
+
* @returns {UserResult} The updated user object.
|
|
73
87
|
*/
|
|
74
88
|
give(user: {
|
|
75
89
|
exp: number;
|
|
76
90
|
level: number;
|
|
77
91
|
totalExp: any;
|
|
78
|
-
}, extraExp?: number, type?: "add" | "extra", multi?: number):
|
|
92
|
+
}, extraExp?: number, type?: "add" | "extra", multi?: number): {
|
|
93
|
+
exp: number;
|
|
94
|
+
level: number;
|
|
95
|
+
totalExp: number;
|
|
96
|
+
};
|
|
79
97
|
/**
|
|
80
98
|
* Removes experience from the user, adjusting their level if necessary.
|
|
81
|
-
* @param {
|
|
99
|
+
* @param {UserEditor} user - The user object.
|
|
82
100
|
* @param {number} extraExp - Experience to remove.
|
|
83
101
|
* @param {'add' | 'extra'} type - Type of removal ('add' or 'extra').
|
|
84
102
|
* @param {number} multi - Multiplier for experience generation.
|
|
85
|
-
* @returns {
|
|
103
|
+
* @returns {UserResult} The updated user object.
|
|
86
104
|
*/
|
|
87
105
|
remove(user: {
|
|
88
106
|
exp: number;
|
|
89
107
|
level: number;
|
|
90
108
|
totalExp: any;
|
|
91
|
-
}, extraExp?: number, type?: "add" | "extra", multi?: number):
|
|
109
|
+
}, extraExp?: number, type?: "add" | "extra", multi?: number): {
|
|
110
|
+
exp: number;
|
|
111
|
+
level: number;
|
|
112
|
+
totalExp: number;
|
|
113
|
+
};
|
|
92
114
|
}
|
|
@@ -11,10 +11,16 @@ class TinyLevelUp {
|
|
|
11
11
|
this.giveExp = giveExp;
|
|
12
12
|
this.expLevel = expLevel;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{ exp: number, level: number, totalExp: number }} UserResult
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {{ exp: number, level: number, totalExp: any }} UserEditor
|
|
19
|
+
*/
|
|
14
20
|
/**
|
|
15
21
|
* Validates and adjusts the user's level based on their current experience.
|
|
16
|
-
* @param {
|
|
17
|
-
* @returns {
|
|
22
|
+
* @param {UserEditor} user - The user object containing experience and level properties.
|
|
23
|
+
* @returns {UserResult} The updated user object.
|
|
18
24
|
*/
|
|
19
25
|
expValidator(user) {
|
|
20
26
|
let extraValue = 0;
|
|
@@ -75,9 +81,9 @@ class TinyLevelUp {
|
|
|
75
81
|
}
|
|
76
82
|
/**
|
|
77
83
|
* Sets the experience value for the user, adjusting their level if necessary.
|
|
78
|
-
* @param {
|
|
84
|
+
* @param {UserEditor} user - The user object.
|
|
79
85
|
* @param {number} value - The new experience value to set.
|
|
80
|
-
* @returns {
|
|
86
|
+
* @returns {UserResult} The updated user object.
|
|
81
87
|
*/
|
|
82
88
|
set(user, value) {
|
|
83
89
|
user.exp = value;
|
|
@@ -87,11 +93,11 @@ class TinyLevelUp {
|
|
|
87
93
|
}
|
|
88
94
|
/**
|
|
89
95
|
* Adds experience to the user, adjusting their level if necessary.
|
|
90
|
-
* @param {
|
|
96
|
+
* @param {UserEditor} user - The user object.
|
|
91
97
|
* @param {number} extraExp - Additional experience to be added.
|
|
92
98
|
* @param {'add' | 'extra'} type - Type of addition ('add' or 'extra').
|
|
93
99
|
* @param {number} multi - Multiplier for experience generation.
|
|
94
|
-
* @returns {
|
|
100
|
+
* @returns {UserResult} The updated user object.
|
|
95
101
|
*/
|
|
96
102
|
give(user, extraExp = 0, type = 'add', multi = 1) {
|
|
97
103
|
if (type === 'add')
|
|
@@ -104,11 +110,11 @@ class TinyLevelUp {
|
|
|
104
110
|
}
|
|
105
111
|
/**
|
|
106
112
|
* Removes experience from the user, adjusting their level if necessary.
|
|
107
|
-
* @param {
|
|
113
|
+
* @param {UserEditor} user - The user object.
|
|
108
114
|
* @param {number} extraExp - Experience to remove.
|
|
109
115
|
* @param {'add' | 'extra'} type - Type of removal ('add' or 'extra').
|
|
110
116
|
* @param {number} multi - Multiplier for experience generation.
|
|
111
|
-
* @returns {
|
|
117
|
+
* @returns {UserResult} The updated user object.
|
|
112
118
|
*/
|
|
113
119
|
remove(user, extraExp = 0, type = 'add', multi = 1) {
|
|
114
120
|
if (type === 'add')
|
|
@@ -11,9 +11,9 @@ var userIP = require('../../http/userIP.cjs');
|
|
|
11
11
|
* This middleware checks the user's IP address and allows or denies the socket connection based on whether
|
|
12
12
|
* the IP is in the block list or not.
|
|
13
13
|
*
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {Array} ioCache.blocklick - The list of blocked IP addresses.
|
|
14
|
+
* @param {Record<string, any>} io - The Socket.IO server instance.
|
|
15
|
+
* @param {Record<string, any>} ioCache - The cache object containing blocked IPs.
|
|
16
|
+
* @param {Array<*>} ioCache.blocklick - The list of blocked IP addresses.
|
|
17
17
|
* @returns {void} This function does not return a value, it just sets the authorization logic for socket connections.
|
|
18
18
|
*/
|
|
19
19
|
function install(io, ioCache) {
|
|
@@ -4,11 +4,9 @@
|
|
|
4
4
|
* This middleware checks the user's IP address and allows or denies the socket connection based on whether
|
|
5
5
|
* the IP is in the block list or not.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {Array} ioCache.blocklick - The list of blocked IP addresses.
|
|
7
|
+
* @param {Record<string, any>} io - The Socket.IO server instance.
|
|
8
|
+
* @param {Record<string, any>} ioCache - The cache object containing blocked IPs.
|
|
9
|
+
* @param {Array<*>} ioCache.blocklick - The list of blocked IP addresses.
|
|
10
10
|
* @returns {void} This function does not return a value, it just sets the authorization logic for socket connections.
|
|
11
11
|
*/
|
|
12
|
-
export default function install(io:
|
|
13
|
-
blocklick: any[];
|
|
14
|
-
}): void;
|
|
12
|
+
export default function install(io: Record<string, any>, ioCache: Record<string, any>): void;
|
|
@@ -6,9 +6,9 @@ import userIp from '../../http/userIP.mjs';
|
|
|
6
6
|
* This middleware checks the user's IP address and allows or denies the socket connection based on whether
|
|
7
7
|
* the IP is in the block list or not.
|
|
8
8
|
*
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {Array} ioCache.blocklick - The list of blocked IP addresses.
|
|
9
|
+
* @param {Record<string, any>} io - The Socket.IO server instance.
|
|
10
|
+
* @param {Record<string, any>} ioCache - The cache object containing blocked IPs.
|
|
11
|
+
* @param {Array<*>} ioCache.blocklick - The list of blocked IP addresses.
|
|
12
12
|
* @returns {void} This function does not return a value, it just sets the authorization logic for socket connections.
|
|
13
13
|
*/
|
|
14
14
|
export default function install(io, ioCache) {
|
|
@@ -26,10 +26,10 @@ setInterval(function () {
|
|
|
26
26
|
* This function checks how many times an IP has attempted to interact with the socket.
|
|
27
27
|
* If the attempts exceed a threshold, the IP is temporarily banned and disconnected.
|
|
28
28
|
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {Array} ioCache.blocklick - The list of blocked IPs.
|
|
32
|
-
* @param {
|
|
29
|
+
* @param {Record<string, any>} socket - The socket object representing the connection.
|
|
30
|
+
* @param {Record<string, any>} ioCache - The cache object that holds the blocklist and flood panel data.
|
|
31
|
+
* @param {Array<*>} ioCache.blocklick - The list of blocked IPs.
|
|
32
|
+
* @param {Record<string, any>} floodPanel - The object tracking flooding attempts and timeouts for each IP.
|
|
33
33
|
* @returns {void} This function does not return anything, it modifies the floodPanel and blocklist.
|
|
34
34
|
*/
|
|
35
35
|
function verify(socket, ioCache) {
|
|
@@ -4,12 +4,10 @@
|
|
|
4
4
|
* This function checks how many times an IP has attempted to interact with the socket.
|
|
5
5
|
* If the attempts exceed a threshold, the IP is temporarily banned and disconnected.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {Array} ioCache.blocklick - The list of blocked IPs.
|
|
10
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} socket - The socket object representing the connection.
|
|
8
|
+
* @param {Record<string, any>} ioCache - The cache object that holds the blocklist and flood panel data.
|
|
9
|
+
* @param {Array<*>} ioCache.blocklick - The list of blocked IPs.
|
|
10
|
+
* @param {Record<string, any>} floodPanel - The object tracking flooding attempts and timeouts for each IP.
|
|
11
11
|
* @returns {void} This function does not return anything, it modifies the floodPanel and blocklist.
|
|
12
12
|
*/
|
|
13
|
-
export default function verify(socket:
|
|
14
|
-
blocklick: any[];
|
|
15
|
-
}): void;
|
|
13
|
+
export default function verify(socket: Record<string, any>, ioCache: Record<string, any>): void;
|
|
@@ -20,10 +20,10 @@ setInterval(function () {
|
|
|
20
20
|
* This function checks how many times an IP has attempted to interact with the socket.
|
|
21
21
|
* If the attempts exceed a threshold, the IP is temporarily banned and disconnected.
|
|
22
22
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {Array} ioCache.blocklick - The list of blocked IPs.
|
|
26
|
-
* @param {
|
|
23
|
+
* @param {Record<string, any>} socket - The socket object representing the connection.
|
|
24
|
+
* @param {Record<string, any>} ioCache - The cache object that holds the blocklist and flood panel data.
|
|
25
|
+
* @param {Array<*>} ioCache.blocklick - The list of blocked IPs.
|
|
26
|
+
* @param {Record<string, any>} floodPanel - The object tracking flooding attempts and timeouts for each IP.
|
|
27
27
|
* @returns {void} This function does not return anything, it modifies the floodPanel and blocklist.
|
|
28
28
|
*/
|
|
29
29
|
export default function verify(socket, ioCache) {
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* Handles the cookie session for a socket connection by simulating an Express request and response.
|
|
7
7
|
* This function uses the provided session module to manage session data for the socket connection.
|
|
8
8
|
*
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {Record<string, any>} socket - The socket object representing the connection.
|
|
10
10
|
* @param {Function} sessionModule - The session module function, typically used with Express, that handles session logic.
|
|
11
|
-
* @returns {Promise<
|
|
11
|
+
* @returns {Promise<Record<string, any>>} A promise that resolves with the session object once the session is processed.
|
|
12
12
|
*/
|
|
13
13
|
function cookieSession(socket, sessionModule) {
|
|
14
14
|
return new Promise((resolve) => {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Handles the cookie session for a socket connection by simulating an Express request and response.
|
|
3
3
|
* This function uses the provided session module to manage session data for the socket connection.
|
|
4
4
|
*
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {Record<string, any>} socket - The socket object representing the connection.
|
|
6
6
|
* @param {Function} sessionModule - The session module function, typically used with Express, that handles session logic.
|
|
7
|
-
* @returns {Promise<
|
|
7
|
+
* @returns {Promise<Record<string, any>>} A promise that resolves with the session object once the session is processed.
|
|
8
8
|
*/
|
|
9
|
-
export default function cookieSession(socket:
|
|
9
|
+
export default function cookieSession(socket: Record<string, any>, sessionModule: Function): Promise<Record<string, any>>;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Handles the cookie session for a socket connection by simulating an Express request and response.
|
|
4
4
|
* This function uses the provided session module to manage session data for the socket connection.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {Record<string, any>} socket - The socket object representing the connection.
|
|
7
7
|
* @param {Function} sessionModule - The session module function, typically used with Express, that handles session logic.
|
|
8
|
-
* @returns {Promise<
|
|
8
|
+
* @returns {Promise<Record<string, any>>} A promise that resolves with the session object once the session is processed.
|
|
9
9
|
*/
|
|
10
10
|
export default function cookieSession(socket, sessionModule) {
|
|
11
11
|
return new Promise((resolve) => {
|
|
@@ -9,10 +9,10 @@ var getUser = require('../firebase/discord/api/getUser.cjs');
|
|
|
9
9
|
* Handles the Discord OAuth2 authentication for a user, stores user data in an in-memory cache,
|
|
10
10
|
* and manages the user's socket connection and disconnection events.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {Record<string, any>} socket - The socket object representing the user's connection.
|
|
13
|
+
* @param {Record<string, any>} ioCache - The shared cache that stores user data and connections.
|
|
14
14
|
* @param {string} token - The OAuth2 token used to fetch user data from Discord.
|
|
15
|
-
* @returns {Promise<
|
|
15
|
+
* @returns {Promise<Record<string, any>>} A promise that resolves with the user data and updates the cache.
|
|
16
16
|
*/
|
|
17
17
|
function discord(socket, ioCache, token) {
|
|
18
18
|
return new Promise((resolve, reject) => {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Handles the Discord OAuth2 authentication for a user, stores user data in an in-memory cache,
|
|
3
3
|
* and manages the user's socket connection and disconnection events.
|
|
4
4
|
*
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
5
|
+
* @param {Record<string, any>} socket - The socket object representing the user's connection.
|
|
6
|
+
* @param {Record<string, any>} ioCache - The shared cache that stores user data and connections.
|
|
7
7
|
* @param {string} token - The OAuth2 token used to fetch user data from Discord.
|
|
8
|
-
* @returns {Promise<
|
|
8
|
+
* @returns {Promise<Record<string, any>>} A promise that resolves with the user data and updates the cache.
|
|
9
9
|
*/
|
|
10
|
-
export default function discord(socket:
|
|
10
|
+
export default function discord(socket: Record<string, any>, ioCache: Record<string, any>, token: string): Promise<Record<string, any>>;
|
|
@@ -4,10 +4,10 @@ import getUser from '../firebase/discord/api/getUser.mjs';
|
|
|
4
4
|
* Handles the Discord OAuth2 authentication for a user, stores user data in an in-memory cache,
|
|
5
5
|
* and manages the user's socket connection and disconnection events.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} socket - The socket object representing the user's connection.
|
|
8
|
+
* @param {Record<string, any>} ioCache - The shared cache that stores user data and connections.
|
|
9
9
|
* @param {string} token - The OAuth2 token used to fetch user data from Discord.
|
|
10
|
-
* @returns {Promise<
|
|
10
|
+
* @returns {Promise<Record<string, any>>} A promise that resolves with the user data and updates the cache.
|
|
11
11
|
*/
|
|
12
12
|
export default function discord(socket, ioCache, token) {
|
|
13
13
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|