@agimon-ai/po-remote 0.0.0-alpha.185 → 0.0.0-alpha.186

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/index.cjs CHANGED
@@ -1485,6 +1485,20 @@ const pairOperation = (name) => `calendar.host-pair.${name}`;
1485
1485
  const pairWorkId = (targetHostId) => `host-pair/${targetHostId}`;
1486
1486
  /** Exact shape only: both constraints, only pair operations, never a workspace or a re-delegation. */
1487
1487
  const exactPairGrant = (grant) => grant.workspaceId === "" && grant.redelegable === false && Object.keys(grant.constraints).length === 2 && grant.constraints.package === PAIR_PACKAGE && grant.constraints.scope === "host-pair" && Array.isArray(grant.operations) && grant.operations.length > 0 && grant.operations.every((name) => PAIR_OPERATIONS.some((op) => name === pairOperation(op)));
1488
+ /**
1489
+ * Host-scoped operations the owner may call directly, traced from every route that reaches `authorize` with an
1490
+ * empty workspace: the network router's user-proof operations and the settings consent route. Anything else is denied.
1491
+ */
1492
+ const OWNER_HOST_OPERATIONS = /* @__PURE__ */ new Set([
1493
+ "voters",
1494
+ "roster.read",
1495
+ "roster.apply",
1496
+ "coordinator.vote",
1497
+ "coordinator.lease",
1498
+ "coordinator.mutate",
1499
+ "settings-consent",
1500
+ "host-pair-consent"
1501
+ ]);
1488
1502
  /** Default own-hub boundary, enabled only by a durable claim and pinned issuer. */
1489
1503
  function createDefaultHubFederation(ports) {
1490
1504
  let opened;
@@ -1704,14 +1718,14 @@ function createDefaultHubFederation(ports) {
1704
1718
  } catch {
1705
1719
  return false;
1706
1720
  }
1707
- if (input.operation === "host-pair-consent") return !caller.via && !grant;
1708
1721
  if (input.operation.startsWith("calendar.host-pair.")) {
1709
1722
  if (!caller.via || !grant || !exactPairGrant(grant) || !grant.operations.includes(input.operation)) return false;
1710
1723
  const held = await pairGrant(caller.via.callingHostId, hostId);
1711
1724
  return held?.payload.grantId === grant.grantId && held.payload.callingHostId === grant.callingHostId && held.payload.targetHostId === grant.targetHostId;
1712
1725
  }
1713
1726
  if (caller.via && input.operation.startsWith("calendar.")) return !!grant && grant.constraints.package === "@agimon-ai/po-calendar" && Object.keys(grant.constraints).length === 1;
1714
- return true;
1727
+ if (caller.via || grant) return false;
1728
+ return input.workspaceId !== "" || OWNER_HOST_OPERATIONS.has(input.operation);
1715
1729
  }
1716
1730
  });
1717
1731
  network = await ports.network?.({
@@ -3192,8 +3206,8 @@ const TRUSTED_DEVICE_PLATFORMS = /* @__PURE__ */ new Set(["ios", "android"]);
3192
3206
  const STORED_ID = /^[A-Za-z0-9_-]{1,64}$/u;
3193
3207
  const STORED_KEY = /^[A-Za-z0-9_-]{1,512}$/u;
3194
3208
  const MAX_STORED_LABEL = 200;
3195
- function defaultRemoteStateDir(homeDir = _agimon_ai_po_core_platform.nodeHost.homeDirectory()) {
3196
- return node_path.default.join((0, _agimon_ai_po_core_piSettings.poHomeDirectory)(homeDir), "web");
3209
+ function defaultRemoteStateDir(homeDir = _agimon_ai_po_core_platform.nodeHost.homeDirectory(), environment = {}) {
3210
+ return node_path.default.join((0, _agimon_ai_po_core_piSettings.poHomeDirectory)(homeDir, environment), "web");
3197
3211
  }
3198
3212
  /** Whether a file mode lets another account read the file. */
3199
3213
  function isLooseMode(mode) {
@@ -4599,7 +4613,7 @@ function readState(filePath, notice) {
4599
4613
  * @deprecated Node-only sync shim; use createRemoteAccessStoreAsync. Removed in M2.
4600
4614
  */
4601
4615
  function createRemoteAccessStore(options = {}) {
4602
- const directory = options.stateDir ?? defaultRemoteStateDir();
4616
+ const directory = options.stateDir ?? defaultRemoteStateDir(void 0, options.environment);
4603
4617
  const notice = options.onNotice ?? (() => {});
4604
4618
  const settingsPath = node_path.default.join(directory, SETTINGS_FILE);
4605
4619
  const credentialsPath = node_path.default.join(directory, CREDENTIALS_FILE);
@@ -6073,7 +6087,7 @@ function createRemoteRuntime(options) {
6073
6087
  let activeRelay;
6074
6088
  if (lanTls !== void 0 && (privateRelay !== void 0 || relaySetup !== void 0)) throw new Error("Private network and private relay exposure cannot both be on.");
6075
6089
  const store = createRemoteAccessStore({
6076
- stateDir: defaultRemoteStateDir(options.homeDirectory),
6090
+ stateDir: defaultRemoteStateDir(options.homeDirectory, options.environment),
6077
6091
  onNotice: (message) => options.onNotice(message)
6078
6092
  });
6079
6093
  const defaultFederation = options.federationPlatform && store.hubTrust ? createDefaultHubFederation({