@volter/supercode-teams 0.2.59 → 0.2.60
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/package.json +1 -1
- package/server/harness-routes.mjs +12 -1
- package/worker/wrangler.toml +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-teams",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.60",
|
|
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",
|
|
@@ -20,15 +20,26 @@ import { attachmentStreamRoute, attachmentFramesRoute, closeMachineAttachmentRou
|
|
|
20
20
|
import { continuationRoute, remoteContinuationArtifactRoute, remoteContinuationRoute } from './continuations.mjs';
|
|
21
21
|
import { fail, parseJson, result, send, guardedMutation, requireRevision, checkRate, grants, syncRuleJson, authGuards } from '@volter/teams/server/http';
|
|
22
22
|
|
|
23
|
+
/** The `sub` a token says it is for, unverified: for a log line only, never for a decision. */
|
|
24
|
+
function unverifiedSubject(token){try{return String(JSON.parse(Buffer.from(String(token).split('.')[1]??'','base64url').toString('utf8')).sub??'').slice(0,80)||'-';}catch{return '-';}}
|
|
25
|
+
|
|
23
26
|
async function preAuth({ api, req, res, path, requestId }) {
|
|
24
27
|
let early;
|
|
25
28
|
// A session view (RH2 ADR 0008): a workplace page reads one session with a token its workplace signed for a Room and
|
|
26
29
|
// Conversation, which reaches only a session its owner bound to them (session_view_bindings). A member's own
|
|
27
30
|
// credential takes the ordinary routes below.
|
|
31
|
+
// A session view that failed in the browser (its read, its follow, its page) reports it here, so the failure is in the
|
|
32
|
+
// server's log under the member it happened to; a token this server does not admit is logged as unverified.
|
|
33
|
+
if(req.method==='POST'&&(early=/^\/api\/v1\/teams\/([^/]+)\/sessions\/([^/]+)\/viewer-errors$/.exec(path))){
|
|
34
|
+
const presented=bearer(req.headers.authorization)??'';checkRate(api,`viewer-errors:${hashToken(presented)}`,30,10);
|
|
35
|
+
const access=looksDelegated(presented)?await delegatedSessionOf(api,presented):null,body=await parseJson(req).catch(()=>({})),text=(value,limit)=>typeof value==='string'?value.replace(/\s+/g,' ').slice(0,limit):null;
|
|
36
|
+
console.log(`viewer-error team=${early[1]} session=${decodeURIComponent(early[2]).slice(0,120)} subject=${access?access.subject:`unverified:${text(unverifiedSubject(presented),80)}`} scope=${access?.scope??'-'} room=${access?.room??'-'} stage=${text(body?.stage,40)} status=${Number.isSafeInteger(body?.status)?body.status:'-'} message=${JSON.stringify(text(body?.message,400))}`);
|
|
37
|
+
send(res,204,null,requestId);return true;
|
|
38
|
+
}
|
|
28
39
|
if(req.method==='GET'&&(early=/^\/api\/v1\/teams\/([^/]+)\/sessions\/([^/]+)(\/messages|\/events)?$/.exec(path))&&looksDelegated(bearer(req.headers.authorization))){
|
|
29
40
|
const access=await delegatedSessionOf(api,bearer(req.headers.authorization));
|
|
30
41
|
const ref=decodeURIComponent(early[2]);
|
|
31
|
-
if(!access||access.teamId!==early[1]||access.sessionRef!==ref)fail(401,'authentication_required','authentication required');
|
|
42
|
+
if(!access||access.teamId!==early[1]||access.sessionRef!==ref){console.log(`session-view refused team=${early[1]} session=${ref.slice(0,120)} subject=${access?access.subject:`unverified:${unverifiedSubject(bearer(req.headers.authorization))}`} reason=${!access?'token not admitted':'token names another session'}`);fail(401,'authentication_required','authentication required');}
|
|
32
43
|
const auth={kind:'session_view',team_id:early[1],principal_id:null,credential_id:null,bound:{issuer:access.issuer,room:access.room,conversation:access.conversation,expiresAt:access.expiresAt}};
|
|
33
44
|
const url=new URL(req.url,'http://local');
|
|
34
45
|
if(!early[3])await sessionDescriptor(api,res,auth,ref,requestId);
|
package/worker/wrangler.toml
CHANGED
|
@@ -18,6 +18,10 @@ compatibility_date = "2026-09-01"
|
|
|
18
18
|
compatibility_flags = ["nodejs_compat"]
|
|
19
19
|
keep_vars = true
|
|
20
20
|
|
|
21
|
+
# Workers Logs: the Worker's log lines (viewer-error, session-view refused, maintain) kept and searchable after the fact.
|
|
22
|
+
[observability]
|
|
23
|
+
enabled = true
|
|
24
|
+
|
|
21
25
|
[[durable_objects.bindings]]
|
|
22
26
|
name = "TEAMS_SERVER"
|
|
23
27
|
class_name = "TeamsServer"
|