@tsed/platform-mcp 8.43.4 → 8.44.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.
@@ -1,5 +1,5 @@
1
1
  import { hasPlaceholders, interpolate } from "./interpolate.js";
2
- const OAUTH_PLACEHOLDERS = ["OAUTH_TOKEN", "OAUTH_CLIENT_ID", "OAUTH_SCOPES"];
2
+ const OAUTH_PLACEHOLDERS = ["OAUTH_TOKEN", "OAUTH_CLIENT_ID", "OAUTH_SCOPES", "OAUTH_SUB"];
3
3
  function mapValues(record, fn) {
4
4
  return record && Object.fromEntries(Object.entries(record).map(([key, value]) => [key, fn(value)]));
5
5
  }
@@ -8,6 +8,13 @@ function getValues(upstream) {
8
8
  ? [...(upstream.args || []), ...Object.values(upstream.env || {})]
9
9
  : Object.values(upstream.headers || {});
10
10
  }
11
+ /**
12
+ * Reads the subject of the caller from the claims the verifier (or the `preAuth` check) exposes in `extra`.
13
+ */
14
+ function getSubject(authInfo) {
15
+ const sub = authInfo?.extra?.sub;
16
+ return typeof sub === "string" ? sub : undefined;
17
+ }
11
18
  /**
12
19
  * Tells whether the upstream definition references the identity of the caller.
13
20
  */
@@ -25,7 +32,8 @@ export function resolveUpstream(upstream, authInfo) {
25
32
  const variables = {
26
33
  OAUTH_TOKEN: authInfo?.token,
27
34
  OAUTH_CLIENT_ID: authInfo?.clientId,
28
- OAUTH_SCOPES: authInfo?.scopes?.join(" ")
35
+ OAUTH_SCOPES: authInfo?.scopes?.join(" "),
36
+ OAUTH_SUB: getSubject(authInfo)
29
37
  };
30
38
  const resolve = (value) => interpolate(value, variables);
31
39
  if (upstream.type === "stdio") {