@casys/mcp-server 0.27.0 → 0.27.1

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.
Files changed (253) hide show
  1. package/CHANGELOG.md +6 -1770
  2. package/README.md +10 -638
  3. package/esm/mod.d.ts +1 -102
  4. package/esm/mod.js +1 -103
  5. package/package.json +17 -25
  6. package/esm/_dnt.polyfills.d.ts +0 -12
  7. package/esm/_dnt.polyfills.d.ts.map +0 -1
  8. package/esm/_dnt.polyfills.js +0 -15
  9. package/esm/_dnt.shims.d.ts +0 -2
  10. package/esm/_dnt.shims.d.ts.map +0 -1
  11. package/esm/_dnt.shims.js +0 -57
  12. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts +0 -33
  13. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts.map +0 -1
  14. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.js +0 -48
  15. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts +0 -106
  16. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts.map +0 -1
  17. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.js +0 -636
  18. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts +0 -67
  19. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts.map +0 -1
  20. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.js +0 -1393
  21. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts +0 -44
  22. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts.map +0 -1
  23. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.js +0 -117
  24. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts +0 -3
  25. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts.map +0 -1
  26. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.js +0 -103
  27. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts +0 -3
  28. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts.map +0 -1
  29. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.js +0 -32
  30. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts +0 -3
  31. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts.map +0 -1
  32. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.js +0 -96
  33. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts +0 -3
  34. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts.map +0 -1
  35. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.js +0 -159
  36. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts +0 -3
  37. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts.map +0 -1
  38. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.js +0 -14
  39. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts +0 -3
  40. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts.map +0 -1
  41. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.js +0 -10
  42. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts +0 -3
  43. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts.map +0 -1
  44. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.js +0 -22
  45. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts +0 -3
  46. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts.map +0 -1
  47. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.js +0 -29
  48. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts +0 -3
  49. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts.map +0 -1
  50. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.js +0 -19
  51. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts +0 -3
  52. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts.map +0 -1
  53. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.js +0 -30
  54. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts +0 -3
  55. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts.map +0 -1
  56. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.js +0 -10
  57. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts +0 -3
  58. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts.map +0 -1
  59. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.js +0 -14
  60. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts +0 -3
  61. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts.map +0 -1
  62. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.js +0 -9
  63. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts +0 -3
  64. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts.map +0 -1
  65. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.js +0 -81
  66. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts +0 -3
  67. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts.map +0 -1
  68. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.js +0 -20
  69. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts +0 -32
  70. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts.map +0 -1
  71. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.js +0 -6
  72. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts +0 -4
  73. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts.map +0 -1
  74. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.js +0 -13
  75. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts +0 -51
  76. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts.map +0 -1
  77. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.js +0 -53
  78. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts +0 -79
  79. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts.map +0 -1
  80. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.js +0 -91
  81. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts +0 -100
  82. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts.map +0 -1
  83. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.js +0 -33
  84. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts +0 -111
  85. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts.map +0 -1
  86. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.js +0 -104
  87. package/esm/mod.d.ts.map +0 -1
  88. package/esm/package.json +0 -3
  89. package/esm/src/auth/as-metadata-proxy.d.ts +0 -112
  90. package/esm/src/auth/as-metadata-proxy.d.ts.map +0 -1
  91. package/esm/src/auth/as-metadata-proxy.js +0 -171
  92. package/esm/src/auth/config.d.ts +0 -117
  93. package/esm/src/auth/config.d.ts.map +0 -1
  94. package/esm/src/auth/config.js +0 -219
  95. package/esm/src/auth/jwt-provider.d.ts +0 -157
  96. package/esm/src/auth/jwt-provider.d.ts.map +0 -1
  97. package/esm/src/auth/jwt-provider.js +0 -187
  98. package/esm/src/auth/middleware.d.ts +0 -61
  99. package/esm/src/auth/middleware.d.ts.map +0 -1
  100. package/esm/src/auth/middleware.js +0 -209
  101. package/esm/src/auth/mod.d.ts +0 -23
  102. package/esm/src/auth/mod.d.ts.map +0 -1
  103. package/esm/src/auth/mod.js +0 -27
  104. package/esm/src/auth/multi-tenant-middleware.d.ts +0 -131
  105. package/esm/src/auth/multi-tenant-middleware.d.ts.map +0 -1
  106. package/esm/src/auth/multi-tenant-middleware.js +0 -128
  107. package/esm/src/auth/presets.d.ts +0 -231
  108. package/esm/src/auth/presets.d.ts.map +0 -1
  109. package/esm/src/auth/presets.js +0 -223
  110. package/esm/src/auth/provider.d.ts +0 -47
  111. package/esm/src/auth/provider.d.ts.map +0 -1
  112. package/esm/src/auth/provider.js +0 -34
  113. package/esm/src/auth/scope-middleware.d.ts +0 -30
  114. package/esm/src/auth/scope-middleware.d.ts.map +0 -1
  115. package/esm/src/auth/scope-middleware.js +0 -48
  116. package/esm/src/auth/static-token-provider.d.ts +0 -155
  117. package/esm/src/auth/static-token-provider.d.ts.map +0 -1
  118. package/esm/src/auth/static-token-provider.js +0 -256
  119. package/esm/src/auth/types.d.ts +0 -151
  120. package/esm/src/auth/types.d.ts.map +0 -1
  121. package/esm/src/auth/types.js +0 -64
  122. package/esm/src/client-auth/callback-server.d.ts +0 -34
  123. package/esm/src/client-auth/callback-server.d.ts.map +0 -1
  124. package/esm/src/client-auth/callback-server.js +0 -141
  125. package/esm/src/client-auth/client-id-metadata.d.ts +0 -29
  126. package/esm/src/client-auth/client-id-metadata.d.ts.map +0 -1
  127. package/esm/src/client-auth/client-id-metadata.js +0 -149
  128. package/esm/src/client-auth/connect.d.ts +0 -32
  129. package/esm/src/client-auth/connect.d.ts.map +0 -1
  130. package/esm/src/client-auth/connect.js +0 -47
  131. package/esm/src/client-auth/mod.d.ts +0 -19
  132. package/esm/src/client-auth/mod.d.ts.map +0 -1
  133. package/esm/src/client-auth/mod.js +0 -19
  134. package/esm/src/client-auth/provider.d.ts +0 -78
  135. package/esm/src/client-auth/provider.d.ts.map +0 -1
  136. package/esm/src/client-auth/provider.js +0 -246
  137. package/esm/src/client-auth/token-store/file-store.d.ts +0 -20
  138. package/esm/src/client-auth/token-store/file-store.d.ts.map +0 -1
  139. package/esm/src/client-auth/token-store/file-store.js +0 -62
  140. package/esm/src/client-auth/token-store/memory-store.d.ts +0 -14
  141. package/esm/src/client-auth/token-store/memory-store.d.ts.map +0 -1
  142. package/esm/src/client-auth/token-store/memory-store.js +0 -25
  143. package/esm/src/client-auth/types.d.ts +0 -89
  144. package/esm/src/client-auth/types.d.ts.map +0 -1
  145. package/esm/src/client-auth/types.js +0 -10
  146. package/esm/src/concurrency/rate-limiter.d.ts +0 -87
  147. package/esm/src/concurrency/rate-limiter.d.ts.map +0 -1
  148. package/esm/src/concurrency/rate-limiter.js +0 -165
  149. package/esm/src/concurrency/request-queue.d.ts +0 -71
  150. package/esm/src/concurrency/request-queue.d.ts.map +0 -1
  151. package/esm/src/concurrency/request-queue.js +0 -128
  152. package/esm/src/http/body.d.ts +0 -20
  153. package/esm/src/http/body.d.ts.map +0 -1
  154. package/esm/src/http/body.js +0 -63
  155. package/esm/src/http/request-guards.d.ts +0 -54
  156. package/esm/src/http/request-guards.d.ts.map +0 -1
  157. package/esm/src/http/request-guards.js +0 -114
  158. package/esm/src/http/wire.d.ts +0 -26
  159. package/esm/src/http/wire.d.ts.map +0 -1
  160. package/esm/src/http/wire.js +0 -35
  161. package/esm/src/inspector/launcher.d.ts +0 -48
  162. package/esm/src/inspector/launcher.d.ts.map +0 -1
  163. package/esm/src/inspector/launcher.js +0 -100
  164. package/esm/src/mcp-app.d.ts +0 -728
  165. package/esm/src/mcp-app.d.ts.map +0 -1
  166. package/esm/src/mcp-app.js +0 -3530
  167. package/esm/src/middleware/backpressure.d.ts +0 -24
  168. package/esm/src/middleware/backpressure.d.ts.map +0 -1
  169. package/esm/src/middleware/backpressure.js +0 -31
  170. package/esm/src/middleware/mod.d.ts +0 -11
  171. package/esm/src/middleware/mod.d.ts.map +0 -1
  172. package/esm/src/middleware/mod.js +0 -11
  173. package/esm/src/middleware/rate-limit.d.ts +0 -22
  174. package/esm/src/middleware/rate-limit.d.ts.map +0 -1
  175. package/esm/src/middleware/rate-limit.js +0 -33
  176. package/esm/src/middleware/runner.d.ts +0 -32
  177. package/esm/src/middleware/runner.d.ts.map +0 -1
  178. package/esm/src/middleware/runner.js +0 -49
  179. package/esm/src/middleware/types.d.ts +0 -76
  180. package/esm/src/middleware/types.d.ts.map +0 -1
  181. package/esm/src/middleware/types.js +0 -9
  182. package/esm/src/middleware/validation.d.ts +0 -24
  183. package/esm/src/middleware/validation.d.ts.map +0 -1
  184. package/esm/src/middleware/validation.js +0 -30
  185. package/esm/src/mrtr/capability-check.d.ts +0 -75
  186. package/esm/src/mrtr/capability-check.d.ts.map +0 -1
  187. package/esm/src/mrtr/capability-check.js +0 -233
  188. package/esm/src/mrtr/mod.d.ts +0 -18
  189. package/esm/src/mrtr/mod.d.ts.map +0 -1
  190. package/esm/src/mrtr/mod.js +0 -12
  191. package/esm/src/mrtr/replay-store.d.ts +0 -50
  192. package/esm/src/mrtr/replay-store.d.ts.map +0 -1
  193. package/esm/src/mrtr/replay-store.js +0 -61
  194. package/esm/src/mrtr/request-state.d.ts +0 -181
  195. package/esm/src/mrtr/request-state.d.ts.map +0 -1
  196. package/esm/src/mrtr/request-state.js +0 -313
  197. package/esm/src/mrtr/retry-guard.d.ts +0 -61
  198. package/esm/src/mrtr/retry-guard.d.ts.map +0 -1
  199. package/esm/src/mrtr/retry-guard.js +0 -53
  200. package/esm/src/mrtr/types.d.ts +0 -99
  201. package/esm/src/mrtr/types.d.ts.map +0 -1
  202. package/esm/src/mrtr/types.js +0 -14
  203. package/esm/src/observability/metrics.d.ts +0 -104
  204. package/esm/src/observability/metrics.d.ts.map +0 -1
  205. package/esm/src/observability/metrics.js +0 -207
  206. package/esm/src/observability/mod.d.ts +0 -12
  207. package/esm/src/observability/mod.d.ts.map +0 -1
  208. package/esm/src/observability/mod.js +0 -11
  209. package/esm/src/observability/otel.d.ts +0 -73
  210. package/esm/src/observability/otel.d.ts.map +0 -1
  211. package/esm/src/observability/otel.js +0 -260
  212. package/esm/src/runtime/runtime.d.ts +0 -10
  213. package/esm/src/runtime/runtime.d.ts.map +0 -1
  214. package/esm/src/runtime/runtime.deno.d.ts +0 -50
  215. package/esm/src/runtime/runtime.deno.d.ts.map +0 -1
  216. package/esm/src/runtime/runtime.deno.js +0 -120
  217. package/esm/src/runtime/runtime.js +0 -41
  218. package/esm/src/runtime/runtime.node.d.ts +0 -51
  219. package/esm/src/runtime/runtime.node.d.ts.map +0 -1
  220. package/esm/src/runtime/runtime.node.js +0 -268
  221. package/esm/src/runtime/types.d.ts +0 -107
  222. package/esm/src/runtime/types.d.ts.map +0 -1
  223. package/esm/src/runtime/types.js +0 -12
  224. package/esm/src/security/channel-hmac.d.ts +0 -43
  225. package/esm/src/security/channel-hmac.d.ts.map +0 -1
  226. package/esm/src/security/channel-hmac.js +0 -135
  227. package/esm/src/security/csp.d.ts +0 -50
  228. package/esm/src/security/csp.d.ts.map +0 -1
  229. package/esm/src/security/csp.js +0 -63
  230. package/esm/src/security/message-signer.d.ts +0 -88
  231. package/esm/src/security/message-signer.d.ts.map +0 -1
  232. package/esm/src/security/message-signer.js +0 -166
  233. package/esm/src/subscriptions/subscription-registry.d.ts +0 -256
  234. package/esm/src/subscriptions/subscription-registry.d.ts.map +0 -1
  235. package/esm/src/subscriptions/subscription-registry.js +0 -406
  236. package/esm/src/tasks/mod.d.ts +0 -13
  237. package/esm/src/tasks/mod.d.ts.map +0 -1
  238. package/esm/src/tasks/mod.js +0 -11
  239. package/esm/src/tasks/task-store.d.ts +0 -342
  240. package/esm/src/tasks/task-store.d.ts.map +0 -1
  241. package/esm/src/tasks/task-store.js +0 -649
  242. package/esm/src/transport/request-headers.d.ts +0 -145
  243. package/esm/src/transport/request-headers.d.ts.map +0 -1
  244. package/esm/src/transport/request-headers.js +0 -525
  245. package/esm/src/types.d.ts +0 -776
  246. package/esm/src/types.d.ts.map +0 -1
  247. package/esm/src/types.js +0 -92
  248. package/esm/src/ui/viewer-utils.d.ts +0 -45
  249. package/esm/src/ui/viewer-utils.d.ts.map +0 -1
  250. package/esm/src/ui/viewer-utils.js +0 -97
  251. package/esm/src/validation/schema-validator.d.ts +0 -115
  252. package/esm/src/validation/schema-validator.d.ts.map +0 -1
  253. package/esm/src/validation/schema-validator.js +0 -249
