@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.
Files changed (52) hide show
  1. package/.env +4 -4
  2. package/CHANGELOG.md +384 -353
  3. package/README.md +73 -73
  4. package/bin/build/post-install.js +18 -18
  5. package/bin/localization/web-server-labels.json +27 -27
  6. package/bin/static/.well-known/appspecific/com.chrome.devtools.json +5 -5
  7. package/bin/static/fragments/components/component-notification-bar.html +21 -21
  8. package/bin/static/fragments/components/component-sidebar.html +33 -33
  9. package/bin/static/fragments/components/component-tooltip.html +10 -10
  10. package/bin/static/fragments/components/component-topbar.html +5 -5
  11. package/bin/static/fragments/frame-administration.html +2 -2
  12. package/bin/static/fragments/frame-application.html +18 -18
  13. package/bin/static/fragments/frame-dashboard.html +2 -2
  14. package/bin/static/fragments/frame-login.html +119 -119
  15. package/bin/static/fragments/frame-not-found.html +2 -2
  16. package/bin/static/fragments/frame-profile.html +2 -2
  17. package/bin/static/index.html +22 -22
  18. package/bin/static/scripts/ti-charts.js +1591 -1591
  19. package/bin/static/scripts/ti-framework.css +3194 -3194
  20. package/bin/static/scripts/ti-framework.js +1427 -1427
  21. package/bin/static/scripts/ti-theme-black-glass.css +216 -216
  22. package/bin/static/scripts/ti-theme-daylight.css +87 -87
  23. package/bin/web-app-manager.js +660 -663
  24. package/bin/web-server.js +936 -937
  25. package/bin/web-server.json +48 -48
  26. package/components/admin-config-handlers.js +95 -92
  27. package/components/auth-manager.js +438 -442
  28. package/components/authorization.js +135 -135
  29. package/components/config-change-notifier.js +98 -98
  30. package/components/config-registry.js +257 -260
  31. package/components/config-service.js +363 -360
  32. package/components/config-store.js +244 -246
  33. package/components/definitions.types.js +28 -26
  34. package/components/session-store.js +113 -110
  35. package/components/user.js +134 -132
  36. package/components/web-config-env.js +85 -85
  37. package/components/web-handlers.js +803 -800
  38. package/package.json +139 -67
  39. package/types/bin/web-app-manager.d.ts +194 -0
  40. package/types/bin/web-server.d.ts +373 -0
  41. package/types/components/admin-config-handlers.d.ts +11 -0
  42. package/types/components/auth-manager.d.ts +125 -0
  43. package/types/components/authorization.d.ts +54 -0
  44. package/types/components/config-change-notifier.d.ts +73 -0
  45. package/types/components/config-registry.d.ts +149 -0
  46. package/types/components/config-service.d.ts +218 -0
  47. package/types/components/config-store.d.ts +128 -0
  48. package/types/components/definitions.types.d.ts +31 -0
  49. package/types/components/session-store.d.ts +56 -0
  50. package/types/components/user.d.ts +83 -0
  51. package/types/components/web-config-env.d.ts +17 -0
  52. package/types/components/web-handlers.d.ts +23 -0
