@trusty-squire/mcp 1.1.13-rc.8 → 1.1.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/README.md +139 -62
- package/assets/login/vnc-input.js +9 -0
- package/assets/login/vnc.html +214 -202
- package/assets/screencaps/connect-walkthrough.png +0 -0
- package/assets/screencaps/connect-walkthrough.svg +1 -1
- package/dist/api-client.d.ts +26 -3
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +19 -31
- package/dist/api-client.js.map +1 -1
- package/dist/bin.js +2 -3
- package/dist/bin.js.map +1 -1
- package/dist/bot/browser.d.ts +134 -77
- package/dist/bot/browser.d.ts.map +1 -1
- package/dist/bot/browser.js +1788 -1543
- package/dist/bot/browser.js.map +1 -1
- package/dist/bot/compact-observation-v2.d.ts +167 -0
- package/dist/bot/compact-observation-v2.d.ts.map +1 -0
- package/dist/bot/compact-observation-v2.js +1038 -0
- package/dist/bot/compact-observation-v2.js.map +1 -0
- package/dist/bot/credential-shape.d.ts +2 -0
- package/dist/bot/credential-shape.d.ts.map +1 -1
- package/dist/bot/credential-shape.js +21 -8
- package/dist/bot/credential-shape.js.map +1 -1
- package/dist/bot/element-fingerprint.d.ts +9 -0
- package/dist/bot/element-fingerprint.d.ts.map +1 -0
- package/dist/bot/element-fingerprint.js +147 -0
- package/dist/bot/element-fingerprint.js.map +1 -0
- package/dist/bot/email-verification.d.ts +7 -1
- package/dist/bot/email-verification.d.ts.map +1 -1
- package/dist/bot/email-verification.js +48 -14
- package/dist/bot/email-verification.js.map +1 -1
- package/dist/bot/google-login.d.ts +28 -52
- package/dist/bot/google-login.d.ts.map +1 -1
- package/dist/bot/google-login.js +246 -1119
- package/dist/bot/google-login.js.map +1 -1
- package/dist/bot/install-completion.d.ts +1 -2
- package/dist/bot/install-completion.d.ts.map +1 -1
- package/dist/bot/install-completion.js +1 -2
- package/dist/bot/install-completion.js.map +1 -1
- package/dist/bot/login-state.d.ts +13 -7
- package/dist/bot/login-state.d.ts.map +1 -1
- package/dist/bot/login-state.js +50 -114
- package/dist/bot/login-state.js.map +1 -1
- package/dist/bot/oauth-providers.d.ts +1 -1
- package/dist/bot/oauth-providers.d.ts.map +1 -1
- package/dist/bot/oauth-providers.js +3 -3
- package/dist/bot/oauth-providers.js.map +1 -1
- package/dist/bot/oauth-scope.d.ts +4 -0
- package/dist/bot/oauth-scope.d.ts.map +1 -0
- package/dist/bot/oauth-scope.js +58 -0
- package/dist/bot/oauth-scope.js.map +1 -0
- package/dist/bot/operator-browser-watchdog.d.ts +127 -0
- package/dist/bot/operator-browser-watchdog.d.ts.map +1 -0
- package/dist/bot/operator-browser-watchdog.js +438 -0
- package/dist/bot/operator-browser-watchdog.js.map +1 -0
- package/dist/bot/owner-process-reaper-worker.d.ts +2 -0
- package/dist/bot/owner-process-reaper-worker.d.ts.map +1 -0
- package/dist/bot/owner-process-reaper-worker.js +17 -0
- package/dist/bot/owner-process-reaper-worker.js.map +1 -0
- package/dist/bot/owner-process-reaper.d.ts +103 -0
- package/dist/bot/owner-process-reaper.d.ts.map +1 -0
- package/dist/bot/owner-process-reaper.js +1058 -0
- package/dist/bot/owner-process-reaper.js.map +1 -0
- package/dist/bot/pay-operator.d.ts +13 -2
- package/dist/bot/pay-operator.d.ts.map +1 -1
- package/dist/bot/pay-operator.js +319 -123
- package/dist/bot/pay-operator.js.map +1 -1
- package/dist/bot/profile.d.ts +10 -1
- package/dist/bot/profile.d.ts.map +1 -1
- package/dist/bot/profile.js +137 -11
- package/dist/bot/profile.js.map +1 -1
- package/dist/bot/promote-to-skill.js +1 -1
- package/dist/bot/promote-to-skill.js.map +1 -1
- package/dist/bot/provision-session.d.ts +60 -164
- package/dist/bot/provision-session.d.ts.map +1 -1
- package/dist/bot/provision-session.js +2049 -1546
- package/dist/bot/provision-session.js.map +1 -1
- package/dist/bot/remote-login-display.d.ts +61 -0
- package/dist/bot/remote-login-display.d.ts.map +1 -0
- package/dist/bot/remote-login-display.js +765 -0
- package/dist/bot/remote-login-display.js.map +1 -0
- package/dist/bot/session/hosts.d.ts +8 -0
- package/dist/bot/session/hosts.d.ts.map +1 -0
- package/dist/bot/session/hosts.js +36 -0
- package/dist/bot/session/hosts.js.map +1 -0
- package/dist/bot/session/lifecycle.d.ts +56 -0
- package/dist/bot/session/lifecycle.d.ts.map +1 -0
- package/dist/bot/session/lifecycle.js +962 -0
- package/dist/bot/session/lifecycle.js.map +1 -0
- package/dist/bot/session/model.d.ts +175 -0
- package/dist/bot/session/model.d.ts.map +1 -0
- package/dist/bot/session/model.js +77 -0
- package/dist/bot/session/model.js.map +1 -0
- package/dist/install/cli.d.ts +29 -9
- package/dist/install/cli.d.ts.map +1 -1
- package/dist/install/cli.js +243 -322
- package/dist/install/cli.js.map +1 -1
- package/dist/install/interactive.d.ts +1 -0
- package/dist/install/interactive.d.ts.map +1 -1
- package/dist/install/interactive.js +19 -5
- package/dist/install/interactive.js.map +1 -1
- package/dist/install/ui.d.ts.map +1 -1
- package/dist/install/ui.js +3 -15
- package/dist/install/ui.js.map +1 -1
- package/dist/operator-env.js +1 -1
- package/dist/operator-env.js.map +1 -1
- package/dist/server-instance-registry.d.ts +103 -0
- package/dist/server-instance-registry.d.ts.map +1 -0
- package/dist/server-instance-registry.js +392 -0
- package/dist/server-instance-registry.js.map +1 -0
- package/dist/server.d.ts +15 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +164 -62
- package/dist/server.js.map +1 -1
- package/dist/session-guard.d.ts +28 -0
- package/dist/session-guard.d.ts.map +1 -0
- package/dist/session-guard.js +84 -0
- package/dist/session-guard.js.map +1 -0
- package/dist/session.d.ts +57 -13
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +246 -127
- package/dist/session.js.map +1 -1
- package/dist/tools/audit-log.d.ts +16 -2
- package/dist/tools/audit-log.d.ts.map +1 -1
- package/dist/tools/audit-log.js +223 -13
- package/dist/tools/audit-log.js.map +1 -1
- package/dist/tools/audit-rollup.d.ts +80 -0
- package/dist/tools/audit-rollup.d.ts.map +1 -0
- package/dist/tools/audit-rollup.js +0 -0
- package/dist/tools/audit-rollup.js.map +1 -0
- package/dist/tools/fetch-credential.d.ts +37 -0
- package/dist/tools/fetch-credential.d.ts.map +1 -0
- package/dist/tools/fetch-credential.js +153 -0
- package/dist/tools/fetch-credential.js.map +1 -0
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +7 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/operate-pay.d.ts +4 -4
- package/dist/tools/operate-pay.d.ts.map +1 -1
- package/dist/tools/operate-pay.js +163 -96
- package/dist/tools/operate-pay.js.map +1 -1
- package/dist/tools/provision-drive.d.ts +43 -35
- package/dist/tools/provision-drive.d.ts.map +1 -1
- package/dist/tools/provision-drive.js +268 -164
- package/dist/tools/provision-drive.js.map +1 -1
- package/dist/tools/use-credential.d.ts.map +1 -1
- package/dist/tools/use-credential.js +3 -2
- package/dist/tools/use-credential.js.map +1 -1
- package/package.json +4 -6
- package/dist/bot/operator-direct-identity.d.ts +0 -26
- package/dist/bot/operator-direct-identity.d.ts.map +0 -1
- package/dist/bot/operator-direct-identity.js +0 -120
- package/dist/bot/operator-direct-identity.js.map +0 -1
- package/dist/bot/operator-profile-pool.d.ts +0 -97
- package/dist/bot/operator-profile-pool.d.ts.map +0 -1
- package/dist/bot/operator-profile-pool.js +0 -855
- package/dist/bot/operator-profile-pool.js.map +0 -1
- package/dist/bot/xvfb.d.ts +0 -13
- package/dist/bot/xvfb.d.ts.map +0 -1
- package/dist/bot/xvfb.js +0 -146
- package/dist/bot/xvfb.js.map +0 -1
package/dist/session.js
CHANGED
|
@@ -1,164 +1,283 @@
|
|
|
1
1
|
// MCP session storage.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// ONE store, ONE pathway: 0600 JSON files under
|
|
4
|
+
// $XDG_CONFIG_HOME/trusty-squire/ (or ~/.config/trusty-squire/). There is no
|
|
5
|
+
// keychain backend or environment-selectable alternate store.
|
|
6
|
+
//
|
|
7
|
+
// Each account owns its source-of-truth `sessions/<account_id>.json`, written
|
|
8
|
+
// atomically. Do not add a cross-process lock: a write touches only one
|
|
9
|
+
// account's file, so accounts cannot lose each other's updates.
|
|
10
|
+
//
|
|
11
|
+
// `session.json` remains the last-write-wins current-account pointer and a
|
|
12
|
+
// flat compatibility mirror for older running builds. Reads never rewrite it;
|
|
13
|
+
// migration to `sessions/<account_id>.json` happens only on an explicit write.
|
|
14
|
+
import { randomUUID } from "node:crypto";
|
|
7
15
|
import { promises as fs } from "node:fs";
|
|
8
16
|
import os from "node:os";
|
|
9
17
|
import path from "node:path";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return path.join(process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config"), "trusty-squire", "session.json");
|
|
20
|
-
}
|
|
21
|
-
// Tries keytar first. Falls back to the file backend if keytar isn't
|
|
22
|
-
// installed or its native binding can't load. The fallback is also the
|
|
23
|
-
// chosen backend for CI / tests.
|
|
24
|
-
export async function openSessionStorage(options = {}) {
|
|
25
|
-
if (options.preferFile === true || preferFileFromEnv()) {
|
|
26
|
-
return new FileStorage();
|
|
27
|
-
}
|
|
28
|
-
const keytar = await tryLoadKeytar();
|
|
29
|
-
if (keytar !== null)
|
|
30
|
-
return new KeytarStorage(keytar);
|
|
31
|
-
return new FileStorage();
|
|
18
|
+
import { VERSION } from "./version.js";
|
|
19
|
+
// rc.21 — DO NOT cache the file path at module-load time. Tests sandbox via
|
|
20
|
+
// beforeEach { process.env.HOME = tmpdir }; a path cached at import time
|
|
21
|
+
// captures the REAL ~/.config/trusty-squire/ and the test then writes the
|
|
22
|
+
// test-fixture session.json to the user's actual home, destroying live
|
|
23
|
+
// credentials. Resolve per-call so the env override in effect at write-time
|
|
24
|
+
// wins.
|
|
25
|
+
function resolveConfigDir() {
|
|
26
|
+
return path.join(process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config"), "trusty-squire");
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const v = (process.env.TRUSTY_SQUIRE_SESSION_FILE ?? "").trim().toLowerCase();
|
|
42
|
-
return v === "1" || v === "true" || v === "yes";
|
|
28
|
+
/**
|
|
29
|
+
* Slot for an entry whose claim has not landed yet, so it has no account to be
|
|
30
|
+
* keyed by. A real account_id is a ULID, so this can never collide with one.
|
|
31
|
+
*/
|
|
32
|
+
export const UNBOUND_ACCOUNT_KEY = "__unbound__";
|
|
33
|
+
export function accountKey(data) {
|
|
34
|
+
const id = data.account_id;
|
|
35
|
+
return id !== undefined && id.length > 0 ? id : UNBOUND_ACCOUNT_KEY;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
deletePassword: mod.default.deletePassword,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return null;
|
|
37
|
+
/**
|
|
38
|
+
* The account entry a server bound to is gone — logged out, or erased by hand.
|
|
39
|
+
* Loud rather than an empty read, because an empty read reports "not installed"
|
|
40
|
+
* for a machine that is installed, just not under this account any more.
|
|
41
|
+
*/
|
|
42
|
+
export class AccountSessionMissingError extends Error {
|
|
43
|
+
accountId;
|
|
44
|
+
available;
|
|
45
|
+
code = "account_session_missing";
|
|
46
|
+
constructor(accountId, available, self = { pid: process.pid, version: VERSION }) {
|
|
47
|
+
super(`This Trusty Squire server (pid ${self.pid}, v${self.version}) is bound to account ` +
|
|
48
|
+
`${accountId}, but that account no longer has a session on this machine ` +
|
|
49
|
+
`(${available.length === 0 ? "no accounts are installed" : `installed: ${available.join(", ")}`}). ` +
|
|
50
|
+
`Refusing to fall back to another account — a credential in one account's vault is ` +
|
|
51
|
+
`not visible from another. Re-run \`npx @trusty-squire/mcp connect\` under account ` +
|
|
52
|
+
`${accountId}, or restart this host agent's Trusty Squire connection to adopt the ` +
|
|
53
|
+
`account it is now installed under.`);
|
|
54
|
+
this.accountId = accountId;
|
|
55
|
+
this.available = available;
|
|
56
|
+
this.name = "AccountSessionMissingError";
|
|
69
57
|
}
|
|
70
58
|
}
|
|
71
59
|
function withoutLegacyProxy(data) {
|
|
72
60
|
const stored = data;
|
|
73
|
-
if (!Object.prototype.hasOwnProperty.call(stored, "proxy_url"))
|
|
74
|
-
return
|
|
75
|
-
}
|
|
61
|
+
if (!Object.prototype.hasOwnProperty.call(stored, "proxy_url"))
|
|
62
|
+
return data;
|
|
76
63
|
const clean = { ...stored };
|
|
77
64
|
delete clean.proxy_url;
|
|
78
|
-
return
|
|
65
|
+
return clean;
|
|
79
66
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
67
|
+
/** A stored entry, or null when the file is absent or not an object. */
|
|
68
|
+
function parseEntry(raw) {
|
|
69
|
+
if (raw === null || typeof raw !== "object")
|
|
70
|
+
return null;
|
|
71
|
+
return withoutLegacyProxy(raw);
|
|
89
72
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.kt = kt;
|
|
94
|
-
}
|
|
95
|
-
async read() {
|
|
96
|
-
const raw = await this.kt.getPassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT);
|
|
97
|
-
if (raw === null)
|
|
98
|
-
return null;
|
|
99
|
-
let data;
|
|
100
|
-
try {
|
|
101
|
-
data = JSON.parse(raw);
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const clean = withoutLegacyProxy(data);
|
|
107
|
-
await migrateLegacyProxy(clean, async (session) => {
|
|
108
|
-
await this.kt.setPassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT, JSON.stringify(session));
|
|
109
|
-
});
|
|
110
|
-
return clean.data;
|
|
111
|
-
}
|
|
112
|
-
async write(data) {
|
|
113
|
-
const clean = withoutLegacyProxy(data).data;
|
|
114
|
-
await this.kt.setPassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT, JSON.stringify(clean));
|
|
115
|
-
}
|
|
116
|
-
async clear() {
|
|
117
|
-
await this.kt.deletePassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT);
|
|
118
|
-
}
|
|
119
|
-
backendName() {
|
|
120
|
-
return "keytar";
|
|
121
|
-
}
|
|
73
|
+
/** Account ids are ULIDs; refuse anything that could escape the directory. */
|
|
74
|
+
function isSafeAccountKey(key) {
|
|
75
|
+
return /^[A-Za-z0-9_-]{1,128}$/.test(key) || key === UNBOUND_ACCOUNT_KEY;
|
|
122
76
|
}
|
|
123
|
-
export class
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
//
|
|
77
|
+
export class SessionStore {
|
|
78
|
+
/** The current-account pointer and pre-per-account compatibility mirror. */
|
|
79
|
+
path;
|
|
80
|
+
dir;
|
|
81
|
+
// Allow tests to override the location. When no override is supplied, resolve
|
|
82
|
+
// the path NOW (constructor invocation) instead of capturing a value cached
|
|
83
|
+
// at module-import time — see resolveConfigDir.
|
|
129
84
|
constructor(filePath) {
|
|
130
|
-
this.
|
|
85
|
+
this.path = filePath ?? path.join(resolveConfigDir(), "session.json");
|
|
86
|
+
this.dir = path.dirname(this.path);
|
|
87
|
+
}
|
|
88
|
+
get sessionsDir() {
|
|
89
|
+
return path.join(this.dir, "sessions");
|
|
90
|
+
}
|
|
91
|
+
accountFile(accountId) {
|
|
92
|
+
return path.join(this.sessionsDir, `${accountId}.json`);
|
|
131
93
|
}
|
|
132
|
-
async
|
|
133
|
-
let raw;
|
|
94
|
+
async readJson(file) {
|
|
134
95
|
try {
|
|
135
|
-
|
|
96
|
+
return JSON.parse(await fs.readFile(file, "utf8"));
|
|
136
97
|
}
|
|
137
98
|
catch (err) {
|
|
138
99
|
if (err.code === "ENOENT")
|
|
139
100
|
return null;
|
|
140
101
|
throw err;
|
|
141
102
|
}
|
|
142
|
-
const clean = withoutLegacyProxy(JSON.parse(raw));
|
|
143
|
-
await migrateLegacyProxy(clean, async (session) => await this.write(session));
|
|
144
|
-
return clean.data;
|
|
145
103
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
104
|
+
/**
|
|
105
|
+
* The legacy flat pointer/mirror. Also the pre-per-account file, which is
|
|
106
|
+
* why a read falls back to it: an install that predates `sessions/` has its
|
|
107
|
+
* only copy here, and reading must not require migrating it first.
|
|
108
|
+
*/
|
|
109
|
+
async readPointer() {
|
|
110
|
+
return parseEntry(await this.readJson(this.path));
|
|
111
|
+
}
|
|
112
|
+
async writeAtomic(file, value) {
|
|
113
|
+
await fs.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
114
|
+
// Write-then-rename so a reader — including an older server reading the
|
|
115
|
+
// pointer — never observes a partially written file. rename within the
|
|
116
|
+
// same directory is atomic.
|
|
117
|
+
const temporary = `${file}.tmp-${randomUUID()}`;
|
|
118
|
+
try {
|
|
119
|
+
await fs.writeFile(temporary, `${JSON.stringify(value, null, 2)}\n`, {
|
|
120
|
+
mode: 0o600,
|
|
121
|
+
flag: "wx",
|
|
122
|
+
});
|
|
123
|
+
await fs.rename(temporary, file);
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
await fs.rm(temporary, { force: true });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async writeAtomicIfMissing(file, value) {
|
|
130
|
+
await fs.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
131
|
+
const temporary = `${file}.tmp-${randomUUID()}`;
|
|
132
|
+
try {
|
|
133
|
+
await fs.writeFile(temporary, `${JSON.stringify(value, null, 2)}\n`, {
|
|
134
|
+
mode: 0o600,
|
|
135
|
+
flag: "wx",
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
await fs.link(temporary, file);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
if (err.code !== "EEXIST")
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
await fs.rm(temporary, { force: true });
|
|
147
|
+
}
|
|
150
148
|
}
|
|
151
|
-
|
|
149
|
+
/** Every account installed on this machine. */
|
|
150
|
+
async listAccounts() {
|
|
151
|
+
let names;
|
|
152
152
|
try {
|
|
153
|
-
await fs.
|
|
153
|
+
names = await fs.readdir(this.sessionsDir);
|
|
154
154
|
}
|
|
155
155
|
catch (err) {
|
|
156
156
|
if (err.code !== "ENOENT")
|
|
157
157
|
throw err;
|
|
158
|
+
names = [];
|
|
158
159
|
}
|
|
160
|
+
const accounts = names
|
|
161
|
+
.filter((name) => name.endsWith(".json") && !name.includes(".tmp-"))
|
|
162
|
+
.map((name) => name.slice(0, -".json".length))
|
|
163
|
+
.filter(isSafeAccountKey);
|
|
164
|
+
// An install that predates `sessions/` lives only in the pointer file.
|
|
165
|
+
if (accounts.length === 0) {
|
|
166
|
+
const legacy = await this.readPointer();
|
|
167
|
+
if (legacy !== null)
|
|
168
|
+
return [accountKey(legacy)];
|
|
169
|
+
}
|
|
170
|
+
return accounts.sort();
|
|
159
171
|
}
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
/** The account the most recent connect bound, for a reader that has no own. */
|
|
173
|
+
async currentAccountId() {
|
|
174
|
+
const pointer = await this.readPointer();
|
|
175
|
+
if (pointer !== null)
|
|
176
|
+
return accountKey(pointer);
|
|
177
|
+
const accounts = await this.listAccounts();
|
|
178
|
+
return accounts.length === 1 ? accounts[0] : null;
|
|
162
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* One account's entry. With `accountId`, ONLY that account's file — a caller
|
|
182
|
+
* bound to an account never silently reads another's. Without it, the account
|
|
183
|
+
* the most recent connect bound.
|
|
184
|
+
*/
|
|
185
|
+
async read(accountId) {
|
|
186
|
+
if (accountId === undefined) {
|
|
187
|
+
const current = await this.currentAccountId();
|
|
188
|
+
return current === null ? null : await this.read(current);
|
|
189
|
+
}
|
|
190
|
+
if (!isSafeAccountKey(accountId))
|
|
191
|
+
return null;
|
|
192
|
+
const own = parseEntry(await this.readJson(this.accountFile(accountId)));
|
|
193
|
+
if (own !== null)
|
|
194
|
+
return own;
|
|
195
|
+
// Mixed builds can still write a flat pointer for an account with no
|
|
196
|
+
// per-account file. That fallback is required for those live sessions;
|
|
197
|
+
// only a manual file deletion leaves it masking a missing account.
|
|
198
|
+
const pointer = await this.readPointer();
|
|
199
|
+
return pointer !== null && accountKey(pointer) === accountId ? pointer : null;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Upsert ONE account's entry. Structurally cannot touch another account's:
|
|
203
|
+
* it writes that account's own file, then refreshes the pointer/mirror.
|
|
204
|
+
*/
|
|
205
|
+
async write(data) {
|
|
206
|
+
const key = accountKey(data);
|
|
207
|
+
if (!isSafeAccountKey(key)) {
|
|
208
|
+
throw new Error(`Invalid session account ID: ${key}`);
|
|
209
|
+
}
|
|
210
|
+
const entry = withoutLegacyProxy(data);
|
|
211
|
+
await this.writeAtomic(this.accountFile(key), entry);
|
|
212
|
+
// A claim that finally names an account supersedes the transient pre-claim
|
|
213
|
+
// entry rather than leaving it behind forever.
|
|
214
|
+
if (key !== UNBOUND_ACCOUNT_KEY) {
|
|
215
|
+
await fs.rm(this.accountFile(UNBOUND_ACCOUNT_KEY), { force: true });
|
|
216
|
+
}
|
|
217
|
+
const pointer = await this.readPointer();
|
|
218
|
+
if (pointer !== null) {
|
|
219
|
+
const pointerKey = accountKey(pointer);
|
|
220
|
+
if (pointerKey !== key &&
|
|
221
|
+
pointerKey !== UNBOUND_ACCOUNT_KEY &&
|
|
222
|
+
isSafeAccountKey(pointerKey)) {
|
|
223
|
+
await this.writeAtomicIfMissing(this.accountFile(pointerKey), pointer);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// The pointer, in the ORIGINAL flat shape, so servers already running an
|
|
227
|
+
// older build keep reading a binding they understand. Last-write-wins is
|
|
228
|
+
// the correct semantics: the most recent connect IS the current account.
|
|
229
|
+
await this.writeAtomic(this.path, entry);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Remove ONE account's entry (the current one by default). Other accounts'
|
|
233
|
+
* files are untouched; the pointer moves to a survivor, or is deleted when
|
|
234
|
+
* nothing is left.
|
|
235
|
+
*/
|
|
236
|
+
async clear(accountId) {
|
|
237
|
+
const key = accountId ?? (await this.currentAccountId());
|
|
238
|
+
if (key === null || key === undefined)
|
|
239
|
+
return;
|
|
240
|
+
if (!isSafeAccountKey(key)) {
|
|
241
|
+
throw new Error(`Invalid session account ID: ${key}`);
|
|
242
|
+
}
|
|
243
|
+
const pointer = await this.readPointer();
|
|
244
|
+
if (pointer !== null && accountKey(pointer) === key) {
|
|
245
|
+
const remaining = (await this.listAccounts()).filter((id) => id !== key);
|
|
246
|
+
if (remaining.length > 0) {
|
|
247
|
+
const survivor = await this.read(remaining[0]);
|
|
248
|
+
if (survivor !== null) {
|
|
249
|
+
await this.writeAtomic(this.path, survivor);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
try {
|
|
253
|
+
await fs.unlink(this.path);
|
|
254
|
+
}
|
|
255
|
+
catch (err) {
|
|
256
|
+
if (err.code !== "ENOENT")
|
|
257
|
+
throw err;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
try {
|
|
263
|
+
await fs.unlink(this.path);
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
if (err.code !== "ENOENT")
|
|
267
|
+
throw err;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const targetFile = this.accountFile(key);
|
|
272
|
+
await fs.rm(targetFile, { force: true });
|
|
273
|
+
// This catches a writer that re-materialized the legacy-only pointer
|
|
274
|
+
// account while logout retargeted the pointer. A writer already paused
|
|
275
|
+
// after its snapshot can still land later, but only for a legacy-only
|
|
276
|
+
// account and only as a stale credential file, never cross-account reads.
|
|
277
|
+
await fs.rm(targetFile, { force: true });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
export async function openSessionStorage(options = {}) {
|
|
281
|
+
return new SessionStore(options.filePath);
|
|
163
282
|
}
|
|
164
283
|
//# sourceMappingURL=session.js.map
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,EAAE;AACF,gDAAgD;AAChD,6EAA6E;AAC7E,8DAA8D;AAC9D,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AACxE,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC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CAAC,CAAC;oBAC7B,CAAC;oBAAC,OAAO,GAAG,EAAE,CAAC;wBACb,IAAK,GAAyB,CAAC,IAAI,KAAK,QAAQ;4BAAE,MAAM,GAAG,CAAC;oBAC9D,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC;oBACH,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,IAAK,GAAyB,CAAC,IAAI,KAAK,QAAQ;wBAAE,MAAM,GAAG,CAAC;gBAC9D,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,qEAAqE;QACrE,uEAAuE;QACvE,sEAAsE;QACtE,0EAA0E;QAC1E,MAAM,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,UAAiC,EAAE;IAEnC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type Tool } from "./index.js";
|
|
3
|
+
import { normalizeAuditType } from "./audit-rollup.js";
|
|
3
4
|
declare const inputSchema: z.ZodObject<{
|
|
4
5
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
5
6
|
before: z.ZodOptional<z.ZodString>;
|
|
6
7
|
type: z.ZodOptional<z.ZodString>;
|
|
7
8
|
reference: z.ZodOptional<z.ZodString>;
|
|
9
|
+
view: z.ZodOptional<z.ZodEnum<["ledger", "raw"]>>;
|
|
10
|
+
scan: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
window_minutes: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
expand: z.ZodOptional<z.ZodString>;
|
|
8
13
|
}, "strip", z.ZodTypeAny, {
|
|
9
14
|
limit?: number | undefined;
|
|
10
15
|
before?: string | undefined;
|
|
11
16
|
type?: string | undefined;
|
|
12
17
|
reference?: string | undefined;
|
|
18
|
+
view?: "raw" | "ledger" | undefined;
|
|
19
|
+
scan?: number | undefined;
|
|
20
|
+
window_minutes?: number | undefined;
|
|
21
|
+
expand?: string | undefined;
|
|
13
22
|
}, {
|
|
14
23
|
limit?: number | undefined;
|
|
15
24
|
before?: string | undefined;
|
|
16
25
|
type?: string | undefined;
|
|
17
26
|
reference?: string | undefined;
|
|
27
|
+
view?: "raw" | "ledger" | undefined;
|
|
28
|
+
scan?: number | undefined;
|
|
29
|
+
window_minutes?: number | undefined;
|
|
30
|
+
expand?: string | undefined;
|
|
18
31
|
}>;
|
|
19
|
-
|
|
20
|
-
export
|
|
32
|
+
type AuditLogArgs = z.infer<typeof inputSchema>;
|
|
33
|
+
export declare const auditLogTool: Tool<AuditLogArgs>;
|
|
34
|
+
export { normalizeAuditType };
|
|
21
35
|
//# sourceMappingURL=audit-log.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-log.d.ts","sourceRoot":"","sources":["../../src/tools/audit-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAa,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"audit-log.d.ts","sourceRoot":"","sources":["../../src/tools/audit-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAa,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EASL,kBAAkB,EAGnB,MAAM,mBAAmB,CAAC;AAa3B,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;EAef,CAAC;AAEH,KAAK,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AA6BhD,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,YAAY,CA4B3C,CAAC;AAmNF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|