vortez 5.0.0-dev.15 → 5.0.0-dev.16

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 (149) hide show
  1. package/.gitignore +0 -0
  2. package/LICENSE +0 -0
  3. package/README.md +0 -0
  4. package/build/Template.d.ts +1 -1
  5. package/build/Template.js +1 -1
  6. package/build/Template.js.map +0 -0
  7. package/build/Vortez.d.ts +1 -1
  8. package/build/Vortez.js +1 -1
  9. package/build/Vortez.js.map +0 -0
  10. package/build/beta/Beta.d.ts +2 -2
  11. package/build/beta/Beta.js +2 -2
  12. package/build/beta/Beta.js.map +1 -1
  13. package/build/beta/JwtManager/Jwt.d.ts +32 -0
  14. package/build/beta/JwtManager/Jwt.js +33 -0
  15. package/build/beta/JwtManager/Jwt.js.map +1 -0
  16. package/build/beta/JwtManager/JwtManager.d.ts +49 -0
  17. package/build/beta/JwtManager/JwtManager.js +74 -0
  18. package/build/beta/JwtManager/JwtManager.js.map +1 -0
  19. package/build/beta/JwtManager/JwtUtils.d.ts +32 -0
  20. package/build/beta/JwtManager/JwtUtils.js +50 -0
  21. package/build/beta/JwtManager/JwtUtils.js.map +1 -0
  22. package/build/beta/JwtManager/KeyGenerator.d.ts +47 -0
  23. package/build/beta/JwtManager/KeyGenerator.js +92 -0
  24. package/build/beta/JwtManager/KeyGenerator.js.map +1 -0
  25. package/build/beta/JwtManager/algorithm/Algorithm.d.ts +68 -0
  26. package/build/beta/JwtManager/algorithm/Algorithm.js +82 -0
  27. package/build/beta/JwtManager/algorithm/Algorithm.js.map +1 -0
  28. package/build/beta/JwtManager/algorithm/ECDSA.d.ts +18 -0
  29. package/build/beta/JwtManager/algorithm/ECDSA.js +46 -0
  30. package/build/beta/JwtManager/algorithm/ECDSA.js.map +1 -0
  31. package/build/beta/JwtManager/algorithm/HMAC.d.ts +24 -0
  32. package/build/beta/JwtManager/algorithm/HMAC.js +38 -0
  33. package/build/beta/JwtManager/algorithm/HMAC.js.map +1 -0
  34. package/build/beta/JwtManager/algorithm/RSA.d.ts +24 -0
  35. package/build/beta/JwtManager/algorithm/RSA.js +52 -0
  36. package/build/beta/JwtManager/algorithm/RSA.js.map +1 -0
  37. package/build/beta/JwtManager/algorithm/RSAPSS.d.ts +24 -0
  38. package/build/beta/JwtManager/algorithm/RSAPSS.js +55 -0
  39. package/build/beta/JwtManager/algorithm/RSAPSS.js.map +1 -0
  40. package/build/beta/Mail.d.ts +1 -1
  41. package/build/beta/Mail.js +1 -1
  42. package/build/beta/Mail.js.map +0 -0
  43. package/build/logger/Debug.d.ts +1 -1
  44. package/build/logger/Debug.js +1 -1
  45. package/build/logger/Debug.js.map +0 -0
  46. package/build/logger/Logger.d.ts +1 -1
  47. package/build/logger/Logger.js +1 -1
  48. package/build/logger/Logger.js.map +0 -0
  49. package/build/server/BodyParser.d.ts +1 -1
  50. package/build/server/BodyParser.js +1 -1
  51. package/build/server/BodyParser.js.map +0 -0
  52. package/build/server/Cookie.d.ts +1 -1
  53. package/build/server/Cookie.js +1 -1
  54. package/build/server/Cookie.js.map +0 -0
  55. package/build/server/LoggerManager.d.ts +1 -1
  56. package/build/server/LoggerManager.js +1 -1
  57. package/build/server/LoggerManager.js.map +0 -0
  58. package/build/server/Request.d.ts +1 -1
  59. package/build/server/Request.js +1 -1
  60. package/build/server/Request.js.map +0 -0
  61. package/build/server/Response.d.ts +1 -1
  62. package/build/server/Response.js +1 -1
  63. package/build/server/Response.js.map +0 -0
  64. package/build/server/Server.d.ts +1 -1
  65. package/build/server/Server.js +1 -1
  66. package/build/server/Server.js.map +0 -0
  67. package/build/server/ServerDebug.d.ts +1 -1
  68. package/build/server/ServerDebug.js +1 -1
  69. package/build/server/ServerDebug.js.map +0 -0
  70. package/build/server/ServerError.d.ts +0 -0
  71. package/build/server/ServerError.js +0 -0
  72. package/build/server/ServerError.js.map +0 -0
  73. package/build/server/Session.d.ts +1 -1
  74. package/build/server/Session.js +1 -1
  75. package/build/server/Session.js.map +0 -0
  76. package/build/server/config/Config.d.ts +1 -1
  77. package/build/server/config/Config.js +1 -1
  78. package/build/server/config/Config.js.map +0 -0
  79. package/build/server/config/ConfigLoader.d.ts +1 -1
  80. package/build/server/config/ConfigLoader.js +1 -1
  81. package/build/server/config/ConfigLoader.js.map +0 -0
  82. package/build/server/config/ConfigValidator.d.ts +1 -1
  83. package/build/server/config/ConfigValidator.js +1 -1
  84. package/build/server/config/ConfigValidator.js.map +0 -0
  85. package/build/server/router/HttpRule.d.ts +0 -0
  86. package/build/server/router/HttpRule.js +0 -0
  87. package/build/server/router/HttpRule.js.map +0 -0
  88. package/build/server/router/Router.d.ts +1 -1
  89. package/build/server/router/Router.js +1 -1
  90. package/build/server/router/Router.js.map +0 -0
  91. package/build/server/router/Rule.d.ts +1 -1
  92. package/build/server/router/Rule.js +1 -1
  93. package/build/server/router/Rule.js.map +0 -0
  94. package/build/server/router/WsRule.d.ts +0 -0
  95. package/build/server/router/WsRule.js +0 -0
  96. package/build/server/router/WsRule.js.map +0 -0
  97. package/build/server/router/middleware/HttpMiddleware.d.ts +1 -1
  98. package/build/server/router/middleware/HttpMiddleware.js +1 -1
  99. package/build/server/router/middleware/HttpMiddleware.js.map +0 -0
  100. package/build/server/router/middleware/Middleware.d.ts +1 -1
  101. package/build/server/router/middleware/Middleware.js +1 -1
  102. package/build/server/router/middleware/Middleware.js.map +0 -0
  103. package/build/server/router/middleware/WsMiddleware.d.ts +1 -1
  104. package/build/server/router/middleware/WsMiddleware.js +1 -1
  105. package/build/server/router/middleware/WsMiddleware.js.map +0 -0
  106. package/build/server/websocket/Chunk.d.ts +1 -1
  107. package/build/server/websocket/Chunk.js +1 -1
  108. package/build/server/websocket/Chunk.js.map +0 -0
  109. package/build/server/websocket/Websocket.d.ts +1 -1
  110. package/build/server/websocket/Websocket.js +1 -1
  111. package/build/server/websocket/Websocket.js.map +0 -0
  112. package/build/utilities/ConsoleUI.d.ts +1 -1
  113. package/build/utilities/ConsoleUI.js +1 -1
  114. package/build/utilities/ConsoleUI.js.map +0 -0
  115. package/build/utilities/DebugUI.d.ts +1 -1
  116. package/build/utilities/DebugUI.js +1 -1
  117. package/build/utilities/DebugUI.js.map +0 -0
  118. package/build/utilities/Env.d.ts +0 -0
  119. package/build/utilities/Env.js +0 -0
  120. package/build/utilities/Env.js.map +0 -0
  121. package/build/utilities/Path.d.ts +0 -0
  122. package/build/utilities/Path.js +0 -0
  123. package/build/utilities/Path.js.map +0 -0
  124. package/build/utilities/Utilities.d.ts +1 -1
  125. package/build/utilities/Utilities.js +1 -1
  126. package/build/utilities/Utilities.js.map +0 -0
  127. package/changes.md +0 -0
  128. package/examples/in-docs.js +0 -0
  129. package/global/Source/Logo_960.png +0 -0
  130. package/global/Source/Logo_SM_960.png +0 -0
  131. package/global/Style/Template/Error.css +0 -0
  132. package/global/Style/Template/Folder.css +0 -0
  133. package/global/Style/Template/Template.css +0 -0
  134. package/global/Template/Error.vhtml +0 -0
  135. package/global/Template/Folder.vhtml +0 -0
  136. package/package.json +13 -9
  137. package/tests/Template/template.js +0 -0
  138. package/tests/Template/template.txt +0 -0
  139. package/tests/Template/template.vhtml +0 -0
  140. package/tests/debug.js +0 -0
  141. package/tests/jwtManager/jwtManager.js +46 -78
  142. package/tests/test.js +0 -0
  143. package/tests/test.vhtml +0 -0
  144. package/tests/utilities.js +0 -0
  145. package/tests/websocket.vhtml +0 -0
  146. package/build/beta/JwtManager.d.ts +0 -114
  147. package/build/beta/JwtManager.js +0 -249
  148. package/build/beta/JwtManager.js.map +0 -1
  149. package/tests/test.env +0 -0
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description add the config loader to the Vortez.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description add the config loader to the Vortez.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description add the config validator to use in the config loader.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description add the config validator to use in the config loader.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Manages the routing of the requests and WebSocket connections.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Manages the routing of the requests and WebSocket connections.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Contains routing rule logic for Vortez.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Contains routing rule logic for Vortez.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Manages the middleware pipeline for HttpRules.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Manages the middleware pipeline for HttpRules.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Manages the middleware pipeline.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Manages the middleware pipeline.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Manages the middleware pipeline for WsRules.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Manages the middleware pipeline for WsRules.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Añade la forma de WebSockets a `Vortez`.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Añade la forma de WebSockets a `Vortez`.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description adds websocket functionality to Vortez
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description adds websocket functionality to Vortez
4
4
  * @license Apache-2.0
