@sovovs/bycli 2.1.1 → 2.1.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.
@@ -0,0 +1,2 @@
1
+ export type DaemonHost = '127.0.0.1' | '0.0.0.0';
2
+ export declare function resolveDaemonHost(env?: NodeJS.ProcessEnv): DaemonHost;
@@ -0,0 +1,11 @@
1
+ import { ConfigError } from './errors.js';
2
+ export function resolveDaemonHost(env = process.env) {
3
+ const raw = env.BYCLI_DAEMON_HOST;
4
+ if (raw === undefined || raw === '') {
5
+ return '127.0.0.1';
6
+ }
7
+ if (raw === '127.0.0.1' || raw === '0.0.0.0') {
8
+ return raw;
9
+ }
10
+ throw new ConfigError(`config_invalid: BYCLI_DAEMON_HOST=${raw} is not allowed`, 'Use 127.0.0.1 for local use or 0.0.0.0 for an isolated sandbox.');
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -17,6 +17,6 @@
17
17
  * Lifecycle:
18
18
  * - Auto-spawned by bycli on first browser command
19
19
  * - Persistent — stays alive until explicit shutdown, SIGTERM, or uninstall
20
- * - Listens on localhost:19825
20
+ * - Listens on 127.0.0.1:19825 by default; isolated sandboxes may opt into 0.0.0.0
21
21
  */
22
22
  export {};
@@ -17,7 +17,7 @@
17
17
  * Lifecycle:
18
18
  * - Auto-spawned by bycli on first browser command
19
19
  * - Persistent — stays alive until explicit shutdown, SIGTERM, or uninstall
20
- * - Listens on localhost:19825
20
+ * - Listens on 127.0.0.1:19825 by default; isolated sandboxes may opt into 0.0.0.0
21
21
  */
22
22
  import { createServer } from 'node:http';
23
23
  import { WebSocketServer, WebSocket } from 'ws';
@@ -37,7 +37,9 @@ import { defaultSessionKeyRegistry } from './recorder/runner/session-keys.js';
37
37
  import { recordExtensionVersion } from './update-check.js';
38
38
  import { EXTENSION_CAPABILITY_MISSING_ERROR_CODE, EXTENSION_CAPABILITY_MISSING_HTTP_STATUS, extensionCapabilityHint, missingRequiredExtensionCapability, normalizeExtensionCapabilities, } from './browser/extension-capabilities.js';
39
39
  import { buildCommandDispatchFailure, buildExtensionDisconnectFailure, getResponseCorsHeaders, } from './daemon-utils.js';
40
+ import { resolveDaemonHost } from './daemon-config.js';
40
41
  const PORT = parseInt(process.env.BYCLI_DAEMON_PORT ?? String(DEFAULT_DAEMON_PORT), 10);
42
+ const HOST = resolveDaemonHost();
41
43
  // The verify runner (M6b) spawns child processes that connect back to THIS daemon for a
42
44
  // browser Page. Hand them our port (→ BYCLI_DAEMON_PORT in the child env) so the child's
43
45
  // Page reaches us, not a freshly-spawned daemon. Must run before the first /v1/verify
@@ -585,8 +587,8 @@ wss.on('connection', (ws) => {
585
587
  });
586
588
  });
587
589
  // ─── Start ───────────────────────────────────────────────────────────
588
- httpServer.listen(PORT, '127.0.0.1', () => {
589
- log.info(`[daemon] Listening on http://127.0.0.1:${PORT}`);
590
+ httpServer.listen(PORT, HOST, () => {
591
+ log.info(`[daemon] Listening on http://${HOST}:${PORT}`);
590
592
  // Temp-store reap policy (M7b · 09:27-29). Resolved once at startup; out-of-range env → throws,
591
593
  // but we keep the daemon alive by falling back to the (validated-elsewhere) defaults on error.
592
594
  let tempPolicy;
@@ -142,7 +142,33 @@ export async function handleVerify(ctx, body) {
142
142
  const executionSeedArgs = body.executionSeedArgs && typeof body.executionSeedArgs === 'object' && !Array.isArray(body.executionSeedArgs)
143
143
  ? body.executionSeedArgs
144
144
  : undefined;
145
- const input = { name, requestId, sessionId, executionSeedArgs, fixture, trace };
145
+ const adapterPathRaw = body.adapterPath;
146
+ const expectedSourceSha256Raw = body.expectedSourceSha256;
147
+ const invalidAdapterPath = adapterPathRaw !== undefined
148
+ && (typeof adapterPathRaw !== 'string' || adapterPathRaw.trim().length === 0);
149
+ const invalidExpectedSourceHash = expectedSourceSha256Raw !== undefined
150
+ && (typeof expectedSourceSha256Raw !== 'string' || !/^[0-9a-f]{64}$/.test(expectedSourceSha256Raw));
151
+ if (invalidAdapterPath || invalidExpectedSourceHash) {
152
+ ctx.registry.finalizeRequest(requestId, {
153
+ status: 'failed',
154
+ error: errorBody('validation_failed', 'adapterPath or expectedSourceSha256 is invalid'),
155
+ });
156
+ return { status: 202, body: accepted(requestId) };
157
+ }
158
+ const adapterPath = typeof adapterPathRaw === 'string' ? adapterPathRaw : undefined;
159
+ const expectedSourceSha256 = typeof expectedSourceSha256Raw === 'string'
160
+ ? expectedSourceSha256Raw
161
+ : undefined;
162
+ const input = {
163
+ name,
164
+ requestId,
165
+ sessionId,
166
+ executionSeedArgs,
167
+ fixture,
168
+ trace,
169
+ adapterPath,
170
+ expectedSourceSha256,
171
+ };
146
172
  const result = await verifyAdapter(input, sessionHmacKey, ctx.runner);
147
173
  if (!result.ok) {
148
174
  ctx.registry.finalizeRequest(requestId, { status: 'failed', error: errorBody(result.errorCode, result.reason) });
@@ -236,7 +236,7 @@ export async function runVerifyRunner(input, emit, dependencies = {}) {
236
236
  emit({
237
237
  type: 'result', requestId: input.requestId, ok: false,
238
238
  data: { stage: 'load', sourceSha256 },
239
- error: { code: 'source_hash_mismatch', message: 'adapter source hash does not match expected source' },
239
+ error: { code: 'validation_failed', message: 'adapter source hash does not match expected source' },
240
240
  });
241
241
  return;
242
242
  }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sovovs/bycli",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },