tiny-essentials 1.3.0 → 1.3.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.
- package/dist/TinyBasicsEs.js +3 -3
- package/dist/TinyBasicsEs.min.js +1 -1
- package/dist/TinyEssentials.js +26 -18
- package/dist/TinyEssentials.min.js +1 -1
- package/dist/TinyLevelUp.js +23 -15
- 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 +23 -15
- package/dist/legacy/libs/userLevel.d.mts +41 -19
- package/dist/legacy/libs/userLevel.mjs +21 -15
- 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/dist/v1/basics/clock.cjs +1 -1
- package/dist/v1/basics/clock.d.mts +1 -1
- package/dist/v1/basics/clock.mjs +1 -1
- package/dist/v1/basics/simpleMath.cjs +2 -2
- package/dist/v1/basics/simpleMath.d.mts +2 -2
- package/dist/v1/basics/simpleMath.mjs +2 -2
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ if (!('toJSON' in Error.prototype)) {
|
|
|
28
28
|
*
|
|
29
29
|
* @param {string} where - The location or context where the log is coming from.
|
|
30
30
|
* @param {string} type - The type of log (log, error, info, or warn).
|
|
31
|
-
* @param {Array} args - The arguments to log (can include strings, numbers, objects, arrays, or errors).
|
|
31
|
+
* @param {Array<*>} args - The arguments to log (can include strings, numbers, objects, arrays, or errors).
|
|
32
32
|
* @returns {Promise<void>} Resolves once the log is stored in the database.
|
|
33
33
|
*/
|
|
34
34
|
const tinyAction = async function (where, type, args) {
|
|
@@ -111,7 +111,7 @@ const checkLastTime = function (value) {
|
|
|
111
111
|
* Each log type is stored in the database with a timestamp and arguments.
|
|
112
112
|
*
|
|
113
113
|
* @param {string} where - The location or context where the log is coming from.
|
|
114
|
-
* @returns {
|
|
114
|
+
* @returns {Record<string, any>} The logger object with methods for logging (log, error, info, warn).
|
|
115
115
|
*/
|
|
116
116
|
const loggerGenerator = function (where) {
|
|
117
117
|
// Done
|
|
@@ -149,9 +149,9 @@ const databaseLogger = {
|
|
|
149
149
|
/**
|
|
150
150
|
* Starts the logger with a new database instance and initializes cache values.
|
|
151
151
|
*
|
|
152
|
-
* @param {
|
|
152
|
+
* @param {Record<string, any>} newDB - The new database instance to use for storing logs.
|
|
153
153
|
* @param {string} where - The context or location where the logger will be used.
|
|
154
|
-
* @returns {Promise<
|
|
154
|
+
* @returns {Promise<Record<string, any>>} The logger instance with methods for logging.
|
|
155
155
|
*/
|
|
156
156
|
start: async function (newDB, where) {
|
|
157
157
|
// Prepare
|
|
@@ -207,7 +207,7 @@ const databaseLogger = {
|
|
|
207
207
|
* Retrieves the logger instance for a given context.
|
|
208
208
|
*
|
|
209
209
|
* @param {string} where - The context or location where the logger will be used.
|
|
210
|
-
* @returns {
|
|
210
|
+
* @returns {Record<string, any>} The logger instance with methods for logging.
|
|
211
211
|
*/
|
|
212
212
|
get: function (where) {
|
|
213
213
|
return loggerGenerator(where);
|
|
@@ -21,9 +21,9 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
21
21
|
* @param {boolean} [data.mute=false] - Whether the user should be server-muted.
|
|
22
22
|
* @param {boolean} [data.deaf=false] - Whether the user should be server-deafened.
|
|
23
23
|
*
|
|
24
|
-
* @returns {Promise<
|
|
24
|
+
* @returns {Promise<Record<string, any>>} Resolves with the user object if successful, or rejects with an error object.
|
|
25
25
|
*
|
|
26
|
-
* @throws {
|
|
26
|
+
* @throws {Record<string, any>} If the request fails or Discord returns an error, rejects with an object containing a `code` and `message`.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* const result = await addGuildMember('your_bot_token', {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* @param {boolean} [data.mute=false] - Whether the user should be server-muted.
|
|
13
13
|
* @param {boolean} [data.deaf=false] - Whether the user should be server-deafened.
|
|
14
14
|
*
|
|
15
|
-
* @returns {Promise<
|
|
15
|
+
* @returns {Promise<Record<string, any>>} Resolves with the user object if successful, or rejects with an error object.
|
|
16
16
|
*
|
|
17
|
-
* @throws {
|
|
17
|
+
* @throws {Record<string, any>} If the request fails or Discord returns an error, rejects with an object containing a `code` and `message`.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* const result = await addGuildMember('your_bot_token', {
|
|
@@ -35,4 +35,4 @@ export default function addGuildMember(bot_token: string, data: {
|
|
|
35
35
|
nickname?: string | undefined;
|
|
36
36
|
mute?: boolean | undefined;
|
|
37
37
|
deaf?: boolean | undefined;
|
|
38
|
-
}): Promise<
|
|
38
|
+
}): Promise<Record<string, any>>;
|
|
@@ -16,9 +16,9 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
16
16
|
* @param {boolean} [data.mute=false] - Whether the user should be server-muted.
|
|
17
17
|
* @param {boolean} [data.deaf=false] - Whether the user should be server-deafened.
|
|
18
18
|
*
|
|
19
|
-
* @returns {Promise<
|
|
19
|
+
* @returns {Promise<Record<string, any>>} Resolves with the user object if successful, or rejects with an error object.
|
|
20
20
|
*
|
|
21
|
-
* @throws {
|
|
21
|
+
* @throws {Record<string, any>} If the request fails or Discord returns an error, rejects with an object containing a `code` and `message`.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* const result = await addGuildMember('your_bot_token', {
|
|
@@ -14,9 +14,9 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
14
14
|
*
|
|
15
15
|
* @param {string} guildID - The ID of the guild whose widget is to be fetched.
|
|
16
16
|
*
|
|
17
|
-
* @returns {Promise<
|
|
17
|
+
* @returns {Promise<Record<string, any>>} Resolves with the guild widget data if successful.
|
|
18
18
|
*
|
|
19
|
-
* @throws {
|
|
19
|
+
* @throws {Record<string, any>} If the request fails or the widget is disabled, rejects with an object containing a `code` and `message`.
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* getGuildWidget('123456789012345678')
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @param {string} guildID - The ID of the guild whose widget is to be fetched.
|
|
7
7
|
*
|
|
8
|
-
* @returns {Promise<
|
|
8
|
+
* @returns {Promise<Record<string, any>>} Resolves with the guild widget data if successful.
|
|
9
9
|
*
|
|
10
|
-
* @throws {
|
|
10
|
+
* @throws {Record<string, any>} If the request fails or the widget is disabled, rejects with an object containing a `code` and `message`.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* getGuildWidget('123456789012345678')
|
|
14
14
|
* .then((data) => console.log(data))
|
|
15
15
|
* .catch((err) => console.error('Widget error:', err));
|
|
16
16
|
*/
|
|
17
|
-
export default function getGuildWidget(guildID: string): Promise<
|
|
17
|
+
export default function getGuildWidget(guildID: string): Promise<Record<string, any>>;
|
|
@@ -9,9 +9,9 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
9
9
|
*
|
|
10
10
|
* @param {string} guildID - The ID of the guild whose widget is to be fetched.
|
|
11
11
|
*
|
|
12
|
-
* @returns {Promise<
|
|
12
|
+
* @returns {Promise<Record<string, any>>} Resolves with the guild widget data if successful.
|
|
13
13
|
*
|
|
14
|
-
* @throws {
|
|
14
|
+
* @throws {Record<string, any>} If the request fails or the widget is disabled, rejects with an object containing a `code` and `message`.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* getGuildWidget('123456789012345678')
|
|
@@ -20,9 +20,9 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
20
20
|
* @param {string} dsData.redirect_uri - The redirect URI used during the authorization.
|
|
21
21
|
* @param {string} [dsData.scope] - The OAuth2 scopes being requested (optional but recommended).
|
|
22
22
|
*
|
|
23
|
-
* @returns {Promise<
|
|
23
|
+
* @returns {Promise<Record<string, any>>} Resolves with the access token data (access_token, token_type, expires_in, refresh_token, scope).
|
|
24
24
|
*
|
|
25
|
-
* @throws {
|
|
25
|
+
* @throws {Record<string, any>} If the request fails or Discord returns an error, rejects with an object containing a `code` and `message`.
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
28
|
* getToken({
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* @param {string} dsData.redirect_uri - The redirect URI used during the authorization.
|
|
12
12
|
* @param {string} [dsData.scope] - The OAuth2 scopes being requested (optional but recommended).
|
|
13
13
|
*
|
|
14
|
-
* @returns {Promise<
|
|
14
|
+
* @returns {Promise<Record<string, any>>} Resolves with the access token data (access_token, token_type, expires_in, refresh_token, scope).
|
|
15
15
|
*
|
|
16
|
-
* @throws {
|
|
16
|
+
* @throws {Record<string, any>} If the request fails or Discord returns an error, rejects with an object containing a `code` and `message`.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* getToken({
|
|
@@ -32,4 +32,4 @@ export default function getToken(dsData: {
|
|
|
32
32
|
code: string;
|
|
33
33
|
redirect_uri: string;
|
|
34
34
|
scope?: string | undefined;
|
|
35
|
-
}): Promise<
|
|
35
|
+
}): Promise<Record<string, any>>;
|
|
@@ -15,9 +15,9 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
15
15
|
* @param {string} dsData.redirect_uri - The redirect URI used during the authorization.
|
|
16
16
|
* @param {string} [dsData.scope] - The OAuth2 scopes being requested (optional but recommended).
|
|
17
17
|
*
|
|
18
|
-
* @returns {Promise<
|
|
18
|
+
* @returns {Promise<Record<string, any>>} Resolves with the access token data (access_token, token_type, expires_in, refresh_token, scope).
|
|
19
19
|
*
|
|
20
|
-
* @throws {
|
|
20
|
+
* @throws {Record<string, any>} If the request fails or Discord returns an error, rejects with an object containing a `code` and `message`.
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* getToken({
|
|
@@ -18,9 +18,9 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
18
18
|
* @param {string} [user='@me'] - The user ID to fetch. Use '@me' to get the authenticated user's profile.
|
|
19
19
|
* @param {string} [version=''] - Optional API version prefix (e.g., 'v10/') if needed by your API setup.
|
|
20
20
|
*
|
|
21
|
-
* @returns {Promise<
|
|
21
|
+
* @returns {Promise<Record<string, any>>} Resolves with the user's profile data returned by Discord.
|
|
22
22
|
*
|
|
23
|
-
* @throws {
|
|
23
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* getUser('access_token_here')
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* @param {string} [user='@me'] - The user ID to fetch. Use '@me' to get the authenticated user's profile.
|
|
10
10
|
* @param {string} [version=''] - Optional API version prefix (e.g., 'v10/') if needed by your API setup.
|
|
11
11
|
*
|
|
12
|
-
* @returns {Promise<
|
|
12
|
+
* @returns {Promise<Record<string, any>>} Resolves with the user's profile data returned by Discord.
|
|
13
13
|
*
|
|
14
|
-
* @throws {
|
|
14
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* getUser('access_token_here')
|
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
* .then(user => console.log('User info:', user))
|
|
25
25
|
* .catch(err => console.error('Error:', err));
|
|
26
26
|
*/
|
|
27
|
-
export default function getUser(access_token: string, type?: string, user?: string, version?: string): Promise<
|
|
27
|
+
export default function getUser(access_token: string, type?: string, user?: string, version?: string): Promise<Record<string, any>>;
|
|
@@ -13,9 +13,9 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
13
13
|
* @param {string} [user='@me'] - The user ID to fetch. Use '@me' to get the authenticated user's profile.
|
|
14
14
|
* @param {string} [version=''] - Optional API version prefix (e.g., 'v10/') if needed by your API setup.
|
|
15
15
|
*
|
|
16
|
-
* @returns {Promise<
|
|
16
|
+
* @returns {Promise<Record<string, any>>} Resolves with the user's profile data returned by Discord.
|
|
17
17
|
*
|
|
18
|
-
* @throws {
|
|
18
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* getUser('access_token_here')
|
|
@@ -17,9 +17,9 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
17
17
|
*
|
|
18
18
|
* @param {string} access_token - The OAuth2 access token used to authenticate the user.
|
|
19
19
|
*
|
|
20
|
-
* @returns {Promise<Array<
|
|
20
|
+
* @returns {Promise<Array<Record<string, any>>>} Resolves with an array of connection objects.
|
|
21
21
|
*
|
|
22
|
-
* @throws {
|
|
22
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
23
23
|
*
|
|
24
24
|
* @see {@link https://discord.com/developers/docs/resources/user#get-user-connections} Discord API Reference
|
|
25
25
|
*
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @param {string} access_token - The OAuth2 access token used to authenticate the user.
|
|
10
10
|
*
|
|
11
|
-
* @returns {Promise<Array<
|
|
11
|
+
* @returns {Promise<Array<Record<string, any>>>} Resolves with an array of connection objects.
|
|
12
12
|
*
|
|
13
|
-
* @throws {
|
|
13
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
14
14
|
*
|
|
15
15
|
* @see {@link https://discord.com/developers/docs/resources/user#get-user-connections} Discord API Reference
|
|
16
16
|
*
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
* })
|
|
24
24
|
* .catch(err => console.error('Failed to get connections:', err));
|
|
25
25
|
*/
|
|
26
|
-
export default function getUserConnections(access_token: string): Promise<Array<
|
|
26
|
+
export default function getUserConnections(access_token: string): Promise<Array<Record<string, any>>>;
|
|
@@ -12,9 +12,9 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
12
12
|
*
|
|
13
13
|
* @param {string} access_token - The OAuth2 access token used to authenticate the user.
|
|
14
14
|
*
|
|
15
|
-
* @returns {Promise<Array<
|
|
15
|
+
* @returns {Promise<Array<Record<string, any>>>} Resolves with an array of connection objects.
|
|
16
16
|
*
|
|
17
|
-
* @throws {
|
|
17
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
18
18
|
*
|
|
19
19
|
* @see {@link https://discord.com/developers/docs/resources/user#get-user-connections} Discord API Reference
|
|
20
20
|
*
|
|
@@ -18,9 +18,9 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
18
18
|
*
|
|
19
19
|
* @param {string} access_token - The OAuth2 access token used to authenticate the user.
|
|
20
20
|
*
|
|
21
|
-
* @returns {Promise<Array<
|
|
21
|
+
* @returns {Promise<Array<Record<string, any>>>} Resolves with an array of guild objects the user is in.
|
|
22
22
|
*
|
|
23
|
-
* @throws {
|
|
23
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* getUserGuilds('your_access_token')
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @param {string} access_token - The OAuth2 access token used to authenticate the user.
|
|
11
11
|
*
|
|
12
|
-
* @returns {Promise<Array<
|
|
12
|
+
* @returns {Promise<Array<Record<string, any>>>} Resolves with an array of guild objects the user is in.
|
|
13
13
|
*
|
|
14
|
-
* @throws {
|
|
14
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* getUserGuilds('your_access_token')
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* })
|
|
23
23
|
* .catch(err => console.error('Failed to get guilds:', err));
|
|
24
24
|
*/
|
|
25
|
-
export default function getUserGuilds(access_token: string): Promise<Array<
|
|
25
|
+
export default function getUserGuilds(access_token: string): Promise<Array<Record<string, any>>>;
|
|
@@ -13,9 +13,9 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
13
13
|
*
|
|
14
14
|
* @param {string} access_token - The OAuth2 access token used to authenticate the user.
|
|
15
15
|
*
|
|
16
|
-
* @returns {Promise<Array<
|
|
16
|
+
* @returns {Promise<Array<Record<string, any>>>} Resolves with an array of guild objects the user is in.
|
|
17
17
|
*
|
|
18
|
-
* @throws {
|
|
18
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* getUserGuilds('your_access_token')
|
|
@@ -21,7 +21,7 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
21
21
|
* @param {string} dsData.redirect_uri - The redirect URI used in the original OAuth2 flow.
|
|
22
22
|
* @param {string} dsData.scope - The scope(s) to request (e.g., 'identify guilds').
|
|
23
23
|
*
|
|
24
|
-
* @returns {Promise<
|
|
24
|
+
* @returns {Promise<Record<string, any>>} Resolves with a new token object from the Discord API:
|
|
25
25
|
* {
|
|
26
26
|
* access_token: string,
|
|
27
27
|
* token_type: string,
|
|
@@ -30,7 +30,7 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
30
30
|
* scope: string
|
|
31
31
|
* }
|
|
32
32
|
*
|
|
33
|
-
* @throws {
|
|
33
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
36
|
* refreshToken({
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @param {string} dsData.redirect_uri - The redirect URI used in the original OAuth2 flow.
|
|
13
13
|
* @param {string} dsData.scope - The scope(s) to request (e.g., 'identify guilds').
|
|
14
14
|
*
|
|
15
|
-
* @returns {Promise<
|
|
15
|
+
* @returns {Promise<Record<string, any>>} Resolves with a new token object from the Discord API:
|
|
16
16
|
* {
|
|
17
17
|
* access_token: string,
|
|
18
18
|
* token_type: string,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* scope: string
|
|
22
22
|
* }
|
|
23
23
|
*
|
|
24
|
-
* @throws {
|
|
24
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* refreshToken({
|
|
@@ -42,4 +42,4 @@ export default function refreshToken(dsData: {
|
|
|
42
42
|
refresh_token: string;
|
|
43
43
|
redirect_uri: string;
|
|
44
44
|
scope: string;
|
|
45
|
-
}): Promise<
|
|
45
|
+
}): Promise<Record<string, any>>;
|
|
@@ -16,7 +16,7 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
16
16
|
* @param {string} dsData.redirect_uri - The redirect URI used in the original OAuth2 flow.
|
|
17
17
|
* @param {string} dsData.scope - The scope(s) to request (e.g., 'identify guilds').
|
|
18
18
|
*
|
|
19
|
-
* @returns {Promise<
|
|
19
|
+
* @returns {Promise<Record<string, any>>} Resolves with a new token object from the Discord API:
|
|
20
20
|
* {
|
|
21
21
|
* access_token: string,
|
|
22
22
|
* token_type: string,
|
|
@@ -25,7 +25,7 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
25
25
|
* scope: string
|
|
26
26
|
* }
|
|
27
27
|
*
|
|
28
|
-
* @throws {
|
|
28
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
31
|
* refreshToken({
|
|
@@ -19,10 +19,10 @@ var errorValidator = require('../get/errorValidator.cjs');
|
|
|
19
19
|
* @param {string} tinyAuth.client_id - The Discord application client ID.
|
|
20
20
|
* @param {string} tinyAuth.client_secret - The Discord application client secret.
|
|
21
21
|
*
|
|
22
|
-
* @returns {Promise<
|
|
22
|
+
* @returns {Promise<Record<string, any>>} Resolves when the token is successfully revoked.
|
|
23
23
|
* The response may not contain any body if successful, so `result.data` may be empty.
|
|
24
24
|
*
|
|
25
|
-
* @throws {
|
|
25
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
28
|
* revokeToken('user-access-token', {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* @param {string} tinyAuth.client_id - The Discord application client ID.
|
|
11
11
|
* @param {string} tinyAuth.client_secret - The Discord application client secret.
|
|
12
12
|
*
|
|
13
|
-
* @returns {Promise<
|
|
13
|
+
* @returns {Promise<Record<string, any>>} Resolves when the token is successfully revoked.
|
|
14
14
|
* The response may not contain any body if successful, so `result.data` may be empty.
|
|
15
15
|
*
|
|
16
|
-
* @throws {
|
|
16
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* revokeToken('user-access-token', {
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
export default function revokeToken(access_token: string, tinyAuth: {
|
|
27
27
|
client_id: string;
|
|
28
28
|
client_secret: string;
|
|
29
|
-
}): Promise<
|
|
29
|
+
}): Promise<Record<string, any>>;
|
|
@@ -15,10 +15,10 @@ import errorValidator from '../get/errorValidator.mjs';
|
|
|
15
15
|
* @param {string} tinyAuth.client_id - The Discord application client ID.
|
|
16
16
|
* @param {string} tinyAuth.client_secret - The Discord application client secret.
|
|
17
17
|
*
|
|
18
|
-
* @returns {Promise<
|
|
18
|
+
* @returns {Promise<Record<string, any>>} Resolves when the token is successfully revoked.
|
|
19
19
|
* The response may not contain any body if successful, so `result.data` may be empty.
|
|
20
20
|
*
|
|
21
|
-
* @throws {
|
|
21
|
+
* @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* revokeToken('user-access-token', {
|
|
@@ -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)
|