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
|
@@ -12,9 +12,9 @@ var config = require('../config.cjs');
|
|
|
12
12
|
* authentication flows, such as logging in or connecting a webhook.
|
|
13
13
|
*
|
|
14
14
|
* @function
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
15
|
+
* @param {Record<string, any>} tinyCfg - The configuration object containing the app's OAuth2 settings.
|
|
16
|
+
* @param {Record<string, any>} jsonState - The state object to be encrypted and passed in the authorization URL.
|
|
17
|
+
* @param {Record<string, any>} tinyCrypto - The crypto object used to encrypt the state.
|
|
18
18
|
* @param {string} type - The type of the request, which determines the URL generation process.
|
|
19
19
|
* Can be `'login'`, `'login_command'`, or `'webhook'`.
|
|
20
20
|
*
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* authentication flows, such as logging in or connecting a webhook.
|
|
5
5
|
*
|
|
6
6
|
* @function
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} tinyCfg - The configuration object containing the app's OAuth2 settings.
|
|
8
|
+
* @param {Record<string, any>} jsonState - The state object to be encrypted and passed in the authorization URL.
|
|
9
|
+
* @param {Record<string, any>} tinyCrypto - The crypto object used to encrypt the state.
|
|
10
10
|
* @param {string} type - The type of the request, which determines the URL generation process.
|
|
11
11
|
* Can be `'login'`, `'login_command'`, or `'webhook'`.
|
|
12
12
|
*
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
* const webhookAuthUrl = authURLGenerator(tinyCfg, jsonState, tinyCrypto, 'webhook');
|
|
21
21
|
* console.log(webhookAuthUrl);
|
|
22
22
|
*/
|
|
23
|
-
export default function authURLGenerator(tinyCfg:
|
|
23
|
+
export default function authURLGenerator(tinyCfg: Record<string, any>, jsonState: Record<string, any>, tinyCrypto: Record<string, any>, type: string): string;
|
|
@@ -7,9 +7,9 @@ import config from '../config.mjs';
|
|
|
7
7
|
* authentication flows, such as logging in or connecting a webhook.
|
|
8
8
|
*
|
|
9
9
|
* @function
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
10
|
+
* @param {Record<string, any>} tinyCfg - The configuration object containing the app's OAuth2 settings.
|
|
11
|
+
* @param {Record<string, any>} jsonState - The state object to be encrypted and passed in the authorization URL.
|
|
12
|
+
* @param {Record<string, any>} tinyCrypto - The crypto object used to encrypt the state.
|
|
13
13
|
* @param {string} type - The type of the request, which determines the URL generation process.
|
|
14
14
|
* Can be `'login'`, `'login_command'`, or `'webhook'`.
|
|
15
15
|
*
|
|
@@ -11,7 +11,7 @@ var objType = require('../../../get/objType.cjs');
|
|
|
11
11
|
* the value is returned. Otherwise, `null` is returned.
|
|
12
12
|
*
|
|
13
13
|
* @function
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {Record<string, any>} req - The request object, which contains the session data.
|
|
15
15
|
* @param {string} where - The key for which the session value is being retrieved.
|
|
16
16
|
*
|
|
17
17
|
* @returns {string|null} The session value associated with the provided key, or `null` if it doesn't exist or isn't valid.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* the value is returned. Otherwise, `null` is returned.
|
|
5
5
|
*
|
|
6
6
|
* @function
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {Record<string, any>} req - The request object, which contains the session data.
|
|
8
8
|
* @param {string} where - The key for which the session value is being retrieved.
|
|
9
9
|
*
|
|
10
10
|
* @returns {string|null} The session value associated with the provided key, or `null` if it doesn't exist or isn't valid.
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
* console.log('No valid token in session');
|
|
18
18
|
* }
|
|
19
19
|
*/
|
|
20
|
-
export default function cookieSession(req:
|
|
20
|
+
export default function cookieSession(req: Record<string, any>, where: string): string | null;
|
|
@@ -6,7 +6,7 @@ import objType from '../../../get/objType.mjs';
|
|
|
6
6
|
* the value is returned. Otherwise, `null` is returned.
|
|
7
7
|
*
|
|
8
8
|
* @function
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {Record<string, any>} req - The request object, which contains the session data.
|
|
10
10
|
* @param {string} where - The key for which the session value is being retrieved.
|
|
11
11
|
*
|
|
12
12
|
* @returns {string|null} The session value associated with the provided key, or `null` if it doesn't exist or isn't valid.
|
|
@@ -13,7 +13,7 @@ var objType = require('../../../get/objType.cjs');
|
|
|
13
13
|
* @function
|
|
14
14
|
* @param {Object|Array} data - The response data to validate. This can be either an object or an array.
|
|
15
15
|
*
|
|
16
|
-
* @returns {
|
|
16
|
+
* @returns {Record<string, any>} The result object containing:
|
|
17
17
|
* - `data` (Object|null): The validated data if no error occurred or null if an error was found.
|
|
18
18
|
* - `error` (Object|null): The error object if there was an issue, or null if no error was found.
|
|
19
19
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @function
|
|
7
7
|
* @param {Object|Array} data - The response data to validate. This can be either an object or an array.
|
|
8
8
|
*
|
|
9
|
-
* @returns {
|
|
9
|
+
* @returns {Record<string, any>} The result object containing:
|
|
10
10
|
* - `data` (Object|null): The validated data if no error occurred or null if an error was found.
|
|
11
11
|
* - `error` (Object|null): The error object if there was an issue, or null if no error was found.
|
|
12
12
|
*
|
|
@@ -25,4 +25,4 @@
|
|
|
25
25
|
* const result = errorValidator(response);
|
|
26
26
|
* console.log(result); // { data: null, error: { code: 500, message: 'Invalid HTTP Result!' } }
|
|
27
27
|
*/
|
|
28
|
-
export default function errorValidator(data: Object | any[]):
|
|
28
|
+
export default function errorValidator(data: Object | any[]): Record<string, any>;
|
|
@@ -8,7 +8,7 @@ import objType from '../../../get/objType.mjs';
|
|
|
8
8
|
* @function
|
|
9
9
|
* @param {Object|Array} data - The response data to validate. This can be either an object or an array.
|
|
10
10
|
*
|
|
11
|
-
* @returns {
|
|
11
|
+
* @returns {Record<string, any>} The result object containing:
|
|
12
12
|
* - `data` (Object|null): The validated data if no error occurred or null if an error was found.
|
|
13
13
|
* - `error` (Object|null): The error object if there was an issue, or null if no error was found.
|
|
14
14
|
*
|
|
@@ -15,9 +15,9 @@ var authURLGenerator = require('../get/authURLGenerator.cjs');
|
|
|
15
15
|
* Depending on the configuration type, it handles various authentication methods like login, login_command, and webhook.
|
|
16
16
|
*
|
|
17
17
|
* @function
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
18
|
+
* @param {Record<string, any>} req - The request object, typically provided by the web framework (e.g., Express).
|
|
19
|
+
* @param {Record<string, any>} res - The response object, typically provided by the web framework (e.g., Express).
|
|
20
|
+
* @param {Record<string, any>} cfg - The configuration object that includes various settings for the login process.
|
|
21
21
|
* @param {boolean} existSession - A flag indicating whether the user already has an active session.
|
|
22
22
|
*
|
|
23
23
|
* @returns {void} This function does not return anything. It sends a redirect response to the user based on the configuration.
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Depending on the configuration type, it handles various authentication methods like login, login_command, and webhook.
|
|
4
4
|
*
|
|
5
5
|
* @function
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
6
|
+
* @param {Record<string, any>} req - The request object, typically provided by the web framework (e.g., Express).
|
|
7
|
+
* @param {Record<string, any>} res - The response object, typically provided by the web framework (e.g., Express).
|
|
8
|
+
* @param {Record<string, any>} cfg - The configuration object that includes various settings for the login process.
|
|
9
9
|
* @param {boolean} existSession - A flag indicating whether the user already has an active session.
|
|
10
10
|
*
|
|
11
11
|
* @returns {void} This function does not return anything. It sends a redirect response to the user based on the configuration.
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
* login(req, res, config, sessionExists);
|
|
19
19
|
* });
|
|
20
20
|
*/
|
|
21
|
-
export default function login(req:
|
|
21
|
+
export default function login(req: Record<string, any>, res: Record<string, any>, cfg: Record<string, any>, existSession: boolean): void;
|
|
@@ -10,9 +10,9 @@ import authURLGenerator from '../get/authURLGenerator.mjs';
|
|
|
10
10
|
* Depending on the configuration type, it handles various authentication methods like login, login_command, and webhook.
|
|
11
11
|
*
|
|
12
12
|
* @function
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
13
|
+
* @param {Record<string, any>} req - The request object, typically provided by the web framework (e.g., Express).
|
|
14
|
+
* @param {Record<string, any>} res - The response object, typically provided by the web framework (e.g., Express).
|
|
15
|
+
* @param {Record<string, any>} cfg - The configuration object that includes various settings for the login process.
|
|
16
16
|
* @param {boolean} existSession - A flag indicating whether the user already has an active session.
|
|
17
17
|
*
|
|
18
18
|
* @returns {void} This function does not return anything. It sends a redirect response to the user based on the configuration.
|
|
@@ -11,14 +11,14 @@ var getUser = require('../api/getUser.cjs');
|
|
|
11
11
|
/**
|
|
12
12
|
* Handles the logout process for the user by revoking the token and redirecting.
|
|
13
13
|
*
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {Record<string, any>} req - The HTTP request object.
|
|
15
15
|
* @param {string|number} access_token - The access token of the user to be revoked.
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {Record<string, any>} cfg - Configuration object containing settings for the logout process.
|
|
17
17
|
* @param {boolean} existSession - A flag indicating whether a session exists.
|
|
18
18
|
*
|
|
19
|
-
* @returns {Promise<
|
|
19
|
+
* @returns {Promise<Record<string, any>>} Resolves with a result object or rejects with an error.
|
|
20
20
|
*
|
|
21
|
-
* @throws {
|
|
21
|
+
* @throws {Record<string, any>} Rejects with an error if configuration or token values are invalid.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* logout(req, 'userAccessToken', cfg, true)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Handles the logout process for the user by revoking the token and redirecting.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {Record<string, any>} req - The HTTP request object.
|
|
5
5
|
* @param {string|number} access_token - The access token of the user to be revoked.
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {Record<string, any>} cfg - Configuration object containing settings for the logout process.
|
|
7
7
|
* @param {boolean} existSession - A flag indicating whether a session exists.
|
|
8
8
|
*
|
|
9
|
-
* @returns {Promise<
|
|
9
|
+
* @returns {Promise<Record<string, any>>} Resolves with a result object or rejects with an error.
|
|
10
10
|
*
|
|
11
|
-
* @throws {
|
|
11
|
+
* @throws {Record<string, any>} Rejects with an error if configuration or token values are invalid.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* logout(req, 'userAccessToken', cfg, true)
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
* // Handle error during logout
|
|
20
20
|
* });
|
|
21
21
|
*/
|
|
22
|
-
export default function logout(req:
|
|
22
|
+
export default function logout(req: Record<string, any>, access_token: string | number, cfg: Record<string, any>, existSession: boolean): Promise<Record<string, any>>;
|
|
@@ -6,14 +6,14 @@ import getUser from '../api/getUser.mjs';
|
|
|
6
6
|
/**
|
|
7
7
|
* Handles the logout process for the user by revoking the token and redirecting.
|
|
8
8
|
*
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {Record<string, any>} req - The HTTP request object.
|
|
10
10
|
* @param {string|number} access_token - The access token of the user to be revoked.
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Record<string, any>} cfg - Configuration object containing settings for the logout process.
|
|
12
12
|
* @param {boolean} existSession - A flag indicating whether a session exists.
|
|
13
13
|
*
|
|
14
|
-
* @returns {Promise<
|
|
14
|
+
* @returns {Promise<Record<string, any>>} Resolves with a result object or rejects with an error.
|
|
15
15
|
*
|
|
16
|
-
* @throws {
|
|
16
|
+
* @throws {Record<string, any>} Rejects with an error if configuration or token values are invalid.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* logout(req, 'userAccessToken', cfg, true)
|
|
@@ -14,14 +14,14 @@ var getUser = require('../api/getUser.cjs');
|
|
|
14
14
|
* Handles the redirection logic for the OAuth flow, including state validation, token retrieval, and user session management.
|
|
15
15
|
* This function is used for handling Discord OAuth redirects and session creation or restoration.
|
|
16
16
|
*
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
17
|
+
* @param {Record<string, any>} req - The request object from the client, which contains query parameters such as `state`, `code`, and `csrfToken`.
|
|
18
|
+
* @param {Record<string, any>} cfg - The configuration object containing settings like `crypto`, `auth`, and `discordScope`.
|
|
19
19
|
* @param {boolean} existSession - Indicates if the user already has an active session.
|
|
20
20
|
*
|
|
21
|
-
* @returns {Promise<
|
|
21
|
+
* @returns {Promise<Record<string, any>>} - A promise that resolves with an object containing the redirection URL and session information.
|
|
22
22
|
* If a new session is created, it also includes user data and the token request.
|
|
23
23
|
*
|
|
24
|
-
* @throws {
|
|
24
|
+
* @throws {Record<string, any>} - Throws an error with a `code` and `message` if any validation fails (e.g., missing token, invalid state).
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* // Example usage of redirect function
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Handles the redirection logic for the OAuth flow, including state validation, token retrieval, and user session management.
|
|
3
3
|
* This function is used for handling Discord OAuth redirects and session creation or restoration.
|
|
4
4
|
*
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
5
|
+
* @param {Record<string, any>} req - The request object from the client, which contains query parameters such as `state`, `code`, and `csrfToken`.
|
|
6
|
+
* @param {Record<string, any>} cfg - The configuration object containing settings like `crypto`, `auth`, and `discordScope`.
|
|
7
7
|
* @param {boolean} existSession - Indicates if the user already has an active session.
|
|
8
8
|
*
|
|
9
|
-
* @returns {Promise<
|
|
9
|
+
* @returns {Promise<Record<string, any>>} - A promise that resolves with an object containing the redirection URL and session information.
|
|
10
10
|
* If a new session is created, it also includes user data and the token request.
|
|
11
11
|
*
|
|
12
|
-
* @throws {
|
|
12
|
+
* @throws {Record<string, any>} - Throws an error with a `code` and `message` if any validation fails (e.g., missing token, invalid state).
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* // Example usage of redirect function
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
* console.error('Error during redirect', err);
|
|
22
22
|
* });
|
|
23
23
|
*/
|
|
24
|
-
export default function redirect(req:
|
|
24
|
+
export default function redirect(req: Record<string, any>, cfg: Record<string, any>, existSession: boolean): Promise<Record<string, any>>;
|
|
@@ -9,14 +9,14 @@ import getUser from '../api/getUser.mjs';
|
|
|
9
9
|
* Handles the redirection logic for the OAuth flow, including state validation, token retrieval, and user session management.
|
|
10
10
|
* This function is used for handling Discord OAuth redirects and session creation or restoration.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {Record<string, any>} req - The request object from the client, which contains query parameters such as `state`, `code`, and `csrfToken`.
|
|
13
|
+
* @param {Record<string, any>} cfg - The configuration object containing settings like `crypto`, `auth`, and `discordScope`.
|
|
14
14
|
* @param {boolean} existSession - Indicates if the user already has an active session.
|
|
15
15
|
*
|
|
16
|
-
* @returns {Promise<
|
|
16
|
+
* @returns {Promise<Record<string, any>>} - A promise that resolves with an object containing the redirection URL and session information.
|
|
17
17
|
* If a new session is created, it also includes user data and the token request.
|
|
18
18
|
*
|
|
19
|
-
* @throws {
|
|
19
|
+
* @throws {Record<string, any>} - Throws an error with a `code` and `message` if any validation fails (e.g., missing token, invalid state).
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* // Example usage of redirect function
|
|
@@ -12,13 +12,13 @@ var refreshToken$1 = require('../api/refreshToken.cjs');
|
|
|
12
12
|
*
|
|
13
13
|
* @async
|
|
14
14
|
* @function refreshToken
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
15
|
+
* @param {Record<string, any>} req - The request object containing query parameters and csrfToken.
|
|
16
|
+
* @param {Record<string, any>} cfg - The configuration object containing auth and state configurations.
|
|
17
17
|
* @param {boolean} existSession - A flag indicating if the user session exists.
|
|
18
18
|
*
|
|
19
|
-
* @returns {Promise<
|
|
19
|
+
* @returns {Promise<Record<string, any>>} Resolves to an object containing the status of the refresh and the new token data, or rejects with an error object.
|
|
20
20
|
*
|
|
21
|
-
* @throws {
|
|
21
|
+
* @throws {Record<string, any>} Rejects with an error object containing the following properties:
|
|
22
22
|
* - `code` {number} The error code (e.g., 401 for invalid CSRF token, 500 for server errors).
|
|
23
23
|
* - `message` {string} The error message describing the issue.
|
|
24
24
|
*
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @async
|
|
5
5
|
* @function refreshToken
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
6
|
+
* @param {Record<string, any>} req - The request object containing query parameters and csrfToken.
|
|
7
|
+
* @param {Record<string, any>} cfg - The configuration object containing auth and state configurations.
|
|
8
8
|
* @param {boolean} existSession - A flag indicating if the user session exists.
|
|
9
9
|
*
|
|
10
|
-
* @returns {Promise<
|
|
10
|
+
* @returns {Promise<Record<string, any>>} Resolves to an object containing the status of the refresh and the new token data, or rejects with an error object.
|
|
11
11
|
*
|
|
12
|
-
* @throws {
|
|
12
|
+
* @throws {Record<string, any>} Rejects with an error object containing the following properties:
|
|
13
13
|
* - `code` {number} The error code (e.g., 401 for invalid CSRF token, 500 for server errors).
|
|
14
14
|
* - `message` {string} The error message describing the issue.
|
|
15
15
|
*
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
* console.log('Token refresh failed');
|
|
22
22
|
* }
|
|
23
23
|
*/
|
|
24
|
-
export default function refreshToken(req:
|
|
24
|
+
export default function refreshToken(req: Record<string, any>, cfg: Record<string, any>, existSession: boolean): Promise<Record<string, any>>;
|
|
@@ -7,13 +7,13 @@ import refreshTokenApi from '../api/refreshToken.mjs';
|
|
|
7
7
|
*
|
|
8
8
|
* @async
|
|
9
9
|
* @function refreshToken
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
10
|
+
* @param {Record<string, any>} req - The request object containing query parameters and csrfToken.
|
|
11
|
+
* @param {Record<string, any>} cfg - The configuration object containing auth and state configurations.
|
|
12
12
|
* @param {boolean} existSession - A flag indicating if the user session exists.
|
|
13
13
|
*
|
|
14
|
-
* @returns {Promise<
|
|
14
|
+
* @returns {Promise<Record<string, any>>} Resolves to an object containing the status of the refresh and the new token data, or rejects with an error object.
|
|
15
15
|
*
|
|
16
|
-
* @throws {
|
|
16
|
+
* @throws {Record<string, any>} Rejects with an error object containing the following properties:
|
|
17
17
|
* - `code` {number} The error code (e.g., 401 for invalid CSRF token, 500 for server errors).
|
|
18
18
|
* - `message` {string} The error message describing the issue.
|
|
19
19
|
*
|
|
@@ -29,8 +29,8 @@ var revokeToken = require('../api/revokeToken.cjs');
|
|
|
29
29
|
* Middleware function to handle Discord and Firebase sessions, including login, logout,
|
|
30
30
|
* and redirection functionalities.
|
|
31
31
|
*
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
32
|
+
* @param {Record<string, any>} app - The Express.js app object.
|
|
33
|
+
* @param {Record<string, any>} cfg - The configuration object for the middleware, including Firebase settings.
|
|
34
34
|
* @throws {Error} Throws an error if the configuration object is invalid.
|
|
35
35
|
*/
|
|
36
36
|
function cookieSession(app, cfg) {
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* Middleware function to handle Discord and Firebase sessions, including login, logout,
|
|
3
3
|
* and redirection functionalities.
|
|
4
4
|
*
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
5
|
+
* @param {Record<string, any>} app - The Express.js app object.
|
|
6
|
+
* @param {Record<string, any>} cfg - The configuration object for the middleware, including Firebase settings.
|
|
7
7
|
* @throws {Error} Throws an error if the configuration object is invalid.
|
|
8
8
|
*/
|
|
9
|
-
export default function cookieSession(app:
|
|
9
|
+
export default function cookieSession(app: Record<string, any>, cfg: Record<string, any>): {
|
|
10
10
|
auth: any;
|
|
11
11
|
commandAuth: any;
|
|
12
|
-
addGuildMember: (data: any) => Promise<
|
|
13
|
-
getGuildWidget: (guildID: any) => Promise<
|
|
12
|
+
addGuildMember: (data: any) => Promise<Record<string, any>>;
|
|
13
|
+
getGuildWidget: (guildID: any) => Promise<Record<string, any>>;
|
|
14
14
|
uidGenerator: (userID: any) => string;
|
|
15
15
|
sessionValidator: (data?: {}) => (req: any, res: any, next: any) => void;
|
|
16
16
|
sessionPlugins: {
|
|
@@ -25,8 +25,8 @@ import revokeToken from '../api/revokeToken.mjs';
|
|
|
25
25
|
* Middleware function to handle Discord and Firebase sessions, including login, logout,
|
|
26
26
|
* and redirection functionalities.
|
|
27
27
|
*
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
28
|
+
* @param {Record<string, any>} app - The Express.js app object.
|
|
29
|
+
* @param {Record<string, any>} cfg - The configuration object for the middleware, including Firebase settings.
|
|
30
30
|
* @throws {Error} Throws an error if the configuration object is invalid.
|
|
31
31
|
*/
|
|
32
32
|
export default function cookieSession(app, cfg) {
|
|
@@ -23,7 +23,7 @@ const escapeRegExp = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
|
|
|
23
23
|
* and decoding components (without the `/` character).
|
|
24
24
|
*
|
|
25
25
|
* @param {Array<string>} chars - The list of characters to encode/decode.
|
|
26
|
-
* @returns {
|
|
26
|
+
* @returns {Record<string, any>} An object containing:
|
|
27
27
|
* - `encode`: Function that encodes characters to hexadecimal format.
|
|
28
28
|
* - `decode`: Function that decodes hexadecimal values back to characters.
|
|
29
29
|
*/
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* and decoding components (without the `/` character).
|
|
7
7
|
*
|
|
8
8
|
* @param {Array<string>} chars - The list of characters to encode/decode.
|
|
9
|
-
* @returns {
|
|
9
|
+
* @returns {Record<string, any>} An object containing:
|
|
10
10
|
* - `encode`: Function that encodes characters to hexadecimal format.
|
|
11
11
|
* - `decode`: Function that decodes hexadecimal values back to characters.
|
|
12
12
|
*/
|
|
13
|
-
export function create(chars: Array<string>):
|
|
13
|
+
export function create(chars: Array<string>): Record<string, any>;
|
|
14
14
|
export const encode: any;
|
|
15
15
|
export const decode: any;
|
|
16
16
|
export const encodeComponents: any;
|
|
@@ -17,7 +17,7 @@ const escapeRegExp = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
|
|
|
17
17
|
* and decoding components (without the `/` character).
|
|
18
18
|
*
|
|
19
19
|
* @param {Array<string>} chars - The list of characters to encode/decode.
|
|
20
|
-
* @returns {
|
|
20
|
+
* @returns {Record<string, any>} An object containing:
|
|
21
21
|
* - `encode`: Function that encodes characters to hexadecimal format.
|
|
22
22
|
* - `decode`: Function that decodes hexadecimal values back to characters.
|
|
23
23
|
*/
|
|
@@ -66,7 +66,7 @@ firebaseObject.database = index;
|
|
|
66
66
|
/**
|
|
67
67
|
* Handles database escaping for safe queries.
|
|
68
68
|
*
|
|
69
|
-
* @type {
|
|
69
|
+
* @type {Record<string, any>}
|
|
70
70
|
*/
|
|
71
71
|
firebaseObject.escape = escape;
|
|
72
72
|
|
|
@@ -115,7 +115,7 @@ firebaseObject.databaseEscape = databaseEscape;
|
|
|
115
115
|
/**
|
|
116
116
|
* Logger to log information using Firebase or console.
|
|
117
117
|
*
|
|
118
|
-
* @type {
|
|
118
|
+
* @type {Record<string, any>}
|
|
119
119
|
*/
|
|
120
120
|
firebaseObject.logger = logger;
|
|
121
121
|
|
|
@@ -131,7 +131,7 @@ firebaseObject.isEmulator = isEmulator;
|
|
|
131
131
|
* Initializes services such as Database, Auth, Firestore, etc.
|
|
132
132
|
*
|
|
133
133
|
* @param {string} value - The Firebase app ID.
|
|
134
|
-
* @param {
|
|
134
|
+
* @param {Record<string, any>} item - Configuration for the Firebase app and services to initialize.
|
|
135
135
|
* @returns {boolean} `true` if the modules were successfully started, `false` otherwise.
|
|
136
136
|
*/
|
|
137
137
|
firebaseObject.startModule = function (value, item) {
|
|
@@ -181,9 +181,9 @@ firebaseObject.startModule = function (value, item) {
|
|
|
181
181
|
/**
|
|
182
182
|
* Starts the Firebase app and initializes required services.
|
|
183
183
|
*
|
|
184
|
-
* @param {
|
|
185
|
-
* @param {
|
|
186
|
-
* @param {
|
|
184
|
+
* @param {Record<string, any>} admin - The Firebase Admin SDK.
|
|
185
|
+
* @param {Record<string, any>} item - Configuration containing app details and options.
|
|
186
|
+
* @param {Record<string, any>} data - Additional data to initialize the app.
|
|
187
187
|
* @throws {Error} Throws an error if the Firebase file is not found or if the app ID is missing.
|
|
188
188
|
*/
|
|
189
189
|
firebaseObject.start = function (admin, item, data) {
|
|
@@ -17,26 +17,26 @@ declare namespace firebaseObject {
|
|
|
17
17
|
export { getDBData };
|
|
18
18
|
export { transactionDBAsync };
|
|
19
19
|
export { databaseEscape };
|
|
20
|
-
export let logger:
|
|
20
|
+
export let logger: Record<string, any>;
|
|
21
21
|
export { isEmulator };
|
|
22
22
|
/**
|
|
23
23
|
* Starts Firebase modules based on the provided configuration.
|
|
24
24
|
* Initializes services such as Database, Auth, Firestore, etc.
|
|
25
25
|
*
|
|
26
26
|
* @param {string} value - The Firebase app ID.
|
|
27
|
-
* @param {
|
|
27
|
+
* @param {Record<string, any>} item - Configuration for the Firebase app and services to initialize.
|
|
28
28
|
* @returns {boolean} `true` if the modules were successfully started, `false` otherwise.
|
|
29
29
|
*/
|
|
30
|
-
export function startModule(value: string, item:
|
|
30
|
+
export function startModule(value: string, item: Record<string, any>): boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Starts the Firebase app and initializes required services.
|
|
33
33
|
*
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
34
|
+
* @param {Record<string, any>} admin - The Firebase Admin SDK.
|
|
35
|
+
* @param {Record<string, any>} item - Configuration containing app details and options.
|
|
36
|
+
* @param {Record<string, any>} data - Additional data to initialize the app.
|
|
37
37
|
* @throws {Error} Throws an error if the Firebase file is not found or if the app ID is missing.
|
|
38
38
|
*/
|
|
39
|
-
export function start(admin:
|
|
39
|
+
export function start(admin: Record<string, any>, item: Record<string, any>, data: Record<string, any>): void;
|
|
40
40
|
}
|
|
41
41
|
import AuthSystem from './cookieSession.mjs';
|
|
42
42
|
import domainRedirect from './domainRedirect.mjs';
|
|
@@ -56,7 +56,7 @@ firebaseObject.database = database;
|
|
|
56
56
|
/**
|
|
57
57
|
* Handles database escaping for safe queries.
|
|
58
58
|
*
|
|
59
|
-
* @type {
|
|
59
|
+
* @type {Record<string, any>}
|
|
60
60
|
*/
|
|
61
61
|
firebaseObject.escape = dbEscape;
|
|
62
62
|
/**
|
|
@@ -98,7 +98,7 @@ firebaseObject.databaseEscape = databaseEscape;
|
|
|
98
98
|
/**
|
|
99
99
|
* Logger to log information using Firebase or console.
|
|
100
100
|
*
|
|
101
|
-
* @type {
|
|
101
|
+
* @type {Record<string, any>}
|
|
102
102
|
*/
|
|
103
103
|
firebaseObject.logger = logger;
|
|
104
104
|
/**
|
|
@@ -112,7 +112,7 @@ firebaseObject.isEmulator = isEmulator;
|
|
|
112
112
|
* Initializes services such as Database, Auth, Firestore, etc.
|
|
113
113
|
*
|
|
114
114
|
* @param {string} value - The Firebase app ID.
|
|
115
|
-
* @param {
|
|
115
|
+
* @param {Record<string, any>} item - Configuration for the Firebase app and services to initialize.
|
|
116
116
|
* @returns {boolean} `true` if the modules were successfully started, `false` otherwise.
|
|
117
117
|
*/
|
|
118
118
|
firebaseObject.startModule = function (value, item) {
|
|
@@ -155,9 +155,9 @@ firebaseObject.startModule = function (value, item) {
|
|
|
155
155
|
/**
|
|
156
156
|
* Starts the Firebase app and initializes required services.
|
|
157
157
|
*
|
|
158
|
-
* @param {
|
|
159
|
-
* @param {
|
|
160
|
-
* @param {
|
|
158
|
+
* @param {Record<string, any>} admin - The Firebase Admin SDK.
|
|
159
|
+
* @param {Record<string, any>} item - Configuration containing app details and options.
|
|
160
|
+
* @param {Record<string, any>} data - Additional data to initialize the app.
|
|
161
161
|
* @throws {Error} Throws an error if the Firebase file is not found or if the app ID is missing.
|
|
162
162
|
*/
|
|
163
163
|
firebaseObject.start = function (admin, item, data) {
|
|
@@ -47,7 +47,7 @@ const loopInteraction = function (data) {
|
|
|
47
47
|
*
|
|
48
48
|
* @param {string} type - The type of log message (e.g., `log`, `info`, `warn`, `error`).
|
|
49
49
|
* @param {Arguments} args - The arguments to be logged.
|
|
50
|
-
* @returns {Promise<
|
|
50
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the result of the logging operation,
|
|
51
51
|
* or the result of logging to the native console if Firebase logger is not available.
|
|
52
52
|
*/
|
|
53
53
|
const logBase = async function (type, args) {
|
|
@@ -100,7 +100,7 @@ const fbLogger = {
|
|
|
100
100
|
* Logs a message with the `log` level. If not in emulator mode, it uses Firebase's logger.
|
|
101
101
|
*
|
|
102
102
|
* @param {...*} args - The arguments to log.
|
|
103
|
-
* @returns {Promise<
|
|
103
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the logging result.
|
|
104
104
|
*/
|
|
105
105
|
log: function () {
|
|
106
106
|
return logBase('log', arguments);
|
|
@@ -110,7 +110,7 @@ const fbLogger = {
|
|
|
110
110
|
* Logs a message with the `info` level. If not in emulator mode, it uses Firebase's logger.
|
|
111
111
|
*
|
|
112
112
|
* @param {...*} args - The arguments to log.
|
|
113
|
-
* @returns {Promise<
|
|
113
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the logging result.
|
|
114
114
|
*/
|
|
115
115
|
info: function () {
|
|
116
116
|
return logBase('info', arguments);
|
|
@@ -120,7 +120,7 @@ const fbLogger = {
|
|
|
120
120
|
* Logs a message with the `warn` level. If not in emulator mode, it uses Firebase's logger.
|
|
121
121
|
*
|
|
122
122
|
* @param {...*} args - The arguments to log.
|
|
123
|
-
* @returns {Promise<
|
|
123
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the logging result.
|
|
124
124
|
*/
|
|
125
125
|
warn: function () {
|
|
126
126
|
return logBase('warn', arguments);
|
|
@@ -130,7 +130,7 @@ const fbLogger = {
|
|
|
130
130
|
* Logs a message with the `error` level. If not in emulator mode, it uses Firebase's logger.
|
|
131
131
|
*
|
|
132
132
|
* @param {...*} args - The arguments to log.
|
|
133
|
-
* @returns {Promise<
|
|
133
|
+
* @returns {Promise<Record<string, any>>} A promise resolving with the logging result.
|
|
134
134
|
*/
|
|
135
135
|
error: function () {
|
|
136
136
|
return logBase('error', arguments);
|