@toa.io/extensions.exposition 1.0.0-alpha.282 → 1.0.0-alpha.284
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 +56 -0
- package/components/exposition.octets/manifest.toa.yaml +11 -0
- package/components/exposition.octets/types/index.d.ts +3 -0
- package/components/exposition.octets/types/toa.d.ts +41 -0
- package/components/identity.bans/operations/transit.js +1 -1
- package/components/identity.bans/tsconfig.json +1 -1
- package/components/identity.bans/tsconfig.tsbuildinfo +1 -1
- package/components/identity.bans/types/index.d.ts +3 -0
- package/components/identity.bans/types/toa.d.ts +34 -0
- package/components/identity.basic/manifest.toa.yaml +13 -2
- package/components/identity.basic/operations/add.js +1 -1
- package/components/identity.basic/operations/authenticate.js +1 -1
- package/components/identity.basic/operations/check.js +1 -1
- package/components/identity.basic/operations/delete.js +1 -1
- package/components/identity.basic/operations/incept.js +18 -2
- package/components/identity.basic/operations/info.js +1 -1
- package/components/identity.basic/operations/lib/credentials.js +1 -1
- package/components/identity.basic/operations/transit.js +3 -2
- package/components/identity.basic/source/add.ts +3 -3
- package/components/identity.basic/source/authenticate.ts +2 -2
- package/components/identity.basic/source/check.ts +1 -1
- package/components/identity.basic/source/delete.ts +2 -2
- package/components/identity.basic/source/incept.ts +31 -3
- package/components/identity.basic/source/info.ts +1 -1
- package/components/identity.basic/source/transit.ts +6 -4
- package/components/identity.basic/tsconfig.json +1 -1
- package/components/identity.basic/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/types/index.d.ts +22 -0
- package/components/identity.basic/types/toa.d.ts +121 -0
- package/components/identity.clients/manifest.toa.yaml +243 -0
- package/components/identity.clients/operations/describe.js +44 -0
- package/components/identity.clients/operations/lib/Context.js +2 -0
- package/components/identity.clients/operations/lib/Entity.js +2 -0
- package/components/identity.clients/operations/lib/canonical.js +24 -0
- package/components/identity.clients/operations/lib/cimd.js +86 -0
- package/components/identity.clients/operations/lib/errors.js +5 -0
- package/components/identity.clients/operations/lib/index.js +7 -0
- package/components/identity.clients/operations/lib/redirect.js +32 -0
- package/components/identity.clients/operations/register.js +84 -0
- package/components/identity.clients/source/describe.ts +65 -0
- package/components/identity.clients/source/lib/Context.ts +38 -0
- package/components/identity.clients/source/lib/Entity.ts +31 -0
- package/components/identity.clients/source/lib/canonical.test.ts +43 -0
- package/components/identity.clients/source/lib/canonical.ts +27 -0
- package/components/identity.clients/source/lib/cimd.test.ts +120 -0
- package/components/identity.clients/source/lib/cimd.ts +107 -0
- package/components/identity.clients/source/lib/errors.ts +4 -0
- package/components/identity.clients/source/lib/index.ts +6 -0
- package/components/identity.clients/source/lib/redirect.test.ts +41 -0
- package/components/identity.clients/source/lib/redirect.ts +35 -0
- package/components/identity.clients/source/register.ts +125 -0
- package/components/identity.clients/tsconfig.json +10 -0
- package/components/identity.clients/tsconfig.tsbuildinfo +1 -0
- package/components/identity.clients/types/index.d.ts +3 -0
- package/components/identity.clients/types/toa.d.ts +109 -0
- package/components/identity.credentials/operations/list.js +1 -1
- package/components/identity.credentials/source/list.ts +2 -1
- package/components/identity.credentials/tsconfig.json +4 -2
- package/components/identity.credentials/tsconfig.tsbuildinfo +1 -1
- package/components/identity.credentials/types/index.d.ts +3 -0
- package/components/identity.credentials/types/toa.d.ts +30 -0
- package/components/identity.federation/manifest.toa.yaml +37 -1
- package/components/identity.federation/operations/authenticate.js +7 -3
- package/components/identity.federation/operations/create.js +1 -1
- package/components/identity.federation/operations/decode.js +1 -1
- package/components/identity.federation/operations/delete.js +1 -1
- package/components/identity.federation/operations/incept.js +6 -2
- package/components/identity.federation/operations/lib/Configuration.js +1 -1
- package/components/identity.federation/operations/lib/Ctx.js +1 -1
- package/components/identity.federation/operations/lib/Payload.js +1 -1
- package/components/identity.federation/operations/lib/decode.js +23 -9
- package/components/identity.federation/operations/lib/discovery.js +1 -1
- package/components/identity.federation/operations/lib/errors.js +5 -1
- package/components/identity.federation/operations/lib/exchange.js +12 -7
- package/components/identity.federation/operations/lib/index.js +2 -1
- package/components/identity.federation/operations/lib/jose.js +1 -1
- package/components/identity.federation/operations/lib/principal.js +14 -0
- package/components/identity.federation/operations/lib/resolve.js +1 -1
- package/components/identity.federation/operations/list.js +1 -1
- package/components/identity.federation/operations/types/Scheme.js +1 -1
- package/components/identity.federation/operations/types/configuration.js +1 -1
- package/components/identity.federation/operations/types/context.js +1 -1
- package/components/identity.federation/operations/types/entity.js +1 -1
- package/components/identity.federation/operations/types/index.js +1 -1
- package/components/identity.federation/source/authenticate.ts +9 -3
- package/components/identity.federation/source/incept.ts +7 -1
- package/components/identity.federation/source/lib/Ctx.ts +2 -2
- package/components/identity.federation/source/lib/decode.ts +25 -9
- package/components/identity.federation/source/lib/errors.ts +5 -0
- package/components/identity.federation/source/lib/exchange.ts +11 -7
- package/components/identity.federation/source/lib/index.ts +1 -0
- package/components/identity.federation/source/lib/principal.ts +17 -0
- package/components/identity.federation/source/types/configuration.ts +1 -1
- package/components/identity.federation/source/types/context.ts +6 -2
- package/components/identity.federation/tsconfig.json +4 -2
- package/components/identity.federation/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/types/index.d.ts +3 -0
- package/components/identity.federation/types/toa.d.ts +127 -0
- package/components/identity.grants/manifest.toa.yaml +245 -0
- package/components/identity.grants/operations/authorize.js +54 -0
- package/components/identity.grants/operations/exchange.js +89 -0
- package/components/identity.grants/operations/lib/code.js +30 -0
- package/components/identity.grants/operations/lib/identify.js +15 -0
- package/components/identity.grants/operations/lib/index.js +3 -0
- package/components/identity.grants/operations/list.js +18 -0
- package/components/identity.grants/operations/revoke.js +25 -0
- package/components/identity.grants/source/authorize.ts +90 -0
- package/components/identity.grants/source/exchange.ts +130 -0
- package/components/identity.grants/source/lib/code.ts +39 -0
- package/components/identity.grants/source/lib/identify.ts +16 -0
- package/components/identity.grants/source/lib/index.ts +3 -0
- package/components/identity.grants/source/list.ts +28 -0
- package/components/identity.grants/source/revoke.ts +38 -0
- package/components/identity.grants/tsconfig.json +10 -0
- package/components/identity.grants/tsconfig.tsbuildinfo +1 -0
- package/components/identity.grants/types/index.d.ts +60 -0
- package/components/identity.grants/types/toa.d.ts +108 -0
- package/components/identity.keys/manifest.toa.yaml +1 -0
- package/components/identity.keys/operations/create.js +1 -1
- package/components/identity.keys/operations/disable.js +1 -1
- package/components/identity.keys/operations/revoke.js +1 -1
- package/components/identity.keys/source/create.ts +1 -1
- package/components/identity.keys/source/revoke.ts +1 -1
- package/components/identity.keys/tsconfig.json +1 -1
- package/components/identity.keys/tsconfig.tsbuildinfo +1 -1
- package/components/identity.keys/types/index.d.ts +3 -0
- package/components/identity.keys/types/toa.d.ts +47 -0
- package/components/identity.otp/operations/authenticate.js +1 -1
- package/components/identity.otp/operations/issue.js +1 -1
- package/components/identity.otp/operations/lib/Context.js +1 -1
- package/components/identity.otp/operations/lib/Entity.js +1 -1
- package/components/identity.otp/operations/lib/index.js +1 -1
- package/components/identity.otp/source/lib/Context.ts +4 -2
- package/components/identity.otp/tsconfig.json +1 -1
- package/components/identity.otp/tsconfig.tsbuildinfo +1 -1
- package/components/identity.otp/types/index.d.ts +3 -0
- package/components/identity.otp/types/toa.d.ts +56 -0
- package/components/identity.passkeys/manifest.toa.yaml +3 -0
- package/components/identity.passkeys/operations/authenticate.js +1 -1
- package/components/identity.passkeys/operations/challenge.js +1 -1
- package/components/identity.passkeys/operations/create.js +1 -1
- package/components/identity.passkeys/operations/delete.js +1 -1
- package/components/identity.passkeys/operations/lib/const.js +1 -1
- package/components/identity.passkeys/operations/list.js +1 -1
- package/components/identity.passkeys/operations/types/Configuration.js +1 -1
- package/components/identity.passkeys/operations/types/Context.js +1 -1
- package/components/identity.passkeys/operations/types/Passkey.js +1 -1
- package/components/identity.passkeys/operations/types/index.js +1 -1
- package/components/identity.passkeys/operations/use.js +1 -1
- package/components/identity.passkeys/source/authenticate.ts +1 -1
- package/components/identity.passkeys/source/challenge.ts +1 -1
- package/components/identity.passkeys/source/create.ts +1 -1
- package/components/identity.passkeys/source/types/Context.ts +2 -1
- package/components/identity.passkeys/source/use.ts +1 -1
- package/components/identity.passkeys/tsconfig.json +1 -1
- package/components/identity.passkeys/tsconfig.tsbuildinfo +1 -1
- package/components/identity.passkeys/types/index.d.ts +3 -0
- package/components/identity.passkeys/types/toa.d.ts +120 -0
- package/components/identity.roles/operations/grant.js +1 -1
- package/components/identity.roles/operations/lib/Entity.js +1 -1
- package/components/identity.roles/operations/list.js +1 -1
- package/components/identity.roles/operations/principal.js +29 -5
- package/components/identity.roles/source/principal.ts +33 -5
- package/components/identity.roles/tsconfig.json +1 -1
- package/components/identity.roles/tsconfig.tsbuildinfo +1 -1
- package/components/identity.roles/types/index.d.ts +3 -0
- package/components/identity.roles/types/toa.d.ts +43 -0
- package/components/identity.tokens/manifest.toa.yaml +34 -3
- package/components/identity.tokens/operations/authenticate.js +9 -1
- package/components/identity.tokens/operations/decrypt.js +3 -3
- package/components/identity.tokens/operations/encrypt.js +1 -1
- package/components/identity.tokens/operations/issue.js +3 -2
- package/components/identity.tokens/operations/lib/form.js +24 -0
- package/components/identity.tokens/operations/lib/index.js +2 -2
- package/components/identity.tokens/operations/lib/jose.js +1 -1
- package/components/identity.tokens/operations/lib/key.js +1 -1
- package/components/identity.tokens/operations/lib/pad.js +1 -1
- package/components/identity.tokens/operations/revoke.js +1 -1
- package/components/identity.tokens/source/authenticate.test.ts +8 -5
- package/components/identity.tokens/source/authenticate.ts +12 -1
- package/components/identity.tokens/source/decrypt.test.ts +1 -1
- package/components/identity.tokens/source/decrypt.ts +4 -3
- package/components/identity.tokens/source/encrypt.test.ts +1 -1
- package/components/identity.tokens/source/encrypt.ts +2 -1
- package/components/identity.tokens/source/issue.test.ts +71 -0
- package/components/identity.tokens/source/issue.ts +4 -2
- package/components/identity.tokens/source/lib/form.test.ts +25 -0
- package/components/identity.tokens/source/lib/form.ts +31 -0
- package/components/identity.tokens/source/lib/index.ts +2 -1
- package/components/identity.tokens/tsconfig.json +1 -1
- package/components/identity.tokens/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/types/index.d.ts +61 -0
- package/components/identity.tokens/types/toa.d.ts +113 -0
- package/documentation/access.md +13 -0
- package/documentation/cache.md +10 -1
- package/documentation/components.md +3 -0
- package/documentation/consent.md +101 -0
- package/documentation/identity.md +3 -1
- package/documentation/introspection.md +13 -5
- package/documentation/io.md +42 -2
- package/documentation/map.md +8 -0
- package/documentation/mcp.md +180 -0
- package/documentation/oauth.md +180 -0
- package/documentation/protocol.md +4 -0
- package/documentation/rpc.md +140 -0
- package/documentation/tree.md +3 -0
- package/features/auth.bearer.feature +120 -0
- package/features/cache.feature +46 -0
- package/features/identity.basic.feature +44 -0
- package/features/identity.federation.feature +2 -5
- package/features/introspection.feature +333 -0
- package/features/mcp.feature +687 -0
- package/features/oauth.clients.feature +195 -0
- package/features/oauth.discovery.feature +164 -0
- package/features/oauth.grants.feature +299 -0
- package/features/octets.cloudinary.feature +1 -0
- package/features/rpc.feature +429 -0
- package/features/steps/Cloudinary.ts +13 -0
- package/features/steps/Components.ts +0 -4
- package/features/steps/Gateway.ts +23 -2
- package/features/steps/Parameters.ts +22 -7
- package/features/steps/Realtime.ts +3 -0
- package/features/steps/components/echo/manifest.toa.yaml +3 -0
- package/features/steps/components/octets.tester/manifest.toa.yaml +2 -0
- package/features/steps/components/octets.tester/operations/redirect.js +6 -1
- package/features/steps/components/pots/manifest.toa.yaml +2 -0
- package/features/steps/components/users/manifest.toa.yaml +1 -0
- package/package.json +8 -6
- package/readme.md +6 -0
- package/schemas/annotation.cos.yaml +63 -0
- package/schemas/call.cos.yaml +18 -0
- package/source/Annotation.ts +54 -0
- package/source/Directive.test.ts +15 -15
- package/source/Directive.ts +77 -9
- package/source/Endpoint.test.ts +67 -0
- package/source/Endpoint.ts +31 -11
- package/source/Factory.ts +6 -2
- package/source/Gateway.ts +73 -11
- package/source/HTTP/Context.ts +7 -0
- package/source/HTTP/Server.ts +15 -5
- package/source/HTTP/exceptions.ts +2 -2
- package/source/HTTP/formats/form.ts +21 -0
- package/source/HTTP/formats/index.ts +17 -2
- package/source/HTTP/messages.test.ts +25 -1
- package/source/HTTP/messages.ts +20 -4
- package/source/Interception.ts +8 -2
- package/source/Introspection.ts +102 -0
- package/source/MCP/Server.ts +275 -0
- package/source/MCP/discover.ts +52 -0
- package/source/MCP/errors.ts +81 -0
- package/source/MCP/index.ts +1 -0
- package/source/MCP/schema.test.ts +85 -0
- package/source/MCP/schema.ts +87 -0
- package/source/MCP/tools.ts +156 -0
- package/source/MCP/types.ts +81 -0
- package/source/Query.ts +48 -8
- package/source/RPC/Context.ts +78 -0
- package/source/RPC/Dispatcher.ts +130 -0
- package/source/RPC/errors.test.ts +52 -0
- package/source/RPC/errors.ts +83 -0
- package/source/RPC/index.ts +1 -0
- package/source/RPC/names.test.ts +122 -0
- package/source/RPC/names.ts +182 -0
- package/source/RPC/types.ts +34 -0
- package/source/RTD/Directives.ts +52 -2
- package/source/RTD/Endpoint.ts +2 -1
- package/source/RTD/Method.ts +14 -11
- package/source/RTD/Node.ts +38 -7
- package/source/RTD/Route.ts +30 -3
- package/source/RTD/Tree.ts +37 -1
- package/source/RTD/expiration.test.ts +1 -1
- package/source/RTD/walk.test.ts +110 -0
- package/source/const.ts +15 -0
- package/source/deployment.ts +11 -1
- package/source/directives/auth/Anonymous.test.ts +38 -0
- package/source/directives/auth/Anonymous.ts +12 -0
- package/source/directives/auth/Anyone.ts +4 -0
- package/source/directives/auth/Authorization.ts +108 -22
- package/source/directives/auth/Delegate.test.ts +36 -0
- package/source/directives/auth/Delegate.ts +14 -0
- package/source/directives/auth/Echo.ts +5 -0
- package/source/directives/auth/Incept.ts +16 -10
- package/source/directives/auth/Role.ts +13 -0
- package/source/directives/auth/Rule.ts +29 -0
- package/source/directives/auth/Scheme.ts +5 -0
- package/source/directives/auth/schemes.test.ts +8 -4
- package/source/directives/auth/schemes.ts +22 -9
- package/source/directives/auth/types.ts +26 -2
- package/source/directives/cache/Cache.ts +14 -5
- package/source/directives/cache/Control.ts +0 -3
- package/source/directives/dev/Development.ts +1 -1
- package/source/directives/flow/Fetch.ts +1 -1
- package/source/directives/flow/Flow.ts +1 -1
- package/source/directives/index.ts +5 -2
- package/source/directives/io/Directive.ts +1 -1
- package/source/directives/io/IO.ts +34 -3
- package/source/directives/io/Input.ts +3 -2
- package/source/directives/io/Output.ts +10 -4
- package/source/directives/io/Status.test.ts +84 -0
- package/source/directives/io/Status.ts +46 -0
- package/source/directives/io/Throttle.ts +1 -1
- package/source/directives/io/lib/throttle/Quotas.ts +2 -2
- package/source/directives/map/Headers.ts +11 -0
- package/source/directives/map/Map.ts +10 -1
- package/source/directives/map/Mapping.ts +23 -0
- package/source/directives/map/Segments.ts +12 -0
- package/source/directives/mcp/MCP.ts +33 -0
- package/source/directives/mcp/Tool.test.ts +66 -0
- package/source/directives/mcp/Tool.ts +28 -0
- package/source/directives/mcp/index.ts +6 -0
- package/source/directives/oauth/Discovery.ts +70 -0
- package/source/directives/oauth/documents.ts +113 -0
- package/source/directives/oauth/index.ts +3 -0
- package/source/directives/octets/Delete.ts +1 -1
- package/source/directives/octets/Get.ts +1 -1
- package/source/directives/octets/Octets.ts +1 -1
- package/source/directives/octets/Workflow.ts +1 -1
- package/source/directives/octets/workflows/Execution.ts +1 -1
- package/source/directives/require/Directive.ts +1 -1
- package/source/directives/require/Headers.ts +1 -1
- package/source/directives/require/Require.ts +2 -2
- package/source/index.ts +6 -0
- package/source/octets.d.ts +17 -0
- package/source/schemas.ts +2 -0
- package/source/userland.ts +47 -0
- package/transpiled/Annotation.d.ts +41 -0
- package/transpiled/Directive.d.ts +18 -1
- package/transpiled/Directive.js +50 -6
- package/transpiled/Directive.js.map +1 -1
- package/transpiled/Endpoint.d.ts +9 -0
- package/transpiled/Endpoint.js +27 -11
- package/transpiled/Endpoint.js.map +1 -1
- package/transpiled/Factory.js +6 -2
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.d.ts +19 -2
- package/transpiled/Gateway.js +51 -9
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Context.d.ts +6 -0
- package/transpiled/HTTP/Context.js +6 -0
- package/transpiled/HTTP/Context.js.map +1 -1
- package/transpiled/HTTP/Server.d.ts +8 -1
- package/transpiled/HTTP/Server.js +4 -3
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/exceptions.d.ts +1 -1
- package/transpiled/HTTP/exceptions.js +2 -2
- package/transpiled/HTTP/exceptions.js.map +1 -1
- package/transpiled/HTTP/formats/form.d.ts +9 -0
- package/transpiled/HTTP/formats/form.js +18 -0
- package/transpiled/HTTP/formats/form.js.map +1 -0
- package/transpiled/HTTP/formats/index.d.ts +10 -2
- package/transpiled/HTTP/formats/index.js +10 -0
- package/transpiled/HTTP/formats/index.js.map +1 -1
- package/transpiled/HTTP/messages.d.ts +12 -0
- package/transpiled/HTTP/messages.js +12 -4
- package/transpiled/HTTP/messages.js.map +1 -1
- package/transpiled/Interception.d.ts +4 -1
- package/transpiled/Interception.js +4 -2
- package/transpiled/Interception.js.map +1 -1
- package/transpiled/Introspection.d.ts +40 -0
- package/transpiled/Introspection.js +50 -1
- package/transpiled/Introspection.js.map +1 -1
- package/transpiled/MCP/Server.d.ts +41 -0
- package/transpiled/MCP/Server.js +180 -0
- package/transpiled/MCP/Server.js.map +1 -0
- package/transpiled/MCP/discover.d.ts +13 -0
- package/transpiled/MCP/discover.js +29 -0
- package/transpiled/MCP/discover.js.map +1 -0
- package/transpiled/MCP/errors.d.ts +24 -0
- package/transpiled/MCP/errors.js +67 -0
- package/transpiled/MCP/errors.js.map +1 -0
- package/transpiled/MCP/index.d.ts +1 -0
- package/transpiled/MCP/index.js +2 -0
- package/transpiled/MCP/index.js.map +1 -0
- package/transpiled/MCP/schema.d.ts +18 -0
- package/transpiled/MCP/schema.js +64 -0
- package/transpiled/MCP/schema.js.map +1 -0
- package/transpiled/MCP/tools.d.ts +31 -0
- package/transpiled/MCP/tools.js +121 -0
- package/transpiled/MCP/tools.js.map +1 -0
- package/transpiled/MCP/types.d.ts +64 -0
- package/transpiled/MCP/types.js +13 -0
- package/transpiled/MCP/types.js.map +1 -0
- package/transpiled/Query.d.ts +7 -0
- package/transpiled/Query.js +38 -7
- package/transpiled/Query.js.map +1 -1
- package/transpiled/RPC/Context.d.ts +11 -0
- package/transpiled/RPC/Context.js +63 -0
- package/transpiled/RPC/Context.js.map +1 -0
- package/transpiled/RPC/Dispatcher.d.ts +19 -0
- package/transpiled/RPC/Dispatcher.js +100 -0
- package/transpiled/RPC/Dispatcher.js.map +1 -0
- package/transpiled/RPC/errors.d.ts +18 -0
- package/transpiled/RPC/errors.js +67 -0
- package/transpiled/RPC/errors.js.map +1 -0
- package/transpiled/RPC/index.d.ts +1 -0
- package/transpiled/RPC/index.js +2 -0
- package/transpiled/RPC/index.js.map +1 -0
- package/transpiled/RPC/names.d.ts +30 -0
- package/transpiled/RPC/names.js +121 -0
- package/transpiled/RPC/names.js.map +1 -0
- package/transpiled/RPC/types.d.ts +27 -0
- package/transpiled/RPC/types.js +8 -0
- package/transpiled/RPC/types.js.map +1 -0
- package/transpiled/RTD/Directives.d.ts +41 -2
- package/transpiled/RTD/Endpoint.d.ts +2 -1
- package/transpiled/RTD/Method.d.ts +8 -3
- package/transpiled/RTD/Method.js +12 -10
- package/transpiled/RTD/Method.js.map +1 -1
- package/transpiled/RTD/Node.d.ts +20 -2
- package/transpiled/RTD/Node.js +22 -4
- package/transpiled/RTD/Node.js.map +1 -1
- package/transpiled/RTD/Route.d.ts +2 -1
- package/transpiled/RTD/Route.js +27 -2
- package/transpiled/RTD/Route.js.map +1 -1
- package/transpiled/RTD/Tree.d.ts +3 -1
- package/transpiled/RTD/Tree.js +26 -0
- package/transpiled/RTD/Tree.js.map +1 -1
- package/transpiled/const.d.ts +12 -0
- package/transpiled/const.js +12 -0
- package/transpiled/const.js.map +1 -1
- package/transpiled/deployment.js +6 -0
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/directives/auth/Anonymous.d.ts +6 -0
- package/transpiled/directives/auth/Anonymous.js +10 -0
- package/transpiled/directives/auth/Anonymous.js.map +1 -1
- package/transpiled/directives/auth/Anyone.d.ts +1 -0
- package/transpiled/directives/auth/Anyone.js +3 -0
- package/transpiled/directives/auth/Anyone.js.map +1 -1
- package/transpiled/directives/auth/Authorization.d.ts +28 -2
- package/transpiled/directives/auth/Authorization.js +87 -19
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/auth/Delegate.d.ts +5 -0
- package/transpiled/directives/auth/Delegate.js +10 -0
- package/transpiled/directives/auth/Delegate.js.map +1 -1
- package/transpiled/directives/auth/Echo.d.ts +2 -0
- package/transpiled/directives/auth/Echo.js +4 -0
- package/transpiled/directives/auth/Echo.js.map +1 -1
- package/transpiled/directives/auth/Incept.d.ts +1 -1
- package/transpiled/directives/auth/Incept.js +13 -8
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/auth/Role.d.ts +2 -0
- package/transpiled/directives/auth/Role.js +9 -0
- package/transpiled/directives/auth/Role.js.map +1 -1
- package/transpiled/directives/auth/Rule.d.ts +5 -0
- package/transpiled/directives/auth/Rule.js +20 -0
- package/transpiled/directives/auth/Rule.js.map +1 -1
- package/transpiled/directives/auth/Scheme.d.ts +2 -0
- package/transpiled/directives/auth/Scheme.js +4 -0
- package/transpiled/directives/auth/Scheme.js.map +1 -1
- package/transpiled/directives/auth/schemes.d.ts +16 -4
- package/transpiled/directives/auth/schemes.js +20 -8
- package/transpiled/directives/auth/schemes.js.map +1 -1
- package/transpiled/directives/auth/types.d.ts +20 -2
- package/transpiled/directives/cache/Cache.d.ts +1 -1
- package/transpiled/directives/cache/Cache.js +10 -3
- package/transpiled/directives/cache/Cache.js.map +1 -1
- package/transpiled/directives/cache/Control.js +0 -2
- package/transpiled/directives/cache/Control.js.map +1 -1
- package/transpiled/directives/dev/Development.d.ts +1 -1
- package/transpiled/directives/dev/Development.js +1 -1
- package/transpiled/directives/dev/Development.js.map +1 -1
- package/transpiled/directives/flow/Flow.d.ts +1 -1
- package/transpiled/directives/flow/Flow.js +1 -1
- package/transpiled/directives/flow/Flow.js.map +1 -1
- package/transpiled/directives/index.js +4 -2
- package/transpiled/directives/index.js.map +1 -1
- package/transpiled/directives/io/Directive.d.ts +1 -1
- package/transpiled/directives/io/IO.d.ts +7 -1
- package/transpiled/directives/io/IO.js +25 -3
- package/transpiled/directives/io/IO.js.map +1 -1
- package/transpiled/directives/io/Input.d.ts +3 -2
- package/transpiled/directives/io/Input.js +2 -1
- package/transpiled/directives/io/Input.js.map +1 -1
- package/transpiled/directives/io/Output.d.ts +5 -3
- package/transpiled/directives/io/Output.js +8 -3
- package/transpiled/directives/io/Output.js.map +1 -1
- package/transpiled/directives/io/Status.d.ts +19 -0
- package/transpiled/directives/io/Status.js +34 -0
- package/transpiled/directives/io/Status.js.map +1 -0
- package/transpiled/directives/io/Throttle.d.ts +1 -1
- package/transpiled/directives/io/Throttle.js +1 -1
- package/transpiled/directives/io/Throttle.js.map +1 -1
- package/transpiled/directives/io/lib/throttle/Quotas.d.ts +1 -1
- package/transpiled/directives/io/lib/throttle/Quotas.js +2 -2
- package/transpiled/directives/io/lib/throttle/Quotas.js.map +1 -1
- package/transpiled/directives/map/Headers.d.ts +2 -0
- package/transpiled/directives/map/Headers.js +8 -0
- package/transpiled/directives/map/Headers.js.map +1 -1
- package/transpiled/directives/map/Map.d.ts +3 -1
- package/transpiled/directives/map/Map.js +7 -1
- package/transpiled/directives/map/Map.js.map +1 -1
- package/transpiled/directives/map/Mapping.d.ts +13 -0
- package/transpiled/directives/map/Mapping.js +20 -0
- package/transpiled/directives/map/Mapping.js.map +1 -1
- package/transpiled/directives/map/Segments.d.ts +3 -0
- package/transpiled/directives/map/Segments.js +9 -0
- package/transpiled/directives/map/Segments.js.map +1 -1
- package/transpiled/directives/mcp/MCP.d.ts +15 -0
- package/transpiled/directives/mcp/MCP.js +23 -0
- package/transpiled/directives/mcp/MCP.js.map +1 -0
- package/transpiled/directives/mcp/Tool.d.ts +13 -0
- package/transpiled/directives/mcp/Tool.js +23 -0
- package/transpiled/directives/mcp/Tool.js.map +1 -0
- package/transpiled/directives/mcp/index.d.ts +4 -0
- package/transpiled/directives/mcp/index.js +4 -0
- package/transpiled/directives/mcp/index.js.map +1 -0
- package/transpiled/directives/oauth/Discovery.d.ts +23 -0
- package/transpiled/directives/oauth/Discovery.js +55 -0
- package/transpiled/directives/oauth/Discovery.js.map +1 -0
- package/transpiled/directives/oauth/documents.d.ts +9 -0
- package/transpiled/directives/oauth/documents.js +82 -0
- package/transpiled/directives/oauth/documents.js.map +1 -0
- package/transpiled/directives/oauth/index.d.ts +2 -0
- package/transpiled/directives/oauth/index.js +3 -0
- package/transpiled/directives/oauth/index.js.map +1 -0
- package/transpiled/directives/octets/Octets.d.ts +1 -1
- package/transpiled/directives/octets/Octets.js +1 -1
- package/transpiled/directives/octets/Octets.js.map +1 -1
- package/transpiled/directives/require/Directive.d.ts +1 -1
- package/transpiled/directives/require/Headers.d.ts +1 -1
- package/transpiled/directives/require/Headers.js +1 -1
- package/transpiled/directives/require/Headers.js.map +1 -1
- package/transpiled/directives/require/Require.d.ts +1 -1
- package/transpiled/directives/require/Require.js +2 -2
- package/transpiled/directives/require/Require.js.map +1 -1
- package/transpiled/index.d.ts +2 -0
- package/transpiled/schemas.d.ts +2 -0
- package/transpiled/schemas.js +1 -0
- package/transpiled/schemas.js.map +1 -1
- package/transpiled/userland.d.ts +39 -0
- package/transpiled/userland.js +7 -0
- package/transpiled/userland.js.map +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/components/identity.bans/operations/transit.d.ts +0 -14
- package/components/identity.bans/operations/transit.js.map +0 -1
- package/components/identity.basic/operations/add.d.ts +0 -3
- package/components/identity.basic/operations/add.js.map +0 -1
- package/components/identity.basic/operations/authenticate.d.ts +0 -13
- package/components/identity.basic/operations/authenticate.js.map +0 -1
- package/components/identity.basic/operations/check.d.ts +0 -7
- package/components/identity.basic/operations/check.js.map +0 -1
- package/components/identity.basic/operations/delete.d.ts +0 -7
- package/components/identity.basic/operations/delete.js.map +0 -1
- package/components/identity.basic/operations/incept.d.ts +0 -12
- package/components/identity.basic/operations/incept.js.map +0 -1
- package/components/identity.basic/operations/info.d.ts +0 -10
- package/components/identity.basic/operations/info.js.map +0 -1
- package/components/identity.basic/operations/lib/credentials.d.ts +0 -5
- package/components/identity.basic/operations/lib/credentials.js.map +0 -1
- package/components/identity.basic/operations/transit.d.ts +0 -14
- package/components/identity.basic/operations/transit.js.map +0 -1
- package/components/identity.basic/operations/types.d.ts +0 -61
- package/components/identity.basic/operations/types.js +0 -2
- package/components/identity.basic/operations/types.js.map +0 -1
- package/components/identity.basic/source/types.ts +0 -69
- package/components/identity.credentials/operations/list.d.ts +0 -51
- package/components/identity.credentials/operations/list.js.map +0 -1
- package/components/identity.federation/operations/authenticate.d.ts +0 -16
- package/components/identity.federation/operations/authenticate.js.map +0 -1
- package/components/identity.federation/operations/create.d.ts +0 -8
- package/components/identity.federation/operations/create.js.map +0 -1
- package/components/identity.federation/operations/decode.d.ts +0 -3
- package/components/identity.federation/operations/decode.js.map +0 -1
- package/components/identity.federation/operations/delete.d.ts +0 -8
- package/components/identity.federation/operations/delete.js.map +0 -1
- package/components/identity.federation/operations/incept.d.ts +0 -11
- package/components/identity.federation/operations/incept.js.map +0 -1
- package/components/identity.federation/operations/lib/Configuration.d.ts +0 -39
- package/components/identity.federation/operations/lib/Configuration.js.map +0 -1
- package/components/identity.federation/operations/lib/Ctx.d.ts +0 -8
- package/components/identity.federation/operations/lib/Ctx.js.map +0 -1
- package/components/identity.federation/operations/lib/Payload.d.ts +0 -5
- package/components/identity.federation/operations/lib/Payload.js.map +0 -1
- package/components/identity.federation/operations/lib/decode.d.ts +0 -3
- package/components/identity.federation/operations/lib/decode.js.map +0 -1
- package/components/identity.federation/operations/lib/discovery.d.ts +0 -5
- package/components/identity.federation/operations/lib/discovery.js.map +0 -1
- package/components/identity.federation/operations/lib/errors.d.ts +0 -70
- package/components/identity.federation/operations/lib/errors.js.map +0 -1
- package/components/identity.federation/operations/lib/exchange.d.ts +0 -3
- package/components/identity.federation/operations/lib/exchange.js.map +0 -1
- package/components/identity.federation/operations/lib/index.d.ts +0 -4
- package/components/identity.federation/operations/lib/index.js.map +0 -1
- package/components/identity.federation/operations/lib/jose.d.ts +0 -1
- package/components/identity.federation/operations/lib/jose.js.map +0 -1
- package/components/identity.federation/operations/lib/resolve.d.ts +0 -3
- package/components/identity.federation/operations/lib/resolve.js.map +0 -1
- package/components/identity.federation/operations/list.d.ts +0 -7
- package/components/identity.federation/operations/list.js.map +0 -1
- package/components/identity.federation/operations/types/Scheme.d.ts +0 -1
- package/components/identity.federation/operations/types/Scheme.js.map +0 -1
- package/components/identity.federation/operations/types/configuration.d.ts +0 -22
- package/components/identity.federation/operations/types/configuration.js.map +0 -1
- package/components/identity.federation/operations/types/context.d.ts +0 -35
- package/components/identity.federation/operations/types/context.js.map +0 -1
- package/components/identity.federation/operations/types/entity.d.ts +0 -9
- package/components/identity.federation/operations/types/entity.js.map +0 -1
- package/components/identity.federation/operations/types/index.d.ts +0 -4
- package/components/identity.federation/operations/types/index.js.map +0 -1
- package/components/identity.keys/operations/create.d.ts +0 -22
- package/components/identity.keys/operations/create.js.map +0 -1
- package/components/identity.keys/operations/disable.d.ts +0 -5
- package/components/identity.keys/operations/disable.js.map +0 -1
- package/components/identity.keys/operations/revoke.d.ts +0 -15
- package/components/identity.keys/operations/revoke.js.map +0 -1
- package/components/identity.otp/operations/authenticate.d.ts +0 -12
- package/components/identity.otp/operations/authenticate.js.map +0 -1
- package/components/identity.otp/operations/issue.d.ts +0 -12
- package/components/identity.otp/operations/issue.js.map +0 -1
- package/components/identity.otp/operations/lib/Context.d.ts +0 -14
- package/components/identity.otp/operations/lib/Context.js.map +0 -1
- package/components/identity.otp/operations/lib/Entity.d.ts +0 -6
- package/components/identity.otp/operations/lib/Entity.js.map +0 -1
- package/components/identity.otp/operations/lib/index.d.ts +0 -1
- package/components/identity.otp/operations/lib/index.js.map +0 -1
- package/components/identity.passkeys/operations/authenticate.d.ts +0 -16
- package/components/identity.passkeys/operations/authenticate.js.map +0 -1
- package/components/identity.passkeys/operations/challenge.d.ts +0 -35
- package/components/identity.passkeys/operations/challenge.js.map +0 -1
- package/components/identity.passkeys/operations/create.d.ts +0 -19
- package/components/identity.passkeys/operations/create.js.map +0 -1
- package/components/identity.passkeys/operations/delete.d.ts +0 -8
- package/components/identity.passkeys/operations/delete.js.map +0 -1
- package/components/identity.passkeys/operations/lib/const.d.ts +0 -1
- package/components/identity.passkeys/operations/lib/const.js.map +0 -1
- package/components/identity.passkeys/operations/list.d.ts +0 -7
- package/components/identity.passkeys/operations/list.js.map +0 -1
- package/components/identity.passkeys/operations/types/Configuration.d.ts +0 -6
- package/components/identity.passkeys/operations/types/Configuration.js.map +0 -1
- package/components/identity.passkeys/operations/types/Context.d.ts +0 -15
- package/components/identity.passkeys/operations/types/Context.js.map +0 -1
- package/components/identity.passkeys/operations/types/Passkey.d.ts +0 -12
- package/components/identity.passkeys/operations/types/Passkey.js.map +0 -1
- package/components/identity.passkeys/operations/types/index.d.ts +0 -2
- package/components/identity.passkeys/operations/types/index.js.map +0 -1
- package/components/identity.passkeys/operations/use.d.ts +0 -16
- package/components/identity.passkeys/operations/use.js.map +0 -1
- package/components/identity.roles/operations/grant.d.ts +0 -10
- package/components/identity.roles/operations/grant.js.map +0 -1
- package/components/identity.roles/operations/lib/Entity.d.ts +0 -5
- package/components/identity.roles/operations/lib/Entity.js.map +0 -1
- package/components/identity.roles/operations/list.d.ts +0 -2
- package/components/identity.roles/operations/list.js.map +0 -1
- package/components/identity.roles/operations/principal.d.ts +0 -13
- package/components/identity.roles/operations/principal.js.map +0 -1
- package/components/identity.tokens/operations/authenticate.d.ts +0 -9
- package/components/identity.tokens/operations/authenticate.js.map +0 -1
- package/components/identity.tokens/operations/decrypt.d.ts +0 -15
- package/components/identity.tokens/operations/decrypt.js.map +0 -1
- package/components/identity.tokens/operations/encrypt.d.ts +0 -8
- package/components/identity.tokens/operations/encrypt.js.map +0 -1
- package/components/identity.tokens/operations/issue.d.ts +0 -24
- package/components/identity.tokens/operations/issue.js.map +0 -1
- package/components/identity.tokens/operations/lib/index.d.ts +0 -3
- package/components/identity.tokens/operations/lib/index.js.map +0 -1
- package/components/identity.tokens/operations/lib/jose.d.ts +0 -1
- package/components/identity.tokens/operations/lib/jose.js.map +0 -1
- package/components/identity.tokens/operations/lib/key.d.ts +0 -1
- package/components/identity.tokens/operations/lib/key.js.map +0 -1
- package/components/identity.tokens/operations/lib/pad.d.ts +0 -1
- package/components/identity.tokens/operations/lib/pad.js.map +0 -1
- package/components/identity.tokens/operations/lib/types.d.ts +0 -88
- package/components/identity.tokens/operations/lib/types.js +0 -2
- package/components/identity.tokens/operations/lib/types.js.map +0 -1
- package/components/identity.tokens/operations/revoke.d.ts +0 -2
- package/components/identity.tokens/operations/revoke.js.map +0 -1
- package/components/identity.tokens/source/lib/types.ts +0 -102
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
/** What a reply may be encoded as, and so what `accept` is negotiated against. */
|
|
1
2
|
export declare const formats: Record<string, Format>;
|
|
2
3
|
export declare const types: string[];
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* What a request body may arrive as. Everything a reply may be, and a form besides — which
|
|
6
|
+
* is read and never written, so it is not something a reply can be asked for.
|
|
7
|
+
*/
|
|
8
|
+
export declare const decoders: Record<string, Decoder>;
|
|
9
|
+
export interface Decoder {
|
|
4
10
|
readonly type: string;
|
|
11
|
+
decode: (buffer: Buffer, charset?: string) => any;
|
|
12
|
+
}
|
|
13
|
+
export interface Format extends Decoder {
|
|
5
14
|
readonly multipart: string;
|
|
6
15
|
encode: (value: any) => Buffer;
|
|
7
|
-
decode: (buffer: Buffer, charset?: string) => any;
|
|
8
16
|
}
|
|
@@ -2,6 +2,8 @@ import * as json from './json.js';
|
|
|
2
2
|
import * as yaml from './yaml.js';
|
|
3
3
|
import * as msgpack from './msgpack.js';
|
|
4
4
|
import * as text from './text.js';
|
|
5
|
+
import * as form from './form.js';
|
|
6
|
+
/** What a reply may be encoded as, and so what `accept` is negotiated against. */
|
|
5
7
|
export const formats = {
|
|
6
8
|
[json.type]: json,
|
|
7
9
|
[yaml.type]: yaml,
|
|
@@ -9,4 +11,12 @@ export const formats = {
|
|
|
9
11
|
[msgpack.type]: msgpack
|
|
10
12
|
};
|
|
11
13
|
export const types = Object.keys(formats);
|
|
14
|
+
/**
|
|
15
|
+
* What a request body may arrive as. Everything a reply may be, and a form besides — which
|
|
16
|
+
* is read and never written, so it is not something a reply can be asked for.
|
|
17
|
+
*/
|
|
18
|
+
export const decoders = {
|
|
19
|
+
...formats,
|
|
20
|
+
[form.type]: form
|
|
21
|
+
};
|
|
12
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/HTTP/formats/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAA2B;IAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;IACjB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;IACjB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;IACjB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO;CACxB,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/HTTP/formats/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,kFAAkF;AAClF,MAAM,CAAC,MAAM,OAAO,GAA2B;IAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;IACjB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;IACjB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;IACjB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO;CACxB,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA4B;IAC/C,GAAG,OAAO;IACV,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI;CAClB,CAAA"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import type { Context } from './Context.js';
|
|
3
3
|
import type { ServerResponse } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Applies what the request accumulated in `pipelines.response` — an `io:output` restriction,
|
|
6
|
+
* a `vary` a `map` directive owes. Separate from `write` because a message is not always
|
|
7
|
+
* written: one call of several produces a value the reply is assembled from.
|
|
8
|
+
*/
|
|
9
|
+
export declare function shape(context: Context, message: OutgoingMessage): Promise<void>;
|
|
4
10
|
export declare function write(context: Context, response: ServerResponse, message: OutgoingMessage): Promise<void>;
|
|
5
11
|
export declare function read(context: Context): Promise<any>;
|
|
6
12
|
/**
|
|
@@ -14,6 +20,12 @@ export interface OutgoingMessage {
|
|
|
14
20
|
body?: any;
|
|
15
21
|
/** tag the response with a hash of the encoded body, see `conditional` */
|
|
16
22
|
etag?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Built by the gateway rather than returned by an operation, as a request is `authentic`
|
|
25
|
+
* when it was made by one: what is in it is the gateway's own, and the checks that answer
|
|
26
|
+
* for what an operation returns have nothing to say about it.
|
|
27
|
+
*/
|
|
28
|
+
authentic?: boolean;
|
|
17
29
|
}
|
|
18
30
|
export interface Query {
|
|
19
31
|
[key: string]: string | number | undefined;
|
|
@@ -4,15 +4,23 @@ import { pipeline } from 'node:stream/promises';
|
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import * as contentType from 'content-type';
|
|
6
6
|
import { console } from 'openspan';
|
|
7
|
-
import {
|
|
7
|
+
import { decoders } from './formats/index.js';
|
|
8
8
|
import { BadRequest, NotAcceptable, UnsupportedMediaType } from './exceptions.js';
|
|
9
9
|
const server = `Exposition/${JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version}` +
|
|
10
10
|
((process.env.TOA_CONTEXT === undefined ? '' : ` ${process.env.TOA_CONTEXT}`) +
|
|
11
11
|
(process.env.TOA_ENV === undefined ? '' : `/${process.env.TOA_ENV}`));
|
|
12
12
|
const pending = new Map();
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Applies what the request accumulated in `pipelines.response` — an `io:output` restriction,
|
|
15
|
+
* a `vary` a `map` directive owes. Separate from `write` because a message is not always
|
|
16
|
+
* written: one call of several produces a value the reply is assembled from.
|
|
17
|
+
*/
|
|
18
|
+
export async function shape(context, message) {
|
|
14
19
|
for (const transform of context.pipelines.response)
|
|
15
20
|
await transform(message);
|
|
21
|
+
}
|
|
22
|
+
export async function write(context, response, message) {
|
|
23
|
+
await shape(context, message);
|
|
16
24
|
if (message?.status !== undefined)
|
|
17
25
|
response.statusCode = message.status;
|
|
18
26
|
response.setHeader('server', server);
|
|
@@ -33,9 +41,9 @@ export async function read(context) {
|
|
|
33
41
|
if (header === undefined)
|
|
34
42
|
return undefined;
|
|
35
43
|
const { type, parameters } = contentType.parse(header);
|
|
36
|
-
if (!(type in
|
|
44
|
+
if (!(type in decoders))
|
|
37
45
|
throw new UnsupportedMediaType();
|
|
38
|
-
const format =
|
|
46
|
+
const format = decoders[type];
|
|
39
47
|
const buf = await context.buffer();
|
|
40
48
|
try {
|
|
41
49
|
return format.decode(buf, parameters.charset);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../source/HTTP/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAe,
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../source/HTTP/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAe,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAIjF,MAAM,MAAM,GAAG,cAAc,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,C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CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IAE1E,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;IACnC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;IAE5B,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACxB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;QACnC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAE1B,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACvB,IAAI,eAAe,KAAK,IAAI;gBAC1B,aAAa,CAAC,eAAe,CAAC,CAAA;YAEhC,eAAe,GAAG,IAAI,CAAA;QACxB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,IAAI,eAAe,KAAK,IAAI;QAC1B,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,CACjC,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,EAC1D,sBAAsB,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import type * as http from './HTTP/index.js';
|
|
1
2
|
import type { Input, Output } from './io.js';
|
|
2
3
|
export declare class Interception implements Interceptor {
|
|
3
4
|
private readonly interceptors;
|
|
4
|
-
constructor(interceptors: Interceptor[]);
|
|
5
|
+
constructor(interceptors: Interceptor[], options: http.Options);
|
|
5
6
|
intercept(input: Input): Promise<Output>;
|
|
6
7
|
}
|
|
7
8
|
export interface Interceptor {
|
|
8
9
|
intercept: (input: Input) => Output | Promise<Output>;
|
|
9
10
|
/** Discards whatever the interceptor accumulated while serving. */
|
|
10
11
|
reset?: () => void;
|
|
12
|
+
/** What the annotation says, for an interceptor that answers from it. */
|
|
13
|
+
mount?: (options: http.Options) => void;
|
|
11
14
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export class Interception {
|
|
2
2
|
interceptors;
|
|
3
|
-
constructor(interceptors) {
|
|
3
|
+
constructor(interceptors, options) {
|
|
4
4
|
this.interceptors = interceptors;
|
|
5
5
|
// interceptors are module singletons, so a second gateway in one process —
|
|
6
6
|
// which is how the features run — would otherwise inherit the first one's state
|
|
7
|
-
for (const interceptor of interceptors)
|
|
7
|
+
for (const interceptor of interceptors) {
|
|
8
8
|
interceptor.reset?.();
|
|
9
|
+
interceptor.mount?.(options);
|
|
10
|
+
}
|
|
9
11
|
}
|
|
10
12
|
async intercept(input) {
|
|
11
13
|
for (const interceptor of this.interceptors) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interception.js","sourceRoot":"","sources":["../source/Interception.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Interception.js","sourceRoot":"","sources":["../source/Interception.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,YAAY;IACN,YAAY,CAAe;IAE5C,YAAoB,YAA2B,EAAE,OAAqB;QACpE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAEhC,2EAA2E;QAC3E,gFAAgF;QAChF,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,WAAW,CAAC,KAAK,EAAE,EAAE,CAAA;YACrB,WAAW,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,CAAA;QAC9B,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,KAAY;QAClC,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5C,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;YAEjD,IAAI,MAAM,KAAK,IAAI;gBACjB,OAAO,MAAM,CAAA;QACjB,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
import type { Remote } from '@toa.io/core';
|
|
2
2
|
export interface Introspection {
|
|
3
|
+
/**
|
|
4
|
+
* What the route states this method is. The operation states what it is too, and that is
|
|
5
|
+
* not this: an operation is written without knowledge of any route, and a method is an
|
|
6
|
+
* operation and a route together — the same operation mounted twice is two methods, and
|
|
7
|
+
* one sentence cannot be true of both. The operation's own is for the Introspection.
|
|
8
|
+
*/
|
|
9
|
+
description?: string;
|
|
3
10
|
route?: Record<string, Schema>;
|
|
4
11
|
query?: Record<string, Schema>;
|
|
12
|
+
/** what a request header carries, which is therefore not the body's to send */
|
|
13
|
+
headers?: Record<string, Sourced>;
|
|
5
14
|
input?: Schema;
|
|
6
15
|
output?: Schema;
|
|
7
16
|
errors?: string[];
|
|
8
17
|
}
|
|
18
|
+
/** A property the gateway reads from somewhere else, and the schema it was declared with. */
|
|
19
|
+
export interface Sourced {
|
|
20
|
+
header: string;
|
|
21
|
+
[keyword: string]: unknown;
|
|
22
|
+
}
|
|
9
23
|
export type Schema = Awaited<ReturnType<Remote['explain']>>['input'];
|
|
24
|
+
/**
|
|
25
|
+
* The same, in the order the shape states — whatever order the families that filled it ran
|
|
26
|
+
* in. What a resource says about itself is read, so it is written the way it is documented.
|
|
27
|
+
*/
|
|
28
|
+
export declare function order(introspection: Introspection): Introspection;
|
|
29
|
+
/**
|
|
30
|
+
* The schema of one input property, taken out of it: a property another family fills is
|
|
31
|
+
* not the caller's to send, and what took it says where it comes from instead.
|
|
32
|
+
*/
|
|
33
|
+
export declare function take(carrier: Carrier, property: string): Schema | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* A schema restricted to the properties a whitelist admits, and an array's items where it
|
|
36
|
+
* describes an array. What is not an object of properties is left alone: a whitelist has
|
|
37
|
+
* nothing to say about a string.
|
|
38
|
+
*/
|
|
39
|
+
export declare function restrict(schema: Schema | undefined, allowed: Set<string>): Schema | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* What a schema is read as here: the keywords these narrow, and whatever else it carries.
|
|
42
|
+
* `Schema` as core declares it requires `properties`, which a schema of a string has not,
|
|
43
|
+
* so the two are cast through rather than assigned.
|
|
44
|
+
*/
|
|
45
|
+
/** Whatever states an input: an explanation as the operation gave it, or as a route left it. */
|
|
46
|
+
interface Carrier {
|
|
47
|
+
input?: Schema;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -1,2 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The same, in the order the shape states — whatever order the families that filled it ran
|
|
3
|
+
* in. What a resource says about itself is read, so it is written the way it is documented.
|
|
4
|
+
*/
|
|
5
|
+
export function order(introspection) {
|
|
6
|
+
const ordered = {};
|
|
7
|
+
for (const key of KEYS)
|
|
8
|
+
if (introspection[key] !== undefined)
|
|
9
|
+
ordered[key] = introspection[key];
|
|
10
|
+
return ordered;
|
|
11
|
+
}
|
|
12
|
+
const KEYS = ['description', 'route', 'query', 'headers', 'input', 'output', 'errors'];
|
|
13
|
+
/**
|
|
14
|
+
* The schema of one input property, taken out of it: a property another family fills is
|
|
15
|
+
* not the caller's to send, and what took it says where it comes from instead.
|
|
16
|
+
*/
|
|
17
|
+
export function take(carrier, property) {
|
|
18
|
+
const input = carrier.input;
|
|
19
|
+
const properties = input?.properties;
|
|
20
|
+
if (input === undefined || input === null || properties === undefined ||
|
|
21
|
+
!(property in properties))
|
|
22
|
+
return undefined;
|
|
23
|
+
const schema = properties[property];
|
|
24
|
+
delete properties[property];
|
|
25
|
+
if (input.required !== undefined)
|
|
26
|
+
input.required = input.required.filter((name) => name !== property);
|
|
27
|
+
return schema;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A schema restricted to the properties a whitelist admits, and an array's items where it
|
|
31
|
+
* describes an array. What is not an object of properties is left alone: a whitelist has
|
|
32
|
+
* nothing to say about a string.
|
|
33
|
+
*/
|
|
34
|
+
export function restrict(schema, allowed) {
|
|
35
|
+
const shape = schema;
|
|
36
|
+
if (shape === undefined || shape === null)
|
|
37
|
+
return schema;
|
|
38
|
+
if (shape.items !== undefined)
|
|
39
|
+
return { ...shape, items: restrict(shape.items, allowed) };
|
|
40
|
+
if (shape.properties === undefined)
|
|
41
|
+
return schema;
|
|
42
|
+
const properties = {};
|
|
43
|
+
for (const [name, property] of Object.entries(shape.properties))
|
|
44
|
+
if (allowed.has(name))
|
|
45
|
+
properties[name] = property;
|
|
46
|
+
const restricted = { ...shape, properties };
|
|
47
|
+
if (shape.required !== undefined)
|
|
48
|
+
restricted.required = shape.required.filter((name) => allowed.has(name));
|
|
49
|
+
return restricted;
|
|
50
|
+
}
|
|
2
51
|
//# sourceMappingURL=Introspection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Introspection.js","sourceRoot":"","sources":["../source/Introspection.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Introspection.js","sourceRoot":"","sources":["../source/Introspection.ts"],"names":[],"mappings":"AA4BA;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAE,aAA4B;IACjD,MAAM,OAAO,GAAkB,EAAE,CAAA;IAEjC,KAAK,MAAM,GAAG,IAAI,IAAI;QACpB,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,SAAS;YACjC,OAAO,CAAC,GAAG,CAAa,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;IAElD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,IAAI,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;AAE/F;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAE,OAAgB,EAAE,QAAgB;IACtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAiC,CAAA;IACvD,MAAM,UAAU,GAAG,KAAK,EAAE,UAAU,CAAA;IAEpC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,UAAU,KAAK,SAAS;QACnE,CAAC,CAAC,QAAQ,IAAI,UAA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,CAAC,CAAA;IAE1E,OAAO,UAA+B,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as http from '../HTTP/index.js';
|
|
2
|
+
import type { Tree } from '../RTD/index.js';
|
|
3
|
+
import type { MCP } from '../Annotation.js';
|
|
4
|
+
/**
|
|
5
|
+
* The Model Context Protocol, as one endpoint that remembers nothing between requests.
|
|
6
|
+
*
|
|
7
|
+
* Two revisions are answered from it. The modern one carries the version and the client's
|
|
8
|
+
* capabilities in every request; the one before it opens with `initialize`, which is what
|
|
9
|
+
* most clients still send. Neither needs a session, and neither needs a stream: every method
|
|
10
|
+
* here answers one object, which is why this can exist in a package that serves no SSE.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Server {
|
|
13
|
+
private readonly options;
|
|
14
|
+
private readonly tree;
|
|
15
|
+
private readonly discovery;
|
|
16
|
+
private readonly origins;
|
|
17
|
+
constructor(options: MCP, tree: Tree);
|
|
18
|
+
process(context: http.Context, route: http.Processor): Promise<http.OutgoingMessage>;
|
|
19
|
+
/** Who may reach the endpoint at all, before anything it carries is read. */
|
|
20
|
+
private admit;
|
|
21
|
+
private answer;
|
|
22
|
+
private tool;
|
|
23
|
+
/**
|
|
24
|
+
* Every result of the modern revision says what kind it is, and who answered it. Where the
|
|
25
|
+
* revision names the operation as one whose result may be held, it says that too, and must.
|
|
26
|
+
*/
|
|
27
|
+
private complete;
|
|
28
|
+
private serverInfo;
|
|
29
|
+
/**
|
|
30
|
+
* Which revision this request is of. `initialize` is one by itself; otherwise the header
|
|
31
|
+
* says, and a request that names none is of a revision that did not send one.
|
|
32
|
+
*/
|
|
33
|
+
private version;
|
|
34
|
+
/**
|
|
35
|
+
* What the modern revision mirrors into headers, so that what routes a request and what
|
|
36
|
+
* answers it cannot be told two different things.
|
|
37
|
+
*/
|
|
38
|
+
private mirrored;
|
|
39
|
+
/** A body the decoder refuses is a parse error; a media type it does not know is not. */
|
|
40
|
+
private read;
|
|
41
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { console } from 'openspan';
|
|
2
|
+
import { BRANCH_TTL } from '../const.js';
|
|
3
|
+
import * as http from '../HTTP/index.js';
|
|
4
|
+
import { discovery } from './discover.js';
|
|
5
|
+
import { call, list } from './tools.js';
|
|
6
|
+
import { HEADER_MISMATCH, INVALID_PARAMS, INVALID_REQUEST, METHOD_NOT_FOUND, PARSE, UNSUPPORTED_VERSION, failure, response } from './errors.js';
|
|
7
|
+
import { CLIENT_CAPABILITIES, JSONRPC, LEGACY, MODERN, PROTOCOL_VERSION, SERVER_INFO, VERSIONS } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* The Model Context Protocol, as one endpoint that remembers nothing between requests.
|
|
10
|
+
*
|
|
11
|
+
* Two revisions are answered from it. The modern one carries the version and the client's
|
|
12
|
+
* capabilities in every request; the one before it opens with `initialize`, which is what
|
|
13
|
+
* most clients still send. Neither needs a session, and neither needs a stream: every method
|
|
14
|
+
* here answers one object, which is why this can exist in a package that serves no SSE.
|
|
15
|
+
*/
|
|
16
|
+
export class Server {
|
|
17
|
+
options;
|
|
18
|
+
tree;
|
|
19
|
+
discovery;
|
|
20
|
+
origins;
|
|
21
|
+
constructor(options, tree) {
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.tree = tree;
|
|
24
|
+
this.discovery = discovery(options);
|
|
25
|
+
this.origins = new Set(options.origins ?? []);
|
|
26
|
+
}
|
|
27
|
+
async process(context, route) {
|
|
28
|
+
if (context.request.method !== 'POST')
|
|
29
|
+
throw new http.MethodNotAllowed(new Headers({ allow: 'POST' }));
|
|
30
|
+
this.admit(context);
|
|
31
|
+
const message = await this.read(context);
|
|
32
|
+
const version = this.version(context, message);
|
|
33
|
+
const modern = version === MODERN;
|
|
34
|
+
if (modern)
|
|
35
|
+
this.mirrored(context, message);
|
|
36
|
+
const result = await this.answer({ context, route, tree: this.tree }, message, modern);
|
|
37
|
+
// a notification is answered by not answering, and there is nothing here to remember
|
|
38
|
+
if (message.id === undefined)
|
|
39
|
+
return { status: ACCEPTED };
|
|
40
|
+
return {
|
|
41
|
+
status: OK,
|
|
42
|
+
body: { jsonrpc: JSONRPC, id: message.id, result },
|
|
43
|
+
headers: new Headers({ 'cache-control': 'no-store' })
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Who may reach the endpoint at all, before anything it carries is read. */
|
|
47
|
+
admit(context) {
|
|
48
|
+
const origin = context.request.headers.origin;
|
|
49
|
+
// the revision requires this against DNS rebinding; a request without one is no browser's
|
|
50
|
+
if (origin !== undefined && !this.origins.has(origin))
|
|
51
|
+
throw new http.Forbidden('Origin is not allowed');
|
|
52
|
+
if (this.options.anonymous === true)
|
|
53
|
+
return;
|
|
54
|
+
if (context.identity == null)
|
|
55
|
+
throw new http.Unauthorized();
|
|
56
|
+
}
|
|
57
|
+
async answer(scope, message, modern) {
|
|
58
|
+
const params = message.params ?? {};
|
|
59
|
+
switch (message.method) {
|
|
60
|
+
case 'server/discover':
|
|
61
|
+
return this.complete(this.discovery.modern, modern, DISCOVERY_CACHE);
|
|
62
|
+
case 'tools/list':
|
|
63
|
+
return this.complete({ tools: await list(this.tree, scope.context) }, modern, TOOLS_CACHE);
|
|
64
|
+
case 'tools/call':
|
|
65
|
+
return this.complete(await this.tool(scope, params), modern);
|
|
66
|
+
// what a client of an earlier revision opens with; no session is made and none is named
|
|
67
|
+
case 'initialize':
|
|
68
|
+
return this.discovery.legacy(declared(params));
|
|
69
|
+
case 'notifications/initialized':
|
|
70
|
+
return null;
|
|
71
|
+
case 'ping':
|
|
72
|
+
return {};
|
|
73
|
+
default:
|
|
74
|
+
throw new http.NotFound(response(message.id ?? null, failure(METHOD_NOT_FOUND, `'${message.method}' is not a method this server answers`)));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async tool(scope, params) {
|
|
78
|
+
const named = params.name;
|
|
79
|
+
if (typeof named !== 'string')
|
|
80
|
+
throw new http.BadRequest(response(null, failure(INVALID_PARAMS, '`tools/call` states the tool it calls by name')));
|
|
81
|
+
const args = params.arguments ?? {};
|
|
82
|
+
if (typeof args !== 'object' || args === null || Array.isArray(args))
|
|
83
|
+
throw new http.BadRequest(response(null, failure(INVALID_PARAMS, '`arguments` must be an object')));
|
|
84
|
+
return await console.span({ name: named }, async () => await call(scope, named, args));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Every result of the modern revision says what kind it is, and who answered it. Where the
|
|
88
|
+
* revision names the operation as one whose result may be held, it says that too, and must.
|
|
89
|
+
*/
|
|
90
|
+
complete(result, modern, cache) {
|
|
91
|
+
return modern
|
|
92
|
+
? { ...result, ...cache, resultType: 'complete', _meta: { [SERVER_INFO]: this.serverInfo() } }
|
|
93
|
+
: result;
|
|
94
|
+
}
|
|
95
|
+
serverInfo() {
|
|
96
|
+
return this.discovery.modern._meta[SERVER_INFO];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Which revision this request is of. `initialize` is one by itself; otherwise the header
|
|
100
|
+
* says, and a request that names none is of a revision that did not send one.
|
|
101
|
+
*/
|
|
102
|
+
version(context, message) {
|
|
103
|
+
if (message.method === 'initialize')
|
|
104
|
+
return LEGACY;
|
|
105
|
+
const header = context.request.headers['mcp-protocol-version'];
|
|
106
|
+
const stated = declared(message.params ?? {});
|
|
107
|
+
if (header !== undefined && stated !== undefined && header !== stated)
|
|
108
|
+
throw new http.BadRequest(response(message.id ?? null, failure(HEADER_MISMATCH, `'MCP-Protocol-Version' says '${String(header)}' and the body says '${stated}'`)));
|
|
109
|
+
const value = header ?? stated;
|
|
110
|
+
if (value === undefined)
|
|
111
|
+
return LEGACY;
|
|
112
|
+
if (!VERSIONS.includes(value))
|
|
113
|
+
throw new http.BadRequest(response(message.id ?? null, failure(UNSUPPORTED_VERSION, 'Unsupported protocol version', { supported: VERSIONS, requested: value })));
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* What the modern revision mirrors into headers, so that what routes a request and what
|
|
118
|
+
* answers it cannot be told two different things.
|
|
119
|
+
*/
|
|
120
|
+
mirrored(context, message) {
|
|
121
|
+
const meta = metadata(message.params ?? {});
|
|
122
|
+
if (meta?.[PROTOCOL_VERSION] === undefined || meta[CLIENT_CAPABILITIES] === undefined)
|
|
123
|
+
throw new http.BadRequest(response(message.id ?? null, failure(INVALID_PARAMS, `'_meta' states '${PROTOCOL_VERSION}' and '${CLIENT_CAPABILITIES}'`)));
|
|
124
|
+
const id = message.id ?? null;
|
|
125
|
+
mirrors(context, { id, header: 'mcp-method', value: message.method });
|
|
126
|
+
if (message.method === 'tools/call')
|
|
127
|
+
mirrors(context, { id, header: 'mcp-name', value: (message.params ?? {}).name });
|
|
128
|
+
}
|
|
129
|
+
/** A body the decoder refuses is a parse error; a media type it does not know is not. */
|
|
130
|
+
async read(context) {
|
|
131
|
+
let body;
|
|
132
|
+
try {
|
|
133
|
+
body = await context.body();
|
|
134
|
+
}
|
|
135
|
+
catch (exception) {
|
|
136
|
+
if (exception instanceof http.BadRequest)
|
|
137
|
+
throw new http.BadRequest(response(null, failure(PARSE, 'Parse error')));
|
|
138
|
+
throw exception;
|
|
139
|
+
}
|
|
140
|
+
if (typeof body !== 'object' || body === null || Array.isArray(body) ||
|
|
141
|
+
body.jsonrpc !== JSONRPC || typeof body.method !== 'string')
|
|
142
|
+
throw new http.BadRequest(response(null, failure(INVALID_REQUEST, 'A request carries one JSON-RPC message')));
|
|
143
|
+
return body;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** What a header says must be what the body says, or what routes and what answers differ. */
|
|
147
|
+
function mirrors(context, mirror) {
|
|
148
|
+
const { id, header, value } = mirror;
|
|
149
|
+
const stated = context.request.headers[header];
|
|
150
|
+
if (stated === undefined)
|
|
151
|
+
throw new http.BadRequest(response(id, failure(HEADER_MISMATCH, `'${header}' is required`)));
|
|
152
|
+
if (decode(String(stated)) !== value)
|
|
153
|
+
throw new http.BadRequest(response(id, failure(HEADER_MISMATCH, `'${header}' says '${String(stated)}' and the body says '${String(value)}'`)));
|
|
154
|
+
}
|
|
155
|
+
function metadata(params) {
|
|
156
|
+
const meta = params._meta;
|
|
157
|
+
return typeof meta === 'object' && meta !== null
|
|
158
|
+
? meta
|
|
159
|
+
: undefined;
|
|
160
|
+
}
|
|
161
|
+
function declared(params) {
|
|
162
|
+
const stated = metadata(params)?.[PROTOCOL_VERSION];
|
|
163
|
+
return typeof stated === 'string' ? stated : undefined;
|
|
164
|
+
}
|
|
165
|
+
/** What a header value that could not be written as ASCII was encoded as. */
|
|
166
|
+
function decode(value) {
|
|
167
|
+
if (!value.startsWith(SENTINEL) || !value.endsWith(TERMINATOR))
|
|
168
|
+
return value;
|
|
169
|
+
const encoded = value.slice(SENTINEL.length, -TERMINATOR.length);
|
|
170
|
+
return Buffer.from(encoded, 'base64').toString('utf8');
|
|
171
|
+
}
|
|
172
|
+
/** A tool list is what the tree holds, which stands until a branch of it expires. */
|
|
173
|
+
const TOOLS_CACHE = { ttlMs: BRANCH_TTL, cacheScope: 'private' };
|
|
174
|
+
/** What the annotation says, which is the same for every caller until the application is redeployed. */
|
|
175
|
+
const DISCOVERY_CACHE = { ttlMs: BRANCH_TTL, cacheScope: 'public' };
|
|
176
|
+
const OK = 200;
|
|
177
|
+
const ACCEPTED = 202;
|
|
178
|
+
const SENTINEL = '=?base64?';
|
|
179
|
+
const TERMINATOR = '?=';
|
|
180
|
+
//# sourceMappingURL=Server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../../source/MCP/Server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAkB,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,IAAI,EAA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AA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MCP } from '../Annotation.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a client is told before it calls anything: the revisions served, what is served, and
|
|
4
|
+
* who serves it. It is a function of the annotation alone, so it is built once and answered
|
|
5
|
+
* as it is.
|
|
6
|
+
*/
|
|
7
|
+
export interface Discovery {
|
|
8
|
+
/** `server/discover`, which the modern revision has replaced the handshake with. */
|
|
9
|
+
modern: object;
|
|
10
|
+
/** `initialize`, in the shape a client of an earlier revision reads. */
|
|
11
|
+
legacy: (offered: string | undefined) => object;
|
|
12
|
+
}
|
|
13
|
+
export declare function discovery(options: MCP): Discovery;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { LEGACY, MODERN, SERVER_INFO, VERSIONS } from './types.js';
|
|
3
|
+
export function discovery(options) {
|
|
4
|
+
const info = { name: options.name, version: VERSION };
|
|
5
|
+
// `listChanged` is a stream a client holds open, and this endpoint holds none
|
|
6
|
+
const capabilities = { tools: {} };
|
|
7
|
+
const modern = {
|
|
8
|
+
supportedVersions: VERSIONS,
|
|
9
|
+
capabilities,
|
|
10
|
+
_meta: { [SERVER_INFO]: info }
|
|
11
|
+
};
|
|
12
|
+
if (options.instructions !== undefined)
|
|
13
|
+
modern.instructions = options.instructions;
|
|
14
|
+
function legacy(offered) {
|
|
15
|
+
const value = {
|
|
16
|
+
// what the client asked for where that is served, and the newest handshake otherwise
|
|
17
|
+
protocolVersion: offered !== undefined && offered !== MODERN ? offered : LEGACY,
|
|
18
|
+
capabilities,
|
|
19
|
+
serverInfo: info
|
|
20
|
+
};
|
|
21
|
+
if (options.instructions !== undefined)
|
|
22
|
+
value.instructions = options.instructions;
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
return { modern, legacy };
|
|
26
|
+
}
|
|
27
|
+
/** What this gateway is, which is what answers however an application names itself. */
|
|
28
|
+
const VERSION = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version;
|
|
29
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../../source/MCP/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAgBlE,MAAM,UAAU,SAAS,CAAE,OAAY;IACrC,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IAErD,8EAA8E;IAC9E,MAAM,YAAY,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;IAElC,MAAM,MAAM,GAA4B;QACtC,iBAAiB,EAAE,QAAQ;QAC3B,YAAY;QACZ,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE;KAC/B,CAAA;IAED,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;QACpC,MAAM,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;IAE5C,SAAS,MAAM,CAAE,OAA2B;QAC1C,MAAM,KAAK,GAA4B;YACrC,qFAAqF;YACrF,eAAe,EAAE,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;YAC/E,YAAY;YACZ,UAAU,EAAE,IAAI;SACjB,CAAA;QAED,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;YACpC,KAAK,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;QAE3C,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AAC3B,CAAC;AAED,uFAAuF;AACvF,MAAM,OAAO,GAAW,IAAI,CAAC,KAAK,CAChC,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as http from '../HTTP/index.js';
|
|
2
|
+
import { type Failure, type Response } from './types.js';
|
|
3
|
+
export declare const PARSE = -32700;
|
|
4
|
+
export declare const INVALID_REQUEST = -32600;
|
|
5
|
+
export declare const METHOD_NOT_FOUND = -32601;
|
|
6
|
+
export declare const INVALID_PARAMS = -32602;
|
|
7
|
+
export declare const INTERNAL = -32603;
|
|
8
|
+
export declare const HEADER_MISMATCH = -32020;
|
|
9
|
+
export declare const MISSING_CAPABILITY = -32021;
|
|
10
|
+
export declare const UNSUPPORTED_VERSION = -32022;
|
|
11
|
+
export declare function failure(code: number, message: string, data?: unknown): Failure;
|
|
12
|
+
export declare function response(id: string | number | null, error: Failure): Response;
|
|
13
|
+
/**
|
|
14
|
+
* What an exception says as a JSON-RPC error.
|
|
15
|
+
*
|
|
16
|
+
* The readable text is `body`, never `message`: `http.Exception` calls `super()` with no
|
|
17
|
+
* argument, so every one of them carries an empty `message`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function of(exception: unknown): Failure;
|
|
20
|
+
/**
|
|
21
|
+
* What the call was refused with, which a model reads and may correct itself by: what the
|
|
22
|
+
* operation said, where it said anything, and otherwise what the status means here.
|
|
23
|
+
*/
|
|
24
|
+
export declare function refusal(exception: http.ClientError): string;
|