@mysten-incubation/memwal-mcp 0.0.14-dev.1 → 0.0.14-dev.3

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/auth.js CHANGED
@@ -10,9 +10,9 @@
10
10
  * documentation patterns transfer cleanly.
11
11
  */
12
12
  import { homedir } from "node:os";
13
- import { randomUUID } from "node:crypto";
14
- import { join, dirname, basename } from "node:path";
15
- import { mkdirSync, readFileSync, writeFileSync, renameSync, unlinkSync, existsSync, } from "node:fs";
13
+ import { createHash, randomUUID } from "node:crypto";
14
+ import { join, dirname, basename, isAbsolute, relative } from "node:path";
15
+ import { mkdirSync, readFileSync, writeFileSync, renameSync, unlinkSync, existsSync, realpathSync, } from "node:fs";
16
16
  import { log } from "./logger.js";
17
17
  const CREDS_FILE = "credentials.json";
18
18
  /** Global, per-machine location. Always the fallback, and the only location
@@ -60,37 +60,285 @@ function projectCredsPath() {
60
60
  dir = parent;
61
61
  }
62
62
  }
63
+ /* ------------------------------------------------------------------------- *
64
+ * Project credentials are opt-IN, per machine (WALM-639).
65
+ *
66
+ * Presence alone used to be the opt-in: a `.memwal/credentials.json` anywhere
67
+ * at or above the working directory simply won. But that file is INSIDE the
68
+ * repository, so anyone who can commit to a repo — or persuade someone to
69
+ * clone one — could choose the account and the relayer every memory written
70
+ * from that directory goes to. Opening a project silently repointed the
71
+ * destination, and the writes land on immutable storage with no delete path.
72
+ *
73
+ * So a project file is now inert until the user approves that exact file,
74
+ * account, delegate and relayer. The approval record lives beside the GLOBAL
75
+ * credentials, never in the repository, because a record a repository can
76
+ * carry is a repository approving itself.
77
+ * ------------------------------------------------------------------------- */
78
+ const APPROVALS_FILE = "project-approvals.json";
79
+ /**
80
+ * Refusal of a `MEMWAL_CREDS_DIR` that cannot be trusted to sit outside a
81
+ * repository. Thrown, never swallowed — see {@link credsDirOverride}.
82
+ */
83
+ export class UntrustedCredsDirError extends Error {
84
+ constructor(message) {
85
+ super(message);
86
+ this.name = "UntrustedCredsDirError";
87
+ }
88
+ }
89
+ /** True when `path` is `root` itself or something underneath it. String
90
+ * prefixes get `/repo` vs `/repo-2` wrong, so this asks `relative` instead. */
91
+ function isInside(root, path) {
92
+ const rel = relative(root, path);
93
+ return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
94
+ }
63
95
  /**
64
- * Which credentials file this process should read and write.
96
+ * Canonical form of a path that need not exist yet.
65
97
  *
66
- * The nearest project-local `.memwal/credentials.json` at or above the working
67
- * directory wins over the global one, the way `.npmrc` and `.git/config`
68
- * resolve. Signing in from one project otherwise repoints every other project
69
- * on the machine at a different account and delegate key, silently memories
70
- * then land on the wrong account, on immutable storage, with no delete path
71
- * (GH #628).
98
+ * `realpathSync` throws on a missing leaf, and the override names a directory
99
+ * this process may be about to create — so resolve the deepest ancestor that
100
+ * does exist and re-append the rest. Without this, comparing it against the
101
+ * project root is decided by which spelling of a symlinked path each side
102
+ * happened to use: on macOS `/tmp/x` and `/private/tmp/x` are the same
103
+ * directory, and a containment check that says otherwise is a check an
104
+ * attacker picks the spelling to defeat.
105
+ */
106
+ function canonicalDir(path) {
107
+ const tail = [];
108
+ let dir = path;
109
+ for (;;) {
110
+ if (existsSync(dir))
111
+ return join(realpathSync(dir), ...tail.reverse());
112
+ const parent = dirname(dir);
113
+ if (parent === dir)
114
+ return path;
115
+ tail.push(basename(dir));
116
+ dir = parent;
117
+ }
118
+ }
119
+ /**
120
+ * The repository the working directory is in, or null.
72
121
  *
73
- * Presence-based on purpose: creating the local file is the opt-in, so this is
74
- * purely additive. Resolved per call rather than at module load, because the
75
- * working directory is not knowable at import time.
122
+ * Bounded exactly like {@link projectCredsPath}'s walk nearest ancestor
123
+ * carrying `.git`, stopping at the home directory or the filesystem root — so
124
+ * "the project" means the same thing to the override check as it does to
125
+ * resolution.
126
+ */
127
+ function projectRoot() {
128
+ const home = homedir();
129
+ let dir = process.cwd();
130
+ for (;;) {
131
+ if (dir === home)
132
+ return null;
133
+ if (existsSync(join(dir, ".git")))
134
+ return dir;
135
+ const parent = dirname(dir);
136
+ if (parent === dir)
137
+ return null;
138
+ dir = parent;
139
+ }
140
+ }
141
+ /**
142
+ * `MEMWAL_CREDS_DIR`, but only when it can be trusted — and the same answer for
143
+ * every reader of it.
144
+ *
145
+ * The override decides the credentials outright and skips the approval gate
146
+ * entirely, which makes it exactly as trustworthy as whoever set the
147
+ * environment. That is the right trade for the thing it exists for — a shell, a
148
+ * test harness, CI — and the wrong one for the way it is reachable: an MCP
149
+ * client reads `.cursor/mcp.json`, `.vscode/mcp.json` or `.claude/settings.json`
150
+ * OUT OF THE CHECKOUT and hands this process the `env` block it finds there. A
151
+ * committed `env` block is a repository setting its own override, which is the
152
+ * thing WALM-639 exists to stop.
153
+ *
154
+ * So two shapes are refused:
155
+ *
156
+ * - **Relative.** `join("", CREDS_FILE)` is the bare string
157
+ * `"credentials.json"` and `join(".memwal", CREDS_FILE)` is repo-local:
158
+ * both resolve against `process.cwd()`. That moves the credentials AND the
159
+ * approval store into whatever directory the client started in — usually
160
+ * the project root, so the store that exists precisely so a repository
161
+ * cannot carry its own approval becomes a file the repository carries.
162
+ * - **Absolute, but inside the current project.** Editors expand
163
+ * `${workspaceFolder}` inside those same config files, so "absolute" is not
164
+ * by itself evidence a human typed it. An override pointing into the
165
+ * checkout contradicts the one property this escape hatch is justified by.
166
+ *
167
+ * Refusing is loud on purpose, and matches the launcher's treatment of a
168
+ * relative runtime directory: falling back to the global directory in silence
169
+ * would hide a misconfigured — or hostile — client config, and leave the user
170
+ * to work out on their own why their override did nothing.
76
171
  *
77
- * `MEMWAL_CREDS_DIR` overrides both project and global resolution when set,
78
- * and is re-read on every call.
172
+ * An EMPTY value is the one thing that is not an error. It names no directory
173
+ * at all, which is what "unset" means, and it is what every other reader of
174
+ * this variable already treats it as; the bug was never that empty meant unset,
175
+ * it was that `??` let empty mean "the working directory".
79
176
  */