5
5
  */
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Provides utilities for console interaction, including text formatting and coloring.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Provides utilities for console interaction, including text formatting and coloring.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Utility to help with debugging tasks and server development.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description Utility to help with debugging tasks and server development.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description add useful functions to the Vortez.
4
4
  * @license Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
2
+ * @author NetFeez <netfeez.dev@gmail.com>
3
3
  * @description add useful functions to the Vortez.
4
4
  * @license Apache-2.0
5
5
  */
File without changes
package/changes.md CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vortez",
3
- "version": "5.0.0-dev.15",
3
+ "version": "5.0.0-dev.16",
4
4
  "description": "a module for web server creation",
5
5
  "type": "module",
6
6
  "main": "build/Vortez.js",
@@ -9,11 +9,11 @@
9
9
  "test": "bash scripts/test.sh",
10
10
  "publish": "bash scripts/publish.sh",
11
11
  "dev": "bash scripts/dev.sh",
12
- "dev.publish": "bash scripts/publish.sh"
12
+ "dev.publish": "bash scripts/publish.sh --dev"
13
13
  },
14
14
  "author": {
15
15
  "name": "NetFeez",
16
- "email": "codefeez.dev@gmail.com",
16
+ "email": "netfeez.dev@gmail.com",
17
17
  "url": "https://NetFeez.github.io"
18
18
  },
