shadok-ai 0.15.18 → 0.15.19
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/README.md +35 -0
- package/dist/accounts.d.ts +36 -5
- package/dist/accounts.js +26 -11
- package/dist/accounts.js.map +1 -1
- package/dist/config.d.ts +10 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -1
- package/dist/server.js +432 -26
- package/dist/server.js.map +1 -1
- package/dist/twofactor.d.ts +119 -0
- package/dist/twofactor.js +227 -0
- package/dist/twofactor.js.map +1 -0
- package/package.json +3 -1
- package/public/index.html +161 -4
package/README.md
CHANGED
|
@@ -369,6 +369,41 @@ know before opening it up:
|
|
|
369
369
|
else you do. Accounts belong to **one instance** (one launch directory), like
|
|
370
370
|
its channels and its scheduled prompts. With no password there are no
|
|
371
371
|
accounts and no login screen — nothing changes for a machine you use alone.
|
|
372
|
+
- **Two-factor sign-in (passkeys).** From the **Users** panel, anyone signed in
|
|
373
|
+
with a named account can register a passkey on their device — the
|
|
374
|
+
fingerprint / face / PIN unlock of the phone or laptop (WebAuthn, user
|
|
375
|
+
verification required). An admin can then turn **Two-factor sign-in** on for
|
|
376
|
+
this instance. From then on a correct password only opens a second step, and
|
|
377
|
+
the session exists once the passkey answers.
|
|
378
|
+
- Switching it on needs **at least 2 named admins, each with a passkey** —
|
|
379
|
+
recovery is "another admin resets you", so a lone admin who lost their phone
|
|
380
|
+
would lock the cockpit for good. The acting admin confirms with their
|
|
381
|
+
passkey.
|
|
382
|
+
- **Adding a device from another one**: on a signed-in device, *Add another
|
|
383
|
+
device (code)* shows an 8-character code valid 10 minutes, single use. On the
|
|
384
|
+
new device, sign in with the password, choose *use a code*, register. A
|
|
385
|
+
password alone never registers a passkey — that is what stops a stolen
|
|
386
|
+
password from enrolling the thief's phone.
|
|
387
|
+
- **Lost password or lost device**: another admin clicks *reset access* on your
|
|
388
|
+
row (confirming with their own passkey). Your password and every passkey are
|
|
389
|
+
removed and they hand you a fresh invitation link, on which you choose a new
|
|
390
|
+
password and register the device you have. Nobody can reset themselves. An
|
|
391
|
+
admin can also hand a member a *device code* directly.
|
|
392
|
+
- While it is on, the instance password (`admin`) **cannot sign in to the
|
|
393
|
+
browser** — it lives in every agent's environment and no one could reset it;
|
|
394
|
+
use a named account. Agents, Telegram and peers keep working (they never use
|
|
395
|
+
the login), but account and two-factor management is reserved to a signed-in
|
|
396
|
+
person: an agent's key can no longer create or reset accounts.
|
|
397
|
+
- Passkeys need a **secure context**: `https://` (see "Behind TLS") or
|
|
398
|
+
`localhost`. They are bound to the hostname — one made on
|
|
399
|
+
`cockpit.example.com` does not work on `localhost`.
|
|
400
|
+
- **Break-glass**, if every admin loses everything at once: on the machine,
|
|
401
|
+
remove the instance's entry under `twoFactor` in `~/.shadok-ai/config.json`
|
|
402
|
+
and restart. Whoever has that shell could read every secret anyway.
|
|
403
|
+
- What it protects against: a leaked password used over the network, and every
|
|
404
|
+
session issued before it was switched on (they stop working). What it does
|
|
405
|
+
not: anything already running as the machine's user — same soft isolation as
|
|
406
|
+
profiles.
|
|
372
407
|
- Once people are named, **a prompt carries its sender**: the agent sees who
|
|
373
408
|
asked, and the other browsers show the name above the message instead of
|
|
374
409
|
"pilot (elsewhere)". The server takes that name from the session, never from
|
package/dist/accounts.d.ts
CHANGED
|
@@ -18,6 +18,27 @@ export interface Account {
|
|
|
18
18
|
token: string;
|
|
19
19
|
expiresAt: number;
|
|
20
20
|
};
|
|
21
|
+
/** Registered passkeys — the second factor (see `src/twofactor.ts`). */
|
|
22
|
+
passkeys?: Passkey[];
|
|
23
|
+
/** An outstanding enrollment code: what lets a device register a passkey
|
|
24
|
+
* while two-factor is on. Single use, short-lived. */
|
|
25
|
+
enroll?: {
|
|
26
|
+
code: string;
|
|
27
|
+
expiresAt: number;
|
|
28
|
+
by: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface Passkey {
|
|
32
|
+
/** Credential id, base64url. */
|
|
33
|
+
id: string;
|
|
34
|
+
/** COSE public key, base64url. */
|
|
35
|
+
publicKey: string;
|
|
36
|
+
counter: number;
|
|
37
|
+
transports?: string[];
|
|
38
|
+
/** Named by the user at enrollment ("iPhone", "MacBook"). */
|
|
39
|
+
label: string;
|
|
40
|
+
createdAt: number;
|
|
41
|
+
lastUsedAt?: number;
|
|
21
42
|
}
|
|
22
43
|
/** The account that lives in SHADOK_GUI_PASSWORD, never in the file. */
|
|
23
44
|
export declare const BOOTSTRAP_ADMIN = "admin";
|
|
@@ -51,11 +72,21 @@ export declare function userWriteVerdict(o: {
|
|
|
51
72
|
* cookie for any user. Untidy becomes impersonation the moment accounts exist.
|
|
52
73
|
*/
|
|
53
74
|
export declare function sessionSecret(): Buffer;
|
|
54
|
-
/** `<user base64url>.<issuedAt>.<hmac>` — the name is encoded so a dot in
|
|
55
|
-
* cannot shift the fields. The ROLE is deliberately absent: it is re-read
|
|
56
|
-
* the account file at use time, so a demotion takes effect immediately
|
|
57
|
-
* of riding in a stale cookie.
|
|
58
|
-
|
|
75
|
+
/** `<user base64url>.<issuedAt>.<mfa>.<hmac>` — the name is encoded so a dot in
|
|
76
|
+
* it cannot shift the fields. The ROLE is deliberately absent: it is re-read
|
|
77
|
+
* from the account file at use time, so a demotion takes effect immediately
|
|
78
|
+
* instead of riding in a stale cookie. `mfa` says the second factor was
|
|
79
|
+
* presented when the cookie was issued: once two-factor is switched on, a
|
|
80
|
+
* cookie without it is refused, which kills every session issued before. */
|
|
81
|
+
export declare function signSession(user: string, issuedAt: number, secret: Buffer, mfa?: boolean): string;
|
|
82
|
+
/**
|
|
83
|
+
* The user and second-factor flag a session cookie carries, or null. Reads the
|
|
84
|
+
* pre-2FA three-field shape too — as `mfa: false`, which is what it was.
|
|
85
|
+
*/
|
|
86
|
+
export declare function readSessionFull(token: string, secret: Buffer, now: number, maxAgeMs: number): {
|
|
87
|
+
user: string;
|
|
88
|
+
mfa: boolean;
|
|
89
|
+
} | null;
|
|
59
90
|
export declare function readSession(token: string, secret: Buffer, now: number, maxAgeMs: number): string | null;
|
|
60
91
|
/** A week: long enough to hand the link over by another channel, short enough
|
|
61
92
|
* that a forgotten one stops working. */
|
package/dist/accounts.js
CHANGED
|
@@ -87,24 +87,35 @@ export function sessionSecret() {
|
|
|
87
87
|
fs.chmodSync(f, 0o600);
|
|
88
88
|
return secret;
|
|
89
89
|
}
|
|
90
|
-
/** `<user base64url>.<issuedAt>.<hmac>` — the name is encoded so a dot in
|
|
91
|
-
* cannot shift the fields. The ROLE is deliberately absent: it is re-read
|
|
92
|
-
* the account file at use time, so a demotion takes effect immediately
|
|
93
|
-
* of riding in a stale cookie.
|
|
94
|
-
|
|
90
|
+
/** `<user base64url>.<issuedAt>.<mfa>.<hmac>` — the name is encoded so a dot in
|
|
91
|
+
* it cannot shift the fields. The ROLE is deliberately absent: it is re-read
|
|
92
|
+
* from the account file at use time, so a demotion takes effect immediately
|
|
93
|
+
* instead of riding in a stale cookie. `mfa` says the second factor was
|
|
94
|
+
* presented when the cookie was issued: once two-factor is switched on, a
|
|
95
|
+
* cookie without it is refused, which kills every session issued before. */
|
|
96
|
+
export function signSession(user, issuedAt, secret, mfa = false) {
|
|
95
97
|
const u = Buffer.from(user, "utf8").toString("base64url");
|
|
96
|
-
const body = `${u}.${issuedAt}`;
|
|
98
|
+
const body = `${u}.${issuedAt}.${mfa ? 1 : 0}`;
|
|
97
99
|
return `${body}.${createHmac("sha256", secret).update(body).digest("hex")}`;
|
|
98
100
|
}
|
|
99
|
-
|
|
101
|
+
/**
|
|
102
|
+
* The user and second-factor flag a session cookie carries, or null. Reads the
|
|
103
|
+
* pre-2FA three-field shape too — as `mfa: false`, which is what it was.
|
|
104
|
+
*/
|
|
105
|
+
export function readSessionFull(token, secret, now, maxAgeMs) {
|
|
100
106
|
const parts = String(token ?? "").split(".");
|
|
101
|
-
if (parts.length !== 3)
|
|
107
|
+
if (parts.length !== 3 && parts.length !== 4)
|
|
108
|
+
return null;
|
|
109
|
+
const mac = parts[parts.length - 1];
|
|
110
|
+
const body = parts.slice(0, -1).join(".");
|
|
111
|
+
const [u, at] = parts;
|
|
112
|
+
const mfa = parts.length === 4 ? parts[2] : "0";
|
|
113
|
+
if (mfa !== "0" && mfa !== "1")
|
|
102
114
|
return null;
|
|
103
|
-
const [u, at, mac] = parts;
|
|
104
115
|
const issuedAt = Number(at);
|
|
105
116
|
if (!at || !Number.isFinite(issuedAt))
|
|
106
117
|
return null;
|
|
107
|
-
const want = createHmac("sha256", secret).update(
|
|
118
|
+
const want = createHmac("sha256", secret).update(body).digest("hex");
|
|
108
119
|
if (mac.length !== want.length)
|
|
109
120
|
return null;
|
|
110
121
|
if (!timingSafeEqual(Buffer.from(mac), Buffer.from(want)))
|
|
@@ -112,12 +123,16 @@ export function readSession(token, secret, now, maxAgeMs) {
|
|
|
112
123
|
if (now - issuedAt > maxAgeMs)
|
|
113
124
|
return null;
|
|
114
125
|
try {
|
|
115
|
-
|
|
126
|
+
const user = Buffer.from(u, "base64url").toString("utf8");
|
|
127
|
+
return user ? { user, mfa: mfa === "1" } : null;
|
|
116
128
|
}
|
|
117
129
|
catch {
|
|
118
130
|
return null;
|
|
119
131
|
}
|
|
120
132
|
}
|
|
133
|
+
export function readSession(token, secret, now, maxAgeMs) {
|
|
134
|
+
return readSessionFull(token, secret, now, maxAgeMs)?.user ?? null;
|
|
135
|
+
}
|
|
121
136
|
/** A week: long enough to hand the link over by another channel, short enough
|
|
122
137
|
* that a forgotten one stops working. */
|
|
123
138
|
export const INVITE_TTL_MS = 7 * 24 * 3600 * 1000;
|
package/dist/accounts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,WAAW,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2EAA2E;IAC3E,6DAA6D;IAC7D,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACvE,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -67,6 +67,13 @@ export interface Config {
|
|
|
67
67
|
* this instance and survives a reload.
|
|
68
68
|
*/
|
|
69
69
|
cockpitTheme?: Record<string, string>;
|
|
70
|
+
/**
|
|
71
|
+
* Per launch-directory two-factor sign-in (a passkey after the password),
|
|
72
|
+
* keyed by absolute cwd. Absent = off. Turned on from the Users panel, under
|
|
73
|
+
* the rules of `twoFactorEnableVerdict`; removing the key by hand IS the
|
|
74
|
+
* break-glass when every admin has lost their device (README).
|
|
75
|
+
*/
|
|
76
|
+
twoFactor?: Record<string, true>;
|
|
70
77
|
}
|
|
71
78
|
export declare const SHADOK_DIR: string;
|
|
72
79
|
export declare function loadConfig(): Config;
|
|
@@ -96,6 +103,9 @@ export declare function themeForCwd(cfg: Config, cwd: string): string | null;
|
|
|
96
103
|
* any unknown key clear the entry, so the instance falls back to the default.
|
|
97
104
|
*/
|
|
98
105
|
export declare function setThemeForCwd(cfg: Config, cwd: string, theme: string): void;
|
|
106
|
+
/** Is two-factor sign-in on for the instance launched in `cwd`? */
|
|
107
|
+
export declare function twoFactorForCwd(cfg: Config, cwd: string): boolean;
|
|
108
|
+
export declare function setTwoFactorForCwd(cfg: Config, cwd: string, on: boolean): void;
|
|
99
109
|
export interface TelegramConfig {
|
|
100
110
|
token: string | null;
|
|
101
111
|
envOverride: boolean;
|
package/dist/config.js
CHANGED
|
@@ -74,6 +74,18 @@ export function setThemeForCwd(cfg, cwd, theme) {
|
|
|
74
74
|
delete cfg.cockpitTheme[cwd];
|
|
75
75
|
saveConfig(cfg);
|
|
76
76
|
}
|
|
77
|
+
/** Is two-factor sign-in on for the instance launched in `cwd`? */
|
|
78
|
+
export function twoFactorForCwd(cfg, cwd) {
|
|
79
|
+
return cfg.twoFactor?.[cwd] === true;
|
|
80
|
+
}
|
|
81
|
+
export function setTwoFactorForCwd(cfg, cwd, on) {
|
|
82
|
+
cfg.twoFactor ??= {};
|
|
83
|
+
if (on)
|
|
84
|
+
cfg.twoFactor[cwd] = true;
|
|
85
|
+
else
|
|
86
|
+
delete cfg.twoFactor[cwd];
|
|
87
|
+
saveConfig(cfg);
|
|
88
|
+
}
|
|
77
89
|
/** Resolve the effective Telegram config for `cwd`: env overrides config. */
|
|
78
90
|
export function telegramConfig(cfg, cwd, env = process.env) {
|
|
79
91
|
const envTok = env.TELEGRAM_BOT_TOKEN;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAgF7B,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAChE,MAAM,WAAW,GAAG,IAAI,CAAC,I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