tiny-essentials 1.8.3 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/TinyBasicsEs.js +31 -0
  2. package/dist/TinyBasicsEs.min.js +1 -1
  3. package/dist/TinyEssentials.js +31 -0
  4. package/dist/TinyEssentials.min.js +1 -1
  5. package/dist/legacy/crypto/decrypt.cjs +1 -1
  6. package/dist/legacy/crypto/decrypt.mjs +3 -3
  7. package/dist/legacy/crypto/default.cjs +0 -2
  8. package/dist/legacy/crypto/default.mjs +0 -1
  9. package/dist/legacy/crypto/encrypt.cjs +1 -2
  10. package/dist/legacy/crypto/encrypt.mjs +3 -4
  11. package/dist/legacy/crypto/index.cjs +1 -1
  12. package/dist/legacy/crypto/index.mjs +0 -1
  13. package/dist/legacy/firebase/database/presence.cjs +4 -1
  14. package/dist/legacy/firebase/database/presence.d.mts +3 -0
  15. package/dist/legacy/firebase/database/presence.mjs +4 -1
  16. package/dist/legacy/firebase/databaseLogger.cjs +2 -2
  17. package/dist/legacy/firebase/discord/get/cookie-session.cjs +2 -2
  18. package/dist/legacy/firebase/discord/get/errorValidator.cjs +2 -2
  19. package/dist/legacy/firebase/discord/http/login.cjs +7 -7
  20. package/dist/legacy/firebase/discord/http/logout.cjs +4 -4
  21. package/dist/legacy/firebase/discord/http/redirect.cjs +7 -7
  22. package/dist/legacy/firebase/discord/http/refreshToken.cjs +5 -5
  23. package/dist/legacy/firebase/discord/template/cookie-session.cjs +8 -8
  24. package/dist/legacy/firebase/logger.cjs +7 -7
  25. package/dist/legacy/firebase/mySQL.cjs +1 -0
  26. package/dist/legacy/firebase/mysqlConnector/sameUser.cjs +2 -2
  27. package/dist/legacy/get/countObj.cjs +2 -22
  28. package/dist/legacy/get/countObj.d.mts +2 -11
  29. package/dist/legacy/get/countObj.mjs +2 -22
  30. package/dist/legacy/get/decimalColor.cjs +10 -11
  31. package/dist/legacy/get/decimalColor.mjs +10 -10
  32. package/dist/legacy/get/objType.cjs +2 -40
  33. package/dist/legacy/get/objType.d.mts +2 -19
  34. package/dist/legacy/get/objType.mjs +2 -41
  35. package/dist/legacy/get/pagination.cjs +30 -25
  36. package/dist/legacy/get/pagination.d.mts +29 -12
  37. package/dist/legacy/get/pagination.mjs +30 -23
  38. package/dist/legacy/get/queryUrlByName.cjs +0 -2
  39. package/dist/legacy/get/queryUrlByName.mjs +0 -1
  40. package/dist/legacy/get/queryUrlJSON.cjs +2 -2
  41. package/dist/legacy/get/queryUrlJSON.mjs +1 -1
  42. package/dist/legacy/get/super_string_filter.cjs +14 -6
  43. package/dist/legacy/get/super_string_filter.mjs +11 -1
  44. package/dist/legacy/get/versionCheck.cjs +18 -19
  45. package/dist/legacy/get/versionCheck.d.mts +15 -5
  46. package/dist/legacy/get/versionCheck.mjs +16 -16
  47. package/dist/legacy/http/HTTP-1.0.cjs +2 -4
  48. package/dist/legacy/http/HTTP-1.0.d.mts +1 -1
  49. package/dist/legacy/http/HTTP-1.0.mjs +2 -3
  50. package/dist/legacy/http/auth.cjs +2 -4
  51. package/dist/legacy/http/auth.d.mts +4 -4
  52. package/dist/legacy/http/auth.mjs +2 -3
  53. package/dist/legacy/http/check_domain.cjs +15 -9
  54. package/dist/legacy/http/check_domain.d.mts +5 -6
  55. package/dist/legacy/http/check_domain.mjs +12 -8
  56. package/dist/legacy/http/csrfTokenAnalyze.cjs +5 -4
  57. package/dist/legacy/http/csrfTokenAnalyze.d.mts +3 -3
  58. package/dist/legacy/http/csrfTokenAnalyze.mjs +7 -4
  59. package/dist/legacy/http/domainValidator.cjs +13 -9
  60. package/dist/legacy/http/domainValidator.d.mts +15 -6
  61. package/dist/legacy/http/domainValidator.mjs +11 -6
  62. package/dist/legacy/http/errorsCallback.cjs +10 -4
  63. package/dist/legacy/http/errorsCallback.d.mts +13 -3
  64. package/dist/legacy/http/errorsCallback.mjs +12 -4
  65. package/dist/legacy/http/fetch/json.cjs +1 -3
  66. package/dist/legacy/http/fetch/json.mjs +1 -1
  67. package/dist/legacy/http/fetch/text.cjs +1 -3
  68. package/dist/legacy/http/fetch/text.mjs +1 -1
  69. package/dist/legacy/http/fileCache.cjs +2 -5
  70. package/dist/legacy/http/fileCache.d.mts +3 -3
  71. package/dist/legacy/http/fileCache.mjs +2 -3
  72. package/dist/legacy/http/getDomainURL.cjs +4 -7
  73. package/dist/legacy/http/getDomainURL.d.mts +2 -2
  74. package/dist/legacy/http/getDomainURL.mjs +4 -5
  75. package/dist/legacy/http/userIP.cjs +7 -5
  76. package/dist/legacy/http/userIP.d.mts +10 -4
  77. package/dist/legacy/http/userIP.mjs +7 -4
  78. package/dist/legacy/index.cjs +3 -4
  79. package/dist/legacy/index.d.mts +8 -9
  80. package/dist/legacy/libs/arraySortPositions.cjs +1 -3
  81. package/dist/legacy/libs/arraySortPositions.d.mts +2 -2
  82. package/dist/legacy/libs/arraySortPositions.mjs +1 -2
  83. package/dist/legacy/libs/capitalize.cjs +0 -2
  84. package/dist/legacy/libs/capitalize.mjs +0 -1
  85. package/dist/legacy/libs/convertBytes.cjs +1 -3
  86. package/dist/legacy/libs/convertBytes.mjs +1 -2
  87. package/dist/legacy/libs/custom_module_loader.cjs +13 -9
  88. package/dist/legacy/libs/custom_module_loader.d.mts +1 -1
  89. package/dist/legacy/libs/custom_module_loader.mjs +10 -5
  90. package/dist/legacy/libs/dice.cjs +0 -2
  91. package/dist/legacy/libs/dice.mjs +0 -1
  92. package/dist/legacy/libs/markdown.cjs +13 -4
  93. package/dist/legacy/libs/markdown.d.mts +7 -71
  94. package/dist/legacy/libs/markdown.mjs +13 -3
  95. package/dist/legacy/libs/percentage.cjs +0 -2
  96. package/dist/legacy/libs/percentage.mjs +0 -1
  97. package/dist/legacy/libs/regex/getLetter.cjs +0 -2
  98. package/dist/legacy/libs/regex/getLetter.mjs +0 -1
  99. package/dist/legacy/libs/rule3.cjs +0 -2
  100. package/dist/legacy/libs/rule3.mjs +0 -1
  101. package/dist/legacy/momentjs/getAge.cjs +0 -3
  102. package/dist/legacy/momentjs/getAge.d.mts +1 -0
  103. package/dist/legacy/momentjs/getAge.mjs +0 -1
  104. package/dist/legacy/momentjs/index.cjs +1 -1
  105. package/dist/legacy/momentjs/index.mjs +0 -1
  106. package/dist/legacy/momentjs/timeDuration.cjs +1 -3
  107. package/dist/legacy/momentjs/timeDuration.d.mts +1 -0
  108. package/dist/legacy/momentjs/timeDuration.mjs +1 -1
  109. package/dist/legacy/socket.io/antiFlood/index.cjs +1 -1
  110. package/dist/legacy/socket.io/antiFlood/index.mjs +0 -1
  111. package/dist/legacy/socket.io/antiFlood/install.cjs +3 -5
  112. package/dist/legacy/socket.io/antiFlood/install.d.mts +5 -3
  113. package/dist/legacy/socket.io/antiFlood/install.mjs +3 -3
  114. package/dist/legacy/socket.io/antiFlood/verify.cjs +10 -6
  115. package/dist/legacy/socket.io/antiFlood/verify.d.mts +8 -3
  116. package/dist/legacy/socket.io/antiFlood/verify.mjs +10 -6
  117. package/dist/legacy/socket.io/cookie-session.cjs +1 -2
  118. package/dist/legacy/socket.io/cookie-session.mjs +1 -1
  119. package/dist/legacy/socket.io/discord.cjs +0 -3
  120. package/dist/legacy/socket.io/discord.mjs +0 -1
  121. package/dist/legacy/socket.io/index.cjs +0 -3
  122. package/dist/legacy/socket.io/index.mjs +0 -1
  123. package/dist/v1/basics/index.cjs +3 -0
  124. package/dist/v1/basics/index.d.mts +3 -1
  125. package/dist/v1/basics/index.mjs +3 -2
  126. package/dist/v1/index.cjs +3 -0
  127. package/dist/v1/index.d.mts +3 -1
  128. package/dist/v1/index.mjs +3 -2
  129. package/docs/basics/array.md +61 -0
  130. package/package.json +8 -2
