Skip to content

Commit 88ceb96

Browse files
committed
Overlay branch overlay/session-ttl on top of upstream-target/2026-10-22 via Merge
* apps/server/src/auth/SessionStore.test.ts * apps/server/src/auth/SessionStore.ts • e9b902f8d6 Overlay branch overlay/session-ttl on top of upstream-target/2026-10-22 via Merge |\ | • f984001 fix(auth): session TTL test uses the renamed store layer | • d7e8015 Overlay branch overlay/session-ttl on top of origin/main via Merge | |\ | | • d622731 Make the default session TTL configurable via T3CODE_SESSION_TTL • | | 6f75bcb feat: ChatGPT Business usage limits offer a copyable admin request (pingdotgg#23361) • | | 002e941 fix(mobile): preserve new-thread drafts and native header layout (pingdotgg#23366) • | | efa5381 fix(mobile): the iOS composer reopens where you left a long draft (pingdotgg#23096) • | | a49d18c fix(source-control): clones retry over HTTPS when the SSH key is refused (pingdotgg#23170)
2 parents 6f75bcb + f984001 commit 88ceb96

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎apps/server/src/auth/SessionStore.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,4 +517,18 @@ it.layer(NodeServices.layer)("SessionStore.layer", (it) => {
517517
expect((yield* readRow)[0]).toEqual({ surface: "mobile", appVersion: "1.3.0" });
518518
}).pipe(Effect.provide(Layer.mergeAll(layerSessionStore(), SqlitePersistence.layerMemory))),
519519
);
520+
it.effect("extends the default session TTL from T3CODE_SESSION_TTL", () =>
521+
Effect.gen(function* () {
522+
const sessions = yield* SessionStore.SessionStore;
523+
const before = process.env.T3CODE_SESSION_TTL;
524+
process.env.T3CODE_SESSION_TTL = "90";
525+
try {
526+
const issued = yield* sessions.issue({ subject: "env-ttl-probe" });
527+
expect(issued.expiresAt.epochMilliseconds).toBe(Duration.toMillis(Duration.days(90)));
528+
} finally {
529+
if (before === undefined) delete process.env.T3CODE_SESSION_TTL;
530+
else process.env.T3CODE_SESSION_TTL = before;
531+
}
532+
}).pipe(Effect.provide(layerSessionStore())),
533+
);
520534
});

‎apps/server/src/auth/SessionStore.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,16 @@ export class SessionStore extends Context.Service<
423423

424424
const SIGNING_SECRET_NAME = "server-signing-key";
425425
const DEFAULT_SESSION_TTL = Duration.days(30);
426+
427+
/** Default session lifetime in days; overrides the 30-day default when a
428+
* positive finite number, so long-lived or headless deployments can extend
429+
* paired sessions without re-pairing every month. */
430+
function defaultSessionTtl(): Duration.Duration {
431+
const raw = process.env.T3CODE_SESSION_TTL;
432+
if (!raw) return DEFAULT_SESSION_TTL;
433+
const days = Number(raw);
434+
return Number.isFinite(days) && days > 0 ? Duration.days(days) : DEFAULT_SESSION_TTL;
435+
}
426436
const DEFAULT_WEBSOCKET_TOKEN_TTL = Duration.minutes(5);
427437

428438
const SessionClaims = Schema.Struct({
@@ -659,7 +669,7 @@ const make = Effect.gen(function* () {
659669
);
660670
const issuedAt = yield* DateTime.now;
661671
const expiresAt = DateTime.add(issuedAt, {
662-
milliseconds: Duration.toMillis(input?.ttl ?? DEFAULT_SESSION_TTL),
672+
milliseconds: Duration.toMillis(input?.ttl ?? defaultSessionTtl()),
663673
});
664674
const claims: SessionClaims = {
665675
v: 1,

0 commit comments

Comments
 (0)