@adobe/helix-html-pipeline 4.1.1 → 4.1.3
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 +14 -0
- package/package.json +5 -5
- package/src/steps/fetch-config-all.js +6 -56
- package/src/utils/auth.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [4.1.3](https://github.com/adobe/helix-html-pipeline/compare/v4.1.2...v4.1.3) (2023-08-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* respond with 401 for invalid auth config ([#375](https://github.com/adobe/helix-html-pipeline/issues/375)) ([84db035](https://github.com/adobe/helix-html-pipeline/commit/84db035f00d648d4daac99249978a6fb4d3d83f0)), closes [#374](https://github.com/adobe/helix-html-pipeline/issues/374)
|
|
7
|
+
|
|
8
|
+
## [4.1.2](https://github.com/adobe/helix-html-pipeline/compare/v4.1.1...v4.1.2) (2023-08-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove legacy loading of metadata.json ([#373](https://github.com/adobe/helix-html-pipeline/issues/373)) ([90b665f](https://github.com/adobe/helix-html-pipeline/commit/90b665f18128a7924b32ea3526ccb24342a09a41))
|
|
14
|
+
|
|
1
15
|
## [4.1.1](https://github.com/adobe/helix-html-pipeline/compare/v4.1.0...v4.1.1) (2023-07-27)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"@semantic-release/changelog": "6.0.3",
|
|
73
73
|
"@semantic-release/git": "10.0.1",
|
|
74
74
|
"@semantic-release/npm": "10.0.4",
|
|
75
|
-
"c8": "8.0.
|
|
76
|
-
"eslint": "8.
|
|
75
|
+
"c8": "8.0.1",
|
|
76
|
+
"eslint": "8.46.0",
|
|
77
77
|
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
78
78
|
"eslint-plugin-header": "3.1.1",
|
|
79
|
-
"eslint-plugin-import": "2.
|
|
80
|
-
"esmock": "2.3.
|
|
79
|
+
"eslint-plugin-import": "2.28.0",
|
|
80
|
+
"esmock": "2.3.5",
|
|
81
81
|
"husky": "8.0.3",
|
|
82
82
|
"js-yaml": "4.1.0",
|
|
83
83
|
"jsdom": "22.1.0",
|
|
@@ -12,60 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
import { PipelineStatusError } from '../PipelineStatusError.js';
|
|
14
14
|
import { extractLastModified, updateLastModified } from '../utils/last-modified.js';
|
|
15
|
-
import {
|
|
15
|
+
import { globToRegExp, Modifiers } from '../utils/modifiers.js';
|
|
16
16
|
import { getOriginalHost } from './utils.js';
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Loads the metadata.json from the content-bus and stores it in `state.metadata` and
|
|
20
|
-
* `state.headers` in modifier form.
|
|
21
|
-
* this is to be backward compatible and can be removed in the future.
|
|
22
|
-
*
|
|
23
|
-
* @type PipelineStep
|
|
24
|
-
* @param {PipelineState} state
|
|
25
|
-
* @param {PipelineRequest} req
|
|
26
|
-
* @param {PipelineResponse} res
|
|
27
|
-
* @returns {Promise<void>}
|
|
28
|
-
*/
|
|
29
|
-
async function fetchMetadata(state, req, res) {
|
|
30
|
-
const { contentBusId, partition } = state;
|
|
31
|
-
const key = `${contentBusId}/${partition}/metadata.json`;
|
|
32
|
-
const ret = await state.s3Loader.getObject('helix-content-bus', key);
|
|
33
|
-
if (ret.status === 200) {
|
|
34
|
-
let json;
|
|
35
|
-
try {
|
|
36
|
-
json = JSON.parse(ret.body);
|
|
37
|
-
} catch (e) {
|
|
38
|
-
throw new PipelineStatusError(500, `failed parsing of /metadata.json: ${e.message}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const { data } = json.default ?? json;
|
|
42
|
-
if (!Array.isArray(data)) {
|
|
43
|
-
throw new PipelineStatusError(500, 'failed loading of /metadata.json: data must be an array');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
state.metadata = Modifiers.fromModifierSheet(
|
|
47
|
-
data,
|
|
48
|
-
(name) => !ALLOWED_RESPONSE_HEADERS.includes(name),
|
|
49
|
-
);
|
|
50
|
-
state.headers = Modifiers.fromModifierSheet(
|
|
51
|
-
data,
|
|
52
|
-
(name) => ALLOWED_RESPONSE_HEADERS.includes(name),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
if (state.type === 'html' && state.info.selector !== 'plain') {
|
|
56
|
-
// also update last-modified (only for extensionless html pipeline)
|
|
57
|
-
updateLastModified(state, res, extractLastModified(ret.headers));
|
|
58
|
-
}
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (ret.status !== 404) {
|
|
63
|
-
throw new PipelineStatusError(502, `failed to load /metadata.json: ${ret.status}`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ignore 404
|
|
67
|
-
}
|
|
68
|
-
|
|
69
18
|
/**
|
|
70
19
|
* Computes the routes from the given config value.
|
|
71
20
|
* @param {string|string[]|undefined} value
|
|
@@ -129,11 +78,12 @@ export default async function fetchConfigAll(state, req, res) {
|
|
|
129
78
|
// set custom preview and live hosts
|
|
130
79
|
state.previewHost = replaceParams(state.config.cdn?.preview?.host, state);
|
|
131
80
|
state.liveHost = replaceParams(state.config.cdn?.live?.host, state);
|
|
132
|
-
} else if (ret.status
|
|
133
|
-
|
|
81
|
+
} else if (ret.status === 404) {
|
|
82
|
+
state.config = {};
|
|
83
|
+
state.metadata = new Modifiers({});
|
|
84
|
+
state.headers = new Modifiers({});
|
|
134
85
|
} else {
|
|
135
|
-
|
|
136
|
-
await fetchMetadata(state, req, res);
|
|
86
|
+
throw new PipelineStatusError(502, `failed to load /.helix/config-all.json: ${ret.status}`);
|
|
137
87
|
}
|
|
138
88
|
|
|
139
89
|
// compute host and routes
|
package/src/utils/auth.js
CHANGED
|
@@ -221,7 +221,7 @@ export class AuthInfo {
|
|
|
221
221
|
const { clientId, clientSecret } = idp.client(state);
|
|
222
222
|
if (!clientId || !clientSecret) {
|
|
223
223
|
log.error('[auth] unable to create login redirect: missing client_id or client_secret');
|
|
224
|
-
res.status =
|
|
224
|
+
res.status = 401;
|
|
225
225
|
res.error = 'invalid auth config.';
|
|
226
226
|
return;
|
|
227
227
|
}
|