@adobe/aem-cli 16.7.32 → 16.8.1

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
+ ## [16.8.1](https://github.com/adobe/helix-cli/compare/v16.8.0...v16.8.1) (2024-12-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency chokidar to v4.0.3 ([#2468](https://github.com/adobe/helix-cli/issues/2468)) ([4225436](https://github.com/adobe/helix-cli/commit/4225436b38f180510b1d472119452286b2bc186d))
7
+
8
+ # [16.8.0](https://github.com/adobe/helix-cli/compare/v16.7.32...v16.8.0) (2024-12-16)
9
+
10
+
11
+ ### Features
12
+
13
+ * Allow passing site token for hlx5 authenticated sites ([#2465](https://github.com/adobe/helix-cli/issues/2465)) ([f3bde8f](https://github.com/adobe/helix-cli/commit/f3bde8f1b5c3f9763bb4039159ae89a85ec23c28))
14
+
1
15
  ## [16.7.32](https://github.com/adobe/helix-cli/compare/v16.7.31...v16.7.32) (2024-12-15)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aem-cli",
3
- "version": "16.7.32",
3
+ "version": "16.8.1",
4
4
  "description": "AEM CLI",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -45,7 +45,7 @@
45
45
  "@adobe/helix-shared-indexer": "2.2.2",
46
46
  "camelcase": "8.0.0",
47
47
  "chalk-template": "1.1.0",
48
- "chokidar": "4.0.1",
48
+ "chokidar": "4.0.3",
49
49
  "compression": "1.7.5",
50
50
  "cookie": "1.0.2",
51
51
  "cookie-parser": "1.4.7",
@@ -76,7 +76,7 @@ export default class HeadHtmlSupport {
76
76
  }
77
77
 
78
78
  constructor({
79
- proxyUrl, directory, allowInsecure, log,
79
+ proxyUrl, directory, allowInsecure, log, siteToken,
80
80
  }) {
81
81
  this.remoteHtml = '';
82
82
  this.remoteDom = null;
@@ -84,6 +84,7 @@ export default class HeadHtmlSupport {
84
84
  this.localHtml = '';
85
85
  this.localStatus = 0;
86
86
  this.cookie = '';
87
+ this.siteToken = siteToken;
87
88
  this.url = new URL(proxyUrl);
88
89
  this.url.pathname = '/head.html';
89
90
  this.filePath = resolve(directory, 'head.html');
@@ -97,6 +98,10 @@ export default class HeadHtmlSupport {
97
98
  if (this.cookie) {
98
99
  headers.cookie = this.cookie;
99
100
  }
101
+ // hlx 5 site auth
102
+ if (this.siteToken) {
103
+ headers.authorization = `token ${this.siteToken}`;
104
+ }
100
105
  const resp = await getFetch(this.allowInsecure)(this.url, {
101
106
  cache: 'no-store',
102
107
  headers,
@@ -32,6 +32,11 @@ export class HelixProject extends BaseProject {
32
32
  return this;
33
33
  }
34
34
 
35
+ withSiteToken(value) {
36
+ this._server.withSiteToken(value);
37
+ return this;
38
+ }
39
+
35
40
  withProxyUrl(value) {
36
41
  this._proxyUrl = value;
37
42
  return this;
@@ -88,6 +93,7 @@ export class HelixProject extends BaseProject {
88
93
  log: this.log,
89
94
  proxyUrl: this.proxyUrl,
90
95
  allowInsecure: this.allowInsecure,
96
+ siteToken: this.siteToken,
91
97
  });
92
98
 
93
99
  // register local head in live-reload
@@ -34,6 +34,11 @@ export class HelixServer extends BaseServer {
34
34
  return this;
35
35
  }
36
36
 
37
+ withSiteToken(value) {
38
+ this._siteToken = value;
39
+ return this;
40
+ }
41
+
37
42
  /**
38
43
  * Proxy Mode route handler
39
44
  * @param {Express.Request} req request
@@ -98,12 +103,14 @@ export class HelixServer extends BaseServer {
98
103
  for (const [key, value] of proxyUrl.searchParams.entries()) {
99
104
  url.searchParams.append(key, value);
100
105
  }
106
+
101
107
  await utils.proxyRequest(ctx, url.href, req, res, {
102
108
  injectLiveReload: this._project.liveReload,
103
109
  headHtml: this._project.headHtml,
104
110
  indexer: this._project.indexer,
105
111
  cacheDirectory: this._project.cacheDirectory,
106
112
  file404html: this._project.file404html,
113
+ siteToken: this._siteToken,
107
114
  });
108
115
  } catch (err) {
109
116
  log.error(`${pfx}failed to proxy AEM request ${ctx.path}: ${err.message}`);
@@ -246,6 +246,12 @@ window.LiveReloadOptions = {
246
246
  ...req.headers,
247
247
  ...(opts.headers || {}),
248
248
  };
249
+
250
+ // hlx 5 site auth
251
+ if (opts.siteToken) {
252
+ headers.authorization = `token ${opts.siteToken}`;
253
+ }
254
+
249
255
  // preserve hlx-auth-token cookie
250
256
  const cookies = cookie.parse(headers.cookie || '');
251
257
  delete headers.cookie;
@@ -255,6 +261,7 @@ window.LiveReloadOptions = {
255
261
  'hlx-auth-token': hlxAuthToken,
256
262
  }).toString();
257
263
  }
264
+
258
265
  delete headers.connection;
259
266
  delete headers['proxy-connection'];
260
267
  delete headers.host;
package/src/up.cmd.js CHANGED
@@ -40,6 +40,11 @@ export default class UpCommand extends AbstractServerCommand {
40
40
  return this;
41
41
  }
42
42
 
43
+ withSiteToken(value) {
44
+ this._siteToken = value;
45
+ return this;
46
+ }
47
+
43
48
  async doStop() {
44
49
  await super.doStop();
45
50
  if (this._watcher) {
@@ -71,7 +76,9 @@ export default class UpCommand extends AbstractServerCommand {
71
76
  .withLogger(this._logger)
72
77
  .withKill(this._kill)
73
78
  .withPrintIndex(this._printIndex)
74
- .withAllowInsecure(this._allowInsecure);
79
+ .withAllowInsecure(this._allowInsecure)
80
+ .withSiteToken(this._siteToken);
81
+
75
82
  this.log.info(chalk`{yellow ___ ________ ___ __ __ v${pkgJson.version}}`);
76
83
  this.log.info(chalk`{yellow / | / ____/ |/ / _____(_)___ ___ __ __/ /___ _/ /_____ _____}`);
77
84
  this.log.info(chalk`{yellow / /| | / __/ / /|_/ / / ___/ / __ \`__ \\/ / / / / __ \`/ __/ __ \\/ ___/}`);
package/src/up.js CHANGED
@@ -51,6 +51,11 @@ export default function up() {
51
51
  type: 'int',
52
52
  default: 3000,
53
53
  })
54
+ .option('site-token', {
55
+ alias: 'siteToken',
56
+ describe: 'Site token to be used by the cli to access the website',
57
+ type: 'string',
58
+ })
54
59
  .option('addr', {
55
60
  describe: 'Bind development server on addr. use * to bind to any address and allow external connections.',
56
61
  type: 'string',
@@ -116,6 +121,7 @@ export default function up() {
116
121
  .withOpen(path.basename(argv.$0) === 'aem' ? argv.open : false)
117
122
  .withTLS(argv.tlsKey, argv.tlsCert)
118
123
  .withLiveReload(argv.livereload)
124
+ .withSiteToken(argv.siteToken)
119
125
  .withUrl(argv.url)
120
126
  .withPrintIndex(argv.printIndex)
121
127
  .withAllowInsecure(argv.allowInsecure)