co-maintainer 0.6.12 → 0.6.13
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/package.json
CHANGED
|
@@ -2,9 +2,7 @@ import { readConfig, configPath, savedKeyProvider, writeRepoConfig, writeUserCon
|
|
|
2
2
|
import { checkReviewSystemPrompt, reviewSystemPromptLimit, } from "../../review/system_prompt.js";
|
|
3
3
|
import { canonicalRepoName } from "../../util/repo_name.js";
|
|
4
4
|
import { hashPassword, passwordProblem } from "../../util/password.js";
|
|
5
|
-
import {
|
|
6
|
-
import { appDbPath, closeAppDb, openAppDb } from "../../store/app_db.js";
|
|
7
|
-
import { existsSync } from "node:fs";
|
|
5
|
+
import { nowIso } from "../../util/time.js";
|
|
8
6
|
import { readTextFile } from "../../util/runtime.js";
|
|
9
7
|
import { verifyAnthropic, verifyOpenAi, verifyOpenRouter, } from "../../ai/verify.js";
|
|
10
8
|
import { verifyOpenCode } from "../../ai/opencode.js";
|
|
@@ -354,23 +352,15 @@ export async function runSet(args) {
|
|
|
354
352
|
console.error(`[set] could not verify the key and model (${result.reason}); saved anyway.`);
|
|
355
353
|
}
|
|
356
354
|
}
|
|
357
|
-
await writeUserConfig(patch);
|
|
358
355
|
// A changed password, allowed user, or sign-in method must not leave old
|
|
359
|
-
// dashboard sessions valid.
|
|
360
|
-
//
|
|
356
|
+
// dashboard sessions valid. A running `serve` holds app.db, so instead of
|
|
357
|
+
// deleting sessions here the change time goes into config.json and
|
|
358
|
+
// `verifySession` refuses every session issued before it.
|
|
361
359
|
const credentialChanged = patch.dashboardPasswordHash !== undefined ||
|
|
362
360
|
patch.passwordAuthDisabled !== undefined ||
|
|
363
361
|
patch.githubAuthEnabled !== undefined ||
|
|
364
362
|
patch.githubOAuthAllowedUser !== undefined;
|
|
365
|
-
|
|
366
|
-
await openAppDb();
|
|
367
|
-
try {
|
|
368
|
-
deleteAllSessions();
|
|
369
|
-
}
|
|
370
|
-
finally {
|
|
371
|
-
await closeAppDb();
|
|
372
|
-
}
|
|
373
|
-
}
|
|
363
|
+
await writeUserConfig(credentialChanged ? { ...patch, credentialsChangedAt: nowIso() } : patch);
|
|
374
364
|
const summary = Object.entries(patch).map(([key, value]) => value === undefined
|
|
375
365
|
? `${key} (unset)`
|
|
376
366
|
: `${key}=${secretFields.has(key) ? "•".repeat(8) : value}`);
|
package/dist/src/config.d.ts
CHANGED
|
@@ -71,6 +71,9 @@ export type UserConfig = {
|
|
|
71
71
|
githubAuthEnabled?: boolean;
|
|
72
72
|
/** scrypt hash of the dashboard password, never the password itself. */
|
|
73
73
|
dashboardPasswordHash?: string;
|
|
74
|
+
/** When `set` last changed a sign-in credential. Dashboard sessions issued
|
|
75
|
+
* before it are refused. */
|
|
76
|
+
credentialsChangedAt?: string;
|
|
74
77
|
defaults?: {
|
|
75
78
|
maxCommits?: number;
|
|
76
79
|
maxPrMonths?: number;
|
package/dist/src/server/auth.js
CHANGED
|
@@ -125,7 +125,14 @@ export async function createSession() {
|
|
|
125
125
|
}
|
|
126
126
|
export async function verifySession(token) {
|
|
127
127
|
const session = getSession(await sha256Hex(token));
|
|
128
|
-
|
|
128
|
+
if (!session)
|
|
129
|
+
return undefined;
|
|
130
|
+
// Read per check, like the password hash, so a credential changed with
|
|
131
|
+
// `co-maintainer set` signs everyone out without restarting `serve`.
|
|
132
|
+
const changedAt = readConfig().credentialsChangedAt;
|
|
133
|
+
if (changedAt && session.created_at < changedAt)
|
|
134
|
+
return undefined;
|
|
135
|
+
return { username: session.username };
|
|
129
136
|
}
|
|
130
137
|
export async function logout(token) {
|
|
131
138
|
deleteSession(await sha256Hex(token));
|
|
@@ -8,7 +8,9 @@ export declare function appDbPath(): string;
|
|
|
8
8
|
export declare function appDbLockPath(): string;
|
|
9
9
|
/** Where the backup taken before a migration lives, and what it covers. */
|
|
10
10
|
export declare function backupPaths(): BackupPaths;
|
|
11
|
-
/** The pid holding the database lock, or `undefined` when nothing live does.
|
|
11
|
+
/** The pid holding the database lock, or `undefined` when nothing live does.
|
|
12
|
+
* Our own pid is never another holder: in a container `serve` gets the same
|
|
13
|
+
* pid on every start, so a lock left by a hard stop names the new process. */
|
|
12
14
|
export declare function liveLockPid(): Promise<number | undefined>;
|
|
13
15
|
export declare function releaseLock(): Promise<void>;
|
|
14
16
|
export declare function isAppDbOpen(): boolean;
|
package/dist/src/store/app_db.js
CHANGED
|
@@ -47,7 +47,9 @@ async function lastVersion() {
|
|
|
47
47
|
throw error;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
/** The pid holding the database lock, or `undefined` when nothing live does.
|
|
50
|
+
/** The pid holding the database lock, or `undefined` when nothing live does.
|
|
51
|
+
* Our own pid is never another holder: in a container `serve` gets the same
|
|
52
|
+
* pid on every start, so a lock left by a hard stop names the new process. */
|
|
51
53
|
export async function liveLockPid() {
|
|
52
54
|
let pid;
|
|
53
55
|
try {
|
|
@@ -57,7 +59,10 @@ export async function liveLockPid() {
|
|
|
57
59
|
if (!isNotFound(error))
|
|
58
60
|
throw error;
|
|
59
61
|
}
|
|
60
|
-
return pid !== undefined &&
|
|
62
|
+
return pid !== undefined &&
|
|
63
|
+
Number.isInteger(pid) &&
|
|
64
|
+
pid !== process.pid &&
|
|
65
|
+
isProcessAlive(pid)
|
|
61
66
|
? pid
|
|
62
67
|
: undefined;
|
|
63
68
|
}
|