80
- export function credsPath() {
81
- const override = process.env.MEMWAL_CREDS_DIR;
177
+ function credsDirOverride() {
178
+ const raw = process.env.MEMWAL_CREDS_DIR;
179
+ if (!raw)
180
+ return null;
181
+ if (!isAbsolute(raw)) {
182
+ throw new UntrustedCredsDirError(`MEMWAL_CREDS_DIR is a relative path (${JSON.stringify(raw)}). It resolves against ` +
183
+ `the working directory, which would put your credentials — and the record of ` +
184
+ `which project credentials you have approved — inside whatever directory this ` +
185
+ `process was started in. Set it to an absolute path, or unset it. ` +
186
+ `If you did not set it yourself, look at the \`env\` block of this project's MCP ` +
187
+ `config (.cursor/mcp.json, .vscode/mcp.json, .claude/settings.json): a value a ` +
188
+ `repository carries is the repository choosing where your memories go.`);
189
+ }
190
+ const root = projectRoot() ?? process.cwd();
191
+ const dir = canonicalDir(raw);
192
+ if (isInside(canonicalDir(root), dir)) {
193
+ throw new UntrustedCredsDirError(`MEMWAL_CREDS_DIR (${raw}) points inside the current project (${root}). The ` +
194
+ `override skips the project-approval gate, so it has to name a directory no ` +
195
+ `repository can write — and an editor expands \`\${workspaceFolder}\` in a ` +
196
+ `committed MCP config, so an absolute path is not by itself proof that you ` +
197
+ `chose it. Point it outside the project, or unset it and run ` +
198
+ `\`memwal-mcp approve-project\` if you did mean to use this project's credentials.`);
199
+ }
200
+ return raw;
201
+ }
202
+ /**
203
+ * Where records that a repository must not be able to write are kept.
204
+ *
205
+ * `MEMWAL_CREDS_DIR` is the trusted escape hatch — when it is set it decides
206
+ * the credentials outright and project resolution never runs — so following it
207
+ * here keeps a sandboxed run (tests, CI) from reaching into the real
208
+ * `~/.memwal`, exactly as #705 required for the credentials file itself. It is
209
+ * read through {@link credsDirOverride} so that "trusted" means the same thing
210
+ * here, in {@link resolveCreds} and in {@link approveProjectCreds}: one rule,
211
+ * checked once, rather than three checks that can drift apart.
212
+ */
213
+ function trustedStateDir() {
214
+ return credsDirOverride() ?? join(homedir(), ".memwal");
215
+ }
216
+ /** The approval store. Outside every repository, on purpose. */
217
+ export function projectApprovalsPath() {
218
+ return join(trustedStateDir(), APPROVALS_FILE);
219
+ }
220
+ /**
221
+ * What approval is granted against: the destination, not the file's bytes.
222
+ *
223
+ * Account, delegate and relayer are the three fields that decide WHERE a
224
+ * memory ends up and WHO signs for it. Hashing them means a project file may
225
+ * be re-saved, relabelled or reformatted freely, while any edit that moves the
226
+ * destination invalidates the approval and has to be approved again. The
227
+ * delegate private key is deliberately NOT part of it — it must never be read
228
+ * into a record that gets written back out.
229
+ */
230
+ export function credentialsFingerprint(creds) {
231
+ return createHash("sha256")
232
+ .update(`${creds.accountId}\n${creds.delegateAddress}\n${creds.relayerUrl}`)
233
+ .digest("hex");
234
+ }
235
+ /** Compare paths the way the filesystem does. `process.cwd()` reports a
236
+ * resolved path and an approval may have been recorded through a symlink (or
237
+ * on macOS, `/tmp` → `/private/tmp`), so both sides go through this. */
238
+ function canonicalPath(path) {
239
+ try {
240
+ return realpathSync(path);
241
+ }
242
+ catch {
243
+ return path;
244
+ }
245
+ }
246
+ function isValidApproval(obj) {
247
+ if (!obj || typeof obj !== "object")
248
+ return false;
249
+ const a = obj;
250
+ return (typeof a.path === "string" &&
251
+ typeof a.fingerprint === "string" &&
252
+ typeof a.accountId === "string" &&
253
+ typeof a.delegateAddress === "string" &&
254
+ typeof a.relayerUrl === "string");
255
+ }
256
+ /** Approvals on record. A missing, malformed or unreadable store approves
257
+ * nothing — the safe direction, since the consequence is falling back to the
258
+ * user's own global account rather than adopting someone else's. */
259
+ function loadApprovals() {
260
+ const path = projectApprovalsPath();
261
+ if (!existsSync(path))
262
+ return [];
263
+ try {
264
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
265
+ if (!parsed || parsed.version !== 1 || !Array.isArray(parsed.approvals))
266
+ return [];
267
+ return parsed.approvals.filter(isValidApproval);
268
+ }
269
+ catch {
270
+ return [];
271
+ }
272
+ }
273
+ /** Through the same writer as the credentials file: it creates the directory
274
+ * at `0700` and the file at `0600`. The record holds no secret, but it decides
275
+ * where memories go, so it should not be writable by anything that could not
276
+ * already write the credentials beside it. */
277
+ function saveApprovals(approvals) {
278
+ writeSecretFile(projectApprovalsPath(), JSON.stringify({ version: 1, approvals }, null, 2));
279
+ }
280
+ /**
281
+ * Which credentials file this process should read and write, and why.
282
+ *
283
+ * `MEMWAL_CREDS_DIR` wins outright, and skips the approval gate — but only a
284
+ * value {@link credsDirOverride} accepts, i.e. a non-empty ABSOLUTE path
285
+ * outside the current project. It is "trusted" exactly as far as whoever set
286
+ * the environment is, and an MCP client will hand this process an `env` block
287
+ * it read out of the checkout, so a value that could have been committed is
288
+ * refused rather than obeyed. Otherwise the nearest project-local
289
+ * `.memwal/credentials.json` at or above the working directory is used IF the
290
+ * user has approved that exact destination on this machine (WALM-639), and the
291
+ * global file is used in every other case — including an unapproved, altered
292
+ * or malformed project file. Falling back rather than failing keeps a machine
293
+ * that has never seen a project file behaving exactly as it always did.
294
+ *
295
+ * Resolved per call rather than at module load, because neither the working
296
+ * directory nor the approval store is knowable at import time.
297
+ */
298
+ export function resolveCreds() {
299
+ const override = credsDirOverride();
82
300
  if (override)
83
- return join(override, CREDS_FILE);
84
- return projectCredsPath() ?? globalCredsPath();
301
+ return { path: join(override, CREDS_FILE), source: "override" };
302
+ const global = globalCredsPath();
303
+ const projectPath = projectCredsPath();
304
+ if (!projectPath)
305
+ return { path: global, source: "global" };
306
+ const project = readCredsFile(projectPath);
307
+ if (!project) {
308
+ return {
309
+ path: global,
310
+ source: "global",
311
+ project: { path: projectPath, decision: "unreadable" },
312
+ };
313
+ }
314
+ const approval = loadApprovals().find((a) => a.path === canonicalPath(projectPath));
315
+ const decision = !approval
316
+ ? "unapproved"
317
+ : approval.fingerprint === credentialsFingerprint(project)
318
+ ? "approved"
319
+ : "changed";
320
+ const info = {
321
+ path: projectPath,
322
+ decision,
323
+ accountId: project.accountId,
324
+ relayerUrl: project.relayerUrl,
325
+ };
326
+ return decision === "approved"
327
+ ? { path: projectPath, source: "project", project: info }
328
+ : { path: global, source: "global", project: info };
85
329
  }
86
- /** Load credentials from disk. Returns null if missing or malformed. */
87
- export function loadCreds() {
88
- const path = credsPath();
330
+ /** The credentials file in use. Thin wrapper over {@link resolveCreds} so the
331
+ * many callers that only need a path are unchanged. */
332
+ export function credsPath() {
333
+ return resolveCreds().path;
334
+ }
335
+ /** Read and validate one credentials file. Returns null if missing or
336
+ * malformed — the caller decides what that means. */
337
+ function readCredsFile(path) {
89
338
  if (!existsSync(path))
90
339
  return null;
91
340
  try {
92
- const raw = readFileSync(path, "utf8");
93
- const parsed = JSON.parse(raw);
341
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
94
342
  if (!isValid(parsed))
95
343
  return null;
96
344
  return parsed;
@@ -99,6 +347,144 @@ export function loadCreds() {
99
347
  return null;
100
348
  }
101
349
  }
350
+ /** Load credentials from disk. Returns null if missing or malformed. */
351
+ export function loadCreds() {
352
+ return readCredsFile(credsPath());
353
+ }
354
+ /**
355
+ * Approve the project-local credentials found from the working directory.
356
+ *
357
+ * Deliberately takes no arguments: it approves what resolution would otherwise
358
+ * ignore, from the same directory, so "what am I approving" and "what will be
359
+ * used" cannot drift apart.
360
+ */
361
+ export function approveProjectCreds() {
362
+ const approvalsPath = projectApprovalsPath();
363
+ if (credsDirOverride())
364
+ return { outcome: "overridden", approvalsPath };
365
+ const projectPath = projectCredsPath();
366
+ if (!projectPath)
367
+ return { outcome: "none", approvalsPath };
368
+ const creds = readCredsFile(projectPath);
369
+ if (!creds)
370
+ return { outcome: "unreadable", projectPath, approvalsPath };
371
+ const key = canonicalPath(projectPath);
372
+ const fingerprint = credentialsFingerprint(creds);
373
+ const approvals = loadApprovals();
374
+ const existing = approvals.find((a) => a.path === key);
375
+ if (existing?.fingerprint === fingerprint) {
376
+ return {
377
+ outcome: "already-approved",
378
+ projectPath,
379
+ accountId: creds.accountId,
380
+ relayerUrl: creds.relayerUrl,
381
+ approvalsPath,
382
+ };
383
+ }
384
+ saveApprovals([
385
+ ...approvals.filter((a) => a.path !== key),
386
+ {
387
+ path: key,
388
+ fingerprint,
389
+ accountId: creds.accountId,
390
+ delegateAddress: creds.delegateAddress,
391
+ relayerUrl: creds.relayerUrl,
392
+ approvedAt: new Date().toISOString(),
393
+ },
394
+ ]);
395
+ return {
396
+ outcome: existing ? "reapproved" : "approved",
397
+ projectPath,
398
+ accountId: creds.accountId,
399
+ relayerUrl: creds.relayerUrl,
400
+ previousAccountId: existing?.accountId,
401
+ previousRelayerUrl: existing?.relayerUrl,
402
+ approvalsPath,
403
+ };
404
+ }
405
+ /**
406
+ * Withdraw the approval for the project-local credentials here.
407
+ *
408
+ * Keyed on the path rather than on the file's current contents, so an approval
409
+ * can be withdrawn even after the file it covered was edited or deleted — a
410
+ * revoke that only worked while the destination still matched would be
411
+ * useless exactly when it is wanted.
412
+ */
413
+ export function revokeProjectCredsApproval() {
414
+ const approvalsPath = projectApprovalsPath();
415
+ const projectPath = projectCredsPath() ?? join(process.cwd(), ".memwal", CREDS_FILE);
416
+ const key = canonicalPath(projectPath);
417
+ const approvals = loadApprovals();
418
+ const remaining = approvals.filter((a) => a.path !== key);
419
+ if (remaining.length === approvals.length)
420
+ return { outcome: "none", projectPath, approvalsPath };
421
+ saveApprovals(remaining);
422
+ return { outcome: "revoked", projectPath, approvalsPath };
423
+ }
424
+ /**
425
+ * The warning for a project credentials file that was found and NOT used, or
426
+ * null when there is nothing to report.
427
+ *
428
+ * Says which file was ignored, where memory is going instead, and the exact
429
+ * command that approves it — a silent fallback would be the mirror image of
430
+ * the silent redirect this gate exists to stop. Never contains a key: the only
431
+ * fields it reads are the account id and the relayer URL.
432
+ */
433
+ export function formatProjectCredsNotice(resolution = resolveCreds()) {
434
+ const project = resolution.project;
435
+ if (!project || project.decision === "approved")
436
+ return null;
437
+ const destination = `account ${project.accountId} on ${project.relayerUrl}`;
438
+ const head = project.decision === "unreadable"
439
+ ? [
440
+ `Ignored the project credentials at ${project.path}: the file is not a valid`,
441
+ `Walrus Memory credentials file, so there is nothing to approve.`,
442
+ ]
443
+ : project.decision === "changed"
444
+ ? [
445
+ `Ignored the project credentials at ${project.path}: they changed since you`,
446
+ `approved them and now point at ${destination}.`,
447
+ `Approving again is required whenever the account, delegate key or relayer moves.`,
448
+ ]
449
+ : [
450
+ `Ignored the project credentials at ${project.path}, which would send memory to`,
451
+ `${destination}.`,
452
+ `A file inside a repository can be committed by anyone, so it is not used until`,
453
+ `you approve it on this machine.`,
454
+ ];
455
+ const lines = [...head, `Memory is going to ${resolution.path} instead.`];
456
+ if (project.decision !== "unreadable") {
457
+ lines.push(`To use it, run \`memwal-mcp approve-project\` in a terminal from this directory.`, `The approval is recorded in ${projectApprovalsPath()}, outside the repository.`);
458
+ }
459
+ return lines.join("\n");
460
+ }
461
+ /**
462
+ * What approving a project credentials file costs, beyond redirecting reads.
463
+ *
464
+ * Approval does not just decide which file is READ — it decides which file is
465
+ * WRITTEN. `saveCreds` writes to `credsPath()`, so from here on every sign-in
466
+ * from this project puts a fresh 64-hex Ed25519 delegate seed, in plaintext,
467
+ * into a directory that is inside the repository. An attacker who planted the
468
+ * file planted the directory too, so it is already tracked rather than ignored,
469
+ * and `git add -A` stages the key. The user cannot weigh that if nobody says
470
+ * it, and "you approved a destination" is not the same sentence as "you
471
+ * approved storing a private key in your repo".
472
+ *
473
+ * Separate from {@link formatProjectCredsNotice} on purpose: that one is about
474
+ * a file that was IGNORED, this one is about a file that is about to be used.
475
+ */
476
+ export function formatProjectCredsStorageWarning(projectPath) {
477
+ const dir = dirname(projectPath);
478
+ return [
479
+ `Note: ${dir} is inside the repository, and approving makes it the file this`,
480
+ `project signs and saves with. Every later sign-in from here writes a delegate`,
481
+ `PRIVATE KEY into ${basename(projectPath)} in plaintext — and a \`.memwal/\` a`,
482
+ `repository already carries is tracked, not ignored, so \`git add -A\` would stage it.`,
483
+ `Add \`.memwal/\` to .gitignore, and never commit ${basename(projectPath)}.`,
484
+ `(The short-lived login write-ahead record is kept outside the repository; the`,
485
+ `credentials file cannot be, because it is the file you approved.)`,
486
+ ].join("\n");
487
+ }
102
488
  /**
103
489
  * Write credentials with secure (`0600`) permission, to whichever file
104
490
  * `credsPath()` resolves to.
@@ -240,14 +626,26 @@ export function replaceWithTemp(tmp, path, contents, deps = {}) {
240
626
  * callback arrives, by which point a delegate key has already been registered
241
627
  * on-chain — so a warning that waits for both ids is a warning that arrives
242
628
  * too late to act on.
629
+ *
630
+ * When the file being replaced is an approved project one, that is also the
631
+ * last moment before a new private key lands inside a repository, so the
632
+ * storage warning is repeated here rather than left behind at approval time —
633
+ * approval may have been months ago, or done by someone else on the machine.
243
634
  */
244
635
  export function formatPendingSignInWarning() {
245
- const current = loadCreds();
636
+ const resolution = resolveCreds();
637
+ const current = readCredsFile(resolution.path);
246
638
  if (!current)
247
639
  return null;
248
- return (`Signing in will replace the credentials in ${credsPath()} ` +
249
- `(currently account ${current.accountId}). ` +
250
- `The existing file is backed up if the new sign-in is a different account.`);
640
+ const lines = [
641
+ `Signing in will replace the credentials in ${resolution.path} ` +
642
+ `(currently account ${current.accountId}). ` +
643
+ `The existing file is backed up if the new sign-in is a different account.`,
644
+ ];
645
+ if (resolution.source === "project") {
646
+ lines.push(formatProjectCredsStorageWarning(resolution.path));
647
+ }
648
+ return lines.join("\n");
251
649
  }
252
650
  /**
253
651
  * The message shown when a sign-in displaced a different account, or null when
@@ -348,6 +746,9 @@ function isValid(obj) {
348
746
  * record that outlives its flow is recovered on next start.
349
747
  * ------------------------------------------------------------------------- */
350
748
  const PENDING_FILE = "login-pending.json";
749
+ /** Where a PROJECT sign-in's write-ahead record goes, under the trusted state
750
+ * directory — one file per approved project. See {@link pendingLoginPath}. */
751
+ const PENDING_DIR = "login-pending";
351
752
  /**
352
753
  * How long a stranded record stays recoverable.
353
754
  *
@@ -357,10 +758,32 @@ const PENDING_FILE = "login-pending.json";
357
758
  * an unregistered key on disk, which grants nothing.
358
759
  */
359
760
  export const PENDING_LOGIN_TTL_MS = 24 * 60 * 60_000;
360
- /** Sits beside whichever credentials file `credsPath()` resolves to, so a
361
- * project-local sign-in recovers into that same project. */
761
+ /**
762
+ * Where the write-ahead record lives never inside a repository.
763
+ *
764
+ * It used to sit beside whichever credentials file `credsPath()` resolved to,
765
+ * which reads as "recover into the project you signed in from" and is the right
766
+ * intent. But for an approved project that path is `<repo>/.memwal/`, so every
767
+ * sign-in dropped a plaintext 64-hex delegate seed into the working tree —
768
+ * under a directory an attacker who planted the credentials file had already
769
+ * created, so tracked rather than ignored, and staged by `git add -A`.
770
+ *
771
+ * Nothing about this record needs to be in the repo. It is short-lived
772
+ * handshake state, nobody edits it by hand, and the only property that matters
773
+ * is that the project which started a sign-in is the one that can reclaim it.
774
+ * So it moves to the trusted state directory, keyed by a hash of the
775
+ * credentials path: same per-project scoping, no key material in the checkout.
776
+ *
777
+ * The non-project cases are byte-for-byte where they always were —
778
+ * `dirname(credsPath())` IS `trustedStateDir()` for both the override and the
779
+ * global file — so a machine that has never approved a project sees no change.
780
+ */
362
781
  export function pendingLoginPath() {
363
- return join(dirname(credsPath()), PENDING_FILE);
782
+ const resolution = resolveCreds();
783
+ if (resolution.source !== "project")
784
+ return join(trustedStateDir(), PENDING_FILE);
785
+ const key = createHash("sha256").update(canonicalPath(resolution.path)).digest("hex");
786
+ return join(trustedStateDir(), PENDING_DIR, `${key}.json`);
364
787
  }
365
788
  /**
366
789
  * Persist the pending keypair. Throws if it cannot.
@@ -371,10 +794,10 @@ export function pendingLoginPath() {
371
794
  * the connect URL while claiming a durability that does not exist — the
372
795
  * original WALM-332 loss, now silent.
373
796
  *
374
- * Failing the login costs the user nothing: this file sits beside
375
- * `credentials.json`, so a directory that cannot take it cannot take the
376
- * credentials either. The same login would have failed at the callback anyway,
377
- * one on-chain `add_delegate_key` later.
797
+ * Failing the login costs the user nothing: this file lives in the same
798
+ * trusted state directory the approval record does, so a directory that cannot
799
+ * take it is one this process cannot keep state in at all. The same login would
800
+ * have failed at the callback anyway, one on-chain `add_delegate_key` later.
378
801
  */
379
802
  export function savePendingLogin(pending) {
380
803
  const path = pendingLoginPath();
package/dist/auth.js.map CHANGED
@@ -1 +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Q;QAC1C,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAChD,OAAO,CAAC,CAAC,eAAe,KAAK,QAAQ;QACrC,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ;QAChC,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ;QAC/B,CAAC,CAAC,OAAO,KAAK,CAAC,CAClB,CAAC;AACN,CAAC"}
package/dist/bridge.d.ts CHANGED
@@ -41,7 +41,8 @@ export interface BridgeConfig {
41
41
  * per-call namespace always wins over the configured default.
42
42
  */
43
43
  /**
44
- * Name the relayer this process dialled in a `memwal_health` result.
44
+ * Name the destination this process is bound to in a `memwal_health` result:
45
+ * the relayer it dialled, and the account it signs for.
45
46
  *
46
47
  * The relayer-side text can only report an origin its deployment published, and
47
48
  * stays silent on a self-hosted or local one, where the sidecar knows nothing
@@ -53,11 +54,18 @@ export interface BridgeConfig {
53
54
  * Rewrites an existing `relayer=` field rather than appending a second one: when
54
55
  * both sides know the origin they describe the same session, and two
55
56
  * conflicting fields would be worse than neither.
57
+ *
58
+ * `account=` rides along for the same reason (WALM-639). A project-local
59
+ * credentials file can point this process at a different account than the one
60
+ * the user signed in with, and "which account am I writing to" was otherwise
61
+ * only visible in stderr the MCP host usually hides — so the half of the
62
+ * destination that decides WHOSE memory this is now shows up beside the half
63
+ * that decides where it is stored.
56
64
  */
57
65
  export declare function annotateHealthResult(result: {
58
66
  content?: unknown;
59
67
  isError?: unknown;
60
- }, relayerUrl: string): void;
68
+ }, relayerUrl: string, accountId?: string): void;
61
69
  export declare function applyDefaultNamespace(msg: RpcMessage, namespace?: string): RpcMessage;
62
70
  /** Reply for a `tools/call` naming a tool the connected relayer does not
63
71
  * serve. Names what IS on offer, because the agent's next move is to pick one
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,iBAAi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