@threadbase-sh/streamer 1.58.2 → 1.58.3
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/dist/cli.cjs +15 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +15 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11435,7 +11435,7 @@ var PairTokenStore = class {
|
|
|
11435
11435
|
};
|
|
11436
11436
|
}
|
|
11437
11437
|
/**
|
|
11438
|
-
*
|
|
11438
|
+
* What `consume` would answer right now, WITHOUT spending the token.
|
|
11439
11439
|
*
|
|
11440
11440
|
* Exists so a caller can reject a bad token before doing any work, and still
|
|
11441
11441
|
* spend the token only once the work has succeeded. A pair token is
|
|
@@ -11444,10 +11444,14 @@ var PairTokenStore = class {
|
|
|
11444
11444
|
* indistinguishable from an attacker replaying a photographed code, which is
|
|
11445
11445
|
* the one signal `design.md` §2.6 designates as replay detection.
|
|
11446
11446
|
*
|
|
11447
|
-
*
|
|
11448
|
-
*
|
|
11447
|
+
* **Named for its relationship to `consume`, deliberately.** It reserves
|
|
11448
|
+
* nothing and takes no lock, so two callers can both be told `{ ok: true }`
|
|
11449
|
+
* for the same token. A name like `verify` would read as a gate that had
|
|
11450
|
+
* decided something, and inviting a caller to act on this alone is precisely
|
|
11451
|
+
* the misuse the ordering it enables exists to prevent. A reader who sees
|
|
11452
|
+
* `wouldConsume` asks where the `consume` is, which is the right question.
|
|
11449
11453
|
*/
|
|
11450
|
-
|
|
11454
|
+
wouldConsume(token) {
|
|
11451
11455
|
const result = this.check(token);
|
|
11452
11456
|
return result.ok ? { ok: true } : result;
|
|
11453
11457
|
}
|
|
@@ -16308,8 +16312,14 @@ var StreamerServer = class {
|
|
|
16308
16312
|
json(res, 400, { error: "Missing token or clientPublicKey" });
|
|
16309
16313
|
return;
|
|
16310
16314
|
}
|
|
16311
|
-
const precheck = this.pairTokens.
|
|
16315
|
+
const precheck = this.pairTokens.wouldConsume(token);
|
|
16312
16316
|
if (!precheck.ok) {
|
|
16317
|
+
if (precheck.reason === "used") {
|
|
16318
|
+
this.log.warn(
|
|
16319
|
+
"[pair] a pair token was replayed. If you did not just pair a device, check the paired-devices list and revoke anything you do not recognise.",
|
|
16320
|
+
{ event: "pair.token_replayed", ip }
|
|
16321
|
+
);
|
|
16322
|
+
}
|
|
16313
16323
|
json(res, 401, { error: `Pair token ${precheck.reason}` });
|
|
16314
16324
|
return;
|
|
16315
16325
|
}
|