@volter/teams 0.2.28 → 0.2.29

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/machine-core.mjs CHANGED
@@ -247,7 +247,7 @@ export class MachineCore extends EventEmitter {
247
247
  }
248
248
  const index = this.nextConnection++;
249
249
  // A delegated caller's claim also carries the name its workplace signed for it (who typed a turn).
250
- const entry = { channel, admitted, principal: claim.principal, name: typeof claim.name === 'string' ? claim.name : null, roomContext: claim.roomContext ?? null, verify: () => this.#admitClaim(claim), localAdmission: () => admitFromGrants(claim, { custodianId: this.custodianId, grants: this.linkGrants }) };
250
+ const entry = { channel, admitted, principal: claim.principal, principalName: typeof claim.principal_name === 'string' ? claim.principal_name : null, name: typeof claim.name === 'string' ? claim.name : null, roomContext: claim.roomContext ?? null, verify: () => this.#admitClaim(claim), localAdmission: () => admitFromGrants(claim, { custodianId: this.custodianId, grants: this.linkGrants }) };
251
251
  this.connections.set(index, entry);
252
252
  stream.on('close', () => { this.connections.delete(index); this.connectionClosed(index); });
253
253
  this.log.append({ principal: entry.principal, cap: 'connect', target: '*', outcome: admitted.class, detail: 'server' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/teams",
3
- "version": "0.2.28",
3
+ "version": "0.2.29",
4
4
  "type": "module",
5
5
  "description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
6
6
  "license": "MIT",
@@ -73,13 +73,16 @@ async function claimFor(api, auth, machineId) {
73
73
  const membership = await api.store.one('SELECT active FROM memberships WHERE team_id=? AND principal_id=?', [auth.team_id, auth.principal_id]);
74
74
  if (!membership?.active) return null;
75
75
  const groups = auth.group_ids ?? [];
76
- if (machine.custodian_id === auth.principal_id) return { principal: auth.principal_id, groups, custodian: true };
76
+ // The principal's name travels with its claim: the machine says who sent what came over this stream (a sender's
77
+ // identity is the link's, never a return address) without asking anyone.
78
+ const principal_name = (await api.store.one('SELECT display_name FROM principals WHERE id=?', [auth.principal_id]))?.display_name ?? null;
79
+ if (machine.custodian_id === auth.principal_id) return { principal: auth.principal_id, principal_name, groups, custodian: true };
77
80
  const subjects = [auth.principal_id, ...groups];
78
81
  const rows = await api.store.query(`SELECT id, revision FROM machine_grants WHERE team_id=? AND machine_id=? AND expires_at>? AND subject_id IN (${subjects.map(() => '?').join(',')}) ORDER BY id`, [auth.team_id, machineId, api.clock.nowMs(), ...subjects]);
79
82
  // Every member holds the team's standing mail grant (TEAM_MAIL_GRANT) besides their own.
80
83
  const held = [...rows, { id: TEAM_MAIL_GRANT, revision: 1 }];
81
84
  // Revisions let the machine notice a grant it holds has changed (rewritten, narrowed) and resync.
82
- return { principal: auth.principal_id, groups: [...groups, teamSubject(auth.team_id)], grants: held.map((row) => row.id), revisions: Object.fromEntries(held.map((row) => [row.id, row.revision])) };
85
+ return { principal: auth.principal_id, principal_name, groups: [...groups, teamSubject(auth.team_id)], grants: held.map((row) => row.id), revisions: Object.fromEntries(held.map((row) => [row.id, row.revision])) };
83
86
  }
84
87
 
85
88
  /** Close every channel a member leaving the team, or a group losing a member or being deleted, leaves without its claimed authority. */