freertc 0.1.31 → 0.1.32
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 +1 -1
- package/package.json +1 -1
- package/public/app.js +25 -3
- package/scripts/non-cloudflare-server.mjs +1 -1
- package/src/index.js +1 -1
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.
|
|
219
|
+
{"ok":true,"version":"0.1.32","protocol_version":"1.0","peers":0}
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
## Auto WebRTC two-tab test
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -120,6 +120,14 @@ function deriveNetworkFromSession(sessionIdValue) {
|
|
|
120
120
|
return `room:${session}`;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
function deriveSessionFromNetwork(networkValue) {
|
|
124
|
+
const network = normalizeText(networkValue);
|
|
125
|
+
if (!network || !isSpecToken(network)) {
|
|
126
|
+
return "room:test";
|
|
127
|
+
}
|
|
128
|
+
return network;
|
|
129
|
+
}
|
|
130
|
+
|
|
123
131
|
createApp({
|
|
124
132
|
setup() {
|
|
125
133
|
const host = window.location.host;
|
|
@@ -152,6 +160,7 @@ createApp({
|
|
|
152
160
|
const appliedFromPeer = ref(fromPeer.value);
|
|
153
161
|
const toPeer = ref("");
|
|
154
162
|
const sessionId = ref("");
|
|
163
|
+
let sessionIdExplicit = false;
|
|
155
164
|
const instanceId = ref("");
|
|
156
165
|
|
|
157
166
|
const activeView = ref("webrtc");
|
|
@@ -701,12 +710,12 @@ createApp({
|
|
|
701
710
|
pushLog("network:error", "Ignoring invalid URL network");
|
|
702
711
|
}
|
|
703
712
|
|
|
704
|
-
|
|
713
|
+
sessionIdExplicit = hasValidUrlSession;
|
|
705
714
|
instanceId.value = hasValidUrlInstance ? instanceParam : `inst-${Math.random().toString(36).slice(2, 10)}`;
|
|
706
715
|
|
|
707
716
|
// Cross-domain links should land in the same room even when each origin has
|
|
708
717
|
// different sessionStorage UI state. URL network wins; otherwise derive from session_id.
|
|
709
|
-
const derivedNetwork = deriveNetworkFromSession(
|
|
718
|
+
const derivedNetwork = hasValidUrlSession ? deriveNetworkFromSession(sessionParam) : "";
|
|
710
719
|
const nextNetwork = hasValidUrlNetwork ? networkParam : (derivedNetwork || normalizedNetworkValue());
|
|
711
720
|
if (nextNetwork && nextNetwork !== network.value) {
|
|
712
721
|
network.value = nextNetwork;
|
|
@@ -715,6 +724,8 @@ createApp({
|
|
|
715
724
|
appliedNetwork.value = nextNetwork;
|
|
716
725
|
}
|
|
717
726
|
|
|
727
|
+
sessionId.value = hasValidUrlSession ? sessionParam : deriveSessionFromNetwork(nextNetwork || normalizedNetworkValue());
|
|
728
|
+
|
|
718
729
|
persistSharedIds();
|
|
719
730
|
}
|
|
720
731
|
|
|
@@ -806,12 +817,18 @@ createApp({
|
|
|
806
817
|
}
|
|
807
818
|
|
|
808
819
|
function regenerateSharedIds() {
|
|
820
|
+
sessionIdExplicit = true;
|
|
809
821
|
sessionId.value = `sess-${Math.random().toString(36).slice(2, 10)}`;
|
|
810
822
|
instanceId.value = `inst-${Math.random().toString(36).slice(2, 10)}`;
|
|
811
823
|
persistSharedIds();
|
|
812
824
|
pushLog("ids", "Generated new shared session_id and instance_id");
|
|
813
825
|
}
|
|
814
826
|
|
|
827
|
+
function applySessionIdChange() {
|
|
828
|
+
sessionIdExplicit = true;
|
|
829
|
+
persistSharedIds();
|
|
830
|
+
}
|
|
831
|
+
|
|
815
832
|
function regeneratePeerId() {
|
|
816
833
|
fromPeer.value = randomHex();
|
|
817
834
|
appliedFromPeer.value = fromPeer.value;
|
|
@@ -835,6 +852,11 @@ createApp({
|
|
|
835
852
|
}
|
|
836
853
|
appliedNetwork.value = next;
|
|
837
854
|
|
|
855
|
+
if (!sessionIdExplicit) {
|
|
856
|
+
sessionId.value = deriveSessionFromNetwork(next);
|
|
857
|
+
persistSharedIds();
|
|
858
|
+
}
|
|
859
|
+
|
|
838
860
|
reconnectLockedByBye = false;
|
|
839
861
|
byeCooldowns.clear();
|
|
840
862
|
failedPeerCooldowns.clear();
|
|
@@ -2683,7 +2705,7 @@ createApp({
|
|
|
2683
2705
|
<div class="field-grid">
|
|
2684
2706
|
<label>
|
|
2685
2707
|
Session ID
|
|
2686
|
-
<input v-model="sessionId" @change="
|
|
2708
|
+
<input v-model="sessionId" @change="applySessionIdChange">
|
|
2687
2709
|
</label>
|
|
2688
2710
|
<label>
|
|
2689
2711
|
Instance ID
|
|
@@ -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.
|
|
10
|
+
const WORKER_VERSION = '0.1.32';
|
|
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.
|
|
2
|
+
const WORKER_VERSION = "0.1.32";
|
|
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"]);
|