@ti-engine/web-framework 1.19.0 → 1.20.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/.env +4 -4
- package/CHANGELOG.md +384 -353
- package/README.md +73 -73
- package/bin/build/post-install.js +18 -18
- package/bin/localization/web-server-labels.json +27 -27
- package/bin/static/.well-known/appspecific/com.chrome.devtools.json +5 -5
- package/bin/static/fragments/components/component-notification-bar.html +21 -21
- package/bin/static/fragments/components/component-sidebar.html +33 -33
- package/bin/static/fragments/components/component-tooltip.html +10 -10
- package/bin/static/fragments/components/component-topbar.html +5 -5
- package/bin/static/fragments/frame-administration.html +2 -2
- package/bin/static/fragments/frame-application.html +18 -18
- package/bin/static/fragments/frame-dashboard.html +2 -2
- package/bin/static/fragments/frame-login.html +119 -119
- package/bin/static/fragments/frame-not-found.html +2 -2
- package/bin/static/fragments/frame-profile.html +2 -2
- package/bin/static/index.html +22 -22
- package/bin/static/scripts/ti-charts.js +1591 -1591
- package/bin/static/scripts/ti-framework.css +3194 -3194
- package/bin/static/scripts/ti-framework.js +1427 -1427
- package/bin/static/scripts/ti-theme-black-glass.css +216 -216
- package/bin/static/scripts/ti-theme-daylight.css +87 -87
- package/bin/web-app-manager.js +660 -663
- package/bin/web-server.js +936 -937
- package/bin/web-server.json +48 -48
- package/components/admin-config-handlers.js +95 -92
- package/components/auth-manager.js +438 -442
- package/components/authorization.js +135 -135
- package/components/config-change-notifier.js +98 -98
- package/components/config-registry.js +257 -260
- package/components/config-service.js +363 -360
- package/components/config-store.js +244 -246
- package/components/definitions.types.js +28 -26
- package/components/session-store.js +113 -110
- package/components/user.js +134 -132
- package/components/web-config-env.js +85 -85
- package/components/web-handlers.js +803 -800
- package/package.json +139 -67
- package/types/bin/web-app-manager.d.ts +194 -0
- package/types/bin/web-server.d.ts +373 -0
- package/types/components/admin-config-handlers.d.ts +11 -0
- package/types/components/auth-manager.d.ts +125 -0
- package/types/components/authorization.d.ts +54 -0
- package/types/components/config-change-notifier.d.ts +73 -0
- package/types/components/config-registry.d.ts +149 -0
- package/types/components/config-service.d.ts +218 -0
- package/types/components/config-store.d.ts +128 -0
- package/types/components/definitions.types.d.ts +31 -0
- package/types/components/session-store.d.ts +56 -0
- package/types/components/user.d.ts +83 -0
- package/types/components/web-config-env.d.ts +17 -0
- package/types/components/web-handlers.d.ts +23 -0
|
@@ -1,111 +1,114 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.
|
|
3
|
-
* Copyright © 2021-2025 Boris Kostadinov <kostadinov.boris@gmail.com>
|
|
4
|
-
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
5
|
-
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
6
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const cache = require( "@ti-engine/core/cache" );
|
|
10
|
-
const logger = require( "@ti-engine/core/logger" );
|
|
11
|
-
const exceptions = require( "@ti-engine/core/exceptions" );
|
|
12
|
-
const _ = require( "lodash" );
|
|
13
|
-
const session = require( "express-session" );
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
class SessionStore
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
callback(
|
|
53
|
-
} )
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
callback(
|
|
70
|
-
} )
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
callback(
|
|
87
|
-
} )
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @
|
|
97
|
-
* @
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
callback(
|
|
106
|
-
} )
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
1
|
+
/*
|
|
2
|
+
* The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.
|
|
3
|
+
* Copyright © 2021-2025 Boris Kostadinov <kostadinov.boris@gmail.com>
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
5
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
6
|
+
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const cache = require( "@ti-engine/core/cache" );
|
|
10
|
+
const logger = require( "@ti-engine/core/logger" );
|
|
11
|
+
const exceptions = require( "@ti-engine/core/exceptions" );
|
|
12
|
+
const _ = require( "lodash" );
|
|
13
|
+
const session = require( "express-session" );
|
|
14
|
+
|
|
15
|
+
/** @import { SessionData } from "express-session" */
|
|
16
|
+
/** @import { TiException } from "@ti-engine/core/exceptions" */
|
|
17
|
+
|
|
18
|
+
// The name of the session store in the cache:
|
|
19
|
+
const sessionStoreName = "ti:web:sessions";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A session store for the web server using the standard 'cache' module of the ti-engine.
|
|
23
|
+
* <br/>
|
|
24
|
+
* NOTE: This implementation is compatible with the 'express-session' module.
|
|
25
|
+
*
|
|
26
|
+
* @class SessionStore
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
class SessionStore extends session.Store {
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @constructor
|
|
33
|
+
*/
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Used to store a user session in the cache.
|
|
40
|
+
*
|
|
41
|
+
* @method
|
|
42
|
+
* @param {string} sessionID
|
|
43
|
+
* @param {SessionData} session
|
|
44
|
+
* @param {(error?: Error|TiException|null) => void} callback
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
set( sessionID, session, callback ) {
|
|
48
|
+
cache.instance.hashSetField( sessionStoreName, sessionID, session ).then( () => {
|
|
49
|
+
let expire = ( session.cookie && _.isNumber( session.cookie.maxAge ) ) ? session.cookie.maxAge / 1000 : null;
|
|
50
|
+
return ( expire ) ? cache.instance.expireValue( sessionID, expire, sessionStoreName ) : null;
|
|
51
|
+
} ).then( () => {
|
|
52
|
+
callback();
|
|
53
|
+
} ).catch( ( error ) => {
|
|
54
|
+
logger.log( `Error while trying to store user session in cache!`, logger.logSeverity.ERROR, error );
|
|
55
|
+
callback( exceptions.raise( error ) );
|
|
56
|
+
} );
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Used to retrieve a user session from the cache.
|
|
61
|
+
*
|
|
62
|
+
* @method
|
|
63
|
+
* @param {string} sessionID
|
|
64
|
+
* @param {(error?: Error|TiException|null, session?: SessionData|null) => void} callback
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
get( sessionID, callback ) {
|
|
68
|
+
cache.instance.hashGetField( sessionStoreName, sessionID ).then( ( session ) => {
|
|
69
|
+
callback( null, session );
|
|
70
|
+
} ).catch( ( error ) => {
|
|
71
|
+
logger.log( `Error while trying to fetch user session from cache!`, logger.logSeverity.ERROR, error );
|
|
72
|
+
callback( exceptions.raise( error ) );
|
|
73
|
+
} );
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Used to remove a user session from the cache.
|
|
78
|
+
*
|
|
79
|
+
* @method
|
|
80
|
+
* @param {string} sessionID
|
|
81
|
+
* @param {(error?: Error|TiException|null) => void} callback
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
destroy( sessionID, callback ) {
|
|
85
|
+
cache.instance.hashDeleteField( sessionStoreName, sessionID ).then( () => {
|
|
86
|
+
callback();
|
|
87
|
+
} ).catch( ( error ) => {
|
|
88
|
+
logger.log( `Error while trying to remove user session from cache!`, logger.logSeverity.ERROR, error );
|
|
89
|
+
callback( exceptions.raise( error ) );
|
|
90
|
+
} );
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Used to update the expiration time of a user session in the cache.
|
|
95
|
+
*
|
|
96
|
+
* @method
|
|
97
|
+
* @param {string} sessionID
|
|
98
|
+
* @param {SessionData} session
|
|
99
|
+
* @param {(error?: Error|TiException|null) => void} callback
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
touch( sessionID, session, callback ) {
|
|
103
|
+
let expire = ( session.cookie && _.isNumber( session.cookie.maxAge ) ) ? session.cookie.maxAge / 1000 : null;
|
|
104
|
+
cache.instance.expireValue( sessionID, expire, sessionStoreName ).then( () => {
|
|
105
|
+
callback();
|
|
106
|
+
} ).catch( ( error ) => {
|
|
107
|
+
logger.log( `Error while trying to refresh user session expiration in cache!`, logger.logSeverity.ERROR, error );
|
|
108
|
+
callback( exceptions.raise( error ) );
|
|
109
|
+
} );
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
111
114
|
module.exports = SessionStore;
|
package/components/user.js
CHANGED
|
@@ -1,133 +1,135 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.
|
|
3
|
-
* Copyright © 2021-2025 Boris Kostadinov <kostadinov.boris@gmail.com>
|
|
4
|
-
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
5
|
-
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
6
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* @
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {string}
|
|
32
|
-
* @param {string} [userData.
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {string
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.#
|
|
42
|
-
this.#
|
|
43
|
-
this.#
|
|
44
|
-
this.#
|
|
45
|
-
this.#
|
|
46
|
-
this.#
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* @
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
* @
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
* @
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* @
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
* @
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* @
|
|
107
|
-
* @
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
* @
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
1
|
+
/*
|
|
2
|
+
* The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.
|
|
3
|
+
* Copyright © 2021-2025 Boris Kostadinov <kostadinov.boris@gmail.com>
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
5
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
6
|
+
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @import { TiLocalizationLanguage } from "@ti-engine/core/localization" */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents a user in the system.
|
|
13
|
+
*
|
|
14
|
+
* @class User
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
class User {
|
|
18
|
+
|
|
19
|
+
#userID;
|
|
20
|
+
#username;
|
|
21
|
+
#email;
|
|
22
|
+
#name;
|
|
23
|
+
#language;
|
|
24
|
+
#roles;
|
|
25
|
+
#permissions;
|
|
26
|
+
#details;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @constructor
|
|
30
|
+
* @param {Object} userData
|
|
31
|
+
* @param {string} userData.userID
|
|
32
|
+
* @param {string} [userData.username]
|
|
33
|
+
* @param {string} [userData.email]
|
|
34
|
+
* @param {string} [userData.name]
|
|
35
|
+
* @param {TiLocalizationLanguage} [userData.language]
|
|
36
|
+
* @param {string[]} [userData.roles]
|
|
37
|
+
* @param {string[]} [userData.permissions]
|
|
38
|
+
* @param {Object} [userData.details]
|
|
39
|
+
*/
|
|
40
|
+
constructor( userData = {} ) {
|
|
41
|
+
this.#userID = userData.userID;
|
|
42
|
+
this.#username = userData.username;
|
|
43
|
+
this.#email = userData.email;
|
|
44
|
+
this.#name = userData.name;
|
|
45
|
+
this.#language = userData.language;
|
|
46
|
+
this.#roles = Array.isArray( userData.roles ) ? userData.roles : [];
|
|
47
|
+
this.#permissions = Array.isArray( userData.permissions ) ? userData.permissions : [];
|
|
48
|
+
this.#details = userData.details || {};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @property
|
|
53
|
+
* @returns {string}
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
get userID() {
|
|
57
|
+
return this.#userID;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @property
|
|
62
|
+
* @returns {string}
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
get username() {
|
|
66
|
+
return this.#username;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @property
|
|
71
|
+
* @returns {string}
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
get email() {
|
|
75
|
+
return this.#email;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @property
|
|
80
|
+
* @returns {string}
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
get name() {
|
|
84
|
+
return this.#name;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @property
|
|
89
|
+
* @returns {TiLocalizationLanguage}
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
get language() {
|
|
93
|
+
return this.#language;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @method
|
|
98
|
+
* @returns {*}
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
getDetail( key ) {
|
|
102
|
+
return this.#details[ key ];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @method
|
|
107
|
+
* @param {string} key
|
|
108
|
+
* @param {*} value
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
setDetail( key, value ) {
|
|
112
|
+
this.#details[ key ] = value;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @method
|
|
117
|
+
* @returns {Object}
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
asJSON() {
|
|
121
|
+
return {
|
|
122
|
+
userID: this.#userID,
|
|
123
|
+
username: this.#username,
|
|
124
|
+
email: this.#email,
|
|
125
|
+
name: this.#name,
|
|
126
|
+
language: this.#language,
|
|
127
|
+
roles: this.#roles,
|
|
128
|
+
permissions: this.#permissions,
|
|
129
|
+
details: this.#details
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
133
135
|
module.exports = User;
|