vortez 5.0.0-dev.18 → 5.0.0
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/.gitignore +11 -4
- package/README.md +699 -177
- package/build/Template/Compiler.d.ts +70 -0
- package/build/Template/Compiler.js +135 -0
- package/build/Template/Compiler.js.map +1 -0
- package/build/Template/StreamCompiler.d.ts +16 -0
- package/build/Template/StreamCompiler.js +54 -0
- package/build/Template/StreamCompiler.js.map +1 -0
- package/build/Template/Template.d.ts +49 -0
- package/build/Template/Template.js +77 -0
- package/build/Template/Template.js.map +1 -0
- package/build/Vortez.d.ts +2 -1
- package/build/Vortez.js +2 -1
- package/build/Vortez.js.map +1 -1
- package/build/beta/JwtManager/JwtError.d.ts +8 -0
- package/build/beta/JwtManager/JwtError.js +10 -0
- package/build/beta/JwtManager/JwtError.js.map +1 -0
- package/build/beta/JwtManager/JwtManager.d.ts +3 -0
- package/build/beta/JwtManager/JwtManager.js +24 -7
- package/build/beta/JwtManager/JwtManager.js.map +1 -1
- package/build/server/BodyParser.d.ts +6 -0
- package/build/server/BodyParser.js +18 -3
- package/build/server/BodyParser.js.map +1 -1
- package/build/server/Request.d.ts +6 -4
- package/build/server/Request.js +15 -10
- package/build/server/Request.js.map +1 -1
- package/build/server/Response.d.ts +25 -10
- package/build/server/Response.js +161 -75
- package/build/server/Response.js.map +1 -1
- package/build/server/Server.d.ts +4 -4
- package/build/server/Server.js +34 -11
- package/build/server/Server.js.map +1 -1
- package/build/server/ServerDebug.d.ts +10 -1
- package/build/server/ServerDebug.js +85 -17
- package/build/server/ServerDebug.js.map +1 -1
- package/build/server/config/Config.d.ts +276 -47
- package/build/server/config/Config.js +70 -47
- package/build/server/config/Config.js.map +1 -1
- package/build/server/config/{ConfigLoader.d.ts → Loader.d.ts} +4 -5
- package/build/server/config/{ConfigLoader.js → Loader.js} +8 -11
- package/build/server/config/Loader.js.map +1 -0
- package/build/server/router/Router.d.ts +88 -31
- package/build/server/router/Router.js +113 -51
- package/build/server/router/Router.js.map +1 -1
- package/build/server/router/algorithm/Algorithm.d.ts +39 -0
- package/build/server/router/algorithm/Algorithm.js +20 -0
- package/build/server/router/algorithm/Algorithm.js.map +1 -0
- package/build/server/router/algorithm/FIFO.d.ts +15 -0
- package/build/server/router/algorithm/FIFO.js +24 -0
- package/build/server/router/algorithm/FIFO.js.map +1 -0
- package/build/server/router/algorithm/Tree.d.ts +38 -0
- package/build/server/router/algorithm/Tree.js +126 -0
- package/build/server/router/algorithm/Tree.js.map +1 -0
- package/build/server/router/middleware/HttpMiddleware.js +1 -1
- package/build/server/router/middleware/HttpMiddleware.js.map +1 -1
- package/build/server/router/middleware/WsMiddleware.js +1 -1
- package/build/server/router/middleware/WsMiddleware.js.map +1 -1
- package/build/server/security/PathSecurity.d.ts +45 -0
- package/build/server/security/PathSecurity.js +108 -0
- package/build/server/security/PathSecurity.js.map +1 -0
- package/build/server/websocket/Websocket.js +4 -1
- package/build/server/websocket/Websocket.js.map +1 -1
- package/build/utilities/ConsoleUI.d.ts +2 -1
- package/build/utilities/ConsoleUI.js +2 -1
- package/build/utilities/ConsoleUI.js.map +1 -1
- package/build/utilities/DebugUI.d.ts +1 -1
- package/build/utilities/DebugUI.js +1 -1
- package/build/utilities/Encoding.d.ts +22 -0
- package/build/utilities/Encoding.js +26 -0
- package/build/utilities/Encoding.js.map +1 -0
- package/build/utilities/Env.js +7 -2
- package/build/utilities/Env.js.map +1 -1
- package/build/utilities/File.d.ts +10 -0
- package/build/utilities/File.js +19 -0
- package/build/utilities/File.js.map +1 -0
- package/build/utilities/Flatten.d.ts +73 -0
- package/build/utilities/Flatten.js +76 -0
- package/build/utilities/Flatten.js.map +1 -0
- package/build/utilities/Object.d.ts +16 -0
- package/build/utilities/Object.js +48 -0
- package/build/utilities/Object.js.map +1 -0
- package/build/utilities/Path.d.ts +31 -11
- package/build/utilities/Path.js +48 -15
- package/build/utilities/Path.js.map +1 -1
- package/build/utilities/Time.d.ts +21 -0
- package/build/utilities/Time.js +25 -0
- package/build/utilities/Time.js.map +1 -0
- package/build/utilities/Utilities.d.ts +50 -92
- package/build/utilities/Utilities.js +56 -71
- package/build/utilities/Utilities.js.map +1 -1
- package/build/utilities/schema/Introspection.d.ts +24 -0
- package/build/utilities/schema/Introspection.js +87 -0
- package/build/utilities/schema/Introspection.js.map +1 -0
- package/build/utilities/schema/JSONSchema.d.ts +68 -0
- package/build/utilities/schema/JSONSchema.js +13 -0
- package/build/utilities/schema/JSONSchema.js.map +1 -0
- package/build/utilities/schema/Schema.d.ts +253 -0
- package/build/utilities/schema/Schema.js +241 -0
- package/build/utilities/schema/Schema.js.map +1 -0
- package/build/utilities/schema/SchemaError.d.ts +10 -0
- package/build/utilities/schema/SchemaError.js +13 -0
- package/build/utilities/schema/SchemaError.js.map +1 -0
- package/build/utilities/schema/Validator.d.ts +94 -0
- package/build/utilities/schema/Validator.js +246 -0
- package/build/utilities/schema/Validator.js.map +1 -0
- package/changes.md +4 -0
- package/docs/ARCHITECTURE.md +142 -0
- package/global/style/template/error.css +29 -0
- package/global/style/template/folder.css +79 -0
- package/global/{Style/Template/Template.css → style/template/template.css} +60 -68
- package/global/template/error.vhtml +29 -0
- package/global/template/folder.vhtml +54 -0
- package/package.json +2 -2
- package/build/Template.d.ts +0 -46
- package/build/Template.js +0 -81
- package/build/Template.js.map +0 -1
- package/build/server/config/ConfigLoader.js.map +0 -1
- package/build/server/config/ConfigValidator.d.ts +0 -71
- package/build/server/config/ConfigValidator.js +0 -131
- package/build/server/config/ConfigValidator.js.map +0 -1
- package/examples/in-docs.js +0 -96
- package/global/Style/Template/Error.css +0 -30
- package/global/Style/Template/Folder.css +0 -77
- package/global/Template/Error.vhtml +0 -29
- package/global/Template/Folder.vhtml +0 -41
- package/tests/Template/template.js +0 -18
- package/tests/Template/template.txt +0 -13
- package/tests/Template/template.vhtml +0 -23
- package/tests/debug.js +0 -34
- package/tests/jwtManager/jwtManager.js +0 -342
- package/tests/test.js +0 -131
- package/tests/test.vhtml +0 -14
- package/tests/utilities.js +0 -28
- package/tests/websocket.vhtml +0 -86
- /package/global/{Source/Logo_960.png → source/logo_960.png} +0 -0
- /package/global/{Source/Logo_SM_960.png → source/logo_SM_960.png} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Add the vhtml template compiler to the Vortez.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare const VARIABLE: RegExp;
|
|
7
|
+
export declare const VARIABLE_TAG: RegExp;
|
|
8
|
+
export declare const EACH_BLOCK: RegExp;
|
|
9
|
+
export declare const IF_BLOCK: RegExp;
|
|
10
|
+
export declare class Compiler {
|
|
11
|
+
/**
|
|
12
|
+
* Compile a template.
|
|
13
|
+
* This internal method takes the raw template content and the data object
|
|
14
|
+
* and performs the actual compilation, replacing variables and processing
|
|
15
|
+
* object/array blocks according to the defined syntax.
|
|
16
|
+
*
|
|
17
|
+
* @example `Template.compile('Hello, ${name}!', { name: 'Alice' });`
|
|
18
|
+
* @param content - The content of the template.
|
|
19
|
+
* @param data - The data used to compile the template.
|
|
20
|
+
* @returns The compiled template.
|
|
21
|
+
* @throws Error if key and value names are equal in object blocks.
|
|
22
|
+
*/
|
|
23
|
+
static compile(content: string, data: Compiler.Data): string;
|
|
24
|
+
/**
|
|
25
|
+
* Compile all the variables in the template content using the provided data object.
|
|
26
|
+
* @param content - The raw template content containing variable placeholders.
|
|
27
|
+
* @param data - The data object used for variable substitution.
|
|
28
|
+
* @returns The template content with all variables replaced by their corresponding values from the data object.
|
|
29
|
+
*/
|
|
30
|
+
private static compileVariables;
|
|
31
|
+
/**
|
|
32
|
+
* Finds the index of the closing tag corresponding to a given opening tag in the template content, accounting for nested tags of the same type.
|
|
33
|
+
* @param content - The raw template content containing the tags.
|
|
34
|
+
* @param openTag - The opening tag to match (e.g., '<vortez-each').
|
|
35
|
+
* @param closeTag - The closing tag to match (e.g., '</vortez-each>').
|
|
36
|
+
* @param startIndex - The index in the content where the search should begin (typically right after the opening tag).
|
|
37
|
+
* @returns The index of the closing tag that matches the opening tag, or -1 if no matching closing tag is found.
|
|
38
|
+
*/
|
|
39
|
+
private static findClosingTag;
|
|
40
|
+
/**
|
|
41
|
+
* Compile all the if/else blocks in the template content using the provided data object.
|
|
42
|
+
* @param content - The raw template content containing if/else block placeholders.
|
|
43
|
+
* @param data - The data object used for block processing.
|
|
44
|
+
* @returns The template content with all if/else blocks processed and replaced by their corresponding generated content based on the data object.
|
|
45
|
+
*/
|
|
46
|
+
static compileEachBlocks(content: string, data: Compiler.Data): string;
|
|
47
|
+
static compileIfBlocks(content: string, data: Compiler.Data): string;
|
|
48
|
+
}
|
|
49
|
+
export declare namespace Compiler {
|
|
50
|
+
interface VariableGroups {
|
|
51
|
+
name: string;
|
|
52
|
+
default?: string;
|
|
53
|
+
}
|
|
54
|
+
interface EachBlockGroups {
|
|
55
|
+
name: string;
|
|
56
|
+
keyName?: string;
|
|
57
|
+
valueName?: string;
|
|
58
|
+
loop: string;
|
|
59
|
+
}
|
|
60
|
+
interface IfBlockGroups {
|
|
61
|
+
name: string;
|
|
62
|
+
condition?: '==' | '!=';
|
|
63
|
+
expected?: string;
|
|
64
|
+
content: string;
|
|
65
|
+
}
|
|
66
|
+
interface Data {
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export default Compiler;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Add the vhtml template compiler to the Vortez.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export const VARIABLE = /\{\{\s*?(?<name>\w+)(?:\s*\|\|\s*(?<quote>["'])(?<default>.*?)\k<quote>)?\s*\}\}/g;
|
|
7
|
+
export const VARIABLE_TAG = /<vortez-var\s+name=["'](?<name>\w+)["'](?:\s+default=["'](?<default>.*?)["'])?\s*(?:\/>|>(?<content>.*?)<\/vortez-var>)/g;
|
|
8
|
+
export const EACH_BLOCK = /<vortez-each\s+name=["'](?<name>\w+)["'](?:\s+value=["'](?<valueName>\w+)["'])?(?:\s+key=["'](?<keyName>\w+)["'])?\s*>(?<loop>[^]+?)<\/vortez-each>/g;
|
|
9
|
+
export const IF_BLOCK = /<vortez-if\s+name=["'](?<name>\w+)["'](?:\s+condition=["'](?<condition>==|!=)["']\s+expected=["'](?<expected>.*?)["'])?\s*>(?<content>[^]+?)<\/vortez-if>/g;
|
|
10
|
+
export class Compiler {
|
|
11
|
+
/**
|
|
12
|
+
* Compile a template.
|
|
13
|
+
* This internal method takes the raw template content and the data object
|
|
14
|
+
* and performs the actual compilation, replacing variables and processing
|
|
15
|
+
* object/array blocks according to the defined syntax.
|
|
16
|
+
*
|
|
17
|
+
* @example `Template.compile('Hello, ${name}!', { name: 'Alice' });`
|
|
18
|
+
* @param content - The content of the template.
|
|
19
|
+
* @param data - The data used to compile the template.
|
|
20
|
+
* @returns The compiled template.
|
|
21
|
+
* @throws Error if key and value names are equal in object blocks.
|
|
22
|
+
*/
|
|
23
|
+
static compile(content, data) {
|
|
24
|
+
content = Compiler.compileEachBlocks(content, data);
|
|
25
|
+
content = Compiler.compileIfBlocks(content, data);
|
|
26
|
+
content = Compiler.compileVariables(content, data);
|
|
27
|
+
return content;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Compile all the variables in the template content using the provided data object.
|
|
31
|
+
* @param content - The raw template content containing variable placeholders.
|
|
32
|
+
* @param data - The data object used for variable substitution.
|
|
33
|
+
* @returns The template content with all variables replaced by their corresponding values from the data object.
|
|
34
|
+
*/
|
|
35
|
+
static compileVariables(content, data) {
|
|
36
|
+
content = content.replace(VARIABLE, (text, ...args) => {
|
|
37
|
+
const groups = args.pop();
|
|
38
|
+
const { name, default: defaultValue } = groups;
|
|
39
|
+
return name && name in data ? data[name] : defaultValue || text;
|
|
40
|
+
});
|
|
41
|
+
content = content.replace(VARIABLE_TAG, (text, ...args) => {
|
|
42
|
+
const groups = args.pop();
|
|
43
|
+
const { name, default: defaultValue, content: tagContent } = groups;
|
|
44
|
+
return name && name in data ? data[name] : defaultValue || tagContent || text;
|
|
45
|
+
});
|
|
46
|
+
return content;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Finds the index of the closing tag corresponding to a given opening tag in the template content, accounting for nested tags of the same type.
|
|
50
|
+
* @param content - The raw template content containing the tags.
|
|
51
|
+
* @param openTag - The opening tag to match (e.g., '<vortez-each').
|
|
52
|
+
* @param closeTag - The closing tag to match (e.g., '</vortez-each>').
|
|
53
|
+
* @param startIndex - The index in the content where the search should begin (typically right after the opening tag).
|
|
54
|
+
* @returns The index of the closing tag that matches the opening tag, or -1 if no matching closing tag is found.
|
|
55
|
+
*/
|
|
56
|
+
static findClosingTag(content, openTag, closeTag, startIndex) {
|
|
57
|
+
let depth = 0;
|
|
58
|
+
const tagRegex = new RegExp(`${openTag}|${closeTag}`, 'g');
|
|
59
|
+
tagRegex.lastIndex = startIndex;
|
|
60
|
+
let match;
|
|
61
|
+
while ((match = tagRegex.exec(content)) !== null) {
|
|
62
|
+
if (match[0].startsWith(openTag.substring(0, 3)))
|
|
63
|
+
depth++;
|
|
64
|
+
if (match[0] === closeTag)
|
|
65
|
+
depth--;
|
|
66
|
+
if (depth === 0)
|
|
67
|
+
return match.index;
|
|
68
|
+
}
|
|
69
|
+
return -1;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Compile all the if/else blocks in the template content using the provided data object.
|
|
73
|
+
* @param content - The raw template content containing if/else block placeholders.
|
|
74
|
+
* @param data - The data object used for block processing.
|
|
75
|
+
* @returns The template content with all if/else blocks processed and replaced by their corresponding generated content based on the data object.
|
|
76
|
+
*/
|
|
77
|
+
static compileEachBlocks(content, data) {
|
|
78
|
+
const openTagMatch = /<vortez-each\s+name=["'](?<name>\w+)["']/.exec(content);
|
|
79
|
+
if (!openTagMatch)
|
|
80
|
+
return content;
|
|
81
|
+
const startIdx = openTagMatch.index;
|
|
82
|
+
const endHeaderIdx = content.indexOf('>', startIdx);
|
|
83
|
+
const closingIdx = this.findClosingTag(content, '<vortez-each', '</vortez-each>', startIdx);
|
|
84
|
+
if (closingIdx === -1)
|
|
85
|
+
return `<p>the block is not closed: ${content.substring(startIdx, startIdx + 30)}...</p>`;
|
|
86
|
+
const fullBlock = content.substring(startIdx, closingIdx + 14);
|
|
87
|
+
const innerLoop = content.substring(endHeaderIdx + 1, closingIdx);
|
|
88
|
+
const header = content.substring(startIdx, endHeaderIdx);
|
|
89
|
+
const name = openTagMatch.groups?.name;
|
|
90
|
+
const valueName = /value=["'](?<v>\w+)["']/.exec(header)?.groups?.v || 'value';
|
|
91
|
+
const keyName = /key=["'](?<k>\w+)["']/.exec(header)?.groups?.k || 'key';
|
|
92
|
+
const iterable = data[name];
|
|
93
|
+
let result = "";
|
|
94
|
+
if (!iterable)
|
|
95
|
+
return `<p>the iterable "${name}" is not defined</p>`;
|
|
96
|
+
if (keyName === valueName)
|
|
97
|
+
return `<p>the key and value names must be different in block: ${fullBlock}</p>`;
|
|
98
|
+
if (iterable instanceof Object) {
|
|
99
|
+
result = Object.entries(iterable).map(([k, v]) => {
|
|
100
|
+
const context = { ...data, [keyName]: k, [valueName]: v };
|
|
101
|
+
return this.compile(innerLoop, context);
|
|
102
|
+
}).join('');
|
|
103
|
+
}
|
|
104
|
+
return this.compileEachBlocks(content.replace(fullBlock, result), data);
|
|
105
|
+
}
|
|
106
|
+
static compileIfBlocks(content, data) {
|
|
107
|
+
const openTagMatch = /<vortez-if\s+name=["'](?<name>\w+)["']/.exec(content);
|
|
108
|
+
if (!openTagMatch)
|
|
109
|
+
return content;
|
|
110
|
+
const startIdx = openTagMatch.index;
|
|
111
|
+
const endHeaderIdx = content.indexOf('>', startIdx);
|
|
112
|
+
const closingIdx = this.findClosingTag(content, '<vortez-if', '</vortez-if>', startIdx);
|
|
113
|
+
if (closingIdx === -1)
|
|
114
|
+
return `<p>the block is not closed: ${content.substring(startIdx, startIdx + 30)}...</p>`;
|
|
115
|
+
const fullBlock = content.substring(startIdx, closingIdx + 12);
|
|
116
|
+
const innerContent = content.substring(endHeaderIdx + 1, closingIdx);
|
|
117
|
+
const header = content.substring(startIdx, endHeaderIdx);
|
|
118
|
+
const name = openTagMatch.groups?.name;
|
|
119
|
+
const condition = /condition=["'](?<c>==|!=)["']/.exec(header)?.groups?.c;
|
|
120
|
+
const expected = /expected=["'](?<e>.*?)["']/.exec(header)?.groups?.e;
|
|
121
|
+
const [ifPart, elsePart] = innerContent.split(/<vortez-else\s*?\/>/);
|
|
122
|
+
const value = data[name];
|
|
123
|
+
let isTrue = false;
|
|
124
|
+
if (condition && expected !== undefined) {
|
|
125
|
+
const resExpected = expected.includes('{{') ? this.compileVariables(expected, data) : expected;
|
|
126
|
+
isTrue = (condition === '==') ? String(value) === String(resExpected) : String(value) !== String(resExpected);
|
|
127
|
+
}
|
|
128
|
+
else
|
|
129
|
+
isTrue = !!value;
|
|
130
|
+
const compiledPart = this.compile(isTrue ? ifPart : (elsePart || ""), data);
|
|
131
|
+
return this.compileIfBlocks(content.replace(fullBlock, compiledPart), data);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export default Compiler;
|
|
135
|
+
//# sourceMappingURL=Compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Compiler.js","sourceRoot":"","sources":["../../src/Template/Compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,mFAAmF,CAAC;AAC5G,MAAM,CAAC,MAAM,YAAY,GAAG,0HAA0H,CAAC;AACvJ,MAAM,CAAC,MAAM,UAAU,GAAG,sJAAsJ,CAAC;AACjL,MAAM,CAAC,MAAM,QAAQ,GAAG,4JAA4J,CAAC;AAErL,MAAM,OAAO,QAAQ;IACpB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AAqB,CAAC,CAAC;QACrE,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAI,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YACtC,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YAC/F,MAAM,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,WAAW,CAAC,CAAC;QAClH,CAAC;;YAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC;QAExB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAE5E,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;CACJ;AAsBD,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Add the vhtml template stream compiler to the Vortez.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Transform, TransformCallback } from 'stream';
|
|
7
|
+
import { Compiler } from './Compiler.js';
|
|
8
|
+
export declare class StreamCompiler extends Transform {
|
|
9
|
+
private buffer;
|
|
10
|
+
private data;
|
|
11
|
+
constructor(data: Compiler.Data);
|
|
12
|
+
_transform(chunk: unknown, encoding: BufferEncoding, callback: TransformCallback): void;
|
|
13
|
+
_flush(callback: TransformCallback): void;
|
|
14
|
+
}
|
|
15
|
+
export declare namespace StreamCompiler { }
|
|
16
|
+
export default StreamCompiler;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Add the vhtml template stream compiler to the Vortez.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Transform } from 'stream';
|
|
7
|
+
import { Compiler } from './Compiler.js';
|
|
8
|
+
export class StreamCompiler extends Transform {
|
|
9
|
+
buffer = '';
|
|
10
|
+
data;
|
|
11
|
+
constructor(data) {
|
|
12
|
+
super();
|
|
13
|
+
this.data = data;
|
|
14
|
+
}
|
|
15
|
+
_transform(chunk, encoding, callback) {
|
|
16
|
+
if (typeof chunk === 'string')
|
|
17
|
+
this.buffer += chunk;
|
|
18
|
+
else if (Buffer.isBuffer(chunk))
|
|
19
|
+
this.buffer += chunk.toString('utf-8');
|
|
20
|
+
else
|
|
21
|
+
return callback(new Error('Invalid chunk type. Expected string or Buffer.'));
|
|
22
|
+
const matches = Array.from(this.buffer.matchAll(/<(vortez-if|vortez-each)|<\/(vortez-if|vortez-each)>/g));
|
|
23
|
+
let depth = 0;
|
|
24
|
+
let lastBalancedIndex = -1;
|
|
25
|
+
if (matches.length > 0) {
|
|
26
|
+
for (const match of matches) {
|
|
27
|
+
if (match[0].startsWith('</'))
|
|
28
|
+
depth--;
|
|
29
|
+
else
|
|
30
|
+
depth++;
|
|
31
|
+
if (depth === 0)
|
|
32
|
+
lastBalancedIndex = match.index + match[0].length;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const lastVar = Math.max(this.buffer.lastIndexOf('}}'), this.buffer.lastIndexOf('/>'));
|
|
37
|
+
if (lastVar !== -1)
|
|
38
|
+
lastBalancedIndex = this.buffer.indexOf('>', lastVar) + 1 || lastVar + 2;
|
|
39
|
+
}
|
|
40
|
+
if (lastBalancedIndex !== -1) {
|
|
41
|
+
const completePart = this.buffer.substring(0, lastBalancedIndex);
|
|
42
|
+
this.buffer = this.buffer.substring(lastBalancedIndex);
|
|
43
|
+
this.push(Compiler.compile(completePart, this.data));
|
|
44
|
+
}
|
|
45
|
+
callback();
|
|
46
|
+
}
|
|
47
|
+
_flush(callback) {
|
|
48
|
+
if (this.buffer.trim())
|
|
49
|
+
this.push(Compiler.compile(this.buffer, this.data));
|
|
50
|
+
callback();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export default StreamCompiler;
|
|
54
|
+
//# sourceMappingURL=StreamCompiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamCompiler.js","sourceRoot":"","sources":["../../src/Template/StreamCompiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAqB,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,OAAO,cAAe,SAAQ,SAAS;IACjC,MAAM,GAAW,EAAE,CAAC;IACpB,IAAI,CAAgB;IAE5B,YAAY,IAAmB;QAC3B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAEW,UAAU,CAAC,KAAc,EAAE,QAAwB,EAAE,QAA2B;QACxF,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC;aAC/C,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;;YACnE,OAAO,QAAQ,CAAC,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC,CAAC;QAElF,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,C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f,CAAC;IAEe,MAAM,CAAC,QAA2B;QAC9C,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,QAAQ,EAAE,CAAC;IACf,CAAC;CACJ;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Add the vhtml template engine to the Vortez.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Readable } from 'stream';
|
|
7
|
+
import Compiler from './Compiler.js';
|
|
8
|
+
import { StreamCompiler } from './StreamCompiler.js';
|
|
9
|
+
export declare class Template {
|
|
10
|
+
/**
|
|
11
|
+
* Load and compile a template.
|
|
12
|
+
* This method reads a template file from the specified path,
|
|
13
|
+
* checks if it's a valid file, and then compiles its content
|
|
14
|
+
* using the provided data object.
|
|
15
|
+
*
|
|
16
|
+
* @example `Template.load('./templates/myTemplate.html', { username: 'John Doe' });`
|
|
17
|
+
* @param path - The path to the template file.
|
|
18
|
+
* @param data - The data used to compile the template.
|
|
19
|
+
* @returns The compiled template.
|
|
20
|
+
* @throws Error if the path is not a file.
|
|
21
|
+
* @throws Error if the file does not exist.
|
|
22
|
+
*/
|
|
23
|
+
static load(path: string, data: Compiler.Data): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Load and compile a template using streams.
|
|
26
|
+
* Ideal for large files or serving directly to a response.
|
|
27
|
+
* @example `Template.stream('./views/index.vhtml', data).pipe(res);`
|
|
28
|
+
* @param path - The path to the template file.
|
|
29
|
+
* @param data - The data used to compile the template.
|
|
30
|
+
* @returns A Readable stream with the compiled content.
|
|
31
|
+
*/
|
|
32
|
+
static stream(path: string, data: Compiler.Data): Promise<Readable>;
|
|
33
|
+
/**
|
|
34
|
+
* Compile a template string with the provided data.
|
|
35
|
+
* @param content - The template content to compile.
|
|
36
|
+
* @param data - The data used to compile the template.
|
|
37
|
+
* @returns The compiled template.
|
|
38
|
+
*/
|
|
39
|
+
static compile(content: string, data: Compiler.Data): string;
|
|
40
|
+
/**
|
|
41
|
+
* Compile a template from a stream with the provided data.
|
|
42
|
+
* @param stream - The Readable stream containing the template content.
|
|
43
|
+
* @param data - The data used to compile the template.
|
|
44
|
+
* @returns A StreamCompiler instance that can be piped to a Writable stream.
|
|
45
|
+
*/
|
|
46
|
+
static compileStream(stream: Readable, data: Compiler.Data): StreamCompiler;
|
|
47
|
+
}
|
|
48
|
+
export declare namespace Template { }
|
|
49
|
+
export default Template;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>
|
|
3
|
+
* @description Add the vhtml template engine to the Vortez.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { promises as FSP, createReadStream } from 'fs';
|
|
7
|
+
import Utilities from '../utilities/Utilities.js';
|
|
8
|
+
import Compiler from './Compiler.js';
|
|
9
|
+
import { StreamCompiler } from './StreamCompiler.js';
|
|
10
|
+
export class Template {
|
|
11
|
+
/**
|
|
12
|
+
* Load and compile a template.
|
|
13
|
+
* This method reads a template file from the specified path,
|
|
14
|
+
* checks if it's a valid file, and then compiles its content
|
|
15
|
+
* using the provided data object.
|
|
16
|
+
*
|
|
17
|
+
* @example `Template.load('./templates/myTemplate.html', { username: 'John Doe' });`
|
|
18
|
+
* @param path - The path to the template file.
|
|
19
|
+
* @param data - The data used to compile the template.
|
|
20
|
+
* @returns The compiled template.
|
|
21
|
+
* @throws Error if the path is not a file.
|
|
22
|
+
* @throws Error if the file does not exist.
|
|
23
|
+
*/
|
|
24
|
+
static async load(path, data) {
|
|
25
|
+
path = Utilities.Path.normalize(path);
|
|
26
|
+
if (!Utilities.File.exists(path))
|
|
27
|
+
throw new Error('template file does not exist');
|
|
28
|
+
const details = await FSP.stat(path);
|
|
29
|
+
if (!details.isFile())
|
|
30
|
+
throw new Error('the path is not a template file');
|
|
31
|
+
const template = await FSP.readFile(path);
|
|
32
|
+
return Compiler.compile(template.toString('utf-8'), data);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Load and compile a template using streams.
|
|
36
|
+
* Ideal for large files or serving directly to a response.
|
|
37
|
+
* @example `Template.stream('./views/index.vhtml', data).pipe(res);`
|
|
38
|
+
* @param path - The path to the template file.
|
|
39
|
+
* @param data - The data used to compile the template.
|
|
40
|
+
* @returns A Readable stream with the compiled content.
|
|
41
|
+
*/
|
|
42
|
+
static async stream(path, data) {
|
|
43
|
+
path = Utilities.Path.normalize(path);
|
|
44
|
+
if (!Utilities.File.exists(path))
|
|
45
|
+
throw new Error('template file does not exist');
|
|
46
|
+
const details = await FSP.stat(path);
|
|
47
|
+
if (!details.isFile())
|
|
48
|
+
throw new Error('the path is not a template file');
|
|
49
|
+
const readStream = createReadStream(path);
|
|
50
|
+
const compiler = new StreamCompiler(data);
|
|
51
|
+
readStream.on('error', (err) => compiler.emit('error', err));
|
|
52
|
+
return readStream.pipe(compiler);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Compile a template string with the provided data.
|
|
56
|
+
* @param content - The template content to compile.
|
|
57
|
+
* @param data - The data used to compile the template.
|
|
58
|
+
* @returns The compiled template.
|
|
59
|
+
*/
|
|
60
|
+
static compile(content, data) {
|
|
61
|
+
return Compiler.compile(content, data);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Compile a template from a stream with the provided data.
|
|
65
|
+
* @param stream - The Readable stream containing the template content.
|
|
66
|
+
* @param data - The data used to compile the template.
|
|
67
|
+
* @returns A StreamCompiler instance that can be piped to a Writable stream.
|
|
68
|
+
*/
|
|
69
|
+
static compileStream(stream, data) {
|
|
70
|
+
const compiler = new StreamCompiler(data);
|
|
71
|
+
stream.on('error', (err) => compiler.emit('error', err));
|
|
72
|
+
stream.pipe(compiler);
|
|
73
|
+
return compiler;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export default Template;
|
|
77
|
+
//# sourceMappingURL=Template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Template.js","sourceRoot":"","sources":["../../src/Template/Template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAGvD,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,QAAQ;IACjB;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,IAAmB;QACtD,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAC1E,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IACD;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,IAAmB;QACxD,IAAI,GAAG,SAAS,CAAC,IAAI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@license Apache-2.0
|
|
6
6
|
*/
|
|
7
7
|
export { Logger } from "./logger/Logger.js";
|
|
8
|
-
export { Template } from "./Template.js";
|
|
8
|
+
export { Template } from "./Template/Template.js";
|
|
9
9
|
export { Utilities } from "./utilities/Utilities.js";
|
|
10
10
|
export * as Beta from "./beta/Beta.js";
|
|
11
11
|
export { ServerError } from "./server/ServerError.js";
|
|
12
12
|
export { Router } from "./server/router/Router.js";
|
|
13
|
+
export { Config } from "./server/config/Config.js";
|
|
13
14
|
export { Server as default, Server as Vortez } from "./server/Server.js";
|
package/build/Vortez.js
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* @license Apache-2.0
|
|
6
6
|
*/
|
|
7
7
|
export { Logger } from "./logger/Logger.js";
|
|
8
|
-
export { Template } from "./Template.js";
|
|
8
|
+
export { Template } from "./Template/Template.js";
|
|
9
9
|
export { Utilities } from "./utilities/Utilities.js";
|
|
10
10
|
export * as Beta from "./beta/Beta.js";
|
|
11
11
|
export { ServerError } from "./server/ServerError.js";
|
|
12
12
|
export { Router } from "./server/router/Router.js";
|
|
13
|
+
export { Config } from "./server/config/Config.js";
|
|
13
14
|
export { Server as default, Server as Vortez } from "./server/Server.js";
|
|
14
15
|
//# sourceMappingURL=Vortez.js.map
|
package/build/Vortez.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vortez.js","sourceRoot":"","sources":["../src/Vortez.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Vortez.js","sourceRoot":"","sources":["../src/Vortez.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class JwtError extends Error {
|
|
2
|
+
readonly code: JwtError.Code;
|
|
3
|
+
constructor(code: JwtError.Code, message: string, options?: ErrorOptions);
|
|
4
|
+
}
|
|
5
|
+
export declare namespace JwtError {
|
|
6
|
+
type Code = ('TOKEN_INVALID' | 'KEY_NOT_FOUND' | 'INVALID_SIGNATURE' | 'TOKEN_EXPIRED' | 'SIGN_FAILED');
|
|
7
|
+
}
|
|
8
|
+
export default JwtError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JwtError.js","sourceRoot":"","sources":["../../../src/beta/JwtManager/JwtError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACf,IAAI,CAAgB;IAEpC,YAAmB,IAAmB,EAAE,OAAe,EAAE,UAAwB,EAAE;QAC/E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ;AAYD,eAAe,QAAQ,CAAC"}
|
|
@@ -3,11 +3,13 @@ import _Algorithm from "./algorithm/Algorithm.js";
|
|
|
3
3
|
import _JwtUtils from "./JwtUtils.js";
|
|
4
4
|
import _KeyEntry from "./KeyEntry.js";
|
|
5
5
|
import _Jwt from "./Jwt.js";
|
|
6
|
+
import _JwtError from "./JwtError.js";
|
|
6
7
|
export { KeyGenerator } from "./KeyGenerator.js";
|
|
7
8
|
export { Algorithm } from "./algorithm/Algorithm.js";
|
|
8
9
|
export { JwtUtils } from "./JwtUtils.js";
|
|
9
10
|
export { KeyEntry as KIDEntry } from "./KeyEntry.js";
|
|
10
11
|
export { Jwt } from "./Jwt.js";
|
|
12
|
+
export { JwtError } from "./JwtError.js";
|
|
11
13
|
export declare class JwtManager {
|
|
12
14
|
protected KIDMap: JwtManager.KIDMap;
|
|
13
15
|
protected defaultEntry: JwtManager.KeyEntry;
|
|
@@ -48,6 +50,7 @@ export declare namespace JwtManager {
|
|
|
48
50
|
export import JwtUtils = _JwtUtils;
|
|
49
51
|
export import KeyEntry = _KeyEntry;
|
|
50
52
|
export import Jwt = _Jwt;
|
|
53
|
+
export import JwtError = _JwtError;
|
|
51
54
|
type KeyOption = KeyEntry | KeyEntry.KeyEntryOptions;
|
|
52
55
|
interface KIDMap {
|
|
53
56
|
[kid: string]: KeyEntry;
|
|
@@ -3,11 +3,13 @@ import _Algorithm from "./algorithm/Algorithm.js";
|
|
|
3
3
|
import _JwtUtils from "./JwtUtils.js";
|
|
4
4
|
import _KeyEntry from "./KeyEntry.js";
|
|
5
5
|
import _Jwt from "./Jwt.js";
|
|
6
|
+
import _JwtError from "./JwtError.js";
|
|
6
7
|
export { KeyGenerator } from "./KeyGenerator.js";
|
|
7
8
|
export { Algorithm } from "./algorithm/Algorithm.js";
|
|
8
9
|
export { JwtUtils } from "./JwtUtils.js";
|
|
9
10
|
export { KeyEntry as KIDEntry } from "./KeyEntry.js";
|
|
10
11
|
export { Jwt } from "./Jwt.js";
|
|
12
|
+
export { JwtError } from "./JwtError.js";
|
|
11
13
|
export class JwtManager {
|
|
12
14
|
KIDMap = {};
|
|
13
15
|
defaultEntry;
|
|
@@ -45,28 +47,42 @@ export class JwtManager {
|
|
|
45
47
|
const kid = header.kid || this.defaultEntry.kid;
|
|
46
48
|
const entry = this.KIDMap[kid];
|
|
47
49
|
if (!entry)
|
|
48
|
-
throw new
|
|
50
|
+
throw new JwtManager.JwtError('KEY_NOT_FOUND', `No key found for kid: ${kid}`);
|
|
49
51
|
const { signer, alg } = entry;
|
|
50
52
|
header = { ...header, alg, kid, typ: 'jwt' };
|
|
51
53
|
const encodedHeader = JwtManager.JwtUtils.objectToBase64Url(header);
|
|
52
54
|
const encodedPayload = JwtManager.JwtUtils.objectToBase64Url(payload);
|
|
53
55
|
const content = `${encodedHeader}.${encodedPayload}`;
|
|
54
|
-
|
|
56
|
+
let signature = '';
|
|
57
|
+
try {
|
|
58
|
+
signature = signer.sign(content);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new JwtManager.JwtError('SIGN_FAILED', 'Failed to sign token', { cause: error });
|
|
62
|
+
}
|
|
55
63
|
return `${content}.${signature}`;
|
|
56
64
|
}
|
|
57
65
|
parse(token) {
|
|
58
|
-
|
|
66
|
+
let tokenParts;
|
|
67
|
+
try {
|
|
68
|
+
tokenParts = JwtManager.JwtUtils.getJwtParts(token);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
throw new JwtManager.JwtError('TOKEN_INVALID', 'Invalid token', { cause: error });
|
|
72
|
+
}
|
|
73
|
+
const { header, payload, signature, encodedHeader, encodedPayload } = tokenParts;
|
|
59
74
|
const kid = header.kid || this.defaultEntry.kid;
|
|
60
75
|
const entry = this.KIDMap[kid];
|
|
61
76
|
if (!entry)
|
|
62
|
-
throw new
|
|
77
|
+
throw new JwtManager.JwtError('KEY_NOT_FOUND', `No key found for kid: ${kid}`);
|
|
63
78
|
const signer = entry.signer;
|
|
64
79
|
const content = `${encodedHeader}.${encodedPayload}`;
|
|
65
|
-
if (!signer.verify(content, signature))
|
|
66
|
-
throw new
|
|
80
|
+
if (!signer.verify(content, signature)) {
|
|
81
|
+
throw new JwtManager.JwtError('INVALID_SIGNATURE', 'Invalid signature');
|
|
82
|
+
}
|
|
67
83
|
const jwt = new JwtManager.Jwt(header, payload, signature, signer);
|
|
68
84
|
if (jwt.expired)
|
|
69
|
-
throw new
|
|
85
|
+
throw new JwtManager.JwtError('TOKEN_EXPIRED', 'Token has expired');
|
|
70
86
|
return jwt;
|
|
71
87
|
}
|
|
72
88
|
// toJSON(): object { return { algorithm: this.algorithmName }; }
|
|
@@ -90,6 +106,7 @@ export class JwtManager {
|
|
|
90
106
|
JwtManager.JwtUtils = _JwtUtils;
|
|
91
107
|
JwtManager.KeyEntry = _KeyEntry;
|
|
92
108
|
JwtManager.Jwt = _Jwt;
|
|
109
|
+
JwtManager.JwtError = _JwtError;
|
|
93
110
|
})(JwtManager || (JwtManager = {}));
|
|
94
111
|
export default JwtManager;
|
|
95
112
|
//# sourceMappingURL=JwtManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JwtManager.js","sourceRoot":"","sources":["../../../src/beta/JwtManager/JwtManager.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"JwtManager.js","sourceRoot":"","sources":["../../../src/beta/JwtManager/JwtManager.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,UAAU,CAAC;AAC5B,OAAO,SAAS,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QA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export declare class BodyParser {
|
|
|
59
59
|
* @param body - The request body.
|
|
60
60
|
*/
|
|
61
61
|
private inferBoundary;
|
|
62
|
+
/**
|
|
63
|
+
* Safely decodes a URI component, returning the original value if decoding fails.
|
|
64
|
+
* @param value - The value to decode.
|
|
65
|
+
* @returns The decoded value or the original if decoding fails.
|
|
66
|
+
*/
|
|
67
|
+
private safeDecodeURIComponent;
|
|
62
68
|
}
|
|
63
69
|
export declare namespace BodyParser {
|
|
64
70
|
namespace Body {
|