@ui5/server 2.2.10 → 3.0.0-alpha.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/CHANGELOG.md CHANGED
@@ -2,7 +2,25 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
- A list of unreleased changes can be found [here](https://github.com/SAP/ui5-server/compare/v2.2.10...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-server/compare/v3.0.0-alpha.0...HEAD).
6
+
7
+ <a name="v3.0.0-alpha.0"></a>
8
+ ## [v3.0.0-alpha.0] - 2021-12-14
9
+
10
+ <a name="v2.4.0"></a>
11
+ ## [v2.4.0] - 2021-10-19
12
+ ### Features
13
+ - Enhance versionInfo middleware to serve sap-ui-version.json ([#420](https://github.com/SAP/ui5-server/issues/420)) [`c6f83f5`](https://github.com/SAP/ui5-server/commit/c6f83f5472eb2fe6a8d4eca10ecdc5f4b522bc3c)
14
+
15
+
16
+ <a name="v2.3.1"></a>
17
+ ## [v2.3.1] - 2021-07-23
18
+
19
+ <a name="v2.3.0"></a>
20
+ ## [v2.3.0] - 2021-07-01
21
+ ### Features
22
+ - **server:** Expose configuration options for SAP CSP policies [`55d6a96`](https://github.com/SAP/ui5-server/commit/55d6a96cc1a3c762af8173d9fb9588fe742a302d)
23
+
6
24
 
7
25
  <a name="v2.2.10"></a>
8
26
  ## [v2.2.10] - 2021-06-01
@@ -231,6 +249,10 @@ Only Node.js v10 or higher is supported.
231
249
  <a name="v0.0.1"></a>
232
250
  ## v0.0.1 - 2018-06-06
233
251
 
252
+ [v3.0.0-alpha.0]: https://github.com/SAP/ui5-server/compare/v2.4.0...v3.0.0-alpha.0
253
+ [v2.4.0]: https://github.com/SAP/ui5-server/compare/v2.3.1...v2.4.0
254
+ [v2.3.1]: https://github.com/SAP/ui5-server/compare/v2.3.0...v2.3.1
255
+ [v2.3.0]: https://github.com/SAP/ui5-server/compare/v2.2.10...v2.3.0
234
256
  [v2.2.10]: https://github.com/SAP/ui5-server/compare/v2.2.9...v2.2.10
235
257
  [v2.2.9]: https://github.com/SAP/ui5-server/compare/v2.2.8...v2.2.9
236
258
  [v2.2.8]: https://github.com/SAP/ui5-server/compare/v2.2.7...v2.2.8
package/LICENSE.txt CHANGED
@@ -1,208 +1,201 @@
1
- Apache License
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
2
4
 
3
- Version 2.0, January 2004
4
-
5
- http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION,
6
- AND DISTRIBUTION
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
6
 
8
7
  1. Definitions.
9
8
 
10
-
11
-
12
- "License" shall mean the terms and conditions for use, reproduction, and distribution
13
- as defined by Sections 1 through 9 of this document.
14
-
15
-
16
-
17
- "Licensor" shall mean the copyright owner or entity authorized by the copyright
18
- owner that is granting the License.
19
-
20
-
21
-
22
- "Legal Entity" shall mean the union of the acting entity and all other entities
23
- that control, are controlled by, or are under common control with that entity.
24
- For the purposes of this definition, "control" means (i) the power, direct
25
- or indirect, to cause the direction or management of such entity, whether
26
- by contract or otherwise, or (ii) ownership of fifty percent (50%) or more
27
- of the outstanding shares, or (iii) beneficial ownership of such entity.
28
-
29
-
30
-
31
- "You" (or "Your") shall mean an individual or Legal Entity exercising permissions
32
- granted by this License.
33
-
34
-
35
-
36
- "Source" form shall mean the preferred form for making modifications, including
37
- but not limited to software source code, documentation source, and configuration
38
- files.
39
-
40
-
41
-
42
- "Object" form shall mean any form resulting from mechanical transformation
43
- or translation of a Source form, including but not limited to compiled object
44
- code, generated documentation, and conversions to other media types.
45
-
46
-
47
-
48
- "Work" shall mean the work of authorship, whether in Source or Object form,
49
- made available under the License, as indicated by a copyright notice that
50
- is included in or attached to the work (an example is provided in the Appendix
51
- below).
52
-
53
-
54
-
55
- "Derivative Works" shall mean any work, whether in Source or Object form,
56
- that is based on (or derived from) the Work and for which the editorial revisions,
57
- annotations, elaborations, or other modifications represent, as a whole, an
58
- original work of authorship. For the purposes of this License, Derivative
59
- Works shall not include works that remain separable from, or merely link (or
60
- bind by name) to the interfaces of, the Work and Derivative Works thereof.
61
-
62
-
63
-
64
- "Contribution" shall mean any work of authorship, including the original version
65
- of the Work and any modifications or additions to that Work or Derivative
66
- Works thereof, that is intentionally submitted to Licensor for inclusion in
67
- the Work by the copyright owner or by an individual or Legal Entity authorized
68
- to submit on behalf of the copyright owner. For the purposes of this definition,
69
- "submitted" means any form of electronic, verbal, or written communication
70
- sent to the Licensor or its representatives, including but not limited to
71
- communication on electronic mailing lists, source code control systems, and
72
- issue tracking systems that are managed by, or on behalf of, the Licensor
73
- for the purpose of discussing and improving the Work, but excluding communication
74
- that is conspicuously marked or otherwise designated in writing by the copyright
75
- owner as "Not a Contribution."
76
-
77
-
78
-
79
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
80
- of whom a Contribution has been received by Licensor and subsequently incorporated
81
- within the Work.
82
-
83
- 2. Grant of Copyright License. Subject to the terms and conditions of this
84
- License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
85
- no-charge, royalty-free, irrevocable copyright license to reproduce, prepare
86
- Derivative Works of, publicly display, publicly perform, sublicense, and distribute
87
- the Work and such Derivative Works in Source or Object form.
88
-
89
- 3. Grant of Patent License. Subject to the terms and conditions of this License,
90
- each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
91
- no-charge, royalty-free, irrevocable (except as stated in this section) patent
92
- license to make, have made, use, offer to sell, sell, import, and otherwise
93
- transfer the Work, where such license applies only to those patent claims
94
- licensable by such Contributor that are necessarily infringed by their Contribution(s)
95
- alone or by combination of their Contribution(s) with the Work to which such
96
- Contribution(s) was submitted. If You institute patent litigation against
97
- any entity (including a cross-claim or counterclaim in a lawsuit) alleging
98
- that the Work or a Contribution incorporated within the Work constitutes direct
99
- or contributory patent infringement, then any patent licenses granted to You
100
- under this License for that Work shall terminate as of the date such litigation
101
- is filed.
102
-
103
- 4. Redistribution. You may reproduce and distribute copies of the Work or
104
- Derivative Works thereof in any medium, with or without modifications, and
105
- in Source or Object form, provided that You meet the following conditions:
106
-
107
- (a) You must give any other recipients of the Work or Derivative Works a copy
108
- of this License; and
109
-
110
- (b) You must cause any modified files to carry prominent notices stating that
111
- You changed the files; and
112
-
113
- (c) You must retain, in the Source form of any Derivative Works that You distribute,
114
- all copyright, patent, trademark, and attribution notices from the Source
115
- form of the Work, excluding those notices that do not pertain to any part
116
- of the Derivative Works; and
117
-
118
- (d) If the Work includes a "NOTICE" text file as part of its distribution,
119
- then any Derivative Works that You distribute must include a readable copy
120
- of the attribution notices contained within such NOTICE file, excluding those
121
- notices that do not pertain to any part of the Derivative Works, in at least
122
- one of the following places: within a NOTICE text file distributed as part
123
- of the Derivative Works; within the Source form or documentation, if provided
124
- along with the Derivative Works; or, within a display generated by the Derivative
125
- Works, if and wherever such third-party notices normally appear. The contents
126
- of the NOTICE file are for informational purposes only and do not modify the
127
- License. You may add Your own attribution notices within Derivative Works
128
- that You distribute, alongside or as an addendum to the NOTICE text from the
129
- Work, provided that such additional attribution notices cannot be construed
130
- as modifying the License.
131
-
132
- You may add Your own copyright statement to Your modifications and may provide
133
- additional or different license terms and conditions for use, reproduction,
134
- or distribution of Your modifications, or for any such Derivative Works as
135
- a whole, provided Your use, reproduction, and distribution of the Work otherwise
136
- complies with the conditions stated in this License.
137
-
138
- 5. Submission of Contributions. Unless You explicitly state otherwise, any
139
- Contribution intentionally submitted for inclusion in the Work by You to the
140
- Licensor shall be under the terms and conditions of this License, without
141
- any additional terms or conditions. Notwithstanding the above, nothing herein
142
- shall supersede or modify the terms of any separate license agreement you
143
- may have executed with Licensor regarding such Contributions.
144
-
145
- 6. Trademarks. This License does not grant permission to use the trade names,
146
- trademarks, service marks, or product names of the Licensor, except as required
147
- for reasonable and customary use in describing the origin of the Work and
148
- reproducing the content of the NOTICE file.
149
-
150
- 7. Disclaimer of Warranty. Unless required by applicable law or agreed to
151
- in writing, Licensor provides the Work (and each Contributor provides its
152
- Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
153
- KIND, either express or implied, including, without limitation, any warranties
154
- or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
155
- A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness
156
- of using or redistributing the Work and assume any risks associated with Your
157
- exercise of permissions under this License.
158
-
159
- 8. Limitation of Liability. In no event and under no legal theory, whether
160
- in tort (including negligence), contract, or otherwise, unless required by
161
- applicable law (such as deliberate and grossly negligent acts) or agreed to
162
- in writing, shall any Contributor be liable to You for damages, including
163
- any direct, indirect, special, incidental, or consequential damages of any
164
- character arising as a result of this License or out of the use or inability
165
- to use the Work (including but not limited to damages for loss of goodwill,
166
- work stoppage, computer failure or malfunction, or any and all other commercial
167
- damages or losses), even if such Contributor has been advised of the possibility
168
- of such damages.
169
-
170
- 9. Accepting Warranty or Additional Liability. While redistributing the Work
171
- or Derivative Works thereof, You may choose to offer, and charge a fee for,
172
- acceptance of support, warranty, indemnity, or other liability obligations
173
- and/or rights consistent with this License. However, in accepting such obligations,
174
- You may act only on Your own behalf and on Your sole responsibility, not on
175
- behalf of any other Contributor, and only if You agree to indemnify, defend,
176
- and hold each Contributor harmless for any liability incurred by, or claims
177
- asserted against, such Contributor by reason of your accepting any such warranty
178
- or additional liability. END OF TERMS AND CONDITIONS
179
-
180
- APPENDIX: How to apply the Apache License to your work.
181
-
182
- To apply the Apache License to your work, attach the following boilerplate
183
- notice, with the fields enclosed by brackets "[]" replaced with your own identifying
184
- information. (Don't include the brackets!) The text should be enclosed in
185
- the appropriate comment syntax for the file format. We also recommend that
186
- a file or class name and description of purpose be included on the same "printed
187
- page" as the copyright notice for easier identification within third-party
188
- archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
-
194
- you may not use this file except in compliance with the License.
195
-
196
- You may obtain a copy of the License at
197
-
198
- http://www.apache.org/licenses/LICENSE-2.0
199
-
200
- Unless required by applicable law or agreed to in writing, software
201
-
202
- distributed under the License is distributed on an "AS IS" BASIS,
203
-
204
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205
-
206
- See the License for the specific language governing permissions and
207
-
208
- limitations under the License.
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2018-2021 SAP SE or an SAP affiliate company and UI5 Tooling contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,5 +1,6 @@
1
1
  const middlewareRepository = require("./middlewareRepository");
2
2
  const MiddlewareUtil = require("./MiddlewareUtil");
3
+ const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
3
4
 
4
5
  /**
5
6
  *
@@ -125,17 +126,42 @@ class MiddlewareManager {
125
126
  "worker-src 'self' blob:; " +
126
127
  "child-src 'self' blob:; " +
127
128
  "connect-src 'self' https: wss:; " +
129
+ "base-uri 'self';",
130
+ "sap-target-level-3":
131
+ "default-src 'self'; " +
132
+ "script-src 'self'; " +
133
+ "style-src 'self'; " +
134
+ "font-src 'self'; " +
135
+ "img-src 'self' https:; " +
136
+ "media-src 'self' https:; " +
137
+ "object-src 'self'; " +
138
+ "frame-src 'self' https: gap: mailto: tel:; " +
139
+ "worker-src 'self'; " +
140
+ "child-src 'self'; " +
141
+ "connect-src 'self' https: wss:; " +
128
142
  "base-uri 'self';"
129
143
  }
130
144
  };
131
145
  if (this.options.sendSAPTargetCSP) {
132
- Object.assign(oCspConfig, {
146
+ const defaultSAPTargetConfig = {
133
147
  defaultPolicy: "sap-target-level-1",
134
148
  defaultPolicyIsReportOnly: true,
135
149
  defaultPolicy2: "sap-target-level-2",
136
150
  defaultPolicy2IsReportOnly: true,
137
151
  ignorePaths: ["test-resources/sap/ui/qunit/testrunner.html"]
138
- });
152
+ };
153
+ Object.assign(oCspConfig, defaultSAPTargetConfig);
154
+
155
+ if (typeof this.options.sendSAPTargetCSP === "object") {
156
+ for (const [name, value] of Object.entries(this.options.sendSAPTargetCSP)) {
157
+ if (!hasOwn(defaultSAPTargetConfig, name)) {
158
+ throw new TypeError(
159
+ `Unknown SAP Target CSP configuration option '${name}'. Allowed options are ` +
160
+ `${Object.keys(defaultSAPTargetConfig)}`);
161
+ }
162
+ oCspConfig[name] = value;
163
+ }
164
+ }
139
165
  }
140
166
  if (this.options.serveCSPReports) {
141
167
  Object.assign(oCspConfig, {
@@ -218,7 +244,8 @@ class MiddlewareManager {
218
244
  if (
219
245
  specVersion === "2.0" || specVersion === "2.1" ||
220
246
  specVersion === "2.2" || specVersion === "2.3" ||
221
- specVersion === "2.4"
247
+ specVersion === "2.4" || specVersion === "2.5" ||
248
+ specVersion === "2.6"
222
249
  ) {
223
250
  // Supply interface to MiddlewareUtil instance starting with specVersion 2.0
224
251
  params.middlewareUtil = middlewareUtil.getInterface(specVersion);
@@ -33,6 +33,8 @@ class MiddlewareUtil {
33
33
  case "2.2":
34
34
  case "2.3":
35
35
  case "2.4":
36
+ case "2.5":
37
+ case "2.6":
36
38
  return baseInterface;
37
39
  default:
38
40
  throw new Error(`MiddlewareUtil: Unknown or unsupported Specification Version ${specVersion}`);
@@ -1,4 +1,7 @@
1
1
  const createVersionInfoProcessor = require("@ui5/builder").processors.versionInfoGenerator;
2
+ const createManifestProcessor = require("@ui5/builder").processors.manifestCreator;
3
+
4
+ const MANIFEST_JSON = "manifest.json";
2
5
 
3
6
  /**
4
7
  * Creates and returns the middleware to create the version info as json object.
@@ -10,37 +13,61 @@ const createVersionInfoProcessor = require("@ui5/builder").processors.versionInf
10
13
  * @returns {Function} Returns a server middleware closure.
11
14
  */
12
15
  function createMiddleware({resources, tree: project}) {
13
- return function versionInfo(req, res, next) {
14
- resources.dependencies.byGlob("/resources/**/.library")
15
- .then((resources) => {
16
- resources.sort((a, b) => {
17
- return a._project.metadata.name.localeCompare(b._project.metadata.name);
18
- });
19
- return createVersionInfoProcessor({
20
- options: {
21
- rootProjectName: project.metadata.name,
22
- rootProjectVersion: project.version,
23
- libraryInfos: resources.map((dotLibResource) => {
24
- return {
25
- name: dotLibResource._project.metadata.name,
26
- version: dotLibResource._project.version
27
- };
28
- })
29
- }
30
- });
31
- })
32
- .then(([versionInfoResource]) => {
33
- return versionInfoResource.getBuffer();
34
- })
35
- .then((versionInfoContent) => {
36
- res.writeHead(200, {
37
- "Content-Type": "application/json"
16
+ return async function versionInfo(req, res, next) {
17
+ try {
18
+ const dependencies = resources.dependencies;
19
+ const dotLibResources = await dependencies.byGlob("/resources/**/.library");
20
+
21
+ dotLibResources.sort((a, b) => {
22
+ return a._project.metadata.name.localeCompare(b._project.metadata.name);
23
+ });
24
+
25
+ const libraryInfosPromises = dotLibResources.map(async (dotLibResource) => {
26
+ const namespace = dotLibResource._project.metadata.namespace;
27
+ const manifestResources = await dependencies.byGlob(`/resources/${namespace}/**/${MANIFEST_JSON}`);
28
+ let libraryManifest = manifestResources.find((manifestResource) => {
29
+ return manifestResource.getPath() === `/resources/${namespace}/${MANIFEST_JSON}`;
38
30
  });
39
- res.end(versionInfoContent.toString());
40
- })
41
- .catch((err) => {
42
- next(err);
31
+ const embeddedManifests =
32
+ manifestResources.filter((manifestResource) => manifestResource !== libraryManifest);
33
+ if (!libraryManifest) {
34
+ const extensions = "js,json,library,less,css,theming,theme,properties";
35
+ const libResources = await dependencies.byGlob(`/resources/${namespace}/**/*.{${extensions}}`);
36
+
37
+ libraryManifest = await createManifestProcessor({
38
+ libraryResource: dotLibResource,
39
+ namespace,
40
+ resources: libResources,
41
+ options: {
42
+ omitMinVersions: true
43
+ }
44
+ });
45
+ }
46
+ return {
47
+ libraryManifest,
48
+ embeddedManifests,
49
+ name: dotLibResource._project.metadata.name,
50
+ version: dotLibResource._project.version
51
+ };
52
+ });
53
+ const libraryInfos = await Promise.all(libraryInfosPromises);
54
+
55
+ const [versionInfoResource] = await createVersionInfoProcessor({
56
+ options: {
57
+ rootProjectName: project.metadata.name,
58
+ rootProjectVersion: project.version,
59
+ libraryInfos
60
+ }
61
+ });
62
+ const versionInfoContent = await versionInfoResource.getBuffer();
63
+
64
+ res.writeHead(200, {
65
+ "Content-Type": "application/json"
43
66
  });
67
+ res.end(versionInfoContent.toString());
68
+ } catch (err) {
69
+ next(err);
70
+ }
44
71
  };
45
72
  }
46
73
 
package/lib/server.js CHANGED
@@ -88,6 +88,20 @@ function _addSsl({app, key, cert}) {
88
88
  return require("spdy").createServer({cert, key}, app);
89
89
  }
90
90
 
91
+
92
+ /**
93
+ * SAP target CSP middleware options
94
+ *
95
+ * @public
96
+ * @typedef {object} module:@ui5/server.server.SAPTargetCSPOptions
97
+ * @property {string} [defaultPolicy="sap-target-level-1"]
98
+ * @property {string} [defaultPolicyIsReportOnly=true]
99
+ * @property {string} [defaultPolicy2="sap-target-level-2"]
100
+ * @property {string} [defaultPolicy2IsReportOnly=true]
101
+ * @property {string[]} [ignorePaths=["test-resources/sap/ui/qunit/testrunner.html"]]
102
+ */
103
+
104
+
91
105
  /**
92
106
  * @public
93
107
  * @namespace
@@ -105,14 +119,15 @@ module.exports = {
105
119
  * @param {boolean} [options.h2=false] Whether HTTP/2 should be used - defaults to <code>http</code>
106
120
  * @param {string} [options.key] Path to private key to be used for https
107
121
  * @param {string} [options.cert] Path to certificate to be used for for https
122
+ * @param {boolean} [options.simpleIndex=false] Use a simplified view for the server directory listing
108
123
  * @param {boolean} [options.acceptRemoteConnections=false] If true, listens to remote connections and
109
124
  * not only to localhost connections
110
- * @param {boolean} [options.sendSAPTargetCSP=false] If true, then the content security policies that SAP and UI5
111
- * aim for (AKA 'target policies'), are send for any requested
112
- * <code>*.html</code> file
113
- * @param {boolean} [options.simpleIndex=false] Use a simplified view for the server directory listing
114
- * @param {boolean} [options.serveCSPReports=false] Enable csp reports serving for request url
115
- * '/.ui5/csp/csp-reports.json'
125
+ * @param {boolean|module:@ui5/server.server.SAPTargetCSPOptions} [options.sendSAPTargetCSP=false]
126
+ * If set to <code>true</code> or an object, then the default (or configured)
127
+ * set of security policies that SAP and UI5 aim for (AKA 'target policies'),
128
+ * are send for any requested <code>*.html</code> file
129
+ * @param {boolean} [options.serveCSPReports=false] Enable CSP reports serving for request url
130
+ * '/.ui5/csp/csp-reports.json'
116
131
  * @returns {Promise<object>} Promise resolving once the server is listening.
117
132
  * It resolves with an object containing the <code>port</code>,
118
133
  * <code>h2</code>-flag and a <code>close</code> function,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/server",
3
- "version": "2.2.10",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "UI5 Tooling - Server",
5
5
  "author": {
6
6
  "name": "SAP SE",
@@ -104,10 +104,10 @@
104
104
  "url": "git@github.com:SAP/ui5-server.git"
105
105
  },
106
106
  "dependencies": {
107
- "@ui5/builder": "^2.9.0",
108
- "@ui5/fs": "^2.0.6",
109
- "@ui5/logger": "^2.0.1",
110
- "body-parser": "^1.19.0",
107
+ "@ui5/builder": "^3.0.0-alpha.0",
108
+ "@ui5/fs": "^3.0.0-alpha.0",
109
+ "@ui5/logger": "^3.0.0-alpha.0",
110
+ "body-parser": "^1.19.1",
111
111
  "compression": "^1.7.4",
112
112
  "connect-openui5": "^0.10.2",
113
113
  "cors": "^2.8.5",
@@ -116,34 +116,34 @@
116
116
  "etag": "^1.8.1",
117
117
  "express": "^4.17.1",
118
118
  "fresh": "^0.5.2",
119
- "graceful-fs": "^4.2.6",
119
+ "graceful-fs": "^4.2.8",
120
120
  "make-dir": "^3.1.0",
121
- "mime-types": "^2.1.30",
121
+ "mime-types": "^2.1.34",
122
122
  "parseurl": "^1.3.3",
123
123
  "portscanner": "^2.1.1",
124
124
  "replacestream": "^4.0.3",
125
- "router": "^1.3.5",
125
+ "router": "^1.3.6",
126
126
  "spdy": "^4.0.2",
127
127
  "treeify": "^1.0.1",
128
128
  "yesno": "^0.3.1"
129
129
  },
130
130
  "devDependencies": {
131
- "@ui5/project": "^2.3.1",
131
+ "@ui5/project": "^2.6.0",
132
132
  "ava": "^3.15.0",
133
- "chokidar-cli": "^2.1.0",
133
+ "chokidar-cli": "^3.0.0",
134
134
  "cross-env": "^7.0.3",
135
- "depcheck": "^1.4.1",
135
+ "depcheck": "^1.4.2",
136
136
  "docdash": "^1.2.0",
137
- "eslint": "^7.27.0",
137
+ "eslint": "^7.32.0",
138
138
  "eslint-config-google": "^0.14.0",
139
- "eslint-plugin-jsdoc": "^35.0.0",
139
+ "eslint-plugin-jsdoc": "^37.2.0",
140
140
  "jsdoc": "^3.6.7",
141
141
  "mock-require": "^3.0.3",
142
142
  "nyc": "^15.1.0",
143
143
  "open-cli": "^6.0.1",
144
144
  "rimraf": "^3.0.2",
145
- "sinon": "^11.1.1",
146
- "supertest": "^6.1.3",
145
+ "sinon": "^11.1.2",
146
+ "supertest": "^6.1.6",
147
147
  "tap-nyan": "^1.1.0",
148
148
  "tap-xunit": "^2.4.1"
149
149
  }