19
19
  "license": "Apache-2.0",
@@ -33,12 +33,16 @@
33
33
  "README.md"
34
34
  ],
35
35
  "keywords": [
36
- "web", "server",
37
- "http", "https",
38
- "ws", "wss", "websocket"
36
+ "web",
37
+ "server",
38
+ "http",
39
+ "https",
40
+ "ws",
41
+ "wss",
42
+ "websocket"
39
43
  ],
40
44
  "devDependencies": {
41
- "@types/node": "^20.14.12",
42
- "typescript": "^5.5.4"
45
+ "@types/node": "^25.5.0",
46
+ "typescript": "^6.0.2"
43
47
  }
44
- }
48
+ }
File without changes
File without changes
File without changes
package/tests/debug.js CHANGED
File without changes
@@ -1,108 +1,76 @@
1
- import { JwtManager } from "../../build/Beta/JwtManager/JwtManager.js";
2
- import CRYPTO from 'crypto';
3
- import Utilities from "../../build/Utilities.js";
1
+ // @ts-check
2
+ import JwtManager from "../../build/beta/JwtManager/JwtManager.js";
4
3
  import { strict as assert } from 'assert';
5
4
 
5
+ /** @type { JwtManager.Algorithm.HashLength[] } */
6
6
  const MASKS = ['256', '384', '512'];