@@ -11,10 +11,10 @@
11
11
  * @param {Object} data - Configuration object.
12
12
  * @param {string} data.login - The expected username.
13
13
  * @param {string} data.password - The expected password.
14
- * @param {Function} [data.customError] - Optional function `(req, res) => {}` called on auth failure.
14
+ * @param {function(import('express').Request, import('express').Response): import('express').Response} [data.customError] - Optional function `(req, res) => {}` called on auth failure.
15
15
  * @param {Function} [callback] - Optional fallback function `(req, res, next) => {}` executed after customError.
16
16
  *
17
- * @returns {Function} Express middleware function.
17
+ * @returns {function(import('express').Request, import('express').Response, import('express').NextFunction): void} Express middleware function.
18
18
  *
19
19
  * @example
20
20
  * import express from 'express';
@@ -37,6 +37,6 @@
37
37
  export default function auth(data: {
38
38
  login: string;
39
39
  password: string;
40
- customError?: Function | undefined;
41
- }, callback?: Function): Function;
40
+ customError?: ((arg0: import("express").Request, arg1: import("express").Response) => import("express").Response) | undefined;
41
+ }, callback?: Function): (arg0: import("express").Request, arg1: import("express").Response, arg2: import("express").NextFunction) => void;
42
42
  //# sourceMappingURL=auth.d.mts.map
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Creates an Express middleware for Basic HTTP Authentication.
4
3
  *
