@kontext-dev/js-sdk 0.3.0 → 1.0.0

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.
@@ -1274,6 +1274,12 @@ var Kontext = class _Kontext {
1274
1274
  // ===========================================================================
1275
1275
  createAgentSession(userToken, mcpSessionId, metadata) {
1276
1276
  if (!this.clientSecret || !userToken) return;
1277
+ if (!metadata?.authenticatedUserId) {
1278
+ console.warn(
1279
+ "[kontext:sessions] create skipped: missing authenticated user id"
1280
+ );
1281
+ return;
1282
+ }
1277
1283
  const tokenIdentifier = crypto$1.createHash("sha256").update(userToken).digest("hex");
1278
1284
  this.getServiceToken().then(
1279
1285
  (token) => fetch(`${this.apiUrl}/api/v1/agent-sessions`, {
@@ -1284,6 +1290,7 @@ var Kontext = class _Kontext {
1284
1290
  },
1285
1291
  body: JSON.stringify({
1286
1292
  tokenIdentifier,
1293
+ authenticatedUserId: metadata.authenticatedUserId,
1287
1294
  clientSessionId: mcpSessionId,
1288
1295
  hostname: metadata?.hostname,
1289
1296
  userAgent: metadata?.userAgent,
@@ -1505,6 +1512,7 @@ var Kontext = class _Kontext {
1505
1512
  status: "ok"
1506
1513
  });
1507
1514
  this.createAgentSession(authInfo?.token, sid, {
1515
+ authenticatedUserId: typeof authInfo?.extra?.sub === "string" ? authInfo.extra.sub : void 0,
1508
1516
  hostname: req.headers["x-forwarded-for"],
1509
1517
  userAgent: req.headers["user-agent"],
1510
1518
  tokenExpiresAt: authInfo?.expiresAt