openbot 0.4.3 → 0.4.4

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/dist/app/cli.js CHANGED
@@ -16,7 +16,7 @@ function checkNodeVersion() {
16
16
  }
17
17
  }
18
18
  checkNodeVersion();
19
- program.name('openbot').description('OpenBot CLI').version('0.4.3');
19
+ program.name('openbot').description('OpenBot CLI').version('0.4.4');
20
20
  program
21
21
  .command('start')
22
22
  .description('Start the OpenBot harness')
@@ -129,6 +129,18 @@ export async function startServer(options = {}) {
129
129
  }
130
130
  }
131
131
  };
132
+ // Support for Chrome's Private Network Access (PNA)
133
+ // https://developer.chrome.com/blog/private-network-access-preflight/
134
+ app.use((req, res, next) => {
135
+ if (req.headers['access-control-request-private-network'] === 'true') {
136
+ res.setHeader('Access-Control-Allow-Private-Network', 'true');
137
+ }
138
+ // If it's a preflight request, we should also ensure the Vary header is set
139
+ if (req.method === 'OPTIONS') {
140
+ res.setHeader('Vary', 'Access-Control-Request-Private-Network');
141
+ }
142
+ next();
143
+ });
132
144
  app.use(cors());
133
145
  const resolvePublicBaseUrl = () => getPublicBaseUrl(PORT, config.publicUrl);
134
146
  app.use((req, res, next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openbot",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
package/src/app/cli.ts CHANGED
@@ -25,7 +25,7 @@ function checkNodeVersion() {
25
25
 
26
26
  checkNodeVersion();
27
27
 
28
- program.name('openbot').description('OpenBot CLI').version('0.4.3');
28
+ program.name('openbot').description('OpenBot CLI').version('0.4.4');
29
29
 
30
30
  program
31
31
  .command('start')
package/src/app/server.ts CHANGED
@@ -164,6 +164,19 @@ export async function startServer(options: ServerOptions = {}) {
164
164
  }
165
165
  };
166
166
 
167
+ // Support for Chrome's Private Network Access (PNA)
168
+ // https://developer.chrome.com/blog/private-network-access-preflight/
169
+ app.use((req, res, next) => {
170
+ if (req.headers['access-control-request-private-network'] === 'true') {
171
+ res.setHeader('Access-Control-Allow-Private-Network', 'true');
172
+ }
173
+ // If it's a preflight request, we should also ensure the Vary header is set
174
+ if (req.method === 'OPTIONS') {
175
+ res.setHeader('Vary', 'Access-Control-Request-Private-Network');
176
+ }
177
+ next();
178
+ });
179
+
167
180
  app.use(cors());
168
181
 
169
182
  const resolvePublicBaseUrl = () => getPublicBaseUrl(PORT, config.publicUrl);