@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
package/package.json
CHANGED
|
@@ -1,67 +1,139 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ti-engine/web-framework",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A web-framework based on the ti-engine. It provides a customizable ready-to-use web-server microservice and a set of tools for creating web applications. NOTICE: This is still a work in progress and the full architecture, design, and functionality are not available!",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
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
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@ti-engine/web-framework",
|
|
3
|
+
"version": "1.20.0",
|
|
4
|
+
"description": "A web-framework based on the ti-engine. It provides a customizable ready-to-use web-server microservice and a set of tools for creating web applications. NOTICE: This is still a work in progress and the full architecture, design, and functionality are not available!",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ti-engine",
|
|
7
|
+
"web-framework",
|
|
8
|
+
"express",
|
|
9
|
+
"microservices",
|
|
10
|
+
"htmx",
|
|
11
|
+
"alpinejs",
|
|
12
|
+
"openid-connect",
|
|
13
|
+
"csp"
|
|
14
|
+
],
|
|
15
|
+
"author": "Boris Kostadinov <kostadinov.boris@gmail.com>",
|
|
16
|
+
"license": "GPL-3.0-or-later",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./config-management": {
|
|
19
|
+
"types": "./types/components/config-service.d.ts",
|
|
20
|
+
"default": "./components/config-service.js"
|
|
21
|
+
},
|
|
22
|
+
"./web-application": {
|
|
23
|
+
"types": "./types/bin/web-app-manager.d.ts",
|
|
24
|
+
"default": "./bin/web-app-manager.js"
|
|
25
|
+
},
|
|
26
|
+
"./web-server": {
|
|
27
|
+
"types": "./types/bin/web-server.d.ts",
|
|
28
|
+
"default": "./bin/web-server.js"
|
|
29
|
+
},
|
|
30
|
+
"./definitions": {
|
|
31
|
+
"types": "./types/components/definitions.types.d.ts",
|
|
32
|
+
"default": "./components/definitions.types.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"imports": {
|
|
36
|
+
"#admin-config-handlers": {
|
|
37
|
+
"types": "./types/components/admin-config-handlers.d.ts",
|
|
38
|
+
"default": "./components/admin-config-handlers.js"
|
|
39
|
+
},
|
|
40
|
+
"#auth-manager": {
|
|
41
|
+
"types": "./types/components/auth-manager.d.ts",
|
|
42
|
+
"default": "./components/auth-manager.js"
|
|
43
|
+
},
|
|
44
|
+
"#authorization": {
|
|
45
|
+
"types": "./types/components/authorization.d.ts",
|
|
46
|
+
"default": "./components/authorization.js"
|
|
47
|
+
},
|
|
48
|
+
"#config-change-notifier": {
|
|
49
|
+
"types": "./types/components/config-change-notifier.d.ts",
|
|
50
|
+
"default": "./components/config-change-notifier.js"
|
|
51
|
+
},
|
|
52
|
+
"#config-registry": {
|
|
53
|
+
"types": "./types/components/config-registry.d.ts",
|
|
54
|
+
"default": "./components/config-registry.js"
|
|
55
|
+
},
|
|
56
|
+
"#config-service": {
|
|
57
|
+
"types": "./types/components/config-service.d.ts",
|
|
58
|
+
"default": "./components/config-service.js"
|
|
59
|
+
},
|
|
60
|
+
"#config-store": {
|
|
61
|
+
"types": "./types/components/config-store.d.ts",
|
|
62
|
+
"default": "./components/config-store.js"
|
|
63
|
+
},
|
|
64
|
+
"#definitions": {
|
|
65
|
+
"types": "./types/components/definitions.types.d.ts",
|
|
66
|
+
"default": "./components/definitions.types.js"
|
|
67
|
+
},
|
|
68
|
+
"#session-store": {
|
|
69
|
+
"types": "./types/components/session-store.d.ts",
|
|
70
|
+
"default": "./components/session-store.js"
|
|
71
|
+
},
|
|
72
|
+
"#user": {
|
|
73
|
+
"types": "./types/components/user.d.ts",
|
|
74
|
+
"default": "./components/user.js"
|
|
75
|
+
},
|
|
76
|
+
"#web-app-manager": {
|
|
77
|
+
"types": "./types/bin/web-app-manager.d.ts",
|
|
78
|
+
"default": "./bin/web-app-manager.js"
|
|
79
|
+
},
|
|
80
|
+
"#web-config-env": {
|
|
81
|
+
"types": "./types/components/web-config-env.d.ts",
|
|
82
|
+
"default": "./components/web-config-env.js"
|
|
83
|
+
},
|
|
84
|
+
"#web-handlers": {
|
|
85
|
+
"types": "./types/components/web-handlers.d.ts",
|
|
86
|
+
"default": "./components/web-handlers.js"
|
|
87
|
+
},
|
|
88
|
+
"#web-server": {
|
|
89
|
+
"types": "./types/bin/web-server.d.ts",
|
|
90
|
+
"default": "./bin/web-server.js"
|
|
91
|
+
},
|
|
92
|
+
"#web-server-config": "./bin/web-server.json"
|
|
93
|
+
},
|
|
94
|
+
"dependencies": {
|
|
95
|
+
"@alpinejs/csp": "^3.15.12",
|
|
96
|
+
"@ti-engine/core": "*",
|
|
97
|
+
"@types/express": "^5.0.6",
|
|
98
|
+
"@types/express-session": "^1.18.2",
|
|
99
|
+
"@types/node": "^24.10.1",
|
|
100
|
+
"ajv": "^8.20.0",
|
|
101
|
+
"cookie-parser": "^1.4.7",
|
|
102
|
+
"express": "^5.2.1",
|
|
103
|
+
"express-session": "^1.19.0",
|
|
104
|
+
"helmet": "^8.3.0",
|
|
105
|
+
"htmx.org": "^2.0.10",
|
|
106
|
+
"lodash": "^4.18.1",
|
|
107
|
+
"openid-client": "^6.8.4"
|
|
108
|
+
},
|
|
109
|
+
"devDependencies": {
|
|
110
|
+
"typescript": "^7.0.2"
|
|
111
|
+
},
|
|
112
|
+
"files": [
|
|
113
|
+
"bin/",
|
|
114
|
+
"!bin/tls/**/*",
|
|
115
|
+
"components/",
|
|
116
|
+
"types/",
|
|
117
|
+
".env",
|
|
118
|
+
"package.json",
|
|
119
|
+
"README.md",
|
|
120
|
+
"CHANGELOG.md"
|
|
121
|
+
],
|
|
122
|
+
"repository": {
|
|
123
|
+
"type": "git",
|
|
124
|
+
"url": "git+https://github.com/Belleal/ti-engine.git",
|
|
125
|
+
"directory": "packages/web-framework"
|
|
126
|
+
},
|
|
127
|
+
"bugs": {
|
|
128
|
+
"url": "https://github.com/Belleal/ti-engine/issues"
|
|
129
|
+
},
|
|
130
|
+
"homepage": "https://github.com/Belleal/ti-engine/tree/master/packages/web-framework#readme",
|
|
131
|
+
"engines": {
|
|
132
|
+
"node": ">=20.0.0"
|
|
133
|
+
},
|
|
134
|
+
"scripts": {
|
|
135
|
+
"postinstall": "node ./bin/build/post-install.js",
|
|
136
|
+
"test": "node --test test/*.test.js",
|
|
137
|
+
"build:types": "tsc -p tsconfig.types.json"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
export = TiWebAppManager;
|
|
2
|
+
import type { TiSession } from "#definitions";
|
|
3
|
+
/**
|
|
4
|
+
* Gates the login-page authentication markup to the effective enabled methods. The login fragment delimits blocks
|
|
5
|
+
* with HTML-comment markers: `<!--ti-auth-method:METHOD-->…<!--/ti-auth-method-->` around each method's control
|
|
6
|
+
* (the `local` credentials form and each OpenID provider button), `<!--ti-auth-divider-->…<!--/ti-auth-divider-->`
|
|
7
|
+
* around the "or continue with" separator, `<!--ti-auth-social-->…<!--/ti-auth-social-->` around the SSO button
|
|
8
|
+
* group, and `<!--ti-auth-none-->…<!--/ti-auth-none-->` around a "no method configured" fallback. It removes the
|
|
9
|
+
* block for any method that is not enabled, drops the social group when no SSO provider is enabled, shows the
|
|
10
|
+
* divider only when a local form AND at least one SSO provider are both present, and shows the fallback only when
|
|
11
|
+
* nothing is enabled. Any remaining markers are stripped so clean HTML ships. Fragments without these markers
|
|
12
|
+
* (every non-login fragment) are returned unchanged.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} html
|
|
15
|
+
* @param {string[]} [enabledMethods] The effective enabled authentication methods.
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
declare function applyAuthMethodVisibility(html: string, enabledMethods?: string[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* A generic web application manager that handles the rendering and behavior of web application views. It is designed to be extended by specific web application
|
|
21
|
+
* managers for each web application you want to implement with the ti-engine web framework.
|
|
22
|
+
* <br/>
|
|
23
|
+
* NOTE: You should not instantiate this class directly. Instead, extend it and override the abstract methods as needed. Additionally, you should configure your
|
|
24
|
+
* ti-engine web server 'TiWebApplicationConfig' settings by specifying the 'classPath' that corresponds to your web application manager. The path should be
|
|
25
|
+
* relative to the intended process's working directory.
|
|
26
|
+
*
|
|
27
|
+
* @class TiWebAppManager
|
|
28
|
+
* @abstract
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
declare class TiWebAppManager {
|
|
32
|
+
#private;
|
|
33
|
+
/**
|
|
34
|
+
* @constructor
|
|
35
|
+
* @param {string} identifier The identifier for this web application. Should be unique and recognizable.
|
|
36
|
+
* @throws {TiException.E_GEN_ABSTRACT_CLASS_INIT} If this class is instantiated directly.
|
|
37
|
+
*/
|
|
38
|
+
constructor(identifier: string);
|
|
39
|
+
/**
|
|
40
|
+
* Returns the identifier for this web application.
|
|
41
|
+
*
|
|
42
|
+
* @property
|
|
43
|
+
* @returns {string}
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
get webAppIdentifier(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Adds a new HTML fragment to the web application.
|
|
49
|
+
* <br/>
|
|
50
|
+
* NOTE: This method should only be called during the initialization phase of your web application manager.
|
|
51
|
+
*
|
|
52
|
+
* @method
|
|
53
|
+
* @param {string} identifier
|
|
54
|
+
* @param {Object} fragment The fragment descriptor (`{ title, path, components }`). May also carry an optional
|
|
55
|
+
* `roles` array (`Array<string|number>`): when present, the default {@link TiWebAppManager#verifyAccess} serves
|
|
56
|
+
* the fragment only to sessions holding at least one of those roles; omit it (or leave empty) for a public screen.
|
|
57
|
+
* @throws {TiException.E_GEN_UNALLOWED_OVERRIDE} If a fragment with the same identifier already exists.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
addFragment(identifier: string, fragment: Object): void;
|
|
61
|
+
/**
|
|
62
|
+
* Registers an editable configuration document with the framework config registry (JSON Schema + semantic
|
|
63
|
+
* validators + default value + editor metadata). Call during initialization. See {@link ConfigRegistry#register}.
|
|
64
|
+
*
|
|
65
|
+
* @method
|
|
66
|
+
* @param {string} configKey
|
|
67
|
+
* @param {Object} definition
|
|
68
|
+
* @returns {TiWebAppManager} this (chainable)
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
registerConfigDocument(configKey: string, definition: Object): TiWebAppManager;
|
|
72
|
+
/**
|
|
73
|
+
* Registers a JSON Schema that is referenced (via `$ref`) by config-document schemas but is not itself a document.
|
|
74
|
+
*
|
|
75
|
+
* @method
|
|
76
|
+
* @param {Object} schema
|
|
77
|
+
* @returns {TiWebAppManager} this (chainable)
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
registerConfigSchema(schema: Object): TiWebAppManager;
|
|
81
|
+
/**
|
|
82
|
+
* Registers a composite (entity) editor with the framework config service — a `compose(docs)`/`decompose(edited,docs)`
|
|
83
|
+
* pair over one or more documents. Call during initialization. See {@link ConfigService#registerEditor}.
|
|
84
|
+
*
|
|
85
|
+
* @method
|
|
86
|
+
* @param {string} editorKey
|
|
87
|
+
* @param {Object} definition
|
|
88
|
+
* @returns {TiWebAppManager} this (chainable)
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
registerConfigEditor(editorKey: string, definition: Object): TiWebAppManager;
|
|
92
|
+
/**
|
|
93
|
+
* Used to clear the static file cache. This is useful for testing purposes to ensure that the web server is always serving fresh content.
|
|
94
|
+
*
|
|
95
|
+
* @method
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
clearStaticFileCache(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Sets the effective enabled authentication methods used to gate login-page provider buttons. The web server
|
|
101
|
+
* calls this at startup, after the auth manager has dropped any enabled-but-unconfigured OpenID providers.
|
|
102
|
+
*
|
|
103
|
+
* @method
|
|
104
|
+
* @param {string[]} methods
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
setEnabledAuthMethods(methods: string[]): void;
|
|
108
|
+
/**
|
|
109
|
+
* Optional HTML transformation hook.
|
|
110
|
+
* <br/>
|
|
111
|
+
* NOTE: Override in subclasses to add nonces or other dynamic data to outgoing HTML.
|
|
112
|
+
*
|
|
113
|
+
* @method
|
|
114
|
+
* @param {string} html
|
|
115
|
+
* @param {Object} [options]
|
|
116
|
+
* @param {string} [options.csrfToken] Optional CSRF token to inject into the HTML.
|
|
117
|
+
* @param {boolean} [options.isHome] Optional flag to indicate whether the requested route is the home page.
|
|
118
|
+
* @param {string} [options.nonce] Optional CSP nonce to inject into inline scripts/styles.
|
|
119
|
+
* @param {string} [options.title] Optional title to replace the placeholder in the HTML.
|
|
120
|
+
* @returns {Promise<string>}
|
|
121
|
+
* @virtual
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
transformHtml(html: string, options?: {
|
|
125
|
+
csrfToken?: string;
|
|
126
|
+
isHome?: boolean;
|
|
127
|
+
nonce?: string;
|
|
128
|
+
title?: string;
|
|
129
|
+
}): Promise<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Used to assemble the complete HTML view for the requested route, including nested HTML fragments.
|
|
132
|
+
*
|
|
133
|
+
* @method
|
|
134
|
+
* @param {TiSession} session
|
|
135
|
+
* @param {string[]} staticContentPaths
|
|
136
|
+
* @param {string} route
|
|
137
|
+
* @param {Object} [options]
|
|
138
|
+
* @param {string} [options.csrfToken] Optional CSRF token to inject into the HTML.
|
|
139
|
+
* @param {boolean} [options.isPartial] Optional flag to indicate whether the requested route is a partial load of a fragment.
|
|
140
|
+
* @param {string} [options.view] Optional view name to load within this route.
|
|
141
|
+
* @param {string} [options.nonce] Optional CSP nonce to inject into inline scripts/styles.
|
|
142
|
+
* @returns {Promise<string>}
|
|
143
|
+
* @public
|
|
144
|
+
*/
|
|
145
|
+
assembleHtmlView(session: TiSession, staticContentPaths: string[], route: string, options?: {
|
|
146
|
+
csrfToken?: string;
|
|
147
|
+
isPartial?: boolean;
|
|
148
|
+
view?: string;
|
|
149
|
+
nonce?: string;
|
|
150
|
+
}): Promise<string>;
|
|
151
|
+
/**
|
|
152
|
+
* Used to process a request for a data resource.
|
|
153
|
+
*
|
|
154
|
+
* @method
|
|
155
|
+
* @param {TiSession} session
|
|
156
|
+
* @param {string} view
|
|
157
|
+
* @param {Object} [options]
|
|
158
|
+
* @returns {Promise<Object>}
|
|
159
|
+
* @virtual
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
processDataRequest(session: TiSession, view: string, options?: Object): Promise<Object>;
|
|
163
|
+
/**
|
|
164
|
+
* Used to process an application service request.
|
|
165
|
+
*
|
|
166
|
+
* @method
|
|
167
|
+
* @param {TiSession} session
|
|
168
|
+
* @param {string} service
|
|
169
|
+
* @param {Object} params
|
|
170
|
+
* @returns {Promise<Object>}
|
|
171
|
+
* @virtual
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
processServiceRequest(session: TiSession, service: string, params: Object): Promise<Object>;
|
|
175
|
+
/**
|
|
176
|
+
* Used to verify whether the current user has access to the requested resource. The default implementation gates
|
|
177
|
+
* HTML fragments by their declared `roles`: a fragment registered via {@link TiWebAppManager#addFragment} with a
|
|
178
|
+
* `roles` array is served only to sessions holding at least one of those roles (see {@link addFragment}); a
|
|
179
|
+
* fragment with no `roles` is public to any authenticated user. This makes role-restricted screens unreachable by
|
|
180
|
+
* direct URL, not merely hidden in the UI. Override in subclasses only to implement additional/alternative checks.
|
|
181
|
+
*
|
|
182
|
+
* @method
|
|
183
|
+
* @virtual
|
|
184
|
+
* @param {TiSession} session
|
|
185
|
+
* @param {Object} resource The fragment descriptor; its optional `resource.roles` lists the roles permitted to load it.
|
|
186
|
+
* @returns {Promise}
|
|
187
|
+
* @exception {TiException.E_SEC_UNAUTHORIZED_ACCESS} (403) When the session holds none of the fragment's required roles.
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
verifyAccess(session: TiSession, resource: Object): Promise<any>;
|
|
191
|
+
}
|
|
192
|
+
declare namespace TiWebAppManager {
|
|
193
|
+
export { applyAuthMethodVisibility };
|
|
194
|
+
}
|