7
- const SECRET = 'secret';
8
7
 
9
- const { publicKey: RSA_PUB_KEY, privateKey: RSA_PRIV_KEY } = CRYPTO.generateKeyPairSync('rsa', {
10
- modulusLength: 2048,
11
- publicKeyEncoding: {
12
- type: 'spki',
13
- format: 'pem'
14
- },
15
- privateKeyEncoding: {
16
- type: 'pkcs8',
17
- format: 'pem'
18
- }
19
- });
20
-
21
- const { publicKey: PSS_PUB_KEY, privateKey: PSS_PRIV_KEY } = CRYPTO.generateKeyPairSync('rsa-pss', {
22
- modulusLength: 2048,
23
- publicKeyEncoding: {
24
- type: 'spki',
25
- format: 'pem'
26
- },
27
- privateKeyEncoding: {
28
- type: 'pkcs8',
29
- format: 'pem'
30
- }
31
- });
32
-
33
- const { publicKey: EC_PUB_KEY, privateKey: EC_PRIV_KEY } = CRYPTO.generateKeyPairSync('ec', {
34
- namedCurve: 'secp256k1',
35
- publicKeyEncoding: {
36
- type: 'spki',
37
- format: 'pem'
38
- },
39
- privateKeyEncoding: {
40
- type: 'pkcs8',
41
- format: 'pem'
42
- }
43
- });
44
-
45
- const body = {
46
- test: 'test',
47
- XD: "xd"
48
- };
8
+ const { pub: HMAC_PUB_KEY, key: SECRET } = JwtManager.KeyGenerator.generate('secret');
9
+ const { pub: RSA_PUB_KEY, key: RSA_PRIV_KEY } = JwtManager.KeyGenerator.generate('rsa');
10
+ const { pub: PSS_PUB_KEY, key: PSS_PRIV_KEY } = JwtManager.KeyGenerator.generate('rsa-pss');
11
+ const { pub: EC_PUB_KEY, key: EC_PRIV_KEY } = JwtManager.KeyGenerator.generate('ec');
49
12
 
