@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/cli.cjs
CHANGED
|
@@ -149112,7 +149112,7 @@ var PairTokenStore = class {
|
|
|
149112
149112
|
};
|
|
149113
149113
|
}
|
|
149114
149114
|
/**
|
|
149115
|
-
*
|
|
149115
|
+
* What `consume` would answer right now, WITHOUT spending the token.
|
|
149116
149116
|
*
|
|
149117
149117
|
* Exists so a caller can reject a bad token before doing any work, and still
|
|
149118
149118
|
* spend the token only once the work has succeeded. A pair token is
|
|
@@ -149121,10 +149121,14 @@ var PairTokenStore = class {
|
|
|
149121
149121
|
* indistinguishable from an attacker replaying a photographed code, which is
|
|
149122
149122
|
* the one signal `design.md` §2.6 designates as replay detection.
|
|
149123
149123
|
*
|
|
149124
|
-
*
|
|
149125
|
-
*
|
|
149124
|
+
* **Named for its relationship to `consume`, deliberately.** It reserves
|
|
149125
|
+
* nothing and takes no lock, so two callers can both be told `{ ok: true }`
|
|
149126
|
+
* for the same token. A name like `verify` would read as a gate that had
|
|
149127
|
+
* decided something, and inviting a caller to act on this alone is precisely
|
|
149128
|
+
* the misuse the ordering it enables exists to prevent. A reader who sees
|
|
149129
|
+
* `wouldConsume` asks where the `consume` is, which is the right question.
|
|
149126
149130
|
*/
|
|
149127
|
-
|
|
149131
|
+
wouldConsume(token) {
|
|
149128
149132
|
const result = this.check(token);
|
|
149129
149133
|
return result.ok ? { ok: true } : result;
|
|
149130
149134
|
}
|
|
@@ -154212,8 +154216,14 @@ var StreamerServer = class {
|
|
|
154212
154216
|
json2(res, 400, { error: "Missing token or clientPublicKey" });
|
|
154213
154217
|
return;
|
|
154214
154218
|
}
|
|
154215
|
-
const precheck = this.pairTokens.
|
|
154219
|
+
const precheck = this.pairTokens.wouldConsume(token);
|
|
154216
154220
|
if (!precheck.ok) {
|
|
154221
|
+
if (precheck.reason === "used") {
|
|
154222
|
+
this.log.warn(
|
|
154223
|
+
"[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.",
|
|
154224
|
+
{ event: "pair.token_replayed", ip }
|
|
154225
|
+
);
|
|
154226
|
+
}
|
|
154217
154227
|
json2(res, 401, { error: `Pair token ${precheck.reason}` });
|
|
154218
154228
|
return;
|
|
154219
154229
|
}
|