@codemem/server 0.47.0 → 0.47.1

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.
@@ -25,6 +25,7 @@ export declare function readRecoveryCandidates(options: {
25
25
  adminSecret: string;
26
26
  groups: readonly string[];
27
27
  device: CandidateDevice;
28
+ timeoutS?: number;
28
29
  }): Promise<RecoveryOwnerCandidate[]>;
29
30
  export {};
30
31
  //# sourceMappingURL=owner-recovery-candidates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"owner-recovery-candidates.d.ts","sourceRoot":"","sources":["../../src/account/owner-recovery-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,qCAAqC,EAG1C,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,sBAAsB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AACD,UAAU,eAAe;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACnB;AA2BD,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,SAAS,OAAO,EAAE,EAC7B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,GACvC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAS1B;AAqBD,wBAAgB,aAAa,CAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EAChC,iBAAiB,EAAE,MAAM,GACvB,sBAAsB,EAAE,CAU1B;AAaD;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACrD,kBAAkB,EAAE,OAAO,qCAAqC,CAAC;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,MAAM,EAAE,eAAe,CAAC;CACxB,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAqBpC"}
1
+ {"version":3,"file":"owner-recovery-candidates.d.ts","sourceRoot":"","sources":["../../src/account/owner-recovery-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,qCAAqC,EAG1C,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,sBAAsB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AACD,UAAU,eAAe;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACnB;AA2BD,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,SAAS,OAAO,EAAE,EAC7B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,GACvC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAS1B;AAqBD,wBAAgB,aAAa,CAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EAChC,iBAAiB,EAAE,MAAM,GACvB,sBAAsB,EAAE,CAU1B;AAaD;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACrD,kBAAkB,EAAE,OAAO,qCAAqC,CAAC;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAsBpC"}
@@ -5,6 +5,11 @@ export declare class AccountOwnerRecoveryError extends Error {
5
5
  readonly code: "invalid" | "busy" | "context_changed" | "unavailable";
6
6
  constructor(code?: "invalid" | "busy" | "context_changed" | "unavailable");
7
7
  }
8
+ /**
9
+ * The fix for an unsafe local state directory, or null for any other error. Matches the
10
+ * core error by code because the bundle can carry a second copy of the core class.
11
+ */
12
+ export declare function unsafeStorageMessage(error: unknown): string | null;
8
13
  export declare function requireRecovery(condition: unknown, code?: AccountOwnerRecoveryError["code"]): asserts condition;
9
14
  export declare function recoveryId(value: unknown): value is string;
10
15
  export declare function recoveryHash(value: unknown): value is string;
@@ -1 +1 @@
1
- {"version":3,"file":"owner-recovery-evidence.d.ts","sourceRoot":"","sources":["../../src/account/owner-recovery-evidence.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,oCAAoC,EACzC,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACX,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,cAAc,0CAA0C,CAAC;AAKtE,qBAAa,yBAA0B,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,iBAAiB,GAAG,aAAa;IAAjF,YAAqB,IAAI,GAAE,SAAS,GAAG,MAAM,GAAG,iBAAiB,GAAG,aAAyB,EAE5F;CACD;AACD,wBAAgB,eAAe,CAC9B,SAAS,EAAE,OAAO,EAClB,IAAI,GAAE,yBAAyB,CAAC,MAAM,CAAa,GACjD,OAAO,CAAC,SAAS,CAEnB;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAQ1D;AACD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE5D;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGtE;AACD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,G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S,EAAE,OAAO,EAClB,IAAI,GAAE,yBAAyB,CAAC,MAAM,CAAa,GACjD,OAAO,CAAC,SAAS,CAEnB;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAQ1D;AACD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE5D;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGtE;AACD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAIjG;AAqFD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oCAAoC,CAWhG;AACD,MAAM,WAAW,uBAAuB;IACvC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,oCAAoC,CAAC;IAC/C,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AACD,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,MAAM,GACb,uBAAuB,CAiDzB;AA8BD,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,iBAAiB,GAC1B,GAAG,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAmCnD"}
@@ -14,8 +14,16 @@ export interface AccountOwnerRecoveryServiceOptions {
14
14
  reviewOwner?: typeof coordinatorAuthControllerReviewAction;
15
15
  /** Read-only device-owner preview used only to suggest recorded owners. */
16
16
  previewDeviceOwner?: typeof coordinatorAuthControllerReviewAction;
17
+ /** Configured `sync_coordinator_timeout_s`, read on every request. */
18
+ readCoordinatorTimeoutS?: () => number;
17
19
  now?: () => number;
18
20
  }
21
+ /**
22
+ * Scoped owner reviews read the full Team history, and confirming sends a fresh preview
23
+ * and then the commit. Each request can take several seconds on the live coordinator, so
24
+ * the 3s sync default would abort a commit the user already approved.
25
+ */
26
+ export declare const MIN_OWNER_REVIEW_TIMEOUT_S = 10;
19
27
  /** No routes or configuration composition: these callbacks are private server capabilities. */
20
28
  declare class AccountOwnerRecoveryService {
21
29
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"owner-recovery-service.d.ts","sourceRoot":"","sources":["../../src/account/owner-recovery-service.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qCAAqC,EAGrC,gCAAgC,EAChC,gDAAgD,EAChD,yCAAyC,EACzC,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAA8B,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EACN,KAAK,sBAAsB,EAE3B,MAAM,gCAAgC,CAAC;AAkBxC,OAAO,KAAK,EACX,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACX,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AACnC,MAAM,WAAW,kCAAkC;IAClD,WAAW,EAAE,oBAAoB,CAAC;IAClC,eAAe,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,gCAAgC,CAAC;IAC3D,qBAAqB,CAAC,EAAE,OAAO,yCAAyC,CAAC;IACzE,uBAAuB,CAAC,EAAE,OAAO,gDAAgD,CAAC;IAClF,WA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@@ var AccountOwnerRecoveryError = class extends Error {
1266
1266
  this.code = code;
1267
1267
  }
1268
1268
  };
1269
+ /**
1270
+ * The fix for an unsafe local state directory, or null for any other error. Matches the
1271
+ * core error by code because the bundle can carry a second copy of the core class.
1272
+ */
1273
+ function unsafeStorageMessage(error) {
1274
+ if (!(error instanceof Error) || !("code" in error)) return null;
1275
+ return error.code === "account_owner_association_directory_unsafe" ? error.message : null;
1276
+ }
1269
1277
  function requireRecovery(condition, code = "invalid") {
1270
1278
  if (!condition) throw new AccountOwnerRecoveryError(code);
1271
1279
  }
@@ -1574,6 +1582,11 @@ async function dispatch(c, service) {
1574
1582
  function accountOwnerRecoveryRoutes(service) {
1575
1583
  const app = new Hono();
1576
1584
  app.onError((error, c) => {
1585
+ const storage = unsafeStorageMessage(error);
1586
+ if (storage) return c.json({
1587
+ error: "account_owner_recovery_storage_unsafe",
1588
+ detail: storage
1589
+ }, 409);
1577
1590
  if (!(error instanceof AccountOwnerRecoveryError)) return c.json({ error: "account_owner_recovery_unavailable" }, 503);
1578
1591
  return c.json({ error: `account_owner_recovery_${error.code}` }, {
1579
1592
  invalid: 400,
@@ -15774,16 +15787,44 @@ function assertPublishedConfigLock(path, staged) {
15774
15787
  function accountOwnerAssociationDirectory() {
15775
15788
  return join(homedir(), ".codemem", "account-owner-associations");
15776
15789
  }
15790
+ /**
15791
+ * A state directory that other local users could change. The message names the path and
15792
+ * the command that fixes it, because callers show it to the person who owns the directory.
15793
+ */
15794
+ var AccountOwnerAssociationDirectoryError = class extends Error {
15795
+ path;
15796
+ problem;
15797
+ code = "account_owner_association_directory_unsafe";
15798
+ constructor(path, problem) {
15799
+ super(directoryProblemMessage(path, problem));
15800
+ this.path = path;
15801
+ this.problem = problem;
15802
+ this.name = "AccountOwnerAssociationDirectoryError";
15803
+ }
15804
+ };
15805
+ function directoryProblemMessage(path, problem) {
15806
+ if (problem === "shared_write") return `${path} is writable by other users. Run \`chmod go-w ${path}\`, then try again.`;
15807
+ if (problem === "not_private") return `${path} must be private to you. Run \`chmod 700 ${path}\`, then try again.`;
15808
+ if (problem === "wrong_owner") return `${path} is owned by another user. Make it yours.`;
15809
+ return `${path} must be a real directory, not a file or symlink.`;
15810
+ }
15811
+ function directoryProblem(stat, options) {
15812
+ if (!stat.isDirectory() || stat.isSymbolicLink()) return "not_directory";
15813
+ if (typeof process.getuid === "function" && stat.uid !== process.getuid()) return "wrong_owner";
15814
+ if (options.private) return (stat.mode & 511) === 448 ? null : "not_private";
15815
+ return (stat.mode & 18) === 0 ? null : "shared_write";
15816
+ }
15777
15817
  function checkDirectory(path, options = {}) {
15818
+ let stat;
15778
15819
  try {
15779
- const stat = lstatSync(path);
15780
- const unsafeMode = options.private ? (stat.mode & 511) !== 448 : (stat.mode & 18) !== 0;
15781
- if (!stat.isDirectory() || stat.isSymbolicLink() || unsafeMode || typeof process.getuid === "function" && stat.uid !== process.getuid()) throw new Error("account_owner_association_invalid");
15782
- return true;
15820
+ stat = lstatSync(path);
15783
15821
  } catch (error) {
15784
15822
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return false;
15785
15823
  throw error;
15786
15824
  }
15825
+ const problem = directoryProblem(stat, options);
15826
+ if (problem) throw new AccountOwnerAssociationDirectoryError(path, problem);
15827
+ return true;
15787
15828
  }
15788
15829
  /** Missing directories stay missing during reads. Never follow a state-directory symlink. */
15789
15830
  function readAccountOwnerAssociationDirectory(path) {
@@ -16169,7 +16210,8 @@ async function readRecoveryCandidates(options) {
16169
16210
  groupId,
16170
16211
  deviceId: device.deviceId,
16171
16212
  fingerprint: device.fingerprint,
16172
- identityId: device.identityId
16213
+ identityId: device.identityId,
16214
+ timeoutS: options.timeoutS
16173
16215
  });
16174
16216
  } catch {
16175
16217
  continue;
@@ -16257,8 +16299,6 @@ function assertNoCompetingOwner(destinations, ownerIdentityId) {
16257
16299
  requireRecovery(!existing || existing.ownerIdentityId === ownerIdentityId);
16258
16300
  }
16259
16301
  }
16260
- //#endregion
16261
- //#region src/account/owner-recovery-service.ts
16262
16302
  var CANDIDATE_TTL_MS = 6e4;
16263
16303
  function groupAction(state) {
16264
16304
  if (state === "ready") return "new";
@@ -16285,6 +16325,10 @@ var AccountOwnerRecoveryService = class {
16285
16325
  #now() {
16286
16326
  return (this.#options.now ?? Date.now)();
16287
16327
  }
16328
+ #timeoutS() {
16329
+ const configured = this.#options.readCoordinatorTimeoutS?.() ?? 0;
16330
+ return Math.max(10, Number.isFinite(configured) ? configured : 0);
16331
+ }
16288
16332
  #assertCurrent(capture, reservation) {
16289
16333
  requireRecovery(!this.#closed, "unavailable");
16290
16334
  requireRecovery(!reservation || reservation.isCurrent(), "context_changed");
@@ -16338,7 +16382,8 @@ var AccountOwnerRecoveryService = class {
16338
16382
  deviceId: c.deviceId,
16339
16383
  fingerprint: c.fingerprint,
16340
16384
  identityId: c.identityId
16341
- }
16385
+ },
16386
+ timeoutS: this.#timeoutS()
16342
16387
  });
16343
16388
  this.#assertCurrent(capture);
16344
16389
  this.#candidateCache = {
@@ -16360,7 +16405,8 @@ var AccountOwnerRecoveryService = class {
16360
16405
  groupId,
16361
16406
  deviceId: capture.context.deviceId,
16362
16407
  fingerprint: capture.context.fingerprint,
16363
- identityId: selection.existingOwnerId
16408
+ identityId: selection.existingOwnerId,
16409
+ timeoutS: this.#timeoutS()
16364
16410
  };
16365
16411
  }
16366
16412
  async #previewReview(entry, groupId) {
@@ -16526,7 +16572,7 @@ var AccountOwnerRecoveryService = class {
16526
16572
  return { outcome: {
16527
16573
  groupId,
16528
16574
  status: staleDenial(error) ? "failed" : "unknown",
16529
- message: "Check coordinator status or import original receipts before trying again."
16575
+ message: unsafeStorageMessage(error) ?? "Check coordinator status or import original receipts before trying again."
16530
16576
  } };
16531
16577
  }
16532
16578
  }
@@ -16601,11 +16647,11 @@ var AccountOwnerRecoveryService = class {
16601
16647
  async #importGroup(entry, groupId, receipt, reservation) {
16602
16648
  try {
16603
16649
  return await this.#verifyAndRetain(entry, groupId, receipt, reservation);
16604
- } catch {
16650
+ } catch (error) {
16605
16651
  return {
16606
16652
  groupId,
16607
16653
  status: "unknown",
16608
- message: "Context or proof outcome changed; check status before importing again."
16654
+ message: unsafeStorageMessage(error) ?? "Context or proof outcome changed; check status before importing again."
16609
16655
  };
16610
16656
  }
16611
16657
  }