@norskvideo/ctl-test-harness 0.1.108 → 0.1.109

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.
Files changed (2) hide show
  1. package/demo/run.js +16 -4
  2. package/package.json +1 -1
package/demo/run.js CHANGED
@@ -585,16 +585,28 @@ export class DemoSession {
585
585
  * auth setting the daemon reads at boot. Returns the daemon's relay env. */
586
586
  async prepareMoqRelay(opts) {
587
587
  const auth = opts.auth ?? "off";
588
- if (auth !== "off") {
589
- const argv = ["config", "set", "--moq-relay-auth", auth];
588
+ // The relay's fingerprint and WebSocket fallback are advertised on the
589
+ // proxy's base URL, i.e. the daemon's public host. In direct reach the
590
+ // browser is in this runner container and reaches the proxy at proxyHost
591
+ // (the host gateway), not the daemon's default of localhost.
592
+ const advertiseProxy = netReachMode() === "direct" && this.publicHost === undefined && this.proxyHost !== "localhost";
593
+ const settings = [
594
+ ...(auth !== "off" ? [{ flag: "--moq-relay-auth", key: "moqRelayAuth", value: auth }] : []),
595
+ ...(advertiseProxy ? [{ flag: "--public-host", key: "publicHost", value: this.proxyHost }] : []),
596
+ ];
597
+ if (settings.length > 0) {
598
+ const argv = ["config", "set", ...settings.flatMap((x) => [x.flag, x.value])];
590
599
  const r = await this.deps.cli(this.storeDir, ["--port", NO_DAEMON_PORT, ...argv]);
591
600
  this.transcript.push({ argv, stdout: r.stdout, stderr: r.stderr, exitCode: r.exitCode });
592
601
  if (r.exitCode !== 0) {
593
602
  throw new Error(`norsk-ctl ${argv.join(" ")} failed (exit ${r.exitCode}):\n${r.stderr || r.stdout}`);
594
603
  }
595
604
  const config = this.deps.readFile(join(this.storeDir, CONFIG_FILE)) ?? "";
596
- if (!new RegExp(`^moqRelayAuth:\\s*["']?${auth}["']?\\s*$`, "m").test(config)) {
597
- throw new Error(`norsk-ctl ${argv.join(" ")} left no moqRelayAuth: ${auth} in ${join(this.storeDir, CONFIG_FILE)} — the resolved ctl predates the moqRelayAuth setting`);
605
+ for (const x of settings) {
606
+ const escaped = x.value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
607
+ if (!new RegExp(`^${x.key}:\\s*["']?${escaped}["']?\\s*$`, "m").test(config)) {
608
+ throw new Error(`norsk-ctl ${argv.join(" ")} left no ${x.key}: ${x.value} in ${join(this.storeDir, CONFIG_FILE)} — the resolved ctl predates the ${x.key} setting`);
609
+ }
598
610
  }
599
611
  }
600
612
  const freePort = this.deps.freePort ?? ((taken) => freeHostPort({ taken }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norskvideo/ctl-test-harness",
3
- "version": "0.1.108",
3
+ "version": "0.1.109",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {