@tsed/platform-mcp 8.42.0 → 8.43.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.
@@ -12,6 +12,7 @@ export * from "./fn/definePrompt.js";
12
12
  export * from "./fn/defineResource.js";
13
13
  export * from "./fn/defineTool.js";
14
14
  export * from "./interfaces/PlatformMcpAuthSettings.js";
15
+ export * from "./interfaces/PlatformMcpPreAuth.js";
15
16
  export * from "./interfaces/PlatformMcpSettings.js";
16
17
  export * from "./interfaces/PlatformMcpUpstreamSettings.js";
17
18
  export * from "./services/PlatformMcpGatewayService.js";
@@ -1,5 +1,6 @@
1
1
  import type { OAuthTokenVerifier } from "@modelcontextprotocol/server";
2
2
  import type { TokenProvider } from "@tsed/di";
3
+ import type { PlatformMcpPreAuthOption } from "./PlatformMcpPreAuth.js";
3
4
  /**
4
5
  * OAuth 2.1 resource-server configuration of a Ts.ED MCP endpoint.
5
6
  *
@@ -9,6 +10,11 @@ import type { TokenProvider } from "@tsed/di";
9
10
  * @module platform/mcp
10
11
  */
11
12
  export interface PlatformMcpAuthSettings {
13
+ /**
14
+ * Custom authentication check run before the OAuth verification, for instance an API key.
15
+ * When it returns an identity, the OAuth verification is skipped: both methods are accepted on the endpoint.
16
+ */
17
+ preAuth?: PlatformMcpPreAuthOption;
12
18
  /**
13
19
  * Issuer URL of the authorization server (OIDC provider) protecting the endpoint.
14
20
  */
@@ -0,0 +1,33 @@
1
+ import type { AuthInfo } from "@modelcontextprotocol/server";
2
+ import type { TokenProvider } from "@tsed/di";
3
+ import type { PlatformContext } from "@tsed/platform-http";
4
+ export type PlatformMcpPreAuthResult = AuthInfo | undefined | Promise<AuthInfo | undefined>;
5
+ /**
6
+ * Custom authentication check of an MCP endpoint, run before the OAuth verification.
7
+ *
8
+ * - Return an `AuthInfo` to authenticate the request: the OAuth verification is skipped and the identity is exposed
9
+ * to the handlers.
10
+ * - Return `undefined` when the check does not apply to the request: the OAuth verification runs when the endpoint
11
+ * declares an issuer, and the request is rejected with `401` otherwise.
12
+ * - Throw to reject the request.
13
+ *
14
+ * @module platform/mcp
15
+ */
16
+ export interface PlatformMcpPreAuth {
17
+ preAuth($ctx: PlatformContext): PlatformMcpPreAuthResult;
18
+ }
19
+ /**
20
+ * Accepted forms of the `auth.preAuth` option: a function, or a DI token resolving to a
21
+ * {@link PlatformMcpPreAuth} provider.
22
+ *
23
+ * @module platform/mcp
24
+ */
25
+ export type PlatformMcpPreAuthOption = (($ctx: PlatformContext) => PlatformMcpPreAuthResult) | TokenProvider<PlatformMcpPreAuth>;
26
+ /**
27
+ * Auth configuration of an MCP endpoint only protected by a custom check, without OAuth.
28
+ *
29
+ * @module platform/mcp
30
+ */
31
+ export interface PlatformMcpPreAuthSettings {
32
+ preAuth: PlatformMcpPreAuthOption;
33
+ }
@@ -2,6 +2,7 @@ import type { Implementation, ServerOptions } from "@modelcontextprotocol/server
2
2
  import type { StreamableHTTPServerTransportOptions } from "@modelcontextprotocol/node";
3
3
  import type { TokenProvider } from "@tsed/di";
4
4
  import type { PlatformMcpAuthSettings } from "./PlatformMcpAuthSettings.js";
5
+ import type { PlatformMcpPreAuthSettings } from "./PlatformMcpPreAuth.js";
5
6
  import type { PlatformMcpUpstreamSettings } from "./PlatformMcpUpstreamSettings.js";
6
7
  /**
7
8
  * Configuration fragment accepted under `configuration.mcp` to wire the Platform MCP module.
@@ -61,9 +62,10 @@ export interface PlatformMcpSettings {
61
62
  */
62
63
  upstream?: PlatformMcpUpstreamSettings;
63
64
  /**
64
- * Protect the HTTP endpoint with an OAuth authorization server.
65
+ * Protect the HTTP endpoint: with an OAuth authorization server (`issuer`, `resource`, ...), with a custom
66
+ * check (`preAuth`), or with both.
65
67
  */
66
- auth?: PlatformMcpAuthSettings;
68
+ auth?: PlatformMcpAuthSettings | PlatformMcpPreAuthSettings;
67
69
  }
68
70
  declare global {
69
71
  namespace TsED {
@@ -1,7 +1,7 @@
1
1
  import { type AuthInfo } from "@modelcontextprotocol/server";
2
2
  import type { PlatformContext } from "@tsed/platform-http";
3
- import type { PlatformMcpAuthSettings } from "../../common/interfaces/PlatformMcpAuthSettings.js";
4
- import { PlatformTokenVerifier } from "../../common/domain/PlatformTokenVerifier.js";
3
+ import type { PlatformMcpAuthSettings, PlatformMcpPreAuthOption, PlatformMcpPreAuthSettings } from "../../common/index.js";
4
+ import { PlatformTokenVerifier } from "../../common/index.js";
5
5
  export declare const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
6
6
  /**
7
7
  * OAuth resource-server behavior of the protected MCP endpoints: configuration validation,
@@ -11,6 +11,16 @@ export declare const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-prot
11
11
  */
12
12
  export declare class PlatformMcpAuthService {
13
13
  protected verifiers: WeakMap<PlatformMcpAuthSettings, PlatformTokenVerifier>;
14
+ /**
15
+ * Tells whether the endpoint is protected by an OAuth authorization server, and not only by a custom check.
16
+ */
17
+ isOAuth(auth?: PlatformMcpAuthSettings | PlatformMcpPreAuthSettings): auth is PlatformMcpAuthSettings;
18
+ /**
19
+ * Runs the custom authentication check of an endpoint.
20
+ *
21
+ * @returns The identity of the caller, or `undefined` when the check does not apply to the request.
22
+ */
23
+ preAuth(preAuth: PlatformMcpPreAuthOption, $ctx: PlatformContext): Promise<AuthInfo | undefined>;
14
24
  /**
15
25
  * Returns the token verifier of an endpoint, created once per `auth` configuration.
16
26
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-mcp",
3
- "version": "8.42.0",
3
+ "version": "8.43.0",
4
4
  "description": "Model Context Protocol integration for Ts.ED HTTP adapters.",
5
5
  "source": "./src/http/index.ts",
6
6
  "type": "module",
@@ -51,13 +51,14 @@
51
51
  "uuid": ">=11.0.2"
52
52
  },
53
53
  "devDependencies": {
54
- "@tsed/barrels": "8.42.0",
55
- "@tsed/core": "8.42.0",
56
- "@tsed/di": "8.42.0",
57
- "@tsed/json-mapper": "8.42.0",
58
- "@tsed/platform-http": "8.42.0",
59
- "@tsed/schema": "8.42.0",
60
- "@tsed/typescript": "8.42.0",
54
+ "@tsed/barrels": "8.43.0",
55
+ "@tsed/core": "8.43.0",
56
+ "@tsed/di": "8.43.0",
57
+ "@tsed/exceptions": "8.43.0",
58
+ "@tsed/json-mapper": "8.43.0",
59
+ "@tsed/platform-http": "8.43.0",
60
+ "@tsed/schema": "8.43.0",
61
+ "@tsed/typescript": "8.43.0",
61
62
  "jose": "^6.1.3",
62
63
  "typescript": "6.0.2",
63
64
  "vitest": "4.1.4"
@@ -12,6 +12,7 @@ export * from "./fn/definePrompt.js";
12
12
  export * from "./fn/defineResource.js";
13
13
  export * from "./fn/defineTool.js";
14
14
  export * from "./interfaces/PlatformMcpAuthSettings.js";
15
+ export * from "./interfaces/PlatformMcpPreAuth.js";
15
16
  export * from "./interfaces/PlatformMcpSettings.js";
16
17
  export * from "./interfaces/PlatformMcpUpstreamSettings.js";
17
18
  export * from "./services/PlatformMcpGatewayService.js";
@@ -1,5 +1,6 @@
1
1
  import type {OAuthTokenVerifier} from "@modelcontextprotocol/server";
2
2
  import type {TokenProvider} from "@tsed/di";
3
+ import type {PlatformMcpPreAuthOption} from "./PlatformMcpPreAuth.js";
3
4
 
4
5
  /**
5
6
  * OAuth 2.1 resource-server configuration of a Ts.ED MCP endpoint.
@@ -10,6 +11,11 @@ import type {TokenProvider} from "@tsed/di";
10
11
  * @module platform/mcp
11
12
  */
12
13
  export interface PlatformMcpAuthSettings {
14
+ /**
15
+ * Custom authentication check run before the OAuth verification, for instance an API key.
16
+ * When it returns an identity, the OAuth verification is skipped: both methods are accepted on the endpoint.
17
+ */
18
+ preAuth?: PlatformMcpPreAuthOption;
13
19
  /**
14
20
  * Issuer URL of the authorization server (OIDC provider) protecting the endpoint.
15
21
  */
@@ -0,0 +1,37 @@
1
+ import type {AuthInfo} from "@modelcontextprotocol/server";
2
+ import type {TokenProvider} from "@tsed/di";
3
+ import type {PlatformContext} from "@tsed/platform-http";
4
+
5
+ export type PlatformMcpPreAuthResult = AuthInfo | undefined | Promise<AuthInfo | undefined>;
6
+
7
+ /**
8
+ * Custom authentication check of an MCP endpoint, run before the OAuth verification.
9
+ *
10
+ * - Return an `AuthInfo` to authenticate the request: the OAuth verification is skipped and the identity is exposed
11
+ * to the handlers.
12
+ * - Return `undefined` when the check does not apply to the request: the OAuth verification runs when the endpoint
13
+ * declares an issuer, and the request is rejected with `401` otherwise.
14
+ * - Throw to reject the request.
15
+ *
16
+ * @module platform/mcp
17
+ */
18
+ export interface PlatformMcpPreAuth {
19
+ preAuth($ctx: PlatformContext): PlatformMcpPreAuthResult;
20
+ }
21
+
22
+ /**
23
+ * Accepted forms of the `auth.preAuth` option: a function, or a DI token resolving to a
24
+ * {@link PlatformMcpPreAuth} provider.
25
+ *
26
+ * @module platform/mcp
27
+ */
28
+ export type PlatformMcpPreAuthOption = (($ctx: PlatformContext) => PlatformMcpPreAuthResult) | TokenProvider<PlatformMcpPreAuth>;
29
+
30
+ /**
31
+ * Auth configuration of an MCP endpoint only protected by a custom check, without OAuth.
32
+ *
33
+ * @module platform/mcp
34
+ */
35
+ export interface PlatformMcpPreAuthSettings {
36
+ preAuth: PlatformMcpPreAuthOption;
37
+ }
@@ -2,6 +2,7 @@ import type {Implementation, ServerOptions} from "@modelcontextprotocol/server";
2
2
  import type {StreamableHTTPServerTransportOptions} from "@modelcontextprotocol/node";
3
3
  import type {TokenProvider} from "@tsed/di";
4
4
  import type {PlatformMcpAuthSettings} from "./PlatformMcpAuthSettings.js";
5
+ import type {PlatformMcpPreAuthSettings} from "./PlatformMcpPreAuth.js";
5
6
  import type {PlatformMcpUpstreamSettings} from "./PlatformMcpUpstreamSettings.js";
6
7
 
7
8
  /**
@@ -62,9 +63,10 @@ export interface PlatformMcpSettings {
62
63
  */
63
64
  upstream?: PlatformMcpUpstreamSettings;
64
65
  /**
65
- * Protect the HTTP endpoint with an OAuth authorization server.
66
+ * Protect the HTTP endpoint: with an OAuth authorization server (`issuer`, `resource`, ...), with a custom
67
+ * check (`preAuth`), or with both.
66
68
  */
67
- auth?: PlatformMcpAuthSettings;
69
+ auth?: PlatformMcpAuthSettings | PlatformMcpPreAuthSettings;
68
70
  }
69
71
 
70
72
  declare global {
@@ -1,7 +1,9 @@
1
1
  import type {AuthInfo} from "@modelcontextprotocol/server";
2
- import {inject, logger} from "@tsed/di";
2
+ import {inject, injectable, logger} from "@tsed/di";
3
+ import type {PlatformContext} from "@tsed/platform-http";
3
4
  import {PlatformTest} from "@tsed/platform-http/testing";
4
5
  import type {PlatformMcpAuthSettings} from "../../common/interfaces/PlatformMcpAuthSettings.js";
6
+ import type {PlatformMcpPreAuth} from "../../common/interfaces/PlatformMcpPreAuth.js";
5
7
  import {PlatformTokenVerifier} from "../../common/domain/PlatformTokenVerifier.js";
6
8
  import {PlatformMcpAuthService} from "./PlatformMcpAuthService.js";
7
9
 
@@ -12,6 +14,14 @@ const authInfo: AuthInfo = {
12
14
  expiresAt: Math.floor(Date.now() / 1000) + 3600
13
15
  };
14
16
 
17
+ class ApiKeyPreAuth implements PlatformMcpPreAuth {
18
+ preAuth($ctx: PlatformContext) {
19
+ return {token: String($ctx.request.headers["x-api-key"]), clientId: "api-key", scopes: []};
20
+ }
21
+ }
22
+
23
+ injectable(ApiKeyPreAuth);
24
+
15
25
  function createAuth(opts: Partial<PlatformMcpAuthSettings> = {}): PlatformMcpAuthSettings {
16
26
  return {issuer: "https://auth.example.com", resource: "https://api.example.com/mcp", ...opts};
17
27
  }
@@ -32,6 +42,54 @@ describe("PlatformMcpAuthService", () => {
32
42
  return PlatformTest.reset();
33
43
  });
34
44
 
45
+ describe("isOAuth()", () => {
46
+ it("tells an OAuth configuration from a configuration only declaring a custom check", () => {
47
+ const service = inject(PlatformMcpAuthService);
48
+
49
+ expect(service.isOAuth(createAuth())).toBe(true);
50
+ expect(service.isOAuth(createAuth({preAuth: vi.fn()}))).toBe(true);
51
+ expect(service.isOAuth({preAuth: vi.fn()})).toBe(false);
52
+ });
53
+ });
54
+
55
+ describe("preAuth()", () => {
56
+ it("runs a function", async () => {
57
+ const service = inject(PlatformMcpAuthService);
58
+ const $ctx = createContext();
59
+ const preAuth = vi.fn().mockResolvedValue(authInfo);
60
+
61
+ await expect(service.preAuth(preAuth, $ctx)).resolves.toBe(authInfo);
62
+ expect(preAuth).toHaveBeenCalledExactlyOnceWith($ctx);
63
+ });
64
+
65
+ it("runs a function declared with the function keyword", async () => {
66
+ const service = inject(PlatformMcpAuthService);
67
+
68
+ function preAuth() {
69
+ return authInfo;
70
+ }
71
+
72
+ await expect(service.preAuth(preAuth, createContext())).resolves.toBe(authInfo);
73
+ });
74
+
75
+ it("resolves an injectable class through the injector", async () => {
76
+ const service = inject(PlatformMcpAuthService);
77
+
78
+ await expect(service.preAuth(ApiKeyPreAuth, createContext({"x-api-key": "key"}))).resolves.toEqual({
79
+ token: "key",
80
+ clientId: "api-key",
81
+ scopes: []
82
+ });
83
+ });
84
+
85
+ it("propagates the error thrown by the check", async () => {
86
+ const service = inject(PlatformMcpAuthService);
87
+ const error = new Error("Unknown API key");
88
+
89
+ await expect(service.preAuth(() => Promise.reject(error), createContext())).rejects.toBe(error);
90
+ });
91
+ });
92
+
35
93
  describe("getVerifier()", () => {
36
94
  it("creates one verifier per auth configuration", () => {
37
95
  const service = inject(PlatformMcpAuthService);
@@ -6,10 +6,15 @@ import {
6
6
  getOAuthProtectedResourceMetadataUrl,
7
7
  verifyBearerToken
8
8
  } from "@modelcontextprotocol/server";
9
- import {injectable, logger} from "@tsed/di";
9
+ import {inject, injectable, injector, logger, type TokenProvider} from "@tsed/di";
10
10
  import type {PlatformContext} from "@tsed/platform-http";
11
- import type {PlatformMcpAuthSettings} from "../../common/interfaces/PlatformMcpAuthSettings.js";
12
- import {PlatformTokenVerifier} from "../../common/domain/PlatformTokenVerifier.js";
11
+ import type {
12
+ PlatformMcpAuthSettings,
13
+ PlatformMcpPreAuth,
14
+ PlatformMcpPreAuthOption,
15
+ PlatformMcpPreAuthSettings
16
+ } from "../../common/index.js";
17
+ import {PlatformTokenVerifier} from "../../common/index.js";
13
18
 
14
19
  export const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
15
20
 
@@ -22,6 +27,29 @@ export const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-re
22
27
  export class PlatformMcpAuthService {
23
28
  protected verifiers = new WeakMap<PlatformMcpAuthSettings, PlatformTokenVerifier>();
24
29
 
30
+ /**
31
+ * Tells whether the endpoint is protected by an OAuth authorization server, and not only by a custom check.
32
+ */
33
+ isOAuth(auth?: PlatformMcpAuthSettings | PlatformMcpPreAuthSettings): auth is PlatformMcpAuthSettings {
34
+ return Boolean((auth as PlatformMcpAuthSettings)?.issuer);
35
+ }
36
+
37
+ /**
38
+ * Runs the custom authentication check of an endpoint.
39
+ *
40
+ * @returns The identity of the caller, or `undefined` when the check does not apply to the request.
41
+ */
42
+ async preAuth(preAuth: PlatformMcpPreAuthOption, $ctx: PlatformContext): Promise<AuthInfo | undefined> {
43
+ if (!injector().providers.has(preAuth)) {
44
+ // not a registered provider: the option is the check itself
45
+ return (preAuth as ($ctx: PlatformContext) => AuthInfo | undefined)($ctx);
46
+ }
47
+
48
+ const instance = inject(preAuth as TokenProvider<PlatformMcpPreAuth>);
49
+
50
+ return instance.preAuth($ctx);
51
+ }
52
+
25
53
  /**
26
54
  * Returns the token verifier of an endpoint, created once per `auth` configuration.
27
55
  */
@@ -194,6 +194,37 @@ describe("PlatformMcpModule", () => {
194
194
  expect(application().post).toHaveBeenCalledOnce();
195
195
  });
196
196
 
197
+ it("fails when auth declares neither an issuer nor a custom check", async () => {
198
+ const {module} = await createModule();
199
+ module["settings"] = {auth: {} as PlatformMcpAuthSettings};
200
+ vi.spyOn(application(), "post").mockReturnValue(undefined as never);
201
+
202
+ expect(() => module.$onRoutesInit()).toThrow("auth requires an issuer, a preAuth check, or both");
203
+ });
204
+
205
+ it("mounts an endpoint only protected by a custom check without OAuth metadata route", async () => {
206
+ const {module} = await createModule();
207
+ module["settings"] = {path: "/mcp/a", auth: {preAuth: vi.fn()}};
208
+ vi.spyOn(application(), "post").mockReturnValue(undefined as never);
209
+ vi.spyOn(application(), "get").mockReturnValue(undefined as never);
210
+
211
+ module.$onRoutesInit();
212
+
213
+ expect(application().get).not.toHaveBeenCalled();
214
+ expect(module.$logRoutes([])).toEqual([{method: "POST", name: "PlatformMcpModule.dispatch()", url: "/mcp/a"}]);
215
+ });
216
+
217
+ it("accepts upstream placeholders on an endpoint only protected by a custom check", async () => {
218
+ const {module} = await createModule();
219
+ module["settings"] = {
220
+ auth: {preAuth: vi.fn()},
221
+ upstream: {type: "http", url: "http://localhost/mcp", headers: {authorization: "Bearer ${OAUTH_TOKEN}"}}
222
+ };
223
+ vi.spyOn(application(), "post").mockReturnValue(undefined as never);
224
+
225
+ expect(() => module.$onRoutesInit()).not.toThrow();
226
+ });
227
+
197
228
  it("registers the protected resource metadata route of protected endpoints", async () => {
198
229
  const {module} = await createModule();
199
230
  module["settings"] = {
@@ -1,6 +1,6 @@
1
1
  import {application, type OnRoutesInit, type PlatformContext, type PlatformRouteDetails} from "@tsed/platform-http";
2
2
  import {constant, inject, injectable} from "@tsed/di";
3
- import type {PlatformMcpSettings} from "../../common/index.js";
3
+ import type {PlatformMcpAuthSettings, PlatformMcpSettings} from "../../common/index.js";
4
4
  import {NodeStreamableHTTPServerTransport} from "@modelcontextprotocol/node";
5
5
  import type {AuthInfo} from "@modelcontextprotocol/server";
6
6
  import {useContextHandler} from "@tsed/platform-router";
@@ -43,7 +43,7 @@ export class PlatformMcpModule implements OnRoutesInit {
43
43
  path
44
44
  };
45
45
 
46
- if (opts.auth) {
46
+ if (this.platformAuthService.isOAuth(opts.auth)) {
47
47
  const metadataPath = this.platformAuthService.getProtectedResourceMetadataPath(path);
48
48
 
49
49
  this.app.get(
@@ -81,8 +81,12 @@ export class PlatformMcpModule implements OnRoutesInit {
81
81
  * Rejects a configuration that cannot work or would be unsafe, before any route is mounted.
82
82
  */
83
83
  protected validate(path: string, opts: PlatformMcpSettings) {
84
- if (opts.auth) {
85
- this.platformAuthService.validate(path, opts.auth);
84
+ const {auth} = opts;
85
+
86
+ if (this.platformAuthService.isOAuth(auth)) {
87
+ this.platformAuthService.validate(path, auth);
88
+ } else if (auth && !auth.preAuth) {
89
+ throw new Error(`MCP endpoint "${path}": auth requires an issuer, a preAuth check, or both.`);
86
90
  }
87
91
 
88
92
  if (opts.upstream && !opts.auth && hasUpstreamPlaceholders(opts.upstream)) {
@@ -91,7 +95,7 @@ export class PlatformMcpModule implements OnRoutesInit {
91
95
  }
92
96
 
93
97
  protected metadata(settings: CreateMcpServerOpts, $ctx: PlatformContext) {
94
- const auth = settings.auth!;
98
+ const auth = settings.auth as PlatformMcpAuthSettings;
95
99
  const resource = this.platformAuthService.getResourceUrl(auth);
96
100
  const body = this.platformAuthService.getProtectedResourceMetadata(auth, resource);
97
101
 
@@ -106,10 +110,20 @@ export class PlatformMcpModule implements OnRoutesInit {
106
110
  }
107
111
 
108
112
  protected async dispatch(settings: CreateMcpServerOpts, $ctx: PlatformContext) {
113
+ const {auth} = settings;
109
114
  let authInfo: AuthInfo | undefined;
110
115
 
111
- if (settings.auth) {
112
- const result = await this.platformAuthService.verifyMcpRequest(settings.auth, $ctx);
116
+ if (auth?.preAuth) {
117
+ authInfo = await this.platformAuthService.preAuth(auth.preAuth, $ctx);
118
+ }
119
+
120
+ if (auth && !authInfo) {
121
+ if (!this.platformAuthService.isOAuth(auth)) {
122
+ // the custom check did not authenticate the request and there is no OAuth to fall back on
123
+ return $ctx.response.status(401).body({error: "unauthorized", error_description: "Authentication required"});
124
+ }
125
+
126
+ const result = await this.platformAuthService.verifyMcpRequest(auth, $ctx);
113
127
 
114
128
  if (result instanceof Response) {
115
129
  return $ctx.response
@@ -119,6 +133,9 @@ export class PlatformMcpModule implements OnRoutesInit {
119
133
  }
120
134
 
121
135
  authInfo = result;
136
+ }
137
+
138
+ if (authInfo) {
122
139
  // the SDK transport reads `req.auth` and exposes it to handlers as `ctx.http.authInfo`
123
140
  ($ctx.getReq() as {auth?: AuthInfo}).auth = authInfo;
124
141
  }