@adobe/helix-html-pipeline 6.24.0 → 6.24.2

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
@@ -1,3 +1,17 @@
1
+ ## [6.24.2](https://github.com/adobe/helix-html-pipeline/compare/v6.24.1...v6.24.2) (2025-04-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Add script nonce to <link as=script> ([#850](https://github.com/adobe/helix-html-pipeline/issues/850)) ([182f281](https://github.com/adobe/helix-html-pipeline/commit/182f2816c018ed4e68af44ff3738ca9722984455))
7
+
8
+ ## [6.24.1](https://github.com/adobe/helix-html-pipeline/compare/v6.24.0...v6.24.1) (2025-03-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * support aem-gcp.page|live internal domain ([f6307bb](https://github.com/adobe/helix-html-pipeline/commit/f6307bb9a3704a5020738b1664a01b5201064f5a))
14
+
1
15
  # [6.24.0](https://github.com/adobe/helix-html-pipeline/compare/v6.23.0...v6.24.0) (2025-03-27)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.24.0",
3
+ "version": "6.24.2",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -54,9 +54,11 @@ const INTERNAL_DOMAINS = [
54
54
  '.aem.page',
55
55
  '.aem-fastly.page',
56
56
  '.aem-cloudflare.page',
57
+ '.aem-gcp.page',
57
58
  '.aem.live',
58
59
  '.aem-fastly.live',
59
60
  '.aem-cloudflare.live',
61
+ '.aem-gcp.live',
60
62
  '.hlx.page',
61
63
  '.hlx-fastly.page',
62
64
  '.hlx-cloudflare.page',
package/src/steps/csp.js CHANGED
@@ -111,9 +111,15 @@ function createAndApplyNonceOnAST(res, tree, metaCSP, headerCSP, headerCSPRO) {
111
111
  }
112
112
 
113
113
  visit(tree, (node) => {
114
- if (scriptNonce && node.tagName === 'script' && node.properties?.nonce === 'aem') {
115
- node.properties.nonce = nonce;
116
- return;
114
+ if (scriptNonce) {
115
+ if (node.tagName === 'script' && node.properties?.nonce === 'aem') {
116
+ node.properties.nonce = nonce;
117
+ return;
118
+ }
119
+ if (node.tagName === 'link' && node.properties?.as === 'script' && node.properties?.nonce === 'aem') {
120
+ node.properties.nonce = nonce;
121
+ return;
122
+ }
117
123
  }
118
124
 
119
125
  if (styleNonce
@@ -222,14 +228,34 @@ export function contentSecurityPolicyOnCode(state, res) {
222
228
  }
223
229
  }
224
230
 
225
- if (scriptNonce && tag.tagName === 'script' && tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')) {
226
- chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
227
- return;
231
+ if (scriptNonce) {
232
+ if (tag.tagName === 'script' && tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')) {
233
+ chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
234
+ return;
235
+ }
236
+
237
+ if (tag.tagName === 'link'
238
+ && tag.attrs.find((attr) => attr.name === 'as' && attr.value === 'script')
239
+ && tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')
240
+ ) {
241
+ chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
242
+ return;
243
+ }
228
244
  }
229
245
 
230
- if (styleNonce && (tag.tagName === 'style' || tag.tagName === 'link') && tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')) {
231
- chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
232
- return;
246
+ if (styleNonce) {
247
+ if (tag.tagName === 'style' && tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')) {
248
+ chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
249
+ return;
250
+ }
251
+
252
+ if (tag.tagName === 'link'
253
+ && tag.attrs.find((attr) => attr.name === 'rel' && attr.value === 'stylesheet')
254
+ && tag.attrs.find((attr) => attr.name === 'nonce' && attr.value === 'aem')
255
+ ) {
256
+ chunks.push(getRawHTML(tag).replace(/nonce="aem"/i, `nonce="${nonce}"`));
257
+ return;
258
+ }
233
259
  }
234
260
 
235
261
  chunks.push(getRawHTML(tag));