50
- const options = {
51
- expire: new Date(Date.now() + 10000)
13
+ const payload = {
14
+ uuid: '00000000-0000-0000-0000-000000000000',
15
+ name: 'NetFeez',
16
+ email: 'netfeez.dev@gmail.com'
52
17
  };
53
18
 
54
- const testBase64UrlEncode = () => {
55
- assert.equal(Utilities.base64UrlEncode('hello world'), 'aGVsbG8gd29ybGQ');
56
- console.log('Utilities.base64UrlEncode passed');
19
+ const header = {
20
+ exp: Math.floor((Date.now() + 10000) / 1000)
57
21
  };
58
-
59
- const testBase64UrlDecode = () => {
60
- assert.equal(Utilities.base64UrlDecode('aGVsbG8gd29ybGQ'), 'hello world');
61
- console.log('Utilities.base64UrlDecode passed');
62
- };
63
-
64
- const testJwtManagerSignVerify = (algorithm, key, pubKey) => {
65
- const jwt = new JwtManager(algorithm, key);
22
+ /**
23
+ * Tests the signing and verification of JWTs using the specified algorithm and key.
24
+ * @param { JwtManager.AlgorithmName } algorithm The name of the algorithm to be tested (e.g., 'HS256', 'RS256', etc.).
25
+ * @param { string } key The secret key or private key to be used for signing and verifying JWTs.
26
+ * @param { string | null } pubKey The public key to be used for verifying JWTs (required for asymmetric algorithms).
27
+ */
28
+ const testJwtManagerSignVerify = (algorithm, key, pubKey = null) => {
29
+ const jwt = new JwtManager(algorithm, {
30
+ key: key,
31
+ pub: pubKey || null
32
+ });
66
33
  console.log('--------------------------')
67
- const JWTObject = jwt.sign(body, options);
68
- console.log('jwt:', JWTObject);
69
- if (algorithm.startsWith('HS')) {
70
- console.log('secret:', key);
71
- } else {
34
+ const token = jwt.sign(payload, header);
35
+ console.log('jwt:', token);
36
+ /* if (algorithm.startsWith('HS')) console.log('secret:', key);
37
+ else {
72
38
  console.log('Private Key:', key);
73
- if (pubKey) {
74
- console.log('Public Key:', pubKey);
75
- }
39
+ if (pubKey) console.log('Public Key:', pubKey);
40
+ } */
41
+ try {
42
+ const parsed = jwt.parse(token);
43
+ console.log(parsed, '\n');
44
+ assert.deepEqual(parsed.payload, payload);
45
+ console.log(`${algorithm} test passed`);
46
+ } catch (error) {
47
+ console.error(`${algorithm} test failed:`, error);
76
48
  }
77
- const verificationResult = jwt.verify(JWTObject);
78
- console.log(verificationResult, '\n');
79
- assert.equal(verificationResult.verify, true);
80
- assert.deepEqual(verificationResult.body, body);
81
- console.log(`${algorithm} test passed`);
82
49
  };
83
50
 
84
51
  const runTests = () => {
85
52
  try {
86
- testBase64UrlEncode();
87
- testBase64UrlDecode();
88
-
89
53
  for (let index = 0; index < MASKS.length; index++) {
90
- const algorithm = 'HS' + MASKS[index];
54
+ /** @type { JwtManager.AlgorithmName } */
55
+ const algorithm = `HS${MASKS[index]}`;
91
56
  testJwtManagerSignVerify(algorithm, SECRET);
92
57
 
93
- const algorithmRS = 'RS' + MASKS[index];
58
+ /** @type { JwtManager.AlgorithmName } */
59
+ const algorithmRS = `RS${MASKS[index]}`;
94
60
  testJwtManagerSignVerify(algorithmRS, RSA_PRIV_KEY, RSA_PUB_KEY);
95
61
 
96
- const algorithmPS = 'PS' + MASKS[index];
62
+ /** @type { JwtManager.AlgorithmName } */
63
+ const algorithmPS = `PS${MASKS[index]}`;
97
64
  testJwtManagerSignVerify(algorithmPS, PSS_PRIV_KEY, PSS_PUB_KEY);
98
65
 
99
- const algorithmES = 'ES' + MASKS[index];
66
+ /** @type { JwtManager.AlgorithmName } */
67
+ const algorithmES = `ES${MASKS[index]}`;
100
68
  testJwtManagerSignVerify(algorithmES, EC_PRIV_KEY, EC_PUB_KEY);
101
69
  }
102
70
 
103
71
  console.log('All tests passed');
104
72
  } catch (error) {
105
- console.error('Test failed:', error.message);
73
+ console.error('Test failed:', error);
106
74
  }
107
75
  };
108
76
 
package/tests/test.js CHANGED
File without changes
package/tests/test.vhtml CHANGED
File without changes
File without changes
File without changes
@@ -1,114 +0,0 @@
1
- /**
2
- * @author NetFeez <codefeez.dev@gmail.com>
3
- * @description add the json web token manager to the Vortez.
4
- * @license Apache-2.0
5
- */
6
- export declare class JwtManager {
7
- private static validSignMethods;
8
- private static validMaskMethods;
9
- private static signMethodMap;
10
- private static maskMethodMap;
11
- private algorithm;
12
- private signMethod;
13
- private maskMethod;
14
- private privKey;
15
- private pubKey;
16
- /**
17
- * create a new jwt manager
18
- * @param algorithm the algorithm to use
19
- * @param key the private key or secret to use
20
- * @throws an error if the algorithm is not valid
21
- * @throws an error if the key/secret is not valid
22
- */
23
- constructor(algorithm: JwtManager.jwtAlgorithms, key: string);
24
- /**
25
- * sign a jwt
26
- * @param body the body of the jwt
27
- * @param options the options to sign the jwt
28
- * @returns the signed jwt
29
- */
30
- sign(body: JwtManager.body, options?: JwtManager.signOptions): string;
31
- /**
32
- * verify a jwt
33
- * @param jwt the jwt to verify
34
- * @param options the options to verify the jwt
35
- * @returns the verified jwt
36
- */
37
- parse(jwt: string, options?: JwtManager.verifyOptions): JwtManager.jwtObject;
38
- /**
39
- * sign a jwt
40
- * @param body the body of the jwt
41
- * @param options the options to sign the jwt
42
- * @returns the signed jwt
43
- * @throws an error if the algorithm is not valid
44
- * @throws an error if the key/secret is not valid
45
- */
46
- static sign(body: JwtManager.body, algorithm: JwtManager.jwtAlgorithms, privKey: string, options: JwtManager.signOptions): string;
47
- /**
48
- * verify a jwt
49
- * @param jwt the jwt to verify
50
- * @param options the options to verify the jwt
51
- * @returns the verified jwt
52
- * @throws an error if the algorithm is not valid
53
- * @throws an error if the key/secret is not valid
54
- */
55
- static parse(jwt: string, pubKey: string, options?: JwtManager.verifyOptions): JwtManager.jwtObject;
56
- /**
57
- * validate an private key
58
- * @param signMethod the sign method
59
- * @param key the private key
60
- * @param sendThrows whether to throw an error if the private key is invalid
61
- * @returns true if the private key is valid
62
- * @throws an error if the private key is invalid
63
- */
64
- private static validateKey;
65
- private static getPubKey;
66
- private static getAlgorithmInfo;
67
- }
68
- export declare namespace JwtManager {
69
- type signMethods = 'HMAC' | 'RSA' | 'ECDSA' | 'RSA-PSS';
70
- type maskMethods = 'SHA256' | 'SHA384' | 'SHA512';
71
- type jwtSignMethods = 'HS' | 'RS' | 'PS' | 'ES';
72
- type jwtMaskMethods = '256' | '384' | '512';
73
- type jwtAlgorithms = `${jwtSignMethods}${jwtMaskMethods}`;
74
- interface signMethodMap {
75
- HS: 'HMAC';
76
- RS: 'RSA';
77
- PS: 'RSA-PSS';
78
- ES: 'ECDSA';
79
- }
80
- interface maskMethodMap {
81
- '256': 'SHA256';
82
- '384': 'SHA384';
83
- '512': 'SHA512';
84
- }
85
- interface algorithmInfo {
86
- signMethod?: signMethods;
87
- maskMethod?: maskMethods;
88
- }
89
- interface headers {
90
- exp?: number;
91
- [key: string]: any | undefined;
92
- }
93
- interface head extends headers {
94
- alg: jwtAlgorithms;
95
- typ: 'JWT';
96
- }
97
- interface body {
98
- [key: string]: any | undefined;
99
- }
100
- interface jwtObject {
101
- body: body;
102
- head: head;
103
- signature: string;
104
- verify: boolean;
105
- }
106
- interface verifyOptions {
107
- expire?: boolean;
108
- }
109
- interface signOptions {
110
- expire?: Date;
111
- [key: string]: any | undefined;
112
- }
113
- }
114
- export default JwtManager;