@toa.io/extensions.exposition 1.0.0-alpha.283 → 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 +29 -0
- package/components/exposition.octets/types/index.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- package/components/identity.basic/source/incept.ts +29 -1
- package/components/identity.basic/tsconfig.json +1 -1
- package/components/identity.basic/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/types/index.d.ts +3 -2
- package/components/identity.clients/operations/describe.js +1 -1
- package/components/identity.clients/operations/lib/Context.js +1 -1
- package/components/identity.clients/operations/lib/Entity.js +1 -1
- package/components/identity.clients/operations/lib/canonical.js +1 -1
- package/components/identity.clients/operations/lib/cimd.js +1 -1
- package/components/identity.clients/operations/lib/errors.js +1 -1
- package/components/identity.clients/operations/lib/index.js +1 -1
- package/components/identity.clients/operations/lib/redirect.js +1 -1
- package/components/identity.clients/operations/register.js +1 -1
- package/components/identity.clients/tsconfig.json +1 -1
- package/components/identity.clients/tsconfig.tsbuildinfo +1 -1
- package/components/identity.clients/types/index.d.ts +1 -1
- package/components/identity.credentials/operations/list.js +1 -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 +1 -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 +1 -1
- package/components/identity.federation/operations/lib/discovery.js +1 -1
- package/components/identity.federation/operations/lib/errors.js +1 -1
- package/components/identity.federation/operations/lib/exchange.js +1 -1
- 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 +8 -2
- package/components/identity.federation/source/incept.ts +7 -1
- 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/context.ts +3 -0
- package/components/identity.federation/tsconfig.json +4 -2
- package/components/identity.federation/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/types/index.d.ts +1 -1
- package/components/identity.grants/operations/authorize.js +1 -1
- package/components/identity.grants/operations/exchange.js +1 -1
- package/components/identity.grants/operations/lib/code.js +1 -1
- package/components/identity.grants/operations/lib/identify.js +1 -1
- package/components/identity.grants/operations/lib/index.js +1 -1
- package/components/identity.grants/operations/list.js +1 -1
- package/components/identity.grants/operations/revoke.js +1 -1
- package/components/identity.grants/tsconfig.json +1 -1
- package/components/identity.grants/tsconfig.tsbuildinfo +1 -1
- package/components/identity.grants/types/index.d.ts +1 -1
- 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/tsconfig.json +1 -1
- package/components/identity.keys/tsconfig.tsbuildinfo +1 -1
- package/components/identity.keys/types/index.d.ts +1 -1
- 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/tsconfig.json +1 -1
- package/components/identity.otp/tsconfig.tsbuildinfo +1 -1
- package/components/identity.otp/types/index.d.ts +1 -1
- 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/tsconfig.json +1 -1
- package/components/identity.passkeys/tsconfig.tsbuildinfo +1 -1
- package/components/identity.passkeys/types/index.d.ts +1 -1
- 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 +1 -1
- package/components/identity.tokens/operations/authenticate.js +1 -1
- package/components/identity.tokens/operations/decrypt.js +1 -1
- package/components/identity.tokens/operations/encrypt.js +1 -1
- package/components/identity.tokens/operations/issue.js +1 -1
- package/components/identity.tokens/operations/lib/form.js +1 -1
- package/components/identity.tokens/operations/lib/index.js +1 -1
- 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/tsconfig.json +1 -1
- package/components/identity.tokens/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/types/index.d.ts +1 -1
- package/documentation/access.md +13 -0
- package/documentation/components.md +3 -0
- package/documentation/introspection.md +13 -5
- package/documentation/io.md +6 -0
- package/documentation/map.md +8 -0
- package/documentation/mcp.md +180 -0
- package/documentation/oauth.md +8 -7
- package/documentation/rpc.md +140 -0
- package/documentation/tree.md +3 -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.discovery.feature +10 -11
- package/features/oauth.grants.feature +22 -9
- 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 +18 -2
- package/features/steps/Parameters.ts +18 -7
- package/features/steps/Realtime.ts +3 -0
- package/features/steps/components/echo/manifest.toa.yaml +1 -0
- package/features/steps/components/pots/manifest.toa.yaml +2 -0
- package/package.json +3 -3
- package/readme.md +3 -0
- package/schemas/annotation.cos.yaml +33 -0
- package/schemas/call.cos.yaml +18 -0
- package/source/Annotation.ts +31 -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 +5 -1
- package/source/Gateway.ts +73 -11
- package/source/HTTP/Context.ts +7 -0
- package/source/HTTP/Server.ts +7 -1
- package/source/HTTP/exceptions.ts +2 -2
- package/source/HTTP/messages.ts +10 -1
- 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 +8 -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 +62 -3
- 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 +2 -1
- 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/types.ts +21 -0
- package/source/directives/cache/Cache.ts +1 -1
- package/source/directives/dev/Development.ts +1 -1
- package/source/directives/flow/Flow.ts +1 -1
- package/source/directives/index.ts +3 -1
- package/source/directives/io/Directive.ts +1 -1
- package/source/directives/io/IO.ts +32 -3
- package/source/directives/io/Input.ts +3 -2
- package/source/directives/io/Output.ts +6 -3
- package/source/directives/io/Status.test.ts +2 -2
- package/source/directives/io/Status.ts +1 -1
- 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 +10 -16
- package/source/directives/octets/Octets.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/schemas.ts +2 -0
- package/transpiled/Annotation.d.ts +24 -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 +5 -1
- 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 +5 -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/messages.d.ts +6 -0
- package/transpiled/HTTP/messages.js +9 -1
- package/transpiled/HTTP/messages.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 +4 -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 +27 -1
- package/transpiled/directives/auth/Authorization.js +49 -1
- 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.js +2 -1
- 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/types.d.ts +16 -0
- package/transpiled/directives/cache/Cache.d.ts +1 -1
- package/transpiled/directives/cache/Cache.js +1 -1
- package/transpiled/directives/cache/Cache.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 +2 -1
- 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 +23 -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 +4 -2
- package/transpiled/directives/io/Output.js.map +1 -1
- package/transpiled/directives/io/Status.d.ts +1 -1
- package/transpiled/directives/io/Status.js +1 -1
- package/transpiled/directives/io/Status.js.map +1 -1
- 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.js +10 -13
- package/transpiled/directives/oauth/Discovery.js.map +1 -1
- 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/schemas.d.ts +2 -0
- package/transpiled/schemas.js +1 -0
- package/transpiled/schemas.js.map +1 -1
- 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 -15
- package/components/identity.basic/operations/transit.js.map +0 -1
- package/components/identity.clients/operations/describe.d.ts +0 -27
- package/components/identity.clients/operations/describe.js.map +0 -1
- package/components/identity.clients/operations/lib/Context.d.ts +0 -29
- package/components/identity.clients/operations/lib/Context.js.map +0 -1
- package/components/identity.clients/operations/lib/Entity.d.ts +0 -29
- package/components/identity.clients/operations/lib/Entity.js.map +0 -1
- package/components/identity.clients/operations/lib/canonical.d.ts +0 -11
- package/components/identity.clients/operations/lib/canonical.js.map +0 -1
- package/components/identity.clients/operations/lib/cimd.d.ts +0 -8
- package/components/identity.clients/operations/lib/cimd.js.map +0 -1
- package/components/identity.clients/operations/lib/errors.d.ts +0 -7
- package/components/identity.clients/operations/lib/errors.js.map +0 -1
- package/components/identity.clients/operations/lib/index.d.ts +0 -6
- package/components/identity.clients/operations/lib/index.js.map +0 -1
- package/components/identity.clients/operations/lib/redirect.d.ts +0 -10
- package/components/identity.clients/operations/lib/redirect.js.map +0 -1
- package/components/identity.clients/operations/register.d.ts +0 -37
- package/components/identity.clients/operations/register.js.map +0 -1
- package/components/identity.credentials/operations/list.d.ts +0 -52
- 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 -77
- 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 -36
- 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.grants/operations/authorize.d.ts +0 -35
- package/components/identity.grants/operations/authorize.js.map +0 -1
- package/components/identity.grants/operations/exchange.d.ts +0 -37
- package/components/identity.grants/operations/exchange.js.map +0 -1
- package/components/identity.grants/operations/lib/code.d.ts +0 -15
- package/components/identity.grants/operations/lib/code.js.map +0 -1
- package/components/identity.grants/operations/lib/identify.d.ts +0 -6
- package/components/identity.grants/operations/lib/identify.js.map +0 -1
- package/components/identity.grants/operations/lib/index.d.ts +0 -3
- package/components/identity.grants/operations/lib/index.js.map +0 -1
- package/components/identity.grants/operations/list.d.ts +0 -13
- package/components/identity.grants/operations/list.js.map +0 -1
- package/components/identity.grants/operations/revoke.d.ts +0 -18
- package/components/identity.grants/operations/revoke.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 -16
- 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 -16
- 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 -10
- package/components/identity.tokens/operations/authenticate.js.map +0 -1
- package/components/identity.tokens/operations/decrypt.d.ts +0 -16
- package/components/identity.tokens/operations/decrypt.js.map +0 -1
- package/components/identity.tokens/operations/encrypt.d.ts +0 -9
- package/components/identity.tokens/operations/encrypt.js.map +0 -1
- package/components/identity.tokens/operations/issue.d.ts +0 -25
- package/components/identity.tokens/operations/issue.js.map +0 -1
- package/components/identity.tokens/operations/lib/form.d.ts +0 -8
- package/components/identity.tokens/operations/lib/form.js.map +0 -1
- package/components/identity.tokens/operations/lib/index.d.ts +0 -4
- 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/revoke.d.ts +0 -2
- package/components/identity.tokens/operations/revoke.js.map +0 -1
|
@@ -36,6 +36,19 @@ export class Role implements Directive {
|
|
|
36
36
|
return this.match(identity.roles, parameters)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** A role naming a route variable cannot be told from a description, which has no values. */
|
|
40
|
+
public async admits (identity: Identity | null): Promise<boolean | undefined> {
|
|
41
|
+
if (this.dynamic)
|
|
42
|
+
return undefined
|
|
43
|
+
|
|
44
|
+
if (identity === null)
|
|
45
|
+
return false
|
|
46
|
+
|
|
47
|
+
identity.roles ??= await Role.get(identity, this.discovery)
|
|
48
|
+
|
|
49
|
+
return this.match(identity.roles, [])
|
|
50
|
+
}
|
|
51
|
+
|
|
39
52
|
private match (roles: string[], parameters: Parameter[]): boolean {
|
|
40
53
|
const required = this.dynamic ? this.substitute(parameters) : this.roles
|
|
41
54
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Parameter } from '../../RTD/index.js'
|
|
2
|
+
import type { Introspection } from '../../Introspection.js'
|
|
2
3
|
import type { Context, Directive, Identity, Create } from './types.js'
|
|
3
4
|
|
|
4
5
|
export class Rule implements Directive {
|
|
@@ -22,4 +23,32 @@ export class Rule implements Directive {
|
|
|
22
23
|
|
|
23
24
|
return true
|
|
24
25
|
}
|
|
26
|
+
|
|
27
|
+
/** Whatever each of them makes of it, in the order they were declared. */
|
|
28
|
+
public describe (introspection: Introspection): Introspection {
|
|
29
|
+
for (const directive of this.directives)
|
|
30
|
+
introspection = directive.describe?.(introspection) ?? introspection
|
|
31
|
+
|
|
32
|
+
return introspection
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** All of them, so one that refuses ends it and one that cannot tell leaves it untold. */
|
|
36
|
+
public async admits (identity: Identity | null, context: Context): Promise<boolean | undefined> {
|
|
37
|
+
let untold = false
|
|
38
|
+
|
|
39
|
+
for (const directive of this.directives) {
|
|
40
|
+
const admits = await directive.admits?.(identity, context)
|
|
41
|
+
|
|
42
|
+
if (admits === undefined) {
|
|
43
|
+
untold = true
|
|
44
|
+
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!admits)
|
|
49
|
+
return false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return untold ? undefined : true
|
|
53
|
+
}
|
|
25
54
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Component } from '@toa.io/core'
|
|
2
2
|
import { type Maybe } from '@toa.io/core'
|
|
3
3
|
import { type Parameter } from '../../RTD/index.js'
|
|
4
|
+
import type { Introspection } from '../../Introspection.js'
|
|
4
5
|
import type * as http from '../../HTTP/index.js'
|
|
5
6
|
import type * as io from '../../io.js'
|
|
6
7
|
|
|
@@ -13,6 +14,26 @@ export interface Directive {
|
|
|
13
14
|
parameters: Parameter[]
|
|
14
15
|
) => boolean | Promise<boolean>
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Whether this admits the identity where that can be told without a request — which is
|
|
19
|
+
* what describing a method is. `undefined` says it cannot be told: a directive reading a
|
|
20
|
+
* route variable's value or the body has neither here, and one that is not implemented
|
|
21
|
+
* says the same by its absence. Nothing here may have an effect on the request.
|
|
22
|
+
*/
|
|
23
|
+
admits?: (
|
|
24
|
+
identity: Identity | null,
|
|
25
|
+
context: Context
|
|
26
|
+
) => boolean | undefined | Promise<boolean | undefined>
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* What this directive makes of what the method says about itself, which is the reverse of
|
|
30
|
+
* what it does to a request: a property it fills from the identity is taken out of the
|
|
31
|
+
* input, because it is not the caller's to send — and a description that offers one invites
|
|
32
|
+
* a caller to name an identity that is not theirs. Nothing here may have an effect on the
|
|
33
|
+
* request.
|
|
34
|
+
*/
|
|
35
|
+
describe?: (introspection: Introspection) => Introspection
|
|
36
|
+
|
|
16
37
|
reply?: (context: Context) => http.OutgoingMessage | null
|
|
17
38
|
|
|
18
39
|
settle?: (context: Context, response: http.OutgoingMessage) => Promise<void>
|
|
@@ -19,7 +19,7 @@ export class Development implements DirectiveFamily<Directive> {
|
|
|
19
19
|
return new Class(value)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
public async
|
|
22
|
+
public async precall (directives: Directive[], input: Input): Promise<Output> {
|
|
23
23
|
let output = null
|
|
24
24
|
|
|
25
25
|
for (const directive of directives) {
|
|
@@ -18,7 +18,7 @@ export class Flow implements DirectiveFamily<Directive> {
|
|
|
18
18
|
return new Class(value, remotes)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
public async
|
|
21
|
+
public async precall (directives: Directive[], input: Input, parameters: Parameter[]): Promise<Output> {
|
|
22
22
|
for (const directive of directives) {
|
|
23
23
|
if (directive.attach !== undefined)
|
|
24
24
|
directive.attach(input)
|
|
@@ -5,11 +5,13 @@ import { dev } from './dev/index.js'
|
|
|
5
5
|
import { octets } from './octets/index.js'
|
|
6
6
|
import { io } from './io/index.js'
|
|
7
7
|
import { map } from './map/index.js'
|
|
8
|
+
import { mcp } from './mcp/index.js'
|
|
8
9
|
import { req } from './require/index.js'
|
|
9
10
|
import { flow } from './flow/index.js'
|
|
10
11
|
import { discovery } from './oauth/index.js'
|
|
11
12
|
import type { DirectiveFamily } from '../RTD/index.js'
|
|
12
13
|
import type { Interceptor } from '../Interception.js'
|
|
13
14
|
|
|
14
|
-
export const families: DirectiveFamily[] =
|
|
15
|
+
export const families: DirectiveFamily[] =
|
|
16
|
+
[authorization, io, cache, map, mcp, req, flow, octets, dev]
|
|
15
17
|
export const interceptors: Interceptor[] = [cors, discovery]
|
|
@@ -4,7 +4,7 @@ import type { Input as Context } from '../../io.js'
|
|
|
4
4
|
import type * as http from '../../HTTP/index.js'
|
|
5
5
|
|
|
6
6
|
export interface Directive {
|
|
7
|
-
|
|
7
|
+
precall: (context: Context, parameters: Parameter[]) => void
|
|
8
8
|
|
|
9
9
|
/** Synchronous by contract: settling holds the response, and none of it needs I/O. */
|
|
10
10
|
settle?: (context: Context, response: http.OutgoingMessage) => void
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { restrict } from '../../Introspection.js'
|
|
1
2
|
import { Output } from './Output.js'
|
|
2
3
|
import { Input } from './Input.js'
|
|
3
4
|
import { Throttle } from './Throttle.js'
|
|
@@ -7,6 +8,7 @@ import type * as http from '../../HTTP/index.js'
|
|
|
7
8
|
import type { Parameter, DirectiveFamily } from '../../RTD/index.js'
|
|
8
9
|
import type { Remotes } from '../../Remotes.js'
|
|
9
10
|
import type { Constructor, Directive } from './Directive.js'
|
|
11
|
+
import type { Introspection } from '../../Introspection.js'
|
|
10
12
|
import { ATOM_GROUP } from '../../const.js'
|
|
11
13
|
import type { extensions } from '@toa.io/core'
|
|
12
14
|
|
|
@@ -38,22 +40,49 @@ export class IO implements DirectiveFamily<Directive> {
|
|
|
38
40
|
return new Directive(value, this.sync!, route)
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
public
|
|
43
|
+
public precall (directives: Directive[], context: http.Context,
|
|
42
44
|
parameters: Parameter[]): null {
|
|
43
45
|
let restricted = false
|
|
44
46
|
|
|
45
47
|
for (const directive of directives) {
|
|
46
48
|
restricted ||= directive instanceof Output
|
|
47
49
|
|
|
48
|
-
directive.
|
|
50
|
+
directive.precall(context, parameters)
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
if (!restricted)
|
|
52
|
-
DENIAL.
|
|
54
|
+
DENIAL.precall(context, parameters)
|
|
53
55
|
|
|
54
56
|
return null
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* What a whitelist admits is what the schema states. Without an `io:output` the reply is
|
|
61
|
+
* dropped before it is sent, so there is no output to describe at all.
|
|
62
|
+
*/
|
|
63
|
+
public explain (directives: Directive[], _: http.Context,
|
|
64
|
+
introspection: Introspection): Introspection {
|
|
65
|
+
let restricted = false
|
|
66
|
+
|
|
67
|
+
for (const directive of directives) {
|
|
68
|
+
if (directive instanceof Input)
|
|
69
|
+
introspection.input = restrict(introspection.input, directive.allowed)
|
|
70
|
+
|
|
71
|
+
if (!(directive instanceof Output))
|
|
72
|
+
continue
|
|
73
|
+
|
|
74
|
+
restricted = true
|
|
75
|
+
|
|
76
|
+
if (!directive.disabled)
|
|
77
|
+
introspection.output = restrict(introspection.output, directive.allowed)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!restricted)
|
|
81
|
+
delete introspection.output
|
|
82
|
+
|
|
83
|
+
return introspection
|
|
84
|
+
}
|
|
85
|
+
|
|
57
86
|
public settle (directives: Directive[], context: http.Context,
|
|
58
87
|
output: http.OutgoingMessage): void {
|
|
59
88
|
for (const directive of directives)
|
|
@@ -5,7 +5,8 @@ import type { Directive } from './Directive.js'
|
|
|
5
5
|
import type { Input as Context } from '../../io.js'
|
|
6
6
|
|
|
7
7
|
export class Input implements Directive {
|
|
8
|
-
|
|
8
|
+
/** what a client may send, which is therefore what the input schema states */
|
|
9
|
+
public readonly allowed: Set<string>
|
|
9
10
|
|
|
10
11
|
public constructor (permissions: Permissions) {
|
|
11
12
|
this.allowed = new Set(permissions)
|
|
@@ -15,7 +16,7 @@ export class Input implements Directive {
|
|
|
15
16
|
schemas.input.validate<Permissions>(permissions, 'Incorrect \'io:input\' format')
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
public
|
|
19
|
+
public precall (context: Context): void {
|
|
19
20
|
// Restrictions are on what the client sent, so the check goes to the front of the
|
|
20
21
|
// pipeline whatever order the families ran in: `auth:delegate` embeds the identity
|
|
21
22
|
// and `map:*` assigns mapped properties, and those additions are the server's own,
|
|
@@ -7,10 +7,13 @@ import type { Input as Context } from '../../io.js'
|
|
|
7
7
|
import type { OutgoingMessage } from '../../HTTP/index.js'
|
|
8
8
|
|
|
9
9
|
export class Output implements Directive {
|
|
10
|
-
|
|
10
|
+
/** whether the reply passes whole, which is when the schema is the operation's own */
|
|
11
|
+
public readonly disabled: boolean = false
|
|
12
|
+
|
|
13
|
+
/** what a reply may carry, which is therefore what the output schema states */
|
|
14
|
+
public readonly allowed: Set<string>
|
|
11
15
|
private readonly omitted: boolean = true
|
|
12
16
|
private readonly permissions: string[] = []
|
|
13
|
-
private readonly allowed: Set<string>
|
|
14
17
|
|
|
15
18
|
public constructor (permissions: Permissions) {
|
|
16
19
|
if (typeof permissions === 'boolean')
|
|
@@ -29,7 +32,7 @@ export class Output implements Directive {
|
|
|
29
32
|
schemas.output.validate(permissions, 'Incorrect \'io:output\' format')
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
public
|
|
35
|
+
public precall (context: Context): void {
|
|
33
36
|
context.pipelines.response.push(this.restriction(context))
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -47,7 +47,7 @@ it('should have a reply it named the status of restricted, whatever that status
|
|
|
47
47
|
const ctx = context()
|
|
48
48
|
const output = new Output(['code', 'error'])
|
|
49
49
|
|
|
50
|
-
output.
|
|
50
|
+
output.precall(ctx, [])
|
|
51
51
|
|
|
52
52
|
const response: OutgoingMessage = {
|
|
53
53
|
body: { status: stated, code: 'SplxlO', error: 'invalid_grant', secret: 'x' }
|
|
@@ -67,7 +67,7 @@ it('should leave a failure the gateway built alone, on such a route too', () =>
|
|
|
67
67
|
const ctx = context()
|
|
68
68
|
const output = new Output(['code'])
|
|
69
69
|
|
|
70
|
-
output.
|
|
70
|
+
output.precall(ctx, [])
|
|
71
71
|
|
|
72
72
|
// what `Server.fail` builds out of an exception, on a route that also declares `io:status`
|
|
73
73
|
const response: OutgoingMessage = {
|
|
@@ -18,7 +18,7 @@ export class Throttle implements Directive {
|
|
|
18
18
|
schemas.throttle.validate(declaration, 'Incorrect \'io:throttle\' format')
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
public
|
|
21
|
+
public precall (context: http.Context, parameters: Parameter[]): void {
|
|
22
22
|
const retry = this.quotas.check(context, parameters)
|
|
23
23
|
|
|
24
24
|
if (retry > 0)
|
|
@@ -34,7 +34,7 @@ export class Quotas {
|
|
|
34
34
|
private readonly entries = new Map<string, Entry>()
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* The key computed at
|
|
37
|
+
* The key computed at precall, for settle to charge against.
|
|
38
38
|
*
|
|
39
39
|
* `segment` reads the route parameters, which settle is not given, and `identity`
|
|
40
40
|
* can be refreshed between the two — so recomputing there would key a request
|
|
@@ -97,7 +97,7 @@ export class Quotas {
|
|
|
97
97
|
if (!this.conditional || !this.keys.matches(input, output))
|
|
98
98
|
return
|
|
99
99
|
|
|
100
|
-
//
|
|
100
|
+
// precall always runs first, and a request it refuses never reaches settle
|
|
101
101
|
const key = this.keyed.get(input) ?? this.keys.get(input)
|
|
102
102
|
|
|
103
103
|
if (key === undefined)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
2
|
import { cors } from '../cors/index.js'
|
|
3
3
|
import { Mapping } from './Mapping.js'
|
|
4
|
+
import { take } from '../../Introspection.js'
|
|
4
5
|
import type { Input } from '../../io.js'
|
|
6
|
+
import type { Introspection } from '../../Introspection.js'
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Forbidden request header names: the browser sets them itself and a script cannot
|
|
@@ -25,6 +27,15 @@ export class Headers extends Mapping<Record<string, string>> {
|
|
|
25
27
|
this.headers.forEach((header) => cors.allow(header))
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
public override explain (introspection: Introspection): void {
|
|
31
|
+
for (const [property, header] of Object.entries(this.value)) {
|
|
32
|
+
const schema = take(introspection, property)
|
|
33
|
+
|
|
34
|
+
introspection.headers ??= {}
|
|
35
|
+
introspection.headers[property] = { ...schema, header }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
public properties (context: Input): Record<string, string> {
|
|
29
40
|
context.pipelines.response.push((response) => {
|
|
30
41
|
response.headers ??= new global.Headers()
|
|
@@ -12,6 +12,7 @@ import type { Directive } from './Directive.js'
|
|
|
12
12
|
import type { Properties } from './Properties.js'
|
|
13
13
|
import type { DirectiveFamily, Parameter } from '../../RTD/index.js'
|
|
14
14
|
import type { Input, Output } from '../../io.js'
|
|
15
|
+
import type { Introspection } from '../../Introspection.js'
|
|
15
16
|
import type { Remotes } from '../../Remotes.js'
|
|
16
17
|
|
|
17
18
|
export class Map implements DirectiveFamily {
|
|
@@ -31,7 +32,15 @@ export class Map implements DirectiveFamily {
|
|
|
31
32
|
})
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
public
|
|
35
|
+
public explain (directives: Directive[], _: Input, introspection: Introspection): Introspection {
|
|
36
|
+
for (const directive of directives)
|
|
37
|
+
if (directive instanceof Mapping)
|
|
38
|
+
directive.explain(introspection)
|
|
39
|
+
|
|
40
|
+
return introspection
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public async precall (directives: Directive[], context: Input, parameters: Parameter[]): Promise<Output> {
|
|
35
44
|
const properties = {}
|
|
36
45
|
|
|
37
46
|
for (const directive of directives)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { take } from '../../Introspection.js'
|
|
1
2
|
import type { Remotes } from '../../Remotes.js'
|
|
2
3
|
import type { Directive } from './Directive.js'
|
|
3
4
|
import type { Input } from '../../io.js'
|
|
4
5
|
import type { Parameter } from '../../RTD/index.js'
|
|
6
|
+
import type { Introspection } from '../../Introspection.js'
|
|
5
7
|
|
|
6
8
|
export abstract class Mapping<T = unknown> {
|
|
7
9
|
protected value: T
|
|
@@ -13,6 +15,27 @@ export abstract class Mapping<T = unknown> {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
public abstract properties (context: Input, parameters: Parameter[], directives: Directive[]): Output
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* What this mapping does to what the method says about itself, which is the reverse of
|
|
21
|
+
* what it does to a request: a property the gateway fills is taken out of the input,
|
|
22
|
+
* because it is not the caller's to send.
|
|
23
|
+
*
|
|
24
|
+
* The default says nothing more than that. A claim, an authority and a language come
|
|
25
|
+
* from the request itself and there is nowhere for a caller to put one; a header and a
|
|
26
|
+
* segment are the caller's, and those say where.
|
|
27
|
+
*/
|
|
28
|
+
public explain (introspection: Introspection): void {
|
|
29
|
+
for (const property of this.names())
|
|
30
|
+
take(introspection, property)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The input properties this mapping fills, however its value names them. */
|
|
34
|
+
protected names (): string[] {
|
|
35
|
+
return typeof this.value === 'string'
|
|
36
|
+
? [this.value]
|
|
37
|
+
: Object.keys(this.value as object)
|
|
38
|
+
}
|
|
16
39
|
}
|
|
17
40
|
|
|
18
41
|
type Properties = Record<string, unknown> | null
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
2
|
import { Mapping } from './Mapping.js'
|
|
3
|
+
import { take } from '../../Introspection.js'
|
|
3
4
|
import type { Parameter } from '../../RTD/index.js'
|
|
5
|
+
import type { Introspection, Schema } from '../../Introspection.js'
|
|
4
6
|
|
|
5
7
|
export class Segments extends Mapping<Record<string, string>> {
|
|
6
8
|
public constructor (map: Record<string, string>) {
|
|
@@ -12,6 +14,16 @@ export class Segments extends Mapping<Record<string, string>> {
|
|
|
12
14
|
super(map)
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
/** A segment is the caller's, so it moves to the route rather than out of sight. */
|
|
18
|
+
public override explain (introspection: Introspection): void {
|
|
19
|
+
for (const property of Object.keys(this.value)) {
|
|
20
|
+
const schema = take(introspection, property)
|
|
21
|
+
|
|
22
|
+
introspection.route ??= {}
|
|
23
|
+
introspection.route[property] = schema ?? ({ type: 'string' } as unknown as Schema)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
public override properties (_: unknown, parameters: Parameter[]): Record<string, string> {
|
|
16
28
|
return Object.entries(this.value).reduce((properties: Record<string, string>, [property, parameter]) => {
|
|
17
29
|
const cut = parameter[0] === '~'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
2
|
+
import { Tool } from './Tool.js'
|
|
3
|
+
import type { Context } from '../../HTTP/index.js'
|
|
4
|
+
import type { Introspection } from '../../Introspection.js'
|
|
5
|
+
import type { DirectiveFamily } from '../../RTD/index.js'
|
|
6
|
+
|
|
7
|
+
/** The name the family is declared under, and what `MCP` asks a method for. */
|
|
8
|
+
export const FAMILY = 'mcp'
|
|
9
|
+
|
|
10
|
+
export class MCP implements DirectiveFamily<Tool> {
|
|
11
|
+
public readonly name = FAMILY
|
|
12
|
+
public readonly mandatory = false
|
|
13
|
+
|
|
14
|
+
/** What this method is published as, which is what the nearest declaration says. */
|
|
15
|
+
public static published (directives: Tool[] | undefined): Tool | null {
|
|
16
|
+
return directives?.[0] ?? null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line max-params
|
|
20
|
+
public create (name: string, value: unknown, _: unknown, route: string): Tool {
|
|
21
|
+
assert.ok(name === 'tool', `Unknown directive: mcp:${name}`)
|
|
22
|
+
|
|
23
|
+
return new Tool(value, route)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** What the route states this method is, which is the only thing that states it. */
|
|
27
|
+
public explain (directives: Tool[], _: Context,
|
|
28
|
+
introspection: Introspection): Introspection {
|
|
29
|
+
const tool = MCP.published(directives)
|
|
30
|
+
|
|
31
|
+
return tool === null ? introspection : { ...introspection, description: tool.description }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
2
|
+
import { describe, it } from 'node:test'
|
|
3
|
+
import { Tool } from './Tool.js'
|
|
4
|
+
import { MCP } from './MCP.js'
|
|
5
|
+
|
|
6
|
+
describe('mcp:tool', () => {
|
|
7
|
+
it('should take what the route states the tool is', () => {
|
|
8
|
+
assert.strictEqual(new Tool('The pots that are hot.', '/pots/hot').description,
|
|
9
|
+
'The pots that are hot.')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('should not accept an empty description', () => {
|
|
13
|
+
assert.throws(() => new Tool(' ', '/pots'), /cannot be empty/)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should not accept a value that is not one', () => {
|
|
17
|
+
// `true` published a tool that stated nothing, back when an operation stated it instead
|
|
18
|
+
assert.throws(() => new Tool(true, '/pots'), /the value is what the tool is/)
|
|
19
|
+
assert.throws(() => new Tool(false, '/pots'), /the value is what the tool is/)
|
|
20
|
+
assert.throws(() => new Tool(1, '/pots'), /the value is what the tool is/)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should refuse a route no name can spell', () => {
|
|
24
|
+
assert.throws(() => new Tool('A pot.', '/pots/a.b'), /no tool name can spell/)
|
|
25
|
+
assert.throws(() => new Tool('A pot.', '/pots/:a.b'), /no tool name can spell/)
|
|
26
|
+
|
|
27
|
+
// an underscore is what the convention keeps for itself
|
|
28
|
+
assert.throws(() => new Tool('A pot.', '/pots/a_b'), /no tool name can spell/)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should name the route it refuses', () => {
|
|
32
|
+
assert.throws(() => new Tool('A pot.', '/pots/a.b'), /'\/pots\/a\.b'/)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe('mcp:tool inheritance', () => {
|
|
37
|
+
const family = new MCP()
|
|
38
|
+
|
|
39
|
+
it('should take the nearest declaration', () => {
|
|
40
|
+
const own = new Tool('Nearest.', '/pots')
|
|
41
|
+
const inherited = new Tool('Furthest.', '/pots')
|
|
42
|
+
|
|
43
|
+
assert.strictEqual(MCP.published([own, inherited])?.description, 'Nearest.')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should publish nothing where nothing is declared', () => {
|
|
47
|
+
assert.strictEqual(MCP.published(undefined), null)
|
|
48
|
+
assert.strictEqual(MCP.published([]), null)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('should describe a method with what the route states', () => {
|
|
52
|
+
const described = family.explain([new Tool('What the route is.', '/pots')], null as never,
|
|
53
|
+
{ description: 'What the operation is.' })
|
|
54
|
+
|
|
55
|
+
assert.strictEqual(described.description, 'What the route is.')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should state nothing where nothing is declared', () => {
|
|
59
|
+
assert.strictEqual(family.explain([], null as never, {}).description, undefined)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('should refuse a directive it does not know', () => {
|
|
63
|
+
assert.throws(() => family.create('resource', 'A pot.', null, '/pots'),
|
|
64
|
+
/Unknown directive: mcp:resource/)
|
|
65
|
+
})
|
|
66
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
2
|
+
import { refusal } from '../../RPC/names.js'
|
|
3
|
+
import { segment } from '../../RTD/segment.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What one method is, published to a model. Declaring it is what publishes it, and what it
|
|
7
|
+
* says is what it says it is: a tool a model cannot read the purpose of is one it cannot
|
|
8
|
+
* choose, so there is no way to publish one that states nothing.
|
|
9
|
+
*
|
|
10
|
+
* The operation states what it is too, and that is not this. An operation is written without
|
|
11
|
+
* knowledge of any route, and a tool is an operation and a route together — the same
|
|
12
|
+
* operation mounted twice is two tools, and one sentence cannot be true of both.
|
|
13
|
+
*/
|
|
14
|
+
export class Tool {
|
|
15
|
+
public readonly description: string
|
|
16
|
+
|
|
17
|
+
public constructor (value: unknown, route: string) {
|
|
18
|
+
assert.ok(typeof value === 'string' && value.trim().length > 0,
|
|
19
|
+
'Directive mcp:tool: the value is what the tool is, which cannot be empty')
|
|
20
|
+
|
|
21
|
+
// a tool is called by name, so a route that cannot be named cannot be one — said where
|
|
22
|
+
// the mistake is, rather than as a tool that is quietly never listed
|
|
23
|
+
assert.ok(refusal(segment(route)) === null,
|
|
24
|
+
`Directive mcp:tool: '${route}' holds a segment no tool name can spell`)
|
|
25
|
+
|
|
26
|
+
this.description = value
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -26,8 +26,17 @@ export class Discovery implements Interceptor {
|
|
|
26
26
|
if (options.oauth === undefined)
|
|
27
27
|
return
|
|
28
28
|
|
|
29
|
+
/*
|
|
30
|
+
* `https` always: RFC 8414 has an issuer be one, and OAuth 2.1 has every endpoint of an
|
|
31
|
+
* authorization server be one — the loopback exception is a client's redirect URI, not
|
|
32
|
+
* a server's address. A gateway served without TLS has no authorization server a client
|
|
33
|
+
* may use, and naming it `http` would hide that behind documents none should accept.
|
|
34
|
+
*
|
|
35
|
+
* The host is the configured one, not the request's, which is the client's to write: a
|
|
36
|
+
* forged one would have these documents name someone else's token endpoint.
|
|
37
|
+
*/
|
|
29
38
|
for (const [authority, host] of Object.entries(options.authorities))
|
|
30
|
-
this.authorities.set(authority, documents(
|
|
39
|
+
this.authorities.set(authority, documents(`https://${host}`, options.oauth))
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
public reset (): void {
|
|
@@ -58,19 +67,4 @@ export class Discovery implements Interceptor {
|
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
69
|
|
|
61
|
-
/**
|
|
62
|
-
* The absolute URL an authority is reached at. Loopback is served over http and everything
|
|
63
|
-
* else over https: the gateway may sit behind a terminating proxy, so the connection does
|
|
64
|
-
* not say which, and the configured host does. Taken from the configuration rather than
|
|
65
|
-
* from the request's `host`, which is the client's to write.
|
|
66
|
-
*/
|
|
67
|
-
function origin (host: string): string {
|
|
68
|
-
const name = host.split(':')[0]
|
|
69
|
-
|
|
70
|
-
const loopback = name === 'localhost' || name === '127.0.0.1' || name === '[::1]' ||
|
|
71
|
-
name.endsWith('.localhost')
|
|
72
|
-
|
|
73
|
-
return `${loopback ? 'http' : 'https'}://${host}`
|
|
74
|
-
}
|
|
75
|
-
|
|
76
70
|
const UNAUTHORIZED = 401
|
|
@@ -28,7 +28,7 @@ export class Octets implements DirectiveFamily<Directive> {
|
|
|
28
28
|
return new Class(value, this.discovery, remotes)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
public async
|
|
31
|
+
public async precall (directives: Directive[], input: Input, parameters: Parameter[]): Promise<Output> {
|
|
32
32
|
let context: Context | null = null
|
|
33
33
|
let action: Directive | null = null
|
|
34
34
|
|
|
@@ -12,7 +12,7 @@ export class Headers implements Directive {
|
|
|
12
12
|
this.headers = headers
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
public
|
|
15
|
+
public precall (context: Input): void {
|
|
16
16
|
for (const header of this.headers)
|
|
17
17
|
if (context.request.headers[header] === undefined)
|
|
18
18
|
throw new BadRequest(`Header required: ${header}`)
|