@@ -12,10 +11,10 @@
12
11
  * @param {Object} data - Configuration object.
13
12
  * @param {string} data.login - The expected username.
14
13
  * @param {string} data.password - The expected password.
15
- * @param {Function} [data.customError] - Optional function `(req, res) => {}` called on auth failure.
14
+ * @param {function(import('express').Request, import('express').Response): import('express').Response} [data.customError] - Optional function `(req, res) => {}` called on auth failure.
16
15
  * @param {Function} [callback] - Optional fallback function `(req, res, next) => {}` executed after customError.
17
16
  *
18
- * @returns {Function} Express middleware function.
17
+ * @returns {function(import('express').Request, import('express').Response, import('express').NextFunction): void} Express middleware function.
19
18
  *
20
19
  * @example
21
20
  * import express from 'express';
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // @ts-nocheck
4
-
5
3
  /**
6
4
  * @module check_domain
7
5
  *
@@ -22,12 +20,14 @@ const check_domain = {
22
20
  * If a domain (`the_domain`) is passed, the function returns a boolean.
23
21
  * If not, it returns the found domain string or `null`.
24
22
  *
25
- * @type {Array<{type: string, callback: function(req: Object, the_domain?: string): (boolean|string|null)}>}
26
23
  */
27
24
  validators: [
28
25
  {
29
26
  type: 'x-forwarded-host',
30
- callback: function (req, the_domain) {
27
+ callback: function (
28
+ /** @type {import('express').Request} */ req,
29
+ /** @type {string} */ the_domain,
30
+ ) {
31
31
  const isString = typeof req.headers['x-forwarded-host'] === 'string';
32
32
  if (the_domain) return isString && req.headers['x-forwarded-host'] === the_domain;
33
33
 
@@ -36,7 +36,10 @@ const check_domain = {
36
36
  },
37
37
  {
38
38
  type: 'hostname',
39
- callback: function (req, the_domain) {
39
+ callback: function (
40
+ /** @type {import('express').Request} */ req,
41
+ /** @type {string} */ the_domain,
42
+ ) {
40
43
  const isString = typeof req.hostname === 'string';
41
44
  if (the_domain) return isString && req.hostname === the_domain;
42
45
 
@@ -45,7 +48,10 @@ const check_domain = {
45
48
  },
46
49
  {
47
50
  type: 'hostname',
48
- callback: function (req, the_domain) {
51
+ callback: function (
52
+ /** @type {import('express').Request} */ req,
53
+ /** @type {string} */ the_domain,
54
+ ) {
49
55
  const isString = typeof req.headers.host === 'string';
50
56
  if (the_domain) return isString && req.headers.host === the_domain;
51
57
  return isString ? req.headers.host : null;
@@ -57,7 +63,7 @@ const check_domain = {
57
63
  * Validates the request against a given domain using all available validators.
58
64
  *
59
65
  * @function
60
- * @param {Record<string, any>} req - The request object from Express.
66
+ * @param {import('express').Request} req - The request object from Express.
61
67
  * @param {string} the_domain - The domain to validate against.
62
68
  * @returns {boolean} True if any validator matches the domain.
63
69
  */
@@ -71,8 +77,8 @@ const check_domain = {
71
77
  * Returns the domain found from the first valid source in the request object.
72
78
  *
73
79
  * @function
74
- * @param {Record<string, any>} req - The request object from Express.
75
- * @returns {string|null} The found domain string or `null` if none matched.
80
+ * @param {import('express').Request} req - The request object from Express.
81
+ * @returns {string|true|string[]|null} The found domain string or `null` if none matched.
76
82
  */
77
83
  get: function (req) {
78
84
  for (const item in check_domain.validators) {
@@ -1,11 +1,10 @@
1
1
  export default check_domain;
2
2
  declare namespace check_domain {
3
- let validators: Array<{
3
+ let validators: {
4
4
  type: string;
5
- callback: (arg0: req) => Object;
6
- the_domain?: string;
7
- }>;
8
- function validator(req: Record<string, any>, the_domain: string): boolean;
9
- function get(req: Record<string, any>): string | null;
5
+ callback: (req: import("express").Request, the_domain: string) => string | boolean | string[] | null | undefined;
6
+ }[];
7
+ function validator(req: import("express").Request, the_domain: string): boolean;
8
+ function get(req: import("express").Request): string | true | string[] | null;
10
9
  }
11
10
  //# sourceMappingURL=check_domain.d.mts.map
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * @module check_domain
4
3
  *
@@ -19,12 +18,13 @@ const check_domain = {
19
18
  * If a domain (`the_domain`) is passed, the function returns a boolean.
20
19
  * If not, it returns the found domain string or `null`.
21
20
  *
22
- * @type {Array<{type: string, callback: function(req: Object, the_domain?: string): (boolean|string|null)}>}
23
21
  */
24
22
  validators: [
25
23
  {
26
24
  type: 'x-forwarded-host',
27
- callback: function (req, the_domain) {
25
+ callback: function (
26
+ /** @type {import('express').Request} */ req,
27
+ /** @type {string} */ the_domain) {
28
28
  const isString = typeof req.headers['x-forwarded-host'] === 'string';
29
29
  if (the_domain)
30
30
  return isString && req.headers['x-forwarded-host'] === the_domain;
@@ -33,7 +33,9 @@ const check_domain = {
33
33
  },
34
34
  {
35
35
  type: 'hostname',
36
- callback: function (req, the_domain) {
36
+ callback: function (
37
+ /** @type {import('express').Request} */ req,
38
+ /** @type {string} */ the_domain) {
37
39
  const isString = typeof req.hostname === 'string';
38
40
  if (the_domain)
39
41
  return isString && req.hostname === the_domain;
@@ -42,7 +44,9 @@ const check_domain = {
42
44
  },
43
45
  {
44
46
  type: 'hostname',
45
- callback: function (req, the_domain) {
47
+ callback: function (
48
+ /** @type {import('express').Request} */ req,
49
+ /** @type {string} */ the_domain) {
46
50
  const isString = typeof req.headers.host === 'string';
47
51
  if (the_domain)
48
52
  return isString && req.headers.host === the_domain;
@@ -54,7 +58,7 @@ const check_domain = {
54
58
  * Validates the request against a given domain using all available validators.
55
59
  *
56
60
  * @function
57
- * @param {Record<string, any>} req - The request object from Express.
61
+ * @param {import('express').Request} req - The request object from Express.
58
62
  * @param {string} the_domain - The domain to validate against.
59
63
  * @returns {boolean} True if any validator matches the domain.
60
64
  */
@@ -68,8 +72,8 @@ const check_domain = {
68
72
  * Returns the domain found from the first valid source in the request object.
69
73
  *
70
74
  * @function
71
- * @param {Record<string, any>} req - The request object from Express.
72
- * @returns {string|null} The found domain string or `null` if none matched.
75
+ * @param {import('express').Request} req - The request object from Express.
76
+ * @returns {string|true|string[]|null} The found domain string or `null` if none matched.
73
77
  */
74
78
  get: function (req) {
75
79
  for (const item in check_domain.validators) {
@@ -1,17 +1,15 @@
1
1
  'use strict';
2
2
 
3
- // @ts-nocheck
4
-
5
3
  /**
6
4
  * @function csrfTokenAnalyze
7
5
  *
8
6
  * Checks if the CSRF token in the request body matches the expected token from the session.
9
7
  * If invalid, returns a 401 response and optionally executes a custom callback.
10
8
  *
11
- * @param {Record<string, any>} req - The Express request object. Should contain:
9
+ * @param {import('express').Request} req - The Express request object. Should contain:
12
10
  * - `req.csrfToken.now`: The expected CSRF token.
13
11
  * - `req.body.csrfToken`: The token provided by the client.
14
- * @param {Record<string, any>} res - The Express response object.
12
+ * @param {import('express').Response} res - The Express response object.
15
13
  * @param {Function} [callback] - Optional custom callback to execute when CSRF validation fails.
16
14
  *
17
15
  * @returns {boolean} Returns `true` if the token is invalid and a response was sent, otherwise `false`.
@@ -25,8 +23,11 @@
25
23
  function csrfTokenAnalyze(req, res, callback) {
26
24
  // Check Values
27
25
  if (
26
+ // @ts-ignore
28
27
  req.csrfToken &&
28
+ // @ts-ignore
29
29
  typeof req.csrfToken.now === 'string' &&
30
+ // @ts-ignore
30
31
  (typeof req.body.csrfToken !== 'string' || req.body.csrfToken !== req.csrfToken.now)
31
32
  ) {
32
33
  // Result
@@ -4,10 +4,10 @@
4
4
  * Checks if the CSRF token in the request body matches the expected token from the session.
5
5
  * If invalid, returns a 401 response and optionally executes a custom callback.
6
6
  *
7
- * @param {Record<string, any>} req - The Express request object. Should contain:
7
+ * @param {import('express').Request} req - The Express request object. Should contain:
8
8
  * - `req.csrfToken.now`: The expected CSRF token.
9
9
  * - `req.body.csrfToken`: The token provided by the client.
10
- * @param {Record<string, any>} res - The Express response object.
10
+ * @param {import('express').Response} res - The Express response object.
11
11
  * @param {Function} [callback] - Optional custom callback to execute when CSRF validation fails.
12
12
  *
13
13
  * @returns {boolean} Returns `true` if the token is invalid and a response was sent, otherwise `false`.
@@ -18,5 +18,5 @@
18
18
  * // Continue with request logic if CSRF is valid
19
19
  * });
20
20
  */
21
- export default function csrfTokenAnalyze(req: Record<string, any>, res: Record<string, any>, callback?: Function): boolean;
21
+ export default function csrfTokenAnalyze(req: import("express").Request, res: import("express").Response, callback?: Function): boolean;
22
22
  //# sourceMappingURL=csrfTokenAnalyze.d.mts.map
@@ -1,14 +1,13 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * @function csrfTokenAnalyze
4
3
  *
5
4
  * Checks if the CSRF token in the request body matches the expected token from the session.
6
5
  * If invalid, returns a 401 response and optionally executes a custom callback.
7
6
  *
8
- * @param {Record<string, any>} req - The Express request object. Should contain:
7
+ * @param {import('express').Request} req - The Express request object. Should contain:
9
8
  * - `req.csrfToken.now`: The expected CSRF token.
10
9
  * - `req.body.csrfToken`: The token provided by the client.
11
- * @param {Record<string, any>} res - The Express response object.
10
+ * @param {import('express').Response} res - The Express response object.
12
11
  * @param {Function} [callback] - Optional custom callback to execute when CSRF validation fails.
13
12
  *
14
13
  * @returns {boolean} Returns `true` if the token is invalid and a response was sent, otherwise `false`.
@@ -21,8 +20,12 @@
21
20
  */
22
21
  export default function csrfTokenAnalyze(req, res, callback) {
23
22
  // Check Values
24
- if (req.csrfToken &&
23
+ if (
24
+ // @ts-ignore
25
+ req.csrfToken &&
26
+ // @ts-ignore
25
27
  typeof req.csrfToken.now === 'string' &&
28
+ // @ts-ignore
26
29
  (typeof req.body.csrfToken !== 'string' || req.body.csrfToken !== req.csrfToken.now)) {
27
30
  // Result
28
31
  res.status(401);
@@ -1,11 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var check_domain = require('./check_domain.cjs');
4
- var objType = require('../get/objType.cjs');
4
+ var objFilter = require('../../v1/basics/objFilter.cjs');
5
5
  var isEmulator = require('../firebase/isEmulator.cjs');
6
6
 
7
- // @ts-nocheck
8
-
7
+ /**
8
+ * @typedef {{
9
+ * verified: boolean; // Whether the domain is verified.
10
+ * domain: string|null|true|string[]; // The detected domain from the request.
11
+ * isStaticPath: boolean // Whether the request matches a static path.
12
+ * }} DomainResult
13
+ */
9
14
 
10
15
  /**
11
16
  * @function domainValidator
@@ -14,17 +19,14 @@ var isEmulator = require('../firebase/isEmulator.cjs');
14
19
  * This is useful for filtering requests by origin or allowing access from specific domains only.
15
20
  * Also detects if Firebase is running in emulator mode, which bypasses domain validation.
16
21
  *
17
- * @param {Record<string, any>} req - The Express request object.
22
+ * @param {import('express').Request} req - The Express request object.
18
23
  * - `req.url`: Full URL path.
19
24
  * - `req.headers`: Expected to contain 'host', 'x-forwarded-host', etc.
20
25
  * @param {Record<string, any>} cfg - Configuration object.
21
26
  * @property {string|string[]} cfg.domain - The allowed domain(s) to validate against.
22
27
  * @property {string[]} [cfg.staticPath] - Optional list of static paths to validate.
23
28
  *
24
- * @returns {Record<string, any>} Returns an object with the following structure:
25
- * @property {boolean} verified - Whether the domain is verified.
26
- * @property {string|null} domain - The detected domain from the request.
27
- * @property {boolean} isStaticPath - Whether the request matches a static path.
29
+ * @returns {DomainResult}
28
30
  *
29
31
  * @example
30
32
  * const result = domainValidator(req, {
@@ -43,16 +45,18 @@ function domainValidator(req, cfg) {
43
45
 
44
46
  // Path
45
47
  var prepareUrlPath = req.url.split('/');
48
+ // @ts-ignore
46
49
  req.url_path = [];
47
50
  for (const item in prepareUrlPath) {
48
51
  if (Number(item) > 0) {
49
52
  // Insert URL Path
53
+ // @ts-ignore
50
54
  req.url_path.push(prepareUrlPath[item].split(/[?#]/)[0]);
51
55
  }
52
56
  }
53
57
 
54
58
  // Is Obj
55
- if (objType(cfg, 'object')) {
59
+ if (objFilter.objType(cfg, 'object')) {
56
60
  // Firebase Is Emulator
57
61
  let firebaseIsEmulator = false;
58
62
  if (isEmulator) {
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @typedef {{
3
+ * verified: boolean; // Whether the domain is verified.
4
+ * domain: string|null|true|string[]; // The detected domain from the request.
5
+ * isStaticPath: boolean // Whether the request matches a static path.
6
+ * }} DomainResult
7
+ */
1
8
  /**
2
9
  * @function domainValidator
3
10
  *
@@ -5,17 +12,14 @@
5
12
  * This is useful for filtering requests by origin or allowing access from specific domains only.
6
13
  * Also detects if Firebase is running in emulator mode, which bypasses domain validation.
7
14
  *
8
- * @param {Record<string, any>} req - The Express request object.
15
+ * @param {import('express').Request} req - The Express request object.
9
16
  * - `req.url`: Full URL path.
10
17
  * - `req.headers`: Expected to contain 'host', 'x-forwarded-host', etc.
11
18
  * @param {Record<string, any>} cfg - Configuration object.
12
19
  * @property {string|string[]} cfg.domain - The allowed domain(s) to validate against.
13
20
  * @property {string[]} [cfg.staticPath] - Optional list of static paths to validate.
14
21
  *
15
- * @returns {Record<string, any>} Returns an object with the following structure:
16
- * @property {boolean} verified - Whether the domain is verified.
17
- * @property {string|null} domain - The detected domain from the request.
18
- * @property {boolean} isStaticPath - Whether the request matches a static path.
22
+ * @returns {DomainResult}
19
23
  *
20
24
  * @example
21
25
  * const result = domainValidator(req, {
@@ -27,5 +31,10 @@
27
31
  * console.log('Domain OK:', result.domain);
28
32
  * }
29
33
  */
30
- export default function domainValidator(req: Record<string, any>, cfg: Record<string, any>): Record<string, any>;
34
+ export default function domainValidator(req: import("express").Request, cfg: Record<string, any>): DomainResult;
35
+ export type DomainResult = {
36
+ verified: boolean;
37
+ domain: string | null | true | string[];
38
+ isStaticPath: boolean;
39
+ };
31
40
  //# sourceMappingURL=domainValidator.d.mts.map
@@ -1,7 +1,13 @@
1
- // @ts-nocheck
2
1
  import checkDomain from './check_domain.mjs';
3
2
  import objType from '../get/objType.mjs';
4
3
  import isEmulator from '../firebase/isEmulator.mjs';
4
+ /**
5
+ * @typedef {{
6
+ * verified: boolean; // Whether the domain is verified.
7
+ * domain: string|null|true|string[]; // The detected domain from the request.
8
+ * isStaticPath: boolean // Whether the request matches a static path.
9
+ * }} DomainResult
10
+ */
5
11
  /**
6
12
  * @function domainValidator
7
13
  *
@@ -9,17 +15,14 @@ import isEmulator from '../firebase/isEmulator.mjs';
9
15
  * This is useful for filtering requests by origin or allowing access from specific domains only.
10
16
  * Also detects if Firebase is running in emulator mode, which bypasses domain validation.
11
17
  *
12
- * @param {Record<string, any>} req - The Express request object.
18
+ * @param {import('express').Request} req - The Express request object.
13
19
  * - `req.url`: Full URL path.
14
20
  * - `req.headers`: Expected to contain 'host', 'x-forwarded-host', etc.
15
21
  * @param {Record<string, any>} cfg - Configuration object.
16
22
  * @property {string|string[]} cfg.domain - The allowed domain(s) to validate against.
17
23
  * @property {string[]} [cfg.staticPath] - Optional list of static paths to validate.
18
24
  *
19
- * @returns {Record<string, any>} Returns an object with the following structure:
20
- * @property {boolean} verified - Whether the domain is verified.
21
- * @property {string|null} domain - The detected domain from the request.
22
- * @property {boolean} isStaticPath - Whether the request matches a static path.
25
+ * @returns {DomainResult}
23
26
  *
24
27
  * @example
25
28
  * const result = domainValidator(req, {
@@ -36,10 +39,12 @@ export default function domainValidator(req, cfg) {
36
39
  let domainStatus = { verified: false, domain: checkDomain.get(req), isStaticPath: false };
37
40
  // Path
38
41
  var prepareUrlPath = req.url.split('/');
42
+ // @ts-ignore
39
43
  req.url_path = [];
40
44
  for (const item in prepareUrlPath) {
41
45
  if (Number(item) > 0) {
42
46
  // Insert URL Path
47
+ // @ts-ignore
43
48
  req.url_path.push(prepareUrlPath[item].split(/[?#]/)[0]);
44
49
  }
45
50
  }
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // @ts-nocheck
4
-
5
3
  /**
6
4
  * @function errorsCallback
7
5
  *
@@ -10,14 +8,19 @@
10
8
  *
11
9
  * If the error does not meet the criteria (e.g., status not defined or < 400), it delegates to the next middleware.
12
10
  *
13
- * @param {Function} callback - A function called when an error with valid status is detected.
11
+ * @param {function(import('express').Request, import('express').Response, import('express').NextFunction, {
12
+ * code: number,
13
+ * path: string,
14
+ * originalUrl: string,
15
+ * err: Error
16
+ * }): void} callback - A function called when an error with valid status is detected.
14
17
  * Receives parameters: (req, res, next, info)
15
18
  * - `info.code`: HTTP status code.
16
19
  * - `info.path`: `req.url` value.
17
20
  * - `info.originalUrl`: `req.originalUrl` value.
18
21
  * - `info.err`: The original error object.
19
22
  *
20
- * @returns {Function} Express middleware function: (err, req, res, next)
23
+ * @returns {function(Error, import('express').Request, import('express').Response, import('express').NextFunction): void} Express middleware function: (err, req, res, next)
21
24
  *
22
25
  * @example
23
26
  * import errorsCallback from './errorsCallback.mjs';
@@ -33,10 +36,12 @@
33
36
  function errorsCallback(callback) {
34
37
  return function (err, req, res, next) {
35
38
  // Err Code
39
+ // @ts-ignore
36
40
  const errCode = Number(err.status);
37
41
 
38
42
  // Error
39
43
  if (
44
+ // @ts-ignore
40
45
  (typeof err.status !== 'number' && typeof err.status !== 'string') ||
41
46
  isNaN(errCode) ||
42
47
  !isFinite(errCode) ||
@@ -46,6 +51,7 @@ function errorsCallback(callback) {
46
51
  // Nope
47
52
  else
48
53
  callback(req, res, next, {
54
+ // @ts-ignore
49
55
  code: err.status,
50
56
  path: req.url,
51
57
  originalUrl: req.originalUrl,
@@ -6,14 +6,19 @@
6
6
  *
7
7
  * If the error does not meet the criteria (e.g., status not defined or < 400), it delegates to the next middleware.
8
8
  *
9
- * @param {Function} callback - A function called when an error with valid status is detected.
9
+ * @param {function(import('express').Request, import('express').Response, import('express').NextFunction, {
10
+ * code: number,
11
+ * path: string,
12
+ * originalUrl: string,
13
+ * err: Error
14
+ * }): void} callback - A function called when an error with valid status is detected.
10
15
  * Receives parameters: (req, res, next, info)
11
16
  * - `info.code`: HTTP status code.
12
17
  * - `info.path`: `req.url` value.
13
18
  * - `info.originalUrl`: `req.originalUrl` value.
14
19
  * - `info.err`: The original error object.
15
20
  *
16
- * @returns {Function} Express middleware function: (err, req, res, next)
21
+ * @returns {function(Error, import('express').Request, import('express').Response, import('express').NextFunction): void} Express middleware function: (err, req, res, next)
17
22
  *
18
23
  * @example
19
24
  * import errorsCallback from './errorsCallback.mjs';
@@ -26,5 +31,10 @@
26
31
  * });
27
32
  * }));
28
33
  */
29
- export default function errorsCallback(callback: Function): Function;
34
+ export default function errorsCallback(callback: (arg0: import("express").Request, arg1: import("express").Response, arg2: import("express").NextFunction, arg3: {
35
+ code: number;
36
+ path: string;
37
+ originalUrl: string;
38
+ err: Error;
39
+ }) => void): (arg0: Error, arg1: import("express").Request, arg2: import("express").Response, arg3: import("express").NextFunction) => void;
30
40
  //# sourceMappingURL=errorsCallback.d.mts.map
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * @function errorsCallback
4
3
  *
@@ -7,14 +6,19 @@
7
6
  *
8
7
  * If the error does not meet the criteria (e.g., status not defined or < 400), it delegates to the next middleware.
9
8
  *
10
- * @param {Function} callback - A function called when an error with valid status is detected.
9
+ * @param {function(import('express').Request, import('express').Response, import('express').NextFunction, {
10
+ * code: number,
11
+ * path: string,
12
+ * originalUrl: string,
13
+ * err: Error
14
+ * }): void} callback - A function called when an error with valid status is detected.
11
15
  * Receives parameters: (req, res, next, info)
12
16
  * - `info.code`: HTTP status code.
13
17
  * - `info.path`: `req.url` value.
14
18
  * - `info.originalUrl`: `req.originalUrl` value.
15
19
  * - `info.err`: The original error object.
16
20
  *
17
- * @returns {Function} Express middleware function: (err, req, res, next)
21
+ * @returns {function(Error, import('express').Request, import('express').Response, import('express').NextFunction): void} Express middleware function: (err, req, res, next)
18
22
  *
19
23
  * @example
20
24
  * import errorsCallback from './errorsCallback.mjs';
@@ -30,9 +34,12 @@
30
34
  export default function errorsCallback(callback) {
31
35
  return function (err, req, res, next) {
32
36
  // Err Code
37
+ // @ts-ignore
33
38
  const errCode = Number(err.status);
34
39
  // Error
35
- if ((typeof err.status !== 'number' && typeof err.status !== 'string') ||
40
+ if (
41
+ // @ts-ignore
42
+ (typeof err.status !== 'number' && typeof err.status !== 'string') ||
36
43
  isNaN(errCode) ||
37
44
  !isFinite(errCode) ||
38
45
  errCode < 400)
@@ -40,6 +47,7 @@ export default function errorsCallback(callback) {
40
47
  // Nope
41
48
  else
42
49
  callback(req, res, next, {
50
+ // @ts-ignore
43
51
  code: err.status,
44
52
  path: req.url,
45
53
  originalUrl: req.originalUrl,
@@ -2,9 +2,6 @@
2
2
 
3
3
  var fetch = require('node-fetch');
4
4
 
5
- // @ts-nocheck
6
-
7
-
8
5
  /**
9
6
  * Performs a `fetch` request using any provided arguments and returns a Promise
10
7
  * that resolves with the parsed JSON response.
@@ -30,6 +27,7 @@ function getJsonFetch() {
30
27
  const tinyArgs = arguments;
31
28
  return new Promise((resolve, reject) =>
32
29
  fetch
30
+ // @ts-ignore
33
31
  .apply(fetch, tinyArgs)
34
32
  .then((response) => {
35
33
  // Get Response
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import fetch from 'node-fetch';
3
2
  /**
4
3
  * Performs a `fetch` request using any provided arguments and returns a Promise
@@ -24,6 +23,7 @@ import fetch from 'node-fetch';
24
23
  export default function getJsonFetch() {
25
24
  const tinyArgs = arguments;
26
25
  return new Promise((resolve, reject) => fetch
26
+ // @ts-ignore
27
27
  .apply(fetch, tinyArgs)
28
28
  .then((response) => {
29
29
  // Get Response
@@ -2,9 +2,6 @@
2
2
 
3
3
  var fetch = require('node-fetch');
4
4
 
5
- // @ts-nocheck
6
-
7
-
8
5
  /**
9
6
  * Performs a `fetch` request using any provided arguments and returns a Promise
10
7
  * that resolves with the raw text response.
@@ -29,6 +26,7 @@ function getTextFetch() {
29
26
  const tinyArgs = arguments;
30
27
  return new Promise((resolve, reject) =>
31
28
  fetch
29
+ // @ts-ignore
32
30
  .apply(fetch, tinyArgs)
33
31
  .then((response) => {
34
32
  // Get Response
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import fetch from 'node-fetch';
3
2
  /**
4
3
  * Performs a `fetch` request using any provided arguments and returns a Promise
@@ -23,6 +22,7 @@ import fetch from 'node-fetch';
23
22
  export default function getTextFetch() {
24
23
  const tinyArgs = arguments;
25
24
  return new Promise((resolve, reject) => fetch
25
+ // @ts-ignore
26
26
  .apply(fetch, tinyArgs)
27
27
  .then((response) => {
28
28
  // Get Response
@@ -5,17 +5,14 @@ var moment = require('moment-timezone');
5
5
  var md5 = require('md5');
6
6
  var byteLength = require('byte-length');
7
7
 
8
- // @ts-nocheck
9
-
10
-
11
8
  /**
12
9
  * @function fileCache
13
10
  *
14
11
  * Sends a stringified file as a response with caching, security headers, and optional metadata.
15
12
  * If `data.file` is not a string, the request is passed to the next middleware.
16
13
  *
17
- * @param {object} res - Express response object.
18
- * @param {Function} next - Express next middleware function.
14
+ * @param {import('express').Response} res - Express response object.
15
+ * @param {import('express').NextFunction} next - Express next middleware function.
19
16
  * @param {object} data - Configuration object for the file response.
20
17
  * @param {string} [data.file] - The content of the file to send (must be a string).
21
18
  * @param {number} [data.fileMaxAge] - Max age in seconds for cache expiration.