@@ -1,85 +1,85 @@
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-2026 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
- "use strict";
10
-
11
- const tools = require( "@ti-engine/core/tools" );
12
-
13
- /**
14
- * Applies TI_WEB_* environment-variable overrides onto an (already-merged) web server configuration object.
15
- * Each override is applied ONLY when its environment variable is defined, so an absent variable leaves the
16
- * configured/default value untouched (fully backward compatible). This gives ti-engine web servers 12-factor,
17
- * container-friendly control over network binding, TLS, the session cookie secret, the enabled authentication
18
- * methods, the admin allowlist, the trusted request origins, and the `/static` cache policy without editing config files. Note `TI_WEB_AUTH_METHODS`,
19
- * `TI_WEB_AUTH_ADMINS`, `TI_WEB_TRUSTED_ORIGINS`, and `TI_WEB_STATIC_IMMUTABLE_PATHS` fully REPLACE their config arrays (`auth.enabledMethods` / `auth.admins` / `trustedOrigins` / `staticCache.immutablePaths`) rather than
20
- * merging — the config-file merge is by-index and cannot cleanly override an array.
21
- *
22
- * @method
23
- * @param {Object} config The web server configuration to augment (mutated in place and returned).
24
- * @param {Object} [env=process.env] The environment source (injectable for testing).
25
- * @returns {Object} The same config object, with any present overrides applied.
26
- * @public
27
- */
28
- function applyWebConfigEnvOverrides( config, env = process.env ) {
29
- if ( !config || typeof config !== "object" ) {
30
- return config;
31
- }
32
- if ( env.TI_WEB_HOST !== undefined ) {
33
- config.host = env.TI_WEB_HOST;
34
- }
35
- if ( env.TI_WEB_PORT !== undefined ) {
36
- const port = Number( env.TI_WEB_PORT );
37
- if ( Number.isInteger( port ) ) {
38
- config.port = port;
39
- }
40
- }
41
- if ( env.TI_WEB_USE_TLS !== undefined ) {
42
- config.useTLS = tools.toBool( env.TI_WEB_USE_TLS );
43
- }
44
- if ( env.TI_WEB_TLS_CERT_PATH !== undefined ) {
45
- config.tlsCertPath = env.TI_WEB_TLS_CERT_PATH;
46
- }
47
- if ( env.TI_WEB_TLS_KEY_PATH !== undefined ) {
48
- config.tlsKeyPath = env.TI_WEB_TLS_KEY_PATH;
49
- }
50
- if ( env.TI_WEB_COOKIE_SECRET !== undefined ) {
51
- config.cookies = config.cookies || {};
52
- config.cookies.secret = env.TI_WEB_COOKIE_SECRET;
53
- }
54
- if ( env.TI_WEB_AUTH_METHODS !== undefined ) {
55
- config.auth = config.auth || {};
56
- config.auth.enabledMethods = env.TI_WEB_AUTH_METHODS.split( "," ).map( ( method ) => method.trim() ).filter( ( method ) => method.length > 0 );
57
- }
58
- if ( env.TI_WEB_AUTH_ADMINS !== undefined ) {
59
- config.auth = config.auth || {};
60
- config.auth.admins = env.TI_WEB_AUTH_ADMINS.split( "," ).map( ( entry ) => entry.trim() ).filter( ( entry ) => entry.length > 0 );
61
- }
62
- if ( env.TI_WEB_TRUSTED_ORIGINS !== undefined ) {
63
- config.trustedOrigins = env.TI_WEB_TRUSTED_ORIGINS.split( "," ).map( ( origin ) => origin.trim() ).filter( ( origin ) => origin.length > 0 );
64
- }
65
- if ( env.TI_WEB_STATIC_MAX_AGE !== undefined ) {
66
- // Seconds, matching the `Cache-Control` directive itself. A non-integer is left to the config value rather
67
- // than coerced, exactly as TI_WEB_PORT is — `TiWebServer.resolveStaticCachePolicy` reports the bad value.
68
- const maxAge = Number( env.TI_WEB_STATIC_MAX_AGE );
69
- if ( Number.isInteger( maxAge ) && maxAge >= 0 ) {
70
- config.staticCache = config.staticCache || {};
71
- config.staticCache.maxAge = maxAge;
72
- }
73
- }
74
- if ( env.TI_WEB_STATIC_IMMUTABLE !== undefined ) {
75
- config.staticCache = config.staticCache || {};
76
- config.staticCache.immutable = tools.toBool( env.TI_WEB_STATIC_IMMUTABLE );
77
- }
78
- if ( env.TI_WEB_STATIC_IMMUTABLE_PATHS !== undefined ) {
79
- config.staticCache = config.staticCache || {};
80
- config.staticCache.immutablePaths = env.TI_WEB_STATIC_IMMUTABLE_PATHS.split( "," ).map( ( prefix ) => prefix.trim() ).filter( ( prefix ) => prefix.length > 0 );
81
- }
82
- return config;
83
- }
84
-
85
- module.exports = applyWebConfigEnvOverrides;
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-2026 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
+ "use strict";
10
+
11
+ const tools = require( "@ti-engine/core/tools" );
12
+
13
+ /**
14
+ * Applies TI_WEB_* environment-variable overrides onto an (already-merged) web server configuration object.
15
+ * Each override is applied ONLY when its environment variable is defined, so an absent variable leaves the
16
+ * configured/default value untouched (fully backward compatible). This gives ti-engine web servers 12-factor,
17
+ * container-friendly control over network binding, TLS, the session cookie secret, the enabled authentication
18
+ * methods, the admin allowlist, the trusted request origins, and the `/static` cache policy without editing config files. Note `TI_WEB_AUTH_METHODS`,
19
+ * `TI_WEB_AUTH_ADMINS`, `TI_WEB_TRUSTED_ORIGINS`, and `TI_WEB_STATIC_IMMUTABLE_PATHS` fully REPLACE their config arrays (`auth.enabledMethods` / `auth.admins` / `trustedOrigins` / `staticCache.immutablePaths`) rather than
20
+ * merging — the config-file merge is by-index and cannot cleanly override an array.
21
+ *
22
+ * @method
23
+ * @param {Object} config The web server configuration to augment (mutated in place and returned).
24
+ * @param {Object} [env=process.env] The environment source (injectable for testing).
25
+ * @returns {Object} The same config object, with any present overrides applied.
26
+ * @public
27
+ */
28
+ function applyWebConfigEnvOverrides( config, env = process.env ) {
29
+ if ( !config || typeof config !== "object" ) {
30
+ return config;
31
+ }
32
+ if ( env.TI_WEB_HOST !== undefined ) {
33
+ config.host = env.TI_WEB_HOST;
34
+ }
35
+ if ( env.TI_WEB_PORT !== undefined ) {
36
+ const port = Number( env.TI_WEB_PORT );
37
+ if ( Number.isInteger( port ) ) {
38
+ config.port = port;
39
+ }
40
+ }
41
+ if ( env.TI_WEB_USE_TLS !== undefined ) {
42
+ config.useTLS = tools.toBool( env.TI_WEB_USE_TLS );
43
+ }
44
+ if ( env.TI_WEB_TLS_CERT_PATH !== undefined ) {
45
+ config.tlsCertPath = env.TI_WEB_TLS_CERT_PATH;
46
+ }
47
+ if ( env.TI_WEB_TLS_KEY_PATH !== undefined ) {
48
+ config.tlsKeyPath = env.TI_WEB_TLS_KEY_PATH;
49
+ }
50
+ if ( env.TI_WEB_COOKIE_SECRET !== undefined ) {
51
+ config.cookies = config.cookies || {};
52
+ config.cookies.secret = env.TI_WEB_COOKIE_SECRET;
53
+ }
54
+ if ( env.TI_WEB_AUTH_METHODS !== undefined ) {
55
+ config.auth = config.auth || {};
56
+ config.auth.enabledMethods = env.TI_WEB_AUTH_METHODS.split( "," ).map( ( method ) => method.trim() ).filter( ( method ) => method.length > 0 );
57
+ }
58
+ if ( env.TI_WEB_AUTH_ADMINS !== undefined ) {
59
+ config.auth = config.auth || {};
60
+ config.auth.admins = env.TI_WEB_AUTH_ADMINS.split( "," ).map( ( entry ) => entry.trim() ).filter( ( entry ) => entry.length > 0 );
61
+ }
62
+ if ( env.TI_WEB_TRUSTED_ORIGINS !== undefined ) {
63
+ config.trustedOrigins = env.TI_WEB_TRUSTED_ORIGINS.split( "," ).map( ( origin ) => origin.trim() ).filter( ( origin ) => origin.length > 0 );
64
+ }
65
+ if ( env.TI_WEB_STATIC_MAX_AGE !== undefined ) {
66
+ // Seconds, matching the `Cache-Control` directive itself. A non-integer is left to the config value rather
67
+ // than coerced, exactly as TI_WEB_PORT is — `TiWebServer.resolveStaticCachePolicy` reports the bad value.
68
+ const maxAge = Number( env.TI_WEB_STATIC_MAX_AGE );
69
+ if ( Number.isInteger( maxAge ) && maxAge >= 0 ) {
70
+ config.staticCache = config.staticCache || {};
71
+ config.staticCache.maxAge = maxAge;
72
+ }
73
+ }
74
+ if ( env.TI_WEB_STATIC_IMMUTABLE !== undefined ) {
75
+ config.staticCache = config.staticCache || {};
76
+ config.staticCache.immutable = tools.toBool( env.TI_WEB_STATIC_IMMUTABLE );
77
+ }
78
+ if ( env.TI_WEB_STATIC_IMMUTABLE_PATHS !== undefined ) {
79
+ config.staticCache = config.staticCache || {};
80
+ config.staticCache.immutablePaths = env.TI_WEB_STATIC_IMMUTABLE_PATHS.split( "," ).map( ( prefix ) => prefix.trim() ).filter( ( prefix ) => prefix.length > 0 );
81
+ }
82
+ return config;
83
+ }
84
+
85
+ module.exports = applyWebConfigEnvOverrides;