@volter/supercode-teams 0.2.126 → 0.2.128

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.mjs CHANGED
@@ -534,11 +534,16 @@ export class TeamsMachine extends MachineCore {
534
534
  // Who typed it is noted before it is typed: a capture can read the session's new line before the door confirms
535
535
  // it (a loaded machine confirmed a frozen-then-resumed line after the line was captured, and it went up unnamed).
536
536
  // A refusal withdraws the note; an unconfirmed turn keeps it, as the line may well be in the session.
537
- const note = { harness, session, text: request.text, at: Date.now(), source: { via: 'room', from: { principalId: principal ?? null, name: entry.name ?? null } } };
537
+ // Room context comes only from the server-authenticated claim. JSON quotes names as data,
538
+ // so a display name cannot introduce another header or masquerade as an instruction.
539
+ const text = entry.roomContext
540
+ ? `[Room ${JSON.stringify(entry.roomContext.name)} (${JSON.stringify(entry.roomContext.id)}); sender ${JSON.stringify(entry.name ?? entry.roomContext.sender)} (${JSON.stringify(entry.roomContext.sender)})]\n${request.text}`
541
+ : request.text;
542
+ const note = { harness, session, text, at: Date.now(), source: { via: 'room', from: { principalId: principal ?? null, name: entry.name ?? null } } };
538
543
  try { this.onTurn?.(note); } catch { /* naming is best-effort; the turn goes either way */ }
539
544
  this.#serveRequest('harness.v1.sessions.message', {
540
545
  locator: { harness, session_id: session, storage: { kind: 'file', path: '' } },
541
- text: request.text,
546
+ text,
542
547
  from_name: entry.name ?? principal ?? 'a Room member',
543
548
  as_user: true,
544
549
  }, TURN_CONFIRM_MS).then((result) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.2.126",
3
+ "version": "0.2.128",
4
4
  "type": "module",
5
5
  "description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
6
6
  "license": "MIT",
@@ -13,7 +13,8 @@ import { captureDigest, captureMessages, handleOtlpRoute, sha256, validateArtifa
13
13
  import { handleCatalogEvents, handleSessionEvents, sessionNames } from './event-routes.mjs';
14
14
  import { exact } from '@volter/teams/server/request-json';
15
15
  import { MESSAGE_AT, OPEN_REVISION } from '@volter/teams/server/migrations';
16
- import { delegatedSessionOf, looksDelegated } from '@volter/teams/server/delegated';
16
+ import { delegatedRoomNoticeOf, delegatedSessionOf, looksDelegated } from '@volter/teams/server/delegated';
17
+ import { deliverSessionRoomNotice } from '@volter/teams/server/machine-link';
17
18
  import { renderSourceCollectorConfig } from './otlp/collector-config.mjs';
18
19
  import { attachmentActionRoute, createAttachment, liveGrantRoute, machineEffectRoute } from './effects.mjs';
19
20
  import { exportSessionRoute, operationRoute } from './exports.mjs';
@@ -26,6 +27,14 @@ function unverifiedSubject(token){try{return String(JSON.parse(Buffer.from(Strin
26
27
 
27
28
  async function preAuth({ api, req, res, path, requestId }) {
28
29
  let early;
30
+ if(req.method==='POST'&&(early=/^\/api\/v1\/teams\/([^/]+)\/sessions\/([^/]+)\/room-notices$/.exec(path))){
31
+ const access=await delegatedRoomNoticeOf(api,bearer(req.headers.authorization));
32
+ if(!access || access.teamId!==early[1] || access.sessionRef!==decodeURIComponent(early[2])) fail(401,'authentication_required','authentication required');
33
+ checkRate(api,`room-notices:${access.issuer}:${access.teamId}`,120,10);
34
+ const receipt=await deliverSessionRoomNotice(api,access);
35
+ send(res,200,{data:receipt},requestId);return true;
36
+ }
37
+
29
38
  // A session view (RH2 ADR 0008): a workplace page reads one session with a token its workplace signed for a Room and
30
39
  // Conversation, which reaches only a session its owner bound to them (session_view_bindings). A member's own
31
40
  // credential takes the ordinary routes below.