@wenrwa/marketplace-cli 0.4.1 → 0.4.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.
@@ -125,6 +125,21 @@ describe('bridge WebSocket server', () => {
125
125
  expect(bad.status).toBe(403);
126
126
  expect(bad.headers.get('access-control-allow-origin')).toBeNull();
127
127
  });
128
+ it('answers the Chrome Private-Network-Access preflight for the arena origin', async () => {
129
+ const res = await fetch(`http://127.0.0.1:${handle.port}/discovery`, {
130
+ method: 'OPTIONS',
131
+ headers: { origin: ORIGIN, 'Access-Control-Request-Private-Network': 'true' },
132
+ });
133
+ expect(res.status).toBe(204);
134
+ expect(res.headers.get('access-control-allow-origin')).toBe(ORIGIN);
135
+ expect(res.headers.get('access-control-allow-private-network')).toBe('true');
136
+ expect(res.headers.get('access-control-allow-methods')).toContain('GET');
137
+ const bad = await fetch(`http://127.0.0.1:${handle.port}/discovery`, {
138
+ method: 'OPTIONS',
139
+ headers: { origin: 'https://evil.example' },
140
+ });
141
+ expect(bad.status).toBe(403);
142
+ });
128
143
  it('unauthenticated frames are rejected', async () => {
129
144
  const ws = connect(handle.port);
130
145
  await new Promise((r) => ws.on('open', r));
@@ -63,6 +63,23 @@ function startBridgeServer(opts) {
63
63
  // read it. (Same-machine cross-user curl with a forged Origin remains
64
64
  // possible; documented as out of scope for v1 in PROTOCOL.md.)
65
65
  const httpServer = http.createServer((req, res) => {
66
+ // Chrome Private-Network-Access: a public origin (app.hiveop.io) calling a
67
+ // local address sends an OPTIONS preflight that MUST be answered with
68
+ // Access-Control-Allow-Private-Network, or the browser blocks discovery.
69
+ if (req.method === 'OPTIONS' && req.url === '/discovery') {
70
+ if (req.headers.origin !== opts.allowedOrigin) {
71
+ res.writeHead(403).end();
72
+ return;
73
+ }
74
+ res.writeHead(204, {
75
+ 'access-control-allow-origin': opts.allowedOrigin,
76
+ 'access-control-allow-private-network': 'true',
77
+ 'access-control-allow-methods': 'GET, OPTIONS',
78
+ 'access-control-max-age': '600',
79
+ });
80
+ res.end();
81
+ return;
82
+ }
66
83
  if (req.method === 'GET' && req.url === '/discovery') {
67
84
  if (req.headers.origin !== opts.allowedOrigin) {
68
85
  res.writeHead(403).end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenrwa/marketplace-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "CLI tool for the Wenrwa Agent Marketplace — monitor bounties, agents, workspaces, and treasury from your terminal",
5
5
  "author": "Wenrwa <dev@wenrwa.com>",
6
6
  "license": "MIT",