@factiii/runner 0.9.5 → 0.9.7

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/dist/cli.js +26 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -23834,14 +23834,26 @@ function toRtcIceServers(servers) {
23834
23834
  for (const server of servers) {
23835
23835
  const urls = Array.isArray(server.urls) ? server.urls : [server.urls];
23836
23836
  for (const url2 of urls) {
23837
- const turn = /^(turns?):(.+)$/.exec(url2);
23837
+ const turn = /^(turns?):([^:?]+)(?::(\d+))?(?:\?transport=(udp|tcp))?$/.exec(
23838
+ url2
23839
+ );
23838
23840
  if (!turn || !server.username || !server.credential) {
23839
23841
  out.push(url2);
23840
23842
  continue;
23841
23843
  }
23842
- const user = encodeURIComponent(server.username);
23843
- const pass = encodeURIComponent(server.credential);
23844
- out.push(`${turn[1]}:${user}:${pass}@${turn[2]}`);
23844
+ const [, scheme, hostname, port, transport] = turn;
23845
+ out.push({
23846
+ hostname,
23847
+ port: Number(port ?? (scheme === "turns" ? 5349 : 3478)),
23848
+ username: server.username,
23849
+ password: server.credential,
23850
+ // String literals, not the RelayType members: it is a `const enum`,
23851
+ // so it is erased at compile time and has no runtime object to read —
23852
+ // `RelayType.TurnUdp` threw, which killed the offer handler before it
23853
+ // could answer and made every connection fail, not just the relayed
23854
+ // ones. The enum's values are exactly these strings.
23855
+ relayType: scheme === "turns" ? "TurnTls" : transport === "tcp" ? "TurnTcp" : "TurnUdp"
23856
+ });
23845
23857
  }
23846
23858
  }
23847
23859
  return out.length > 0 ? out : fallback;
@@ -24126,9 +24138,17 @@ async function startDaemon(config) {
24126
24138
  console.log(`Received WebRTC offer from ${data.fromSocketId}`);
24127
24139
  const scope = toChannelScope(data.scope);
24128
24140
  try {
24129
- const iceServers = toRtcIceServers(data.iceServers);
24141
+ let iceServers;
24142
+ try {
24143
+ iceServers = toRtcIceServers(data.iceServers);
24144
+ } catch (error) {
24145
+ console.error("[webrtc] ICE server list unusable, using STUN:", error);
24146
+ iceServers = ["stun:stun.l.google.com:19302"];
24147
+ }
24130
24148
  console.log(
24131
- `[webrtc] ICE servers: ${iceServers.map((u) => u.replace(/:[^:@]+@/, ":***@")).join(", ")}`
24149
+ `[webrtc] ICE servers: ${iceServers.map(
24150
+ (u) => typeof u === "string" ? u : `${u.relayType}:${u.hostname}:${u.port} user=${u.username?.slice(0, 8)}\u2026`
24151
+ ).join(", ")}`
24132
24152
  );
24133
24153
  const peer = new import_node_datachannel.PeerConnection("runner", { iceServers });
24134
24154
  const iceCandidateHandler = (msg) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factiii/runner",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "Factiii Runner, run Board AI agents on a machine you control. Pairs with the Factiii web/mobile clients over WebRTC.",
5
5
  "license": "ISC",
6
6
  "keywords": [