jsflow-sdk 1.0.0-rc.1 → 1.0.0-rc.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,19 @@ All notable changes to `jsflow-sdk`. The format follows
6
6
  contract; metric names passed to `onMetric` are diagnostic and may change in
7
7
  any minor release.
8
8
 
9
+ ## [1.0.0-rc.2] - 2026-11-18
10
+
11
+ The second release candidate for 1.0.0, under the npm tag `next` as before.
12
+
13
+ ### Fixed
14
+ - **A reliable message is never delivered twice across a page reload.** If a
15
+ receiver got a `sendReliable()` message, then reloaded (or restarted)
16
+ before its acknowledgement reached the sender (for example while the
17
+ sender's page was hidden), the sender's retransmission could reach the
18
+ receiver's new page as well. The new page now drops it, and the sender
19
+ gets `undelivered` for it, as for any message whose delivery it cannot
20
+ confirm. Nothing changes on the wire.
21
+
9
22
  ## [1.0.0-rc.1] - 2026-11-18
10
23
 
11
24
  The release candidate for 1.0.0: everything listed under 1.0.0 below. Published under the npm tag `next`
@@ -55,7 +68,8 @@ The first stable API, on wire version 2.
55
68
  6. **Tickets (optional, recommended).** Your backend signs a short-lived
56
69
  ticket with the app's secret key (`mintTicket` in the docs, no call to
57
70
  us) and the page passes it as `join({ ticket })`, a string or a
58
- function the SDK calls again at every rejoin. With `requireTickets` on
71
+ function the SDK calls at every `join()` call (not when a
72
+ page returns from `away`, nor at a token refresh). With `requireTickets` on
59
73
  for the app, a join without one is refused. `room.user(peerId)` then
60
74
  gives each peer's user id.
61
75
  7. **CDN URLs.** The version directory now holds two files: `jsflow.js`
@@ -78,6 +92,9 @@ The first stable API, on wire version 2.
78
92
  `SDK_VERSION`, `WIRE` and `MAX_RELIABLE` exports.
79
93
  - Every broadcast and link-state message is signed (Ed25519) and checked
80
94
  by every peer; forged ones are dropped where they arrive.
95
+ - `sendReliable()` delivers to the receiver's page that was there when it
96
+ was sent, never to a reloaded one: an unconfirmed message to a peer that
97
+ restarted is reported as `undelivered` (fixed in rc.2).
81
98
  - Tokens and relay credentials refresh, so rooms live past 6 hours; the
82
99
  signalling stream resumes after a drop without losing signals.
83
100
  - HTTP/2 to the signalling service; rooms move between service instances
package/jsflow.js CHANGED
@@ -1,4 +1,4 @@
1
- // jsflow-sdk 1.0.0-rc.1. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
1
+ // jsflow-sdk 1.0.0-rc.2. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
2
2
 
3
3
  // core/link-main.js
4
4
  function linkKind(stats) {
@@ -215,7 +215,7 @@ function ticketRegion(ticket) {
215
215
  return void 0;
216
216
  }
217
217
  }
218
- var SDK_VERSION = "1.0.0-rc.1";
218
+ var SDK_VERSION = "1.0.0-rc.2";
219
219
  var WIRE = 2;
220
220
  var MAX_DATAGRAM = 1052;
221
221
  var MAX_RELIABLE = 65536;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsflow-sdk",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.2",
4
4
  "description": "jsflow: peer-to-peer rooms for the browser (WebRTC mesh, signalling and relays as a service).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
package/sri.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.0.0-rc.1",
3
- "jsflow.js": "sha384-GI+N/3q6SXvwQT3qPSuhgUzpzbdUXBs8/qPbvlDz3boKBAgUb+Id24YQ/OsPckd+",
4
- "worker.js": "sha384-YfMMFSVgGKwvlSSzmmfdZaFJRoVK6BsbiRX2CjVwB3NhuoQdxyfrQS5sjr1Q8XyB",
2
+ "version": "1.0.0-rc.2",
3
+ "jsflow.js": "sha384-TWv5Y1/UHWbfvHc9hVVcidbLAzwNnLqkRvKNozohCiccy7pZjReUXYnFpH3cM5Wt",
4
+ "worker.js": "sha384-FP6p48dOLeb623bV9GRoeszT6RpUwimgxAPat059QIIDg2W8i/6hVNZZc1RAFe+2",
5
5
  "jsflow.d.ts": "sha384-ZQeEwggqNXnSnd25+7iK7oiLLI636vR16LRNPNflzbnxx/IsTmEsct592Eiq2mEg"
6
6
  }
package/worker.js CHANGED
@@ -1,4 +1,4 @@
1
- // jsflow-sdk 1.0.0-rc.1. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
1
+ // jsflow-sdk 1.0.0-rc.2. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
2
2
 
3
3
  // core/header.js
4
4
  var VERSION = 2;
@@ -1833,6 +1833,7 @@ function reliable({
1833
1833
  if (Math.ceil(maxMessage / FRAG) > W) throw new RangeError("reliable: a maxMessage message must fit in the window");
1834
1834
  if (!(rxIdleMs > giveUpMs && rxIdleMs > txIdleMs)) throw new RangeError("reliable: rxIdleMs must outlast giveUpMs and txIdleMs");
1835
1835
  const peers = /* @__PURE__ */ new Map();
1836
+ const meshInc = /* @__PURE__ */ new Map();
1836
1837
  const stats = { sent: 0, data: 0, retx: 0, fast: 0, timeLoss: 0, rto: 0, acks: 0, piggy: 0, dup: 0, delivered: 0, giveUps: 0, resets: 0, bad: 0 };
1837
1838
  let sids = 0, sweep = null;
1838
1839
  const bad = (why) => {
@@ -1846,7 +1847,7 @@ function reliable({
1846
1847
  metric2("reliablePeersFull", peer);
1847
1848
  return null;
1848
1849
  }
1849
- peers.set(peer, rec = { inc: 0, tx: null, rx: null, rtt: { srtt: null, var: 0, min: Infinity, latest: 0 }, seen: now(), noticeAt: -Infinity });
1850
+ peers.set(peer, rec = { inc: meshInc.get(peer) ?? 0, tx: null, rx: null, rtt: { srtt: null, var: 0, min: Infinity, latest: 0 }, seen: now(), noticeAt: -Infinity });
1850
1851
  if (!sweep) sweep = setTimer(sweepMs, onSweep);
1851
1852
  return rec;
1852
1853
  }
@@ -2261,8 +2262,13 @@ function reliable({
2261
2262
  // than the one we talk to: it restarted, so drop the old one's state now
2262
2263
  // rather than when our retransmissions (paced by RTO backoff) reach it.
2263
2264
  peerIncarnation(peer, pinc) {
2265
+ if (!(pinc <= (meshInc.get(peer) ?? 0))) meshInc.set(peer, pinc);
2264
2266
  const rec = peers.get(peer);
2265
- if (!rec || !rec.inc || !(pinc > rec.inc)) return;
2267
+ if (rec && !rec.inc) {
2268
+ rec.inc = pinc;
2269
+ return;
2270
+ }
2271
+ if (!rec || !(pinc > rec.inc)) return;
2266
2272
  stats.resets++;
2267
2273
  metric2("reliablePeerRestart", { peer, inc: pinc, was: rec.inc, how: "mesh" });
2268
2274
  forget(peer, "reset");