freertc 0.1.7 → 0.1.8

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/README.md CHANGED
@@ -216,7 +216,7 @@ Quick checks:
216
216
  Expected `/health` response includes JSON like:
217
217
 
218
218
  ```json
219
- {"ok":true,"version":"0.1.7","protocol_version":"1.0","peers":0}
219
+ {"ok":true,"version":"0.1.8","protocol_version":"1.0","peers":0}
220
220
  ```
221
221
 
222
222
  ## Auto WebRTC two-tab test
package/bin/freertc.mjs CHANGED
@@ -58,13 +58,51 @@ function runInProject(command, args, { bootstrap = false } = {}) {
58
58
  function requireWranglerConfig() {
59
59
  const configPath = path.join(PROJECT_ROOT, 'wrangler.jsonc');
60
60
  if (fs.existsSync(configPath)) {
61
- return;
61
+ return configPath;
62
62
  }
63
63
 
64
64
  console.error(`Missing ${configPath}. Run "npx freertc" or "npx freertc wizard" from this project directory first.`);
65
65
  process.exit(1);
66
66
  }
67
67
 
68
+ function validateWranglerConfigForDeploy(configPath) {
69
+ const configText = fs.readFileSync(configPath, 'utf8');
70
+ const failures = [];
71
+
72
+ const placeholderChecks = [
73
+ { test: /YOUR_D1_DATABASE_ID/, message: 'Replace YOUR_D1_DATABASE_ID in wrangler.jsonc.' },
74
+ { test: /Your App Relay/, message: 'Set vars.RELAY_NAME to your actual relay name.' },
75
+ { test: /wss:\/\/your-domain\.example\/ws/i, message: 'Set vars.RELAY_URL to your real deployed relay WebSocket URL.' },
76
+ { test: /"main"\s*:\s*"build\/worker\/shim\.mjs"/, message: 'Switch wrangler.jsonc main to src/index.js unless you intentionally use the Rust/WASM worker path.' },
77
+ { test: /"command"\s*:\s*"worker-build --release"/, message: 'Remove the worker-build step unless you intentionally deploy the Rust/WASM worker path.' }
78
+ ];
79
+
80
+ for (const check of placeholderChecks) {
81
+ if (check.test.test(configText)) {
82
+ failures.push(check.message);
83
+ }
84
+ }
85
+
86
+ const relayUrlMatch = configText.match(/"RELAY_URL"\s*:\s*"([^"]*)"/);
87
+ if (!relayUrlMatch || !/^wss:\/\/[^\s"/]+\/ws$/i.test(relayUrlMatch[1])) {
88
+ failures.push('Set vars.RELAY_URL to a valid wss://<host>/ws URL.');
89
+ }
90
+
91
+ const relayNameMatch = configText.match(/"RELAY_NAME"\s*:\s*"([^"]*)"/);
92
+ if (!relayNameMatch || !relayNameMatch[1].trim()) {
93
+ failures.push('Set vars.RELAY_NAME to a non-empty relay name.');
94
+ }
95
+
96
+ if (failures.length > 0) {
97
+ console.error(`Refusing to deploy with placeholder or invalid wrangler config: ${configPath}`);
98
+ for (const failure of failures) {
99
+ console.error(`- ${failure}`);
100
+ }
101
+ console.error('Run "npx freertc wizard" in the domain repo to patch wrangler.jsonc before deploying.');
102
+ process.exit(1);
103
+ }
104
+ }
105
+
68
106
  function compareVersions(left, right) {
69
107
  const leftParts = String(left).split('.').map((value) => Number.parseInt(value, 10) || 0);
70
108
  const rightParts = String(right).split('.').map((value) => Number.parseInt(value, 10) || 0);
@@ -143,7 +181,8 @@ async function main() {
143
181
  if (subcommand === 'deploy') {
144
182
  await assertLatestCliForDeploy();
145
183
  ensureProjectFiles(PROJECT_ROOT);
146
- requireWranglerConfig();
184
+ const configPath = requireWranglerConfig();
185
+ validateWranglerConfigForDeploy(configPath);
147
186
  const wrangler = resolveWranglerCommand(PROJECT_ROOT);
148
187
  runInProject(wrangler.command, [...wrangler.baseArgs, 'deploy', '--env', 'production', ...rest]);
149
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freertc",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Cloudflare Worker signaling relay for WebRTC peers with D1 storage.",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
7
7
  import { WebSocketServer } from 'ws';
8
8
 
9
9
  const PSP_VERSION = '1.0';
10
- const WORKER_VERSION = '0.1.7';
10
+ const WORKER_VERSION = '0.1.8';
11
11
  const DEFAULT_TTL_MS = 30_000;
12
12
  const MAX_TTL_MS = 120_000;
13
13
  const MAX_MESSAGE_SIZE = 64 * 1024;
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const PSP_VERSION = "1.0";
2
- const WORKER_VERSION = "0.1.7";
2
+ const WORKER_VERSION = "0.1.8";
3
3
 
4
4
  const DISCOVERY_TYPES = new Set(["announce", "withdraw", "discover", "peer_list", "redirect"]);
5
5
  const NEGOTIATION_TYPES = new Set(["connect_request", "connect_accept", "connect_reject", "offer", "answer", "ice_candidate", "ice_end", "renegotiate"]);