@casys/mcp-server 0.26.1 → 0.27.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.
- package/CHANGELOG.md +1779 -0
- package/LICENSE +21 -0
- package/README.md +15 -4
- package/esm/_dnt.polyfills.d.ts +12 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +57 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts +33 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.js +48 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts +106 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.js +636 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts +67 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.js +1393 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts +44 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.js +117 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.js +103 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.js +32 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.js +96 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.js +159 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.js +14 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.js +10 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.js +22 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.js +29 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.js +19 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.js +30 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.js +10 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.js +14 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.js +9 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.js +81 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.js +20 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts +32 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.js +6 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts +4 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.js +13 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts +51 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.js +53 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts +79 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.js +91 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts +100 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.js +33 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts +111 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.2.0/types.js +104 -0
- package/esm/mod.d.ts +102 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +103 -0
- package/esm/package.json +3 -0
- package/esm/src/auth/as-metadata-proxy.d.ts +112 -0
- package/esm/src/auth/as-metadata-proxy.d.ts.map +1 -0
- package/esm/src/auth/as-metadata-proxy.js +171 -0
- package/esm/src/auth/config.d.ts +117 -0
- package/esm/src/auth/config.d.ts.map +1 -0
- package/esm/src/auth/config.js +219 -0
- package/esm/src/auth/jwt-provider.d.ts +157 -0
- package/esm/src/auth/jwt-provider.d.ts.map +1 -0
- package/esm/src/auth/jwt-provider.js +187 -0
- package/esm/src/auth/middleware.d.ts +61 -0
- package/esm/src/auth/middleware.d.ts.map +1 -0
- package/esm/src/auth/middleware.js +209 -0
- package/esm/src/auth/mod.d.ts +23 -0
- package/esm/src/auth/mod.d.ts.map +1 -0
- package/esm/src/auth/mod.js +27 -0
- package/esm/src/auth/multi-tenant-middleware.d.ts +131 -0
- package/esm/src/auth/multi-tenant-middleware.d.ts.map +1 -0
- package/esm/src/auth/multi-tenant-middleware.js +128 -0
- package/esm/src/auth/presets.d.ts +231 -0
- package/esm/src/auth/presets.d.ts.map +1 -0
- package/esm/src/auth/presets.js +223 -0
- package/{src/auth/provider.ts → esm/src/auth/provider.d.ts} +13 -15
- package/esm/src/auth/provider.d.ts.map +1 -0
- package/esm/src/auth/provider.js +34 -0
- package/esm/src/auth/scope-middleware.d.ts +30 -0
- package/esm/src/auth/scope-middleware.d.ts.map +1 -0
- package/esm/src/auth/scope-middleware.js +48 -0
- package/esm/src/auth/static-token-provider.d.ts +155 -0
- package/esm/src/auth/static-token-provider.d.ts.map +1 -0
- package/esm/src/auth/static-token-provider.js +256 -0
- package/esm/src/auth/types.d.ts +151 -0
- package/esm/src/auth/types.d.ts.map +1 -0
- package/esm/src/auth/types.js +64 -0
- package/esm/src/client-auth/callback-server.d.ts +34 -0
- package/esm/src/client-auth/callback-server.d.ts.map +1 -0
- package/esm/src/client-auth/callback-server.js +141 -0
- package/esm/src/client-auth/client-id-metadata.d.ts +29 -0
- package/esm/src/client-auth/client-id-metadata.d.ts.map +1 -0
- package/esm/src/client-auth/client-id-metadata.js +149 -0
- package/esm/src/client-auth/connect.d.ts +32 -0
- package/esm/src/client-auth/connect.d.ts.map +1 -0
- package/esm/src/client-auth/connect.js +47 -0
- package/esm/src/client-auth/mod.d.ts +19 -0
- package/esm/src/client-auth/mod.d.ts.map +1 -0
- package/{src/client-auth/mod.ts → esm/src/client-auth/mod.js} +1 -26
- package/esm/src/client-auth/provider.d.ts +78 -0
- package/esm/src/client-auth/provider.d.ts.map +1 -0
- package/esm/src/client-auth/provider.js +246 -0
- package/esm/src/client-auth/token-store/file-store.d.ts +20 -0
- package/esm/src/client-auth/token-store/file-store.d.ts.map +1 -0
- package/esm/src/client-auth/token-store/file-store.js +62 -0
- package/esm/src/client-auth/token-store/memory-store.d.ts +14 -0
- package/esm/src/client-auth/token-store/memory-store.d.ts.map +1 -0
- package/esm/src/client-auth/token-store/memory-store.js +25 -0
- package/esm/src/client-auth/types.d.ts +89 -0
- package/esm/src/client-auth/types.d.ts.map +1 -0
- package/esm/src/client-auth/types.js +10 -0
- package/esm/src/concurrency/rate-limiter.d.ts +87 -0
- package/esm/src/concurrency/rate-limiter.d.ts.map +1 -0
- package/esm/src/concurrency/rate-limiter.js +165 -0
- package/esm/src/concurrency/request-queue.d.ts +71 -0
- package/esm/src/concurrency/request-queue.d.ts.map +1 -0
- package/esm/src/concurrency/request-queue.js +128 -0
- package/esm/src/http/body.d.ts +20 -0
- package/esm/src/http/body.d.ts.map +1 -0
- package/esm/src/http/body.js +63 -0
- package/esm/src/http/request-guards.d.ts +54 -0
- package/esm/src/http/request-guards.d.ts.map +1 -0
- package/esm/src/http/request-guards.js +114 -0
- package/esm/src/http/wire.d.ts +26 -0
- package/esm/src/http/wire.d.ts.map +1 -0
- package/{src/http/wire.ts → esm/src/http/wire.js} +13 -19
- package/esm/src/inspector/launcher.d.ts +48 -0
- package/esm/src/inspector/launcher.d.ts.map +1 -0
- package/esm/src/inspector/launcher.js +100 -0
- package/esm/src/mcp-app.d.ts +728 -0
- package/esm/src/mcp-app.d.ts.map +1 -0
- package/esm/src/mcp-app.js +3530 -0
- package/{src/middleware/backpressure.ts → esm/src/middleware/backpressure.d.ts} +2 -14
- package/esm/src/middleware/backpressure.d.ts.map +1 -0
- package/esm/src/middleware/backpressure.js +31 -0
- package/esm/src/middleware/mod.d.ts +11 -0
- package/esm/src/middleware/mod.d.ts.map +1 -0
- package/{src/middleware/mod.ts → esm/src/middleware/mod.js} +0 -10
- package/{src/middleware/rate-limit.ts → esm/src/middleware/rate-limit.d.ts} +2 -25
- package/esm/src/middleware/rate-limit.d.ts.map +1 -0
- package/esm/src/middleware/rate-limit.js +33 -0
- package/esm/src/middleware/runner.d.ts +32 -0
- package/esm/src/middleware/runner.d.ts.map +1 -0
- package/esm/src/middleware/runner.js +49 -0
- package/esm/src/middleware/types.d.ts +76 -0
- package/esm/src/middleware/types.d.ts.map +1 -0
- package/esm/src/middleware/types.js +9 -0
- package/esm/src/middleware/validation.d.ts +24 -0
- package/esm/src/middleware/validation.d.ts.map +1 -0
- package/esm/src/middleware/validation.js +30 -0
- package/esm/src/mrtr/capability-check.d.ts +75 -0
- package/esm/src/mrtr/capability-check.d.ts.map +1 -0
- package/esm/src/mrtr/capability-check.js +233 -0
- package/esm/src/mrtr/mod.d.ts +18 -0
- package/esm/src/mrtr/mod.d.ts.map +1 -0
- package/esm/src/mrtr/mod.js +12 -0
- package/esm/src/mrtr/replay-store.d.ts +50 -0
- package/esm/src/mrtr/replay-store.d.ts.map +1 -0
- package/esm/src/mrtr/replay-store.js +61 -0
- package/esm/src/mrtr/request-state.d.ts +181 -0
- package/esm/src/mrtr/request-state.d.ts.map +1 -0
- package/esm/src/mrtr/request-state.js +313 -0
- package/esm/src/mrtr/retry-guard.d.ts +61 -0
- package/esm/src/mrtr/retry-guard.d.ts.map +1 -0
- package/esm/src/mrtr/retry-guard.js +53 -0
- package/esm/src/mrtr/types.d.ts +99 -0
- package/esm/src/mrtr/types.d.ts.map +1 -0
- package/esm/src/mrtr/types.js +14 -0
- package/esm/src/observability/metrics.d.ts +104 -0
- package/esm/src/observability/metrics.d.ts.map +1 -0
- package/esm/src/observability/metrics.js +207 -0
- package/{src/observability/mod.ts → esm/src/observability/mod.d.ts} +2 -11
- package/esm/src/observability/mod.d.ts.map +1 -0
- package/esm/src/observability/mod.js +11 -0
- package/esm/src/observability/otel.d.ts +73 -0
- package/esm/src/observability/otel.d.ts.map +1 -0
- package/esm/src/observability/otel.js +260 -0
- package/esm/src/runtime/runtime.d.ts +10 -0
- package/esm/src/runtime/runtime.d.ts.map +1 -0
- package/esm/src/runtime/runtime.deno.d.ts +50 -0
- package/esm/src/runtime/runtime.deno.d.ts.map +1 -0
- package/esm/src/runtime/runtime.deno.js +120 -0
- package/{src/runtime/runtime.ts → esm/src/runtime/runtime.js} +5 -14
- package/esm/src/runtime/runtime.node.d.ts +51 -0
- package/esm/src/runtime/runtime.node.d.ts.map +1 -0
- package/esm/src/runtime/runtime.node.js +268 -0
- package/{src/runtime/types.ts → esm/src/runtime/types.d.ts} +28 -51
- package/esm/src/runtime/types.d.ts.map +1 -0
- package/esm/src/runtime/types.js +12 -0
- package/esm/src/security/channel-hmac.d.ts +43 -0
- package/esm/src/security/channel-hmac.d.ts.map +1 -0
- package/{src/security/channel-hmac.ts → esm/src/security/channel-hmac.js} +12 -17
- package/esm/src/security/csp.d.ts +50 -0
- package/esm/src/security/csp.d.ts.map +1 -0
- package/esm/src/security/csp.js +63 -0
- package/esm/src/security/message-signer.d.ts +88 -0
- package/esm/src/security/message-signer.d.ts.map +1 -0
- package/esm/src/security/message-signer.js +166 -0
- package/esm/src/subscriptions/subscription-registry.d.ts +256 -0
- package/esm/src/subscriptions/subscription-registry.d.ts.map +1 -0
- package/esm/src/subscriptions/subscription-registry.js +406 -0
- package/{src/tasks/mod.ts → esm/src/tasks/mod.d.ts} +3 -23
- package/esm/src/tasks/mod.d.ts.map +1 -0
- package/esm/src/tasks/mod.js +11 -0
- package/esm/src/tasks/task-store.d.ts +342 -0
- package/esm/src/tasks/task-store.d.ts.map +1 -0
- package/esm/src/tasks/task-store.js +649 -0
- package/esm/src/transport/request-headers.d.ts +145 -0
- package/esm/src/transport/request-headers.d.ts.map +1 -0
- package/esm/src/transport/request-headers.js +525 -0
- package/esm/src/types.d.ts +776 -0
- package/esm/src/types.d.ts.map +1 -0
- package/esm/src/types.js +92 -0
- package/esm/src/ui/viewer-utils.d.ts +45 -0
- package/esm/src/ui/viewer-utils.d.ts.map +1 -0
- package/esm/src/ui/viewer-utils.js +97 -0
- package/esm/src/validation/schema-validator.d.ts +115 -0
- package/esm/src/validation/schema-validator.d.ts.map +1 -0
- package/esm/src/validation/schema-validator.js +249 -0
- package/package.json +35 -24
- package/mod.ts +0 -302
- package/src/auth/as-metadata-proxy.ts +0 -288
- package/src/auth/config.ts +0 -368
- package/src/auth/jwt-provider.ts +0 -327
- package/src/auth/middleware.ts +0 -257
- package/src/auth/mod.ts +0 -89
- package/src/auth/multi-tenant-middleware.ts +0 -236
- package/src/auth/presets.ts +0 -351
- package/src/auth/scope-middleware.ts +0 -59
- package/src/auth/static-token-provider.ts +0 -197
- package/src/auth/types.ts +0 -207
- package/src/client-auth/callback-server.ts +0 -166
- package/src/client-auth/client-id-metadata.ts +0 -260
- package/src/client-auth/connect.ts +0 -72
- package/src/client-auth/provider.ts +0 -300
- package/src/client-auth/token-store/file-store.ts +0 -73
- package/src/client-auth/token-store/memory-store.ts +0 -32
- package/src/client-auth/types.ts +0 -95
- package/src/concurrency/rate-limiter.ts +0 -190
- package/src/concurrency/request-queue.ts +0 -140
- package/src/http/body.ts +0 -72
- package/src/http/request-guards.ts +0 -137
- package/src/inspector/launcher.ts +0 -131
- package/src/mcp-app.ts +0 -4595
- package/src/middleware/runner.ts +0 -63
- package/src/middleware/types.ts +0 -104
- package/src/middleware/validation.ts +0 -28
- package/src/mrtr/capability-check.ts +0 -303
- package/src/mrtr/mod.ts +0 -54
- package/src/mrtr/replay-store.ts +0 -103
- package/src/mrtr/request-state.ts +0 -435
- package/src/mrtr/retry-guard.ts +0 -110
- package/src/mrtr/types.ts +0 -107
- package/src/observability/metrics.ts +0 -336
- package/src/observability/otel.ts +0 -330
- package/src/runtime/runtime.deno.ts +0 -149
- package/src/runtime/runtime.node.ts +0 -324
- package/src/security/csp.ts +0 -89
- package/src/security/message-signer.ts +0 -223
- package/src/subscriptions/subscription-registry.ts +0 -558
- package/src/tasks/task-store.ts +0 -1014
- package/src/transport/request-headers.ts +0 -661
- package/src/types.ts +0 -908
- package/src/ui/viewer-utils.ts +0 -117
- package/src/validation/schema-validator.ts +0 -307
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OIDC auth provider presets.
|
|
3
|
+
*
|
|
4
|
+
* Factory functions for common OIDC providers. Each preset pre-configures
|
|
5
|
+
* the issuer, JWKS URI, and authorization server for the provider.
|
|
6
|
+
*
|
|
7
|
+
* Bridge layer (0.16.0): presets accept raw `string` fields for `resource`,
|
|
8
|
+
* `resourceMetadataUrl`, and `authorizationServers`, then wrap them through
|
|
9
|
+
* {@link httpsUrl} before passing to the branded {@link JwtAuthProviderOptions}
|
|
10
|
+
* constructor. This keeps the YAML/env config pipeline (`createAuthProviderFromConfig`)
|
|
11
|
+
* working with raw strings while the core `JwtAuthProvider` API enforces the
|
|
12
|
+
* `HttpsUrl` brand at the type level.
|
|
13
|
+
*
|
|
14
|
+
* @module lib/server/auth/presets
|
|
15
|
+
*/
|
|
16
|
+
import { JwtAuthProvider } from "./jwt-provider.js";
|
|
17
|
+
import { httpsUrl, tryHttpsUrl } from "./types.js";
|
|
18
|
+
/**
|
|
19
|
+
* GitHub Actions OIDC provider.
|
|
20
|
+
*
|
|
21
|
+
* Validates tokens issued by GitHub Actions workflows.
|
|
22
|
+
* Issuer: https://token.actions.githubusercontent.com
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const provider = createGitHubAuthProvider({
|
|
27
|
+
* audience: "https://my-mcp.example.com",
|
|
28
|
+
* resource: "https://my-mcp.example.com",
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function createGitHubAuthProvider(options) {
|
|
33
|
+
return buildJwtAuthProvider({
|
|
34
|
+
issuer: "https://token.actions.githubusercontent.com",
|
|
35
|
+
audience: options.audience,
|
|
36
|
+
authorizationServers: ["https://token.actions.githubusercontent.com"],
|
|
37
|
+
scopesSupported: options.scopesSupported,
|
|
38
|
+
resource: options.resource,
|
|
39
|
+
resourceMetadataUrl: options.resourceMetadataUrl,
|
|
40
|
+
}, "createGitHubAuthProvider");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Google OIDC provider.
|
|
44
|
+
*
|
|
45
|
+
* Validates tokens issued by Google accounts.
|
|
46
|
+
* Issuer: https://accounts.google.com
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const provider = createGoogleAuthProvider({
|
|
51
|
+
* audience: "https://my-mcp.example.com",
|
|
52
|
+
* resource: "https://my-mcp.example.com",
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function createGoogleAuthProvider(options) {
|
|
57
|
+
return buildJwtAuthProvider({
|
|
58
|
+
issuer: "https://accounts.google.com",
|
|
59
|
+
audience: options.audience,
|
|
60
|
+
authorizationServers: ["https://accounts.google.com"],
|
|
61
|
+
jwksUri: "https://www.googleapis.com/oauth2/v3/certs",
|
|
62
|
+
scopesSupported: options.scopesSupported,
|
|
63
|
+
resource: options.resource,
|
|
64
|
+
resourceMetadataUrl: options.resourceMetadataUrl,
|
|
65
|
+
}, "createGoogleAuthProvider");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Auth0 OIDC provider.
|
|
69
|
+
*
|
|
70
|
+
* Validates tokens issued by an Auth0 tenant.
|
|
71
|
+
* Issuer: https://{domain}/
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const provider = createAuth0AuthProvider({
|
|
76
|
+
* domain: "my-tenant.auth0.com",
|
|
77
|
+
* audience: "https://my-mcp.example.com",
|
|
78
|
+
* resource: "https://my-mcp.example.com",
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export function createAuth0AuthProvider(options) {
|
|
83
|
+
const issuer = `https://${options.domain}/`;
|
|
84
|
+
return buildJwtAuthProvider({
|
|
85
|
+
issuer,
|
|
86
|
+
audience: options.audience,
|
|
87
|
+
authorizationServers: [issuer],
|
|
88
|
+
jwksUri: `${issuer}.well-known/jwks.json`,
|
|
89
|
+
scopesSupported: options.scopesSupported,
|
|
90
|
+
resource: options.resource,
|
|
91
|
+
resourceMetadataUrl: options.resourceMetadataUrl,
|
|
92
|
+
}, "createAuth0AuthProvider");
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Generic OIDC provider.
|
|
96
|
+
*
|
|
97
|
+
* For any OIDC-compliant provider not covered by presets.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const provider = createOIDCAuthProvider({
|
|
102
|
+
* issuer: "https://my-idp.example.com",
|
|
103
|
+
* audience: "https://my-mcp.example.com",
|
|
104
|
+
* resource: "https://my-mcp.example.com",
|
|
105
|
+
* authorizationServers: ["https://my-idp.example.com"],
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export function createOIDCAuthProvider(options) {
|
|
110
|
+
return buildJwtAuthProvider({
|
|
111
|
+
issuer: options.issuer,
|
|
112
|
+
audience: options.audience,
|
|
113
|
+
jwksUri: options.jwksUri,
|
|
114
|
+
authorizationServers: options.authorizationServers ?? [options.issuer],
|
|
115
|
+
scopesSupported: options.scopesSupported,
|
|
116
|
+
resource: options.resource,
|
|
117
|
+
resourceMetadataUrl: options.resourceMetadataUrl,
|
|
118
|
+
}, "createOIDCAuthProvider");
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Bridge raw-string options to a fully-constructed `JwtAuthProvider`.
|
|
122
|
+
*
|
|
123
|
+
* This is the shared validation + DU-branch-selection pathway used by all
|
|
124
|
+
* four built-in preset factories (`createGitHubAuthProvider` et al). 0.17.0
|
|
125
|
+
* exports it as public API so 3rd-party OIDC provider implementations
|
|
126
|
+
* (Keycloak, Zitadel custom, Okta, ...) can reuse the same pathway instead
|
|
127
|
+
* of reimplementing URL-vs-opaque detection, `HttpsUrl` wrapping, and
|
|
128
|
+
* empty-metadata fall-through.
|
|
129
|
+
*
|
|
130
|
+
* Rules:
|
|
131
|
+
* - `authorizationServers[]`: every entry must be a valid absolute HTTP(S)
|
|
132
|
+
* URL. Invalid entries throw with a `[${label}] authorizationServers[i]`
|
|
133
|
+
* prefix for pinpointing.
|
|
134
|
+
* - `resource`: if parseable as HTTP(S) URL → `UrlResource` branch (metadata
|
|
135
|
+
* URL derivable per RFC 9728 § 3.1). Otherwise → `OpaqueResource` branch
|
|
136
|
+
* requiring explicit `resourceMetadataUrl`.
|
|
137
|
+
* - `resourceMetadataUrl`: empty or whitespace-only strings are treated as
|
|
138
|
+
* absent (matches YAML-key-with-no-value semantics from 0.15.1).
|
|
139
|
+
*
|
|
140
|
+
* @param opts Raw-string options, as from YAML/env config.
|
|
141
|
+
* @param label Identifier used in error messages — REQUIRED. Pass your
|
|
142
|
+
* factory name so error prefixes point at the actual caller rather than
|
|
143
|
+
* the anonymous bridge layer. E.g., `"createKeycloakAuthProvider"`.
|
|
144
|
+
* (0.17.0: required, was optional with a misleading default in the
|
|
145
|
+
* draft — type-design review recommendation Q4.)
|
|
146
|
+
*
|
|
147
|
+
* @example Custom OIDC provider factory
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import { buildJwtAuthProvider, type JwtAuthProvider } from "@casys/mcp-server";
|
|
150
|
+
*
|
|
151
|
+
* export interface KeycloakPresetOptions {
|
|
152
|
+
* keycloakHost: string;
|
|
153
|
+
* realm: string;
|
|
154
|
+
* audience: string;
|
|
155
|
+
* resource: string;
|
|
156
|
+
* resourceMetadataUrl?: string;
|
|
157
|
+
* }
|
|
158
|
+
*
|
|
159
|
+
* export function createKeycloakAuthProvider(
|
|
160
|
+
* options: KeycloakPresetOptions,
|
|
161
|
+
* ): JwtAuthProvider {
|
|
162
|
+
* const issuer = `https://${options.keycloakHost}/realms/${options.realm}`;
|
|
163
|
+
* return buildJwtAuthProvider({
|
|
164
|
+
* issuer,
|
|
165
|
+
* audience: options.audience,
|
|
166
|
+
* authorizationServers: [issuer],
|
|
167
|
+
* jwksUri: `${issuer}/protocol/openid-connect/certs`,
|
|
168
|
+
* resource: options.resource,
|
|
169
|
+
* resourceMetadataUrl: options.resourceMetadataUrl,
|
|
170
|
+
* }, "createKeycloakAuthProvider");
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export function buildJwtAuthProvider(opts, label) {
|
|
175
|
+
const wrappedAuthServers = opts.authorizationServers.map((raw, i) => {
|
|
176
|
+
try {
|
|
177
|
+
return httpsUrl(raw);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
throw new Error(`[${label}] authorizationServers[${i}] is not a valid ` +
|
|
181
|
+
`HTTP(S) URL: ${err.message}`);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
const explicitMetadata = opts.resourceMetadataUrl &&
|
|
185
|
+
opts.resourceMetadataUrl.trim().length > 0
|
|
186
|
+
? httpsUrl(opts.resourceMetadataUrl)
|
|
187
|
+
: undefined;
|
|
188
|
+
const base = {
|
|
189
|
+
issuer: opts.issuer,
|
|
190
|
+
audience: opts.audience,
|
|
191
|
+
jwksUri: opts.jwksUri,
|
|
192
|
+
authorizationServers: wrappedAuthServers,
|
|
193
|
+
scopesSupported: opts.scopesSupported,
|
|
194
|
+
};
|
|
195
|
+
const resourceUrl = tryHttpsUrl(opts.resource);
|
|
196
|
+
if (resourceUrl !== null) {
|
|
197
|
+
// URL resource branch — metadata URL optional (derivable). 0.17.0 sets
|
|
198
|
+
// the explicit `kind: "url"` tag so the DU narrowing in the constructor
|
|
199
|
+
// body is structurally sound.
|
|
200
|
+
return new JwtAuthProvider({
|
|
201
|
+
...base,
|
|
202
|
+
kind: "url",
|
|
203
|
+
resource: resourceUrl,
|
|
204
|
+
resourceMetadataUrl: explicitMetadata,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// Opaque resource branch — metadata URL required
|
|
208
|
+
if (!explicitMetadata) {
|
|
209
|
+
throw new Error(`[${label}] resourceMetadataUrl is required when 'resource' is ` +
|
|
210
|
+
`not an HTTP(S) URL (got resource=${JSON.stringify(opts.resource)}). ` +
|
|
211
|
+
`Per RFC 9728 § 2, 'resource' can be an opaque URI (e.g., an OIDC ` +
|
|
212
|
+
`project ID used as JWT audience); in that case the metadata ` +
|
|
213
|
+
`document URL is a separate concept and must be provided explicitly. ` +
|
|
214
|
+
`Set 'resourceMetadataUrl' to the HTTPS URL where your ` +
|
|
215
|
+
`/.well-known/oauth-protected-resource endpoint is served publicly.`);
|
|
216
|
+
}
|
|
217
|
+
return new JwtAuthProvider({
|
|
218
|
+
...base,
|
|
219
|
+
kind: "opaque",
|
|
220
|
+
resource: opts.resource,
|
|
221
|
+
resourceMetadataUrl: explicitMetadata,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module lib/server/auth/provider
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
9
|
import type { AuthInfo, ProtectedResourceMetadata } from "./types.js";
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* Base class for authentication providers.
|
|
14
12
|
*
|
|
@@ -33,17 +31,17 @@ import type { AuthInfo, ProtectedResourceMetadata } from "./types.js";
|
|
|
33
31
|
* }
|
|
34
32
|
* ```
|
|
35
33
|
*/
|
|
36
|
-
export abstract class AuthProvider {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
abstract getResourceMetadata(): ProtectedResourceMetadata;
|
|
34
|
+
export declare abstract class AuthProvider {
|
|
35
|
+
/**
|
|
36
|
+
* Validate a token and extract auth information.
|
|
37
|
+
*
|
|
38
|
+
* @param token - The raw Bearer token string
|
|
39
|
+
* @returns AuthInfo if valid, null if invalid/expired
|
|
40
|
+
*/
|
|
41
|
+
abstract verifyToken(token: string): Promise<AuthInfo | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Return RFC 9728 Protected Resource Metadata for this provider.
|
|
44
|
+
*/
|
|
45
|
+
abstract getResourceMetadata(): ProtectedResourceMetadata;
|
|
49
46
|
}
|
|
47
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/src/auth/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,YAAY;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAE7D;;OAEG;IACH,QAAQ,CAAC,mBAAmB,IAAI,yBAAyB;CAC1D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthProvider abstract class.
|
|
3
|
+
*
|
|
4
|
+
* Abstract class (not interface) for DI compatibility with diod tokens.
|
|
5
|
+
* Implement this to provide custom token validation (API keys, opaque tokens, etc.)
|
|
6
|
+
*
|
|
7
|
+
* @module lib/server/auth/provider
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base class for authentication providers.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* class ApiKeyProvider extends AuthProvider {
|
|
15
|
+
* async verifyToken(token: string): Promise<AuthInfo | null> {
|
|
16
|
+
* const user = await db.findByApiKey(token);
|
|
17
|
+
* if (!user) return null;
|
|
18
|
+
* return { subject: user.id, scopes: user.scopes };
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* getResourceMetadata(): ProtectedResourceMetadata {
|
|
22
|
+
* return {
|
|
23
|
+
* resource: "https://my-mcp.example.com",
|
|
24
|
+
* resource_metadata_url:
|
|
25
|
+
* "https://my-mcp.example.com/.well-known/oauth-protected-resource",
|
|
26
|
+
* authorization_servers: ["https://auth.example.com"],
|
|
27
|
+
* bearer_methods_supported: ["header"],
|
|
28
|
+
* };
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export class AuthProvider {
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|