@@ -1,30 +0,0 @@
1
- /**
2
- * Scope enforcement middleware.
3
- *
4
- * Verifies that the authenticated user has the required scopes
5
- * for the tool being called. Placed after the auth middleware.
6
- *
7
- * @module lib/server/auth/scope-middleware
8
- */
9
- import type { Middleware, MiddlewareContext } from "../middleware/types.js";
10
- /**
11
- * Source of the scopes required for one tool call.
12
- *
13
- * A map preserves the original public helper API. A resolver lets McpApp bind
14
- * authorization to the exact tool definition captured for an in-flight call,
15
- * including tools registered or replaced after startup.
16
- */
17
- type ToolScopesSource = ReadonlyMap<string, readonly string[]> | ((ctx: MiddlewareContext) => readonly string[] | undefined);
18
- /**
19
- * Create a scope enforcement middleware.
20
- *
21
- * Checks `requiredScopes` for the called tool against `ctx.authInfo.scopes`.
22
- * STDIO calls (no HTTP request) pass through without auth. An HTTP call for a
23
- * scoped tool fails closed when no authInfo is available.
24
- * If the tool has no requiredScopes, the middleware passes through.
25
- *
26
- * @param toolScopes - Map of tool name to required scopes, or a per-call resolver
27
- */
28
- export declare function createScopeMiddleware(toolScopes: ToolScopesSource): Middleware;
29
- export {};
30
- //# sourceMappingURL=scope-middleware.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scope-middleware.d.ts","sourceRoot":"","sources":["../../../src/src/auth/scope-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE5E;;;;;;GAMG;AACH,KAAK,gBAAgB,GACjB,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,GACtC,CAAC,CAAC,GAAG,EAAE,iBAAiB,KAAK,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAEhE;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,gBAAgB,GAC3B,UAAU,CAoCZ"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Scope enforcement middleware.
3
- *
4
- * Verifies that the authenticated user has the required scopes
5
- * for the tool being called. Placed after the auth middleware.
6
- *
7
- * @module lib/server/auth/scope-middleware
8
- */
9
- import { AuthError } from "./middleware.js";
10
- /**
11
- * Create a scope enforcement middleware.
12
- *
13
- * Checks `requiredScopes` for the called tool against `ctx.authInfo.scopes`.
14
- * STDIO calls (no HTTP request) pass through without auth. An HTTP call for a
15
- * scoped tool fails closed when no authInfo is available.
16
- * If the tool has no requiredScopes, the middleware passes through.
17
- *
18
- * @param toolScopes - Map of tool name to required scopes, or a per-call resolver
19
- */
20
- export function createScopeMiddleware(toolScopes) {
21
- // deno-lint-ignore require-await
22
- return async (ctx, next) => {
23
- const requiredScopes = typeof toolScopes === "function"
24
- ? toolScopes(ctx)
25
- : toolScopes.get(ctx.toolName);
26
- // No scopes required for this tool
27
- if (!requiredScopes?.length)
28
- return next();
29
- // No auth configured: STDIO (no request) is fine, HTTP without authInfo is a misconfiguration
30
- const authInfo = ctx.authInfo;
31
- if (!authInfo) {
32
- if (!ctx.request)
33
- return next(); // STDIO: local transport, no auth needed
34
- // HTTP request with required scopes but no authInfo = auth middleware is missing
35
- throw new Error(`[ScopeMiddleware] Tool "${ctx.toolName}" requires scopes [${requiredScopes.join(", ")}] ` +
36
- "but no authInfo found on HTTP request. Ensure auth middleware is configured in the pipeline.");
37
- }
38
- const hasAll = requiredScopes.every((s) => authInfo.scopes.includes(s));
39
- if (!hasAll) {
40
- const missingScopes = requiredScopes.filter((s) => !authInfo.scopes.includes(s));
41
- // Used by 403 responses to advertise protected resource metadata in
42
- // WWW-Authenticate; auth middleware populates it for HTTP requests.
43
- const metadataUrl = ctx.resourceMetadataUrl ?? "";
44
- throw new AuthError("insufficient_scope", metadataUrl, missingScopes);
45
- }
46
- return next();
47
- };
48
- }
@@ -1,155 +0,0 @@
1
- /**
2
- * Static (opaque) bearer-token auth provider.
3
- *
4
- * Validates a fixed set of pre-shared bearer tokens with no OIDC/JWT
5
- * infrastructure — no issuer, no JWKS endpoint, no key management. Suited to
6
- * same-network deployments (Docker, VPN, LAN), server-to-server integrations,
7
- * and CI pipelines where a full OAuth flow is disproportionate.
8
- *
9
- * The original string-list form maps every valid token to one shared
10
- * {@link AuthInfo}. An identity-aware credential form can instead assign a
11
- * distinct subject and scopes to each token. For externally issued identity,
12
- * expiry, rotation policy, or SSO, use {@link JwtAuthProvider} / the OIDC
13
- * presets instead.
14
- *
15
- * Per RFC 9728 the emitted {@link ProtectedResourceMetadata} carries an empty
16
- * `authorization_servers` array: there is no authorization server in a static
17
- * token scheme — tokens are provisioned out of band — which is the correct
18
- * signal for clients not to attempt AS discovery.
19
- *
20
- * @module lib/server/auth/static-token-provider
21
- */
22
- import { AuthProvider } from "./provider.js";
23
- import { type AuthInfo, type ProtectedResourceMetadata } from "./types.js";
24
- /**
25
- * One opaque bearer token with caller identity owned by the resource server.
26
- *
27
- * Use this form only when the server provisions its own long-lived credentials.
28
- * The token is used exclusively as a lookup key; it is never copied into the
29
- * resulting {@link AuthInfo}, metadata, logs, or validation errors.
30
- */
31
- export interface StaticTokenCredential {
32
- /** Opaque bearer token, normally loaded from env or a secrets manager. */
33
- readonly token: string;
34
- /** Stable non-empty caller identity. Reserved/control values are invalid. */
35
- readonly subject: string;
36
- /** Scopes granted to this credential. Default `[]`. */
37
- readonly scopes?: readonly string[];
38
- }
39
- /**
40
- * Options for {@link createStaticTokenAuthProvider} /
41
- * {@link StaticTokenAuthProvider}.
42
- */
43
- export interface StaticTokenAuthProviderOptions {
44
- /**
45
- * RFC 9728 § 2 resource identifier — an absolute HTTP(S) URL identifying
46
- * this server, validated via {@link httpsUrl} at construction. Required: the
47
- * {@link AuthProvider} contract must emit Protected Resource Metadata, which
48
- * needs a resource URL.
49
- */
50
- resource: string;
51
- /**
52
- * `subject` reported in {@link AuthInfo} for every valid token in the shared
53
- * string-list form. Rejected when identity-aware credentials are used.
54
- * Default `"static-token-user"`.
55
- */
56
- subject?: string;
57
- /**
58
- * `scopes` granted to every valid token in the shared string-list form.
59
- * Default `[]` — a pure gate with no scopes, which is the common same-network
60
- * case. Rejected when identity-aware credentials are used.
61
- */
62
- scopes?: readonly string[];
63
- /**
64
- * `scopes_supported` advertised in the metadata document (what the resource
65
- * accepts). Defaults to shared `scopes` for the string-list form and to the
66
- * union of credential scopes for the identity-aware form.
67
- */
68
- scopesSupported?: readonly string[];
69
- /**
70
- * Explicit Protected Resource Metadata URL. When omitted it is auto-derived
71
- * from `resource` per RFC 9728 § 3.1, identically to {@link JwtAuthProvider}.
72
- * Empty / whitespace-only values are treated as absent.
73
- */
74
- resourceMetadataUrl?: string;
75
- }
76
- /**
77
- * {@link AuthProvider} that accepts a fixed set of opaque bearer tokens.
78
- *
79
- * Token lookup is O(1) via a pre-built `Map`. The string-list form stores the
80
- * same frozen {@link AuthInfo} for every token; the credential form stores one
81
- * distinct frozen value per token. Tokens are trimmed to match the bearer value
82
- * the HTTP middleware extracts. Note that `Map.get()` is not constant-time —
83
- * prefer long, high-entropy tokens (>= 32 random bytes) and rotate them
84
- * regularly.
85
- *
86
- * @example
87
- * ```typescript
88
- * const provider = new StaticTokenAuthProvider(
89
- * [Deno.env.get("MCP_AUTH_TOKEN")!],
90
- * { resource: "https://my-mcp.example.com", scopes: ["tools:invoke"] },
91
- * );
92
- * ```
93
- *
94
- * @example Identity-aware credentials
95
- * ```typescript
96
- * const provider = new StaticTokenAuthProvider(
97
- * [
98
- * { token: aliceToken, subject: "alice", scopes: ["erp:read"] },
99
- * {
100
- * token: automationToken,
101
- * subject: "automation",
102
- * scopes: ["erp:read", "erp:write"],
103
- * },
104
- * ],
105
- * { resource: "https://my-mcp.example.com" },
106
- * );
107
- * ```
108
- */
109
- export declare class StaticTokenAuthProvider extends AuthProvider {
110
- private readonly authByToken;
111
- private readonly resource;
112
- private readonly resourceMetadataUrl;
113
- private readonly scopesSupported;
114
- constructor(entries: readonly string[] | readonly StaticTokenCredential[], options: StaticTokenAuthProviderOptions);
115
- verifyToken(token: string): Promise<AuthInfo | null>;
116
- getResourceMetadata(): ProtectedResourceMetadata;
117
- }
118
- /**
119
- * Create a static (opaque) bearer-token {@link AuthProvider}.
120
- *
121
- * @param entries Either a non-empty shared-authority list of bearer tokens, or
122
- * a non-empty list of identity-aware credentials. Load tokens from env / a
123
- * secrets manager — never hard-code them in source.
124
- * @param options Provider configuration; `options.resource` is required.
125
- *
126
- * @example
127
- * ```typescript
128
- * import { createStaticTokenAuthProvider, McpApp } from "@casys/mcp-server";
129
- *
130
- * const app = new McpApp({
131
- * name: "my-server",
132
- * version: "1.0.0",
133
- * auth: {
134
- * provider: createStaticTokenAuthProvider(
135
- * (Deno.env.get("MCP_AUTH_TOKENS") ?? "").split(",").filter(Boolean),
136
- * { resource: "https://my-mcp.example.com" },
137
- * ),
138
- * },
139
- * });
140
- * await app.startHttp({ port: 7654, requireAuth: true });
141
- * ```
142
- *
143
- * @example Identity and scopes per credential
144
- * ```typescript
145
- * const provider = createStaticTokenAuthProvider(
146
- * [
147
- * { token: aliceToken, subject: "alice", scopes: ["read"] },
148
- * { token: ciToken, subject: "ci", scopes: ["read", "write"] },
149
- * ],
150
- * { resource: "https://my-mcp.example.com" },
151
- * );
152
- * ```
153
- */
154
- export declare function createStaticTokenAuthProvider(entries: readonly string[] | readonly StaticTokenCredential[], options: StaticTokenAuthProviderOptions): StaticTokenAuthProvider;
155
- //# sourceMappingURL=static-token-provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"static-token-provider.d.ts","sourceRoot":"","sources":["../../../src/src/auth/static-token-provider.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,KAAK,QAAQ,EAGb,KAAK,yBAAyB,EAC/B,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B;;;;OAIG;IACH,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAqDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAW;IAC/C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;gBAGrD,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,qBAAqB,EAAE,EAC7D,OAAO,EAAE,8BAA8B;IA2InC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAM1D,mBAAmB,IAAI,yBAAyB;CAYjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,qBAAqB,EAAE,EAC7D,OAAO,EAAE,8BAA8B,GACtC,uBAAuB,CAEzB"}
@@ -1,256 +0,0 @@
1
- // deno-lint-ignore-file require-await
2
- /**
3
- * Static (opaque) bearer-token auth provider.
4
- *
5
- * Validates a fixed set of pre-shared bearer tokens with no OIDC/JWT
6
- * infrastructure — no issuer, no JWKS endpoint, no key management. Suited to
7
- * same-network deployments (Docker, VPN, LAN), server-to-server integrations,
8
- * and CI pipelines where a full OAuth flow is disproportionate.
9
- *
10
- * The original string-list form maps every valid token to one shared
11
- * {@link AuthInfo}. An identity-aware credential form can instead assign a
12
- * distinct subject and scopes to each token. For externally issued identity,
13
- * expiry, rotation policy, or SSO, use {@link JwtAuthProvider} / the OIDC
14
- * presets instead.
15
- *
16
- * Per RFC 9728 the emitted {@link ProtectedResourceMetadata} carries an empty
17
- * `authorization_servers` array: there is no authorization server in a static
18
- * token scheme — tokens are provisioned out of band — which is the correct
19
- * signal for clients not to attempt AS discovery.
20
- *
21
- * @module lib/server/auth/static-token-provider
22
- */
23
- import { AuthProvider } from "./provider.js";
24
- import { httpsUrl, } from "./types.js";
25
- function freezeScopes(scopes) {
26
- return Object.freeze([...scopes]);
27
- }
28
- function freezeAuthInfo(subject, scopes) {
29
- return Object.freeze({
30
- subject,
31
- scopes: freezeScopes(scopes),
32
- });
33
- }
34
- function normalizeScopeList(value, field) {
35
- if (!Array.isArray(value)) {
36
- throw new Error(`[StaticTokenAuthProvider] ${field} must be an array of non-empty strings`);
37
- }
38
- const normalized = [];
39
- const seen = new Set();
40
- for (const [index, rawScope] of value.entries()) {
41
- if (typeof rawScope !== "string" || rawScope.trim().length === 0) {
42
- throw new Error(`[StaticTokenAuthProvider] ${field} contains an invalid scope at index ${index}`);
43
- }
44
- const scope = rawScope.trim();
45
- if (!seen.has(scope)) {
46
- seen.add(scope);
47
- normalized.push(scope);
48
- }
49
- }
50
- return normalized;
51
- }
52
- function normalizeCredentialScopes(value, index) {
53
- if (value === undefined)
54
- return [];
55
- return normalizeScopeList(value, `credential at index ${index} scopes`);
56
- }
57
- function containsAsciiControl(value) {
58
- for (const character of value) {
59
- const codePoint = character.codePointAt(0);
60
- if (codePoint <= 0x1f || codePoint === 0x7f)
61
- return true;
62
- }
63
- return false;
64
- }
65
- /**
66
- * {@link AuthProvider} that accepts a fixed set of opaque bearer tokens.
67
- *
68
- * Token lookup is O(1) via a pre-built `Map`. The string-list form stores the
69
- * same frozen {@link AuthInfo} for every token; the credential form stores one
70
- * distinct frozen value per token. Tokens are trimmed to match the bearer value
71
- * the HTTP middleware extracts. Note that `Map.get()` is not constant-time —
72
- * prefer long, high-entropy tokens (>= 32 random bytes) and rotate them
73
- * regularly.
74
- *
75
- * @example
76
- * ```typescript
77
- * const provider = new StaticTokenAuthProvider(
78
- * [Deno.env.get("MCP_AUTH_TOKEN")!],
79
- * { resource: "https://my-mcp.example.com", scopes: ["tools:invoke"] },
80
- * );
81
- * ```
82
- *
83
- * @example Identity-aware credentials
84
- * ```typescript
85
- * const provider = new StaticTokenAuthProvider(
86
- * [
87
- * { token: aliceToken, subject: "alice", scopes: ["erp:read"] },
88
- * {
89
- * token: automationToken,
90
- * subject: "automation",
91
- * scopes: ["erp:read", "erp:write"],
92
- * },
93
- * ],
94
- * { resource: "https://my-mcp.example.com" },
95
- * );
96
- * ```
97
- */
98
- export class StaticTokenAuthProvider extends AuthProvider {
99
- authByToken;
100
- resource;
101
- resourceMetadataUrl;
102
- scopesSupported;
103
- constructor(entries, options) {
104
- super();
105
- if (entries.length === 0) {
106
- throw new Error("[StaticTokenAuthProvider] `tokens` must contain at least one token");
107
- }
108
- const rawEntries = entries;
109
- const allStrings = rawEntries.every((entry) => typeof entry === "string");
110
- const allObjects = rawEntries.every((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry));
111
- if (!allStrings && !allObjects) {
112
- throw new Error("[StaticTokenAuthProvider] entries must be either all token strings or all credential objects");
113
- }
114
- const authByToken = new Map();
115
- let scopesSupported;
116
- if (allStrings) {
117
- const tokens = rawEntries;
118
- if (tokens.some((token) => token.trim().length === 0)) {
119
- throw new Error("[StaticTokenAuthProvider] `tokens` must not contain empty entries");
120
- }
121
- // Keep the original shared-authority contract exactly: normalized
122
- // duplicates collapse, and every token resolves to this same object.
123
- const sharedAuthInfo = freezeAuthInfo(options.subject ?? "static-token-user", options.scopes ?? []);
124
- const scopes = sharedAuthInfo.scopes;
125
- for (const token of tokens)
126
- authByToken.set(token.trim(), sharedAuthInfo);
127
- scopesSupported = options.scopesSupported !== undefined
128
- ? freezeScopes(options.scopesSupported)
129
- : (scopes.length > 0 ? scopes : undefined);
130
- }
131
- else {
132
- if (options.subject !== undefined || options.scopes !== undefined) {
133
- throw new Error("[StaticTokenAuthProvider] identity-aware credentials cannot be combined with shared `subject` or `scopes` options");
134
- }
135
- const grantedScopes = [];
136
- const grantedScopeSet = new Set();
137
- for (const [index, rawEntry] of rawEntries.entries()) {
138
- const entry = rawEntry;
139
- if (typeof entry.token !== "string" || entry.token.trim().length === 0) {
140
- throw new Error(`[StaticTokenAuthProvider] credential at index ${index} must contain a non-empty token`);
141
- }
142
- const token = entry.token.trim();
143
- if (authByToken.has(token)) {
144
- throw new Error(`[StaticTokenAuthProvider] duplicate token mapping at credential index ${index}`);
145
- }
146
- if (typeof entry.subject !== "string" ||
147
- entry.subject.trim().length === 0 ||
148
- entry.subject.trim() === "unknown" ||
149
- containsAsciiControl(entry.subject.trim())) {
150
- throw new Error(`[StaticTokenAuthProvider] credential at index ${index} must contain a non-empty, non-reserved subject without control characters`);
151
- }
152
- const subject = entry.subject.trim();
153
- const scopes = normalizeCredentialScopes(entry.scopes, index);
154
- for (const scope of scopes) {
155
- if (!grantedScopeSet.has(scope)) {
156
- grantedScopeSet.add(scope);
157
- grantedScopes.push(scope);
158
- }
159
- }
160
- authByToken.set(token, freezeAuthInfo(subject, scopes));
161
- }
162
- if (options.scopesSupported !== undefined) {
163
- const declaredScopes = normalizeScopeList(options.scopesSupported, "`scopesSupported`");
164
- const declaredSet = new Set(declaredScopes);
165
- if (grantedScopes.some((scope) => !declaredSet.has(scope))) {
166
- throw new Error("[StaticTokenAuthProvider] `scopesSupported` must include every scope granted by an identity-aware credential");
167
- }
168
- scopesSupported = freezeScopes(declaredScopes);
169
- }
170
- else {
171
- scopesSupported = grantedScopes.length > 0
172
- ? freezeScopes(grantedScopes)
173
- : undefined;
174
- }
175
- }
176
- if (!options.resource?.trim()) {
177
- throw new Error("[StaticTokenAuthProvider] `resource` is required");
178
- }
179
- // Validate `resource` as an absolute HTTP(S) URL unconditionally, so the
180
- // documented guarantee holds even when `resourceMetadataUrl` is supplied.
181
- const resourceUrl = httpsUrl(options.resource);
182
- this.authByToken = authByToken;
183
- // Store the caller's raw resource string (RFC 9728 allows opaque URIs, and
184
- // JwtAuthProvider does the same); `resourceUrl` above is used only for
185
- // validation and metadata-URL derivation.
186
- this.resource = options.resource;
187
- this.scopesSupported = scopesSupported;
188
- // RFC 9728 § 3.1: when `resourceMetadataUrl` is omitted, insert the
189
- // well-known suffix between the resource's origin and its path/query
190
- // (identical derivation to JwtAuthProvider).
191
- if (options.resourceMetadataUrl?.trim()) {
192
- this.resourceMetadataUrl = httpsUrl(options.resourceMetadataUrl);
193
- }
194
- else {
195
- const parsed = new URL(resourceUrl);
196
- const pathPart = parsed.pathname === "/" ? "" : parsed.pathname;
197
- this.resourceMetadataUrl = httpsUrl(`${parsed.origin}/.well-known/oauth-protected-resource${pathPart}${parsed.search}`);
198
- }
199
- }
200
- async verifyToken(token) {
201
- // Trim to match how tokens are stored (and how the HTTP middleware extracts
202
- // the bearer), so direct callers and the middleware path behave identically.
203
- return this.authByToken.get(token.trim()) ?? null;
204
- }
205
- getResourceMetadata() {
206
- // Fresh object per call (matching JwtAuthProvider) so a caller cannot
207
- // mutate shared metadata — e.g. the `authorization_servers` array.
208
- return {
209
- resource: this.resource,
210
- resource_metadata_url: this.resourceMetadataUrl,
211
- // No authorization server: static tokens are provisioned out of band.
212
- authorization_servers: [],
213
- scopes_supported: this.scopesSupported,
214
- bearer_methods_supported: ["header"],
215
- };
216
- }
217
- }
218
- /**
219
- * Create a static (opaque) bearer-token {@link AuthProvider}.
220
- *
221
- * @param entries Either a non-empty shared-authority list of bearer tokens, or
222
- * a non-empty list of identity-aware credentials. Load tokens from env / a
223
- * secrets manager — never hard-code them in source.
224
- * @param options Provider configuration; `options.resource` is required.
225
- *
226
- * @example
227
- * ```typescript
228
- * import { createStaticTokenAuthProvider, McpApp } from "@casys/mcp-server";
229
- *
230
- * const app = new McpApp({
231
- * name: "my-server",
232
- * version: "1.0.0",
233
- * auth: {
234
- * provider: createStaticTokenAuthProvider(
235
- * (Deno.env.get("MCP_AUTH_TOKENS") ?? "").split(",").filter(Boolean),
236
- * { resource: "https://my-mcp.example.com" },
237
- * ),
238
- * },
239
- * });
240
- * await app.startHttp({ port: 7654, requireAuth: true });
241
- * ```
242
- *
243
- * @example Identity and scopes per credential
244
- * ```typescript
245
- * const provider = createStaticTokenAuthProvider(
246
- * [
247
- * { token: aliceToken, subject: "alice", scopes: ["read"] },
248
- * { token: ciToken, subject: "ci", scopes: ["read", "write"] },
249
- * ],
250
- * { resource: "https://my-mcp.example.com" },
251
- * );
252
- * ```
253
- */
254
- export function createStaticTokenAuthProvider(entries, options) {
255
- return new StaticTokenAuthProvider(entries, options);
256
- }
@@ -1,151 +0,0 @@
1
- /**
2
- * Authentication types for McpApp.
3
- *
4
- * Types follow RFC 9728 (OAuth Protected Resource Metadata)
5
- * and MCP Auth spec (draft 2025-11-25).
6
- *
7
- * @module lib/server/auth/types
8
- */
9
- declare const httpsUrlBrand: unique symbol;
10
- /**
11
- * A string that has been validated as a syntactically valid absolute HTTP(S)
12
- * URL. Cannot be constructed by type assertion — callers MUST go through
13
- * {@link httpsUrl} (which parses, normalizes, and throws on invalid input) so
14
- * the invariant is enforced at both the type level and runtime.
15
- *
16
- * Added in 0.16.0 to lift `resource_metadata_url`, `authorization_servers`,
17
- * and the URL-resource branch of {@link JwtAuthProviderOptions} from raw
18
- * `string` into a type that structurally encodes the invariant. The motivating
19
- * incident was 0.14.x silently producing `"://host/.well-known/..."` in
20
- * `WWW-Authenticate` headers when callers mis-set `resource` — a class of bug
21
- * that 0.15.x closed with runtime guards and 0.16.0 closes at the type level.
22
- */
23
- export type HttpsUrl = string & {
24
- readonly [httpsUrlBrand]: never;
25
- };
26
- /**
27
- * Parse, validate, and normalize a string as an absolute HTTP(S) URL.
28
- *
29
- * Trims leading/trailing whitespace before parsing so YAML keys with trailing
30
- * spaces don't produce unparseable URLs. Delegates parsing to `new URL()`,
31
- * which lowercases the scheme — so `HTTPS://foo.com` is accepted and returned
32
- * as `https://foo.com/`.
33
- *
34
- * @throws if the string is empty/whitespace-only, unparseable as a URL, or
35
- * uses a non-HTTP(S) scheme (RFC 9728 § 3 requires HTTPS for metadata
36
- * documents; http is permitted here for local dev only).
37
- *
38
- * @example
39
- * ```typescript
40
- * const url = httpsUrl("https://my-mcp.example.com");
41
- * // url is of type HttpsUrl and can be passed wherever HttpsUrl is required.
42
- * ```
43
- */
44
- export declare function httpsUrl(raw: string): HttpsUrl;
45
- /**
46
- * Non-throwing variant of {@link httpsUrl}. Returns the normalized `HttpsUrl`
47
- * on success, `null` on any validation failure. Use this when you need to
48
- * branch on validity without catching exceptions — typically to detect whether
49
- * an RFC 9728 § 2 `resource` identifier is an HTTP(S) URL (the URL-resource
50
- * branch) or an opaque URI (the opaque-resource branch that requires an
51
- * explicit metadata URL).
52
- */
53
- export declare function tryHttpsUrl(raw: string): HttpsUrl | null;
54
- /**
55
- * Information extracted from a validated token.
56
- * Frozen (Object.freeze) before being passed to tool handlers.
57
- */
58
- export interface AuthInfo {
59
- /** User ID (sub claim from JWT) */
60
- subject: string;
61
- /** OAuth client ID (optional - azp or client_id claim) */
62
- clientId?: string;
63
- /** Granted scopes */
64
- scopes: string[];
65
- /** Additional JWT claims */
66
- claims?: Record<string, unknown>;
67
- /** Token expiration timestamp (Unix epoch seconds) */
68
- expiresAt?: number;
69
- /**
70
- * Tenant identifier for multi-tenant servers.
71
- *
72
- * Populated by `createMultiTenantMiddleware` when a `TenantResolver`
73
- * is configured. Undefined on single-tenant servers.
74
- *
75
- * Tool handlers in multi-tenant servers should read this (never trust
76
- * raw JWT claims directly) to scope data access to the current tenant.
77
- */
78
- tenantId?: string;
79
- }
80
- /**
81
- * Auth configuration slot for {@link McpAppOptions.auth}.
82
- *
83
- * 0.17.0: slimmed to a single `provider` field. Previously exposed
84
- * `authorizationServers`, `resource`, and `scopesSupported` fields that
85
- * were NEVER read by `McpApp` at runtime (only `provider` was consumed at
86
- * `mcp-app.ts:1061`). Those fields were vestigial from a pre-0.15 design
87
- * where `McpApp` could auto-construct a `JwtAuthProvider` from its own
88
- * `auth:` option; that auto-construction path was removed when
89
- * `createAuthProviderFromConfig` took over YAML/env provider construction,
90
- * but the dead fields stayed in the interface. 0.17.0 deletes them as part
91
- * of the auth-module cleanup (Casys-AI/mcp-server#13).
92
- *
93
- * The interface is kept (rather than reducing `McpAppOptions.auth` to a
94
- * bare `AuthProvider`) so that future additions like pipeline-level auth
95
- * hooks have a named extension point without another BC break.
96
- */
97
- export interface AuthOptions {
98
- /**
99
- * The `AuthProvider` that validates bearer tokens and produces RFC 9728
100
- * metadata. Construct via {@link JwtAuthProvider}, any of the preset
101
- * factories (`createGitHubAuthProvider`, `createGoogleAuthProvider`,
102
- * `createAuth0AuthProvider`, `createOIDCAuthProvider`), or a custom
103
- * `AuthProvider` subclass for non-JWT token schemes.
104
- */
105
- provider: AuthProvider;
106
- }
107
- import type { AuthProvider } from "./provider.js";
108
- /**
109
- * RFC 9728 Protected Resource Metadata.
110
- * Returned by /.well-known/oauth-protected-resource
111
- *
112
- * @see https://datatracker.ietf.org/doc/html/rfc9728
113
- */
114
- export interface ProtectedResourceMetadata {
115
- /**
116
- * RFC 9728 § 2 resource identifier. URI that identifies the protected
117
- * resource — used as the JWT `aud` claim. Can be an HTTP(S) URL OR an
118
- * opaque URI (e.g., an OIDC project ID). Stays `string` because RFC 9728
119
- * explicitly allows opaque URIs; callers must NOT assume it parses as
120
- * an URL.
121
- */
122
- resource: string;
123
- /**
124
- * Absolute HTTP(S) URL where this metadata document is served publicly.
125
- * Per RFC 9728 § 3, this is the URL a client discovers via the
126
- * WWW-Authenticate challenge. Always an HTTP(S) URL, regardless of
127
- * whether `resource` itself is an URL or an opaque URI.
128
- *
129
- * 0.16.0: typed as {@link HttpsUrl} (branded). The invariant is now
130
- * structurally enforced — producers must construct the value via
131
- * {@link httpsUrl}, which validates at runtime AND returns the brand.
132
- * Prior to 0.16.0 this was a raw `string` guarded only by a runtime
133
- * validator in the `JwtAuthProvider` constructor (0.15.1).
134
- */
135
- resource_metadata_url: HttpsUrl;
136
- /**
137
- * Authorization servers that can issue valid tokens.
138
- *
139
- * 0.16.0: each element is branded as {@link HttpsUrl} so downstream
140
- * consumers (e.g., MCP clients building discovery URLs) can rely on
141
- * them being parseable absolute URLs without re-validation. Construct
142
- * via {@link httpsUrl}.
143
- */
144
- authorization_servers: HttpsUrl[];
145
- /** Scopes this resource supports */
146
- scopes_supported?: string[];
147
- /** How bearer tokens can be presented (always ["header"]) */
148
- bearer_methods_supported: string[];
149
- }
150
- export {};
151
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/auth/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CA4B9C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAMxD;AAMD;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAEhB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,qBAAqB;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,QAAQ,EAAE,YAAY,CAAC;CACxB;AAGD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;OAWG;IACH,qBAAqB,EAAE,QAAQ,CAAC;IAEhC;;;;;;;OAOG;IACH,qBAAqB,EAAE,QAAQ,EAAE,CAAC;IAElC,oCAAoC;IACpC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE5B,6DAA6D;IAC7D,wBAAwB,EAAE,MAAM,EAAE,CAAC;CACpC"}