@threadbase-sh/streamer 1.58.0 → 1.58.1
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 +51 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +51 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -120682,11 +120682,19 @@ var init_codex_pty_runner = __esm({
|
|
|
120682
120682
|
onStatusChange;
|
|
120683
120683
|
onPhaseChange;
|
|
120684
120684
|
onReady;
|
|
120685
|
-
//
|
|
120686
|
-
//
|
|
120685
|
+
// Every Codex prompt the client can answer — startup gates (directory trust,
|
|
120686
|
+
// hooks review), command approvals, and the rate-limit model picker — is
|
|
120687
|
+
// broadcast through this one channel; null dismisses the card once the prompt
|
|
120688
|
+
// leaves the screen.
|
|
120689
|
+
//
|
|
120690
|
+
// Deliberately NOT onLiveQuestion/onLiveQuestionGone, which is Claude's
|
|
120691
|
+
// AskUserQuestion transport. Both channels land on the same mobile
|
|
120692
|
+
// QuestionCard, and the permission one is the correct fit for Codex: its menus
|
|
120693
|
+
// are answered by the option's real on-screen number (parseCodexNumberedOptions
|
|
120694
|
+
// emits `answerKeys: "2\r"`), which is exactly what `permissionIndices` carries
|
|
120695
|
+
// and what AskUserQuestion's down-arrow-count model cannot express. Wiring the
|
|
120696
|
+
// question channel as well would be a second path to the same card.
|
|
120687
120697
|
onPermissionChange;
|
|
120688
|
-
onLiveQuestion;
|
|
120689
|
-
onLiveQuestionGone;
|
|
120690
120698
|
onUserMessage;
|
|
120691
120699
|
log;
|
|
120692
120700
|
// Tracks sessions whose PTY has spawned but Codex hasn't yet reached its
|
|
@@ -120736,8 +120744,6 @@ var init_codex_pty_runner = __esm({
|
|
|
120736
120744
|
this.onPhaseChange = options.onPhaseChange;
|
|
120737
120745
|
this.onReady = options.onReady;
|
|
120738
120746
|
this.onPermissionChange = options.onPermissionChange;
|
|
120739
|
-
this.onLiveQuestion = options.onLiveQuestion;
|
|
120740
|
-
this.onLiveQuestionGone = options.onLiveQuestionGone;
|
|
120741
120747
|
this.onUserMessage = options.onUserMessage;
|
|
120742
120748
|
this.log = options.logger ?? getLogger("codex-pty");
|
|
120743
120749
|
}
|
|
@@ -149023,7 +149029,37 @@ var PairTokenStore = class {
|
|
|
149023
149029
|
expiresInSeconds: Math.floor(this.ttlMs / 1e3)
|
|
149024
149030
|
};
|
|
149025
149031
|
}
|
|
149032
|
+
/**
|
|
149033
|
+
* Whether `consume` would succeed right now, WITHOUT spending the token.
|
|
149034
|
+
*
|
|
149035
|
+
* Exists so a caller can reject a bad token before doing any work, and still
|
|
149036
|
+
* spend the token only once the work has succeeded. A pair token is
|
|
149037
|
+
* single-use and lives 180 seconds, so spending it on a request that then
|
|
149038
|
+
* fails costs the user a whole new QR — and, worse, makes their retry
|
|
149039
|
+
* indistinguishable from an attacker replaying a photographed code, which is
|
|
149040
|
+
* the one signal `design.md` §2.6 designates as replay detection.
|
|
149041
|
+
*
|
|
149042
|
+
* Advisory, not a reservation: it takes no lock and holds nothing. The
|
|
149043
|
+
* authoritative answer is still `consume`'s.
|
|
149044
|
+
*/
|
|
149045
|
+
verify(token) {
|
|
149046
|
+
const result = this.check(token);
|
|
149047
|
+
return result.ok ? { ok: true } : result;
|
|
149048
|
+
}
|
|
149026
149049
|
consume(token) {
|
|
149050
|
+
const result = this.check(token);
|
|
149051
|
+
if (!result.ok) return result;
|
|
149052
|
+
result.record.used = true;
|
|
149053
|
+
return { ok: true };
|
|
149054
|
+
}
|
|
149055
|
+
/**
|
|
149056
|
+
* The shared predicate behind `verify` and `consume`.
|
|
149057
|
+
*
|
|
149058
|
+
* One implementation on purpose: two copies of "is this token usable" is two
|
|
149059
|
+
* places for the expiry or single-use rule to drift, and a drift in this
|
|
149060
|
+
* direction fails open.
|
|
149061
|
+
*/
|
|
149062
|
+
check(token) {
|
|
149027
149063
|
const record3 = this.current;
|
|
149028
149064
|
if (!record3 || record3.token !== token) return { ok: false, reason: "unknown" };
|
|
149029
149065
|
if (Date.now() > record3.expiresAt) {
|
|
@@ -149031,8 +149067,7 @@ var PairTokenStore = class {
|
|
|
149031
149067
|
return { ok: false, reason: "expired" };
|
|
149032
149068
|
}
|
|
149033
149069
|
if (record3.used) return { ok: false, reason: "used" };
|
|
149034
|
-
|
|
149035
|
-
return { ok: true };
|
|
149070
|
+
return { ok: true, record: record3 };
|
|
149036
149071
|
}
|
|
149037
149072
|
peek() {
|
|
149038
149073
|
return this.current;
|
|
@@ -154050,9 +154085,9 @@ var StreamerServer = class {
|
|
|
154050
154085
|
json2(res, 400, { error: "Missing token or clientPublicKey" });
|
|
154051
154086
|
return;
|
|
154052
154087
|
}
|
|
154053
|
-
const
|
|
154054
|
-
if (!
|
|
154055
|
-
json2(res, 401, { error: `Pair token ${
|
|
154088
|
+
const precheck = this.pairTokens.verify(token);
|
|
154089
|
+
if (!precheck.ok) {
|
|
154090
|
+
json2(res, 401, { error: `Pair token ${precheck.reason}` });
|
|
154056
154091
|
return;
|
|
154057
154092
|
}
|
|
154058
154093
|
let sealed;
|
|
@@ -154063,6 +154098,11 @@ var StreamerServer = class {
|
|
|
154063
154098
|
json2(res, 400, { error: message });
|
|
154064
154099
|
return;
|
|
154065
154100
|
}
|
|
154101
|
+
const result = this.pairTokens.consume(token);
|
|
154102
|
+
if (!result.ok) {
|
|
154103
|
+
json2(res, 401, { error: `Pair token ${result.reason}` });
|
|
154104
|
+
return;
|
|
154105
|
+
}
|
|
154066
154106
|
const ts2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
154067
154107
|
this.log.info(`[pair] token exchanged from ${ip} at ${ts2}`, {
|
|
154068
154108
|
event: "pair.token_exchanged",
|