@frontmcp/sdk 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -18
- package/package.json +20 -5
- package/src/app/app.registry.d.ts +3 -2
- package/src/app/app.registry.js +3 -1
- package/src/app/app.registry.js.map +1 -1
- package/src/app/instances/app.local.instance.js +2 -2
- package/src/app/instances/app.local.instance.js.map +1 -1
- package/src/auth/auth.registry.d.ts +34 -2
- package/src/auth/auth.registry.js +162 -24
- package/src/auth/auth.registry.js.map +1 -1
- package/src/auth/auth.utils.js +8 -9
- package/src/auth/auth.utils.js.map +1 -1
- package/src/auth/authorization/authorization.class.d.ts +125 -0
- package/src/auth/authorization/authorization.class.js +224 -0
- package/src/auth/authorization/authorization.class.js.map +1 -0
- package/src/auth/authorization/authorization.types.d.ts +300 -0
- package/src/auth/authorization/authorization.types.js +79 -0
- package/src/auth/authorization/authorization.types.js.map +1 -0
- package/src/auth/authorization/index.d.ts +5 -0
- package/src/auth/authorization/index.js +19 -0
- package/src/auth/authorization/index.js.map +1 -0
- package/src/auth/authorization/orchestrated.authorization.d.ts +242 -0
- package/src/auth/authorization/orchestrated.authorization.js +306 -0
- package/src/auth/authorization/orchestrated.authorization.js.map +1 -0
- package/src/auth/authorization/public.authorization.d.ts +91 -0
- package/src/auth/authorization/public.authorization.js +132 -0
- package/src/auth/authorization/public.authorization.js.map +1 -0
- package/src/auth/authorization/transparent.authorization.d.ts +130 -0
- package/src/auth/authorization/transparent.authorization.js +147 -0
- package/src/auth/authorization/transparent.authorization.js.map +1 -0
- package/src/auth/consent/consent.types.d.ts +111 -0
- package/src/auth/consent/consent.types.js +119 -0
- package/src/auth/consent/consent.types.js.map +1 -0
- package/src/auth/consent/index.d.ts +1 -0
- package/src/auth/consent/index.js +13 -0
- package/src/auth/consent/index.js.map +1 -0
- package/src/auth/detection/auth-provider-detection.d.ts +84 -0
- package/src/auth/detection/auth-provider-detection.js +230 -0
- package/src/auth/detection/auth-provider-detection.js.map +1 -0
- package/src/auth/detection/index.d.ts +1 -0
- package/src/auth/detection/index.js +15 -0
- package/src/auth/detection/index.js.map +1 -0
- package/src/auth/flows/auth.verify.flow.d.ts +110 -0
- package/src/auth/flows/auth.verify.flow.js +379 -0
- package/src/auth/flows/auth.verify.flow.js.map +1 -0
- package/src/auth/flows/oauth.authorize.flow.d.ts +118 -164
- package/src/auth/flows/oauth.authorize.flow.js +701 -33
- package/src/auth/flows/oauth.authorize.flow.js.map +1 -1
- package/src/auth/flows/oauth.callback.flow.d.ts +117 -0
- package/src/auth/flows/oauth.callback.flow.js +357 -0
- package/src/auth/flows/oauth.callback.flow.js.map +1 -0
- package/src/auth/flows/oauth.register.flow.d.ts +32 -125
- package/src/auth/flows/oauth.token.flow.d.ts +52 -154
- package/src/auth/flows/oauth.token.flow.js +193 -55
- package/src/auth/flows/oauth.token.flow.js.map +1 -1
- package/src/auth/flows/session.verify.flow.d.ts +66 -321
- package/src/auth/flows/session.verify.flow.js +107 -18
- package/src/auth/flows/session.verify.flow.js.map +1 -1
- package/src/auth/flows/well-known.jwks.flow.d.ts +34 -205
- package/src/auth/flows/well-known.jwks.flow.js +15 -8
- package/src/auth/flows/well-known.jwks.flow.js.map +1 -1
- package/src/auth/flows/well-known.oauth-authorization-server.flow.d.ts +48 -223
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js +2 -3
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js.map +1 -1
- package/src/auth/flows/well-known.prm.flow.d.ts +19 -120
- package/src/auth/flows/well-known.prm.flow.js +3 -4
- package/src/auth/flows/well-known.prm.flow.js.map +1 -1
- package/src/auth/instances/instance.local-primary-auth.d.ts +91 -4
- package/src/auth/instances/instance.local-primary-auth.js +236 -6
- package/src/auth/instances/instance.local-primary-auth.js.map +1 -1
- package/src/auth/instances/instance.remote-primary-auth.d.ts +4 -3
- package/src/auth/instances/instance.remote-primary-auth.js +2 -2
- package/src/auth/instances/instance.remote-primary-auth.js.map +1 -1
- package/src/auth/session/authorization-vault.d.ts +611 -0
- package/src/auth/session/authorization-vault.js +817 -0
- package/src/auth/session/authorization-vault.js.map +1 -0
- package/src/auth/session/authorization.store.d.ts +301 -0
- package/src/auth/session/authorization.store.js +323 -0
- package/src/auth/session/authorization.store.js.map +1 -0
- package/src/auth/session/encrypted-authorization-vault.d.ts +181 -0
- package/src/auth/session/encrypted-authorization-vault.js +493 -0
- package/src/auth/session/encrypted-authorization-vault.js.map +1 -0
- package/src/auth/session/index.d.ts +4 -4
- package/src/auth/session/index.js +11 -7
- package/src/auth/session/index.js.map +1 -1
- package/src/auth/session/session.schema.d.ts +1 -1
- package/src/auth/session/session.service.d.ts +1 -1
- package/src/auth/session/transport-session.manager.d.ts +101 -0
- package/src/auth/session/transport-session.manager.js +300 -0
- package/src/auth/session/transport-session.manager.js.map +1 -0
- package/src/auth/session/transport-session.types.d.ts +457 -0
- package/src/auth/session/transport-session.types.js +110 -0
- package/src/auth/session/transport-session.types.js.map +1 -0
- package/src/auth/session/utils/session-id.utils.d.ts +14 -2
- package/src/auth/session/utils/session-id.utils.js +68 -19
- package/src/auth/session/utils/session-id.utils.js.map +1 -1
- package/src/auth/session/vault-encryption.d.ts +189 -0
- package/src/auth/session/vault-encryption.js +263 -0
- package/src/auth/session/vault-encryption.js.map +1 -0
- package/src/auth/ui/base-layout.d.ts +188 -0
- package/src/auth/ui/base-layout.js +292 -0
- package/src/auth/ui/base-layout.js.map +1 -0
- package/src/auth/ui/htmx-templates.d.ts +135 -0
- package/src/auth/ui/htmx-templates.js +433 -0
- package/src/auth/ui/htmx-templates.js.map +1 -0
- package/src/auth/ui/index.d.ts +11 -0
- package/src/auth/ui/index.js +35 -0
- package/src/auth/ui/index.js.map +1 -0
- package/src/auth/utils/audience.validator.d.ts +129 -0
- package/src/auth/utils/audience.validator.js +196 -0
- package/src/auth/utils/audience.validator.js.map +1 -0
- package/src/auth/utils/index.d.ts +2 -0
- package/src/auth/utils/index.js +7 -0
- package/src/auth/utils/index.js.map +1 -0
- package/src/auth/utils/www-authenticate.utils.d.ts +97 -0
- package/src/auth/utils/www-authenticate.utils.js +183 -0
- package/src/auth/utils/www-authenticate.utils.js.map +1 -0
- package/src/common/common.schema.d.ts +2 -16
- package/src/common/constants.d.ts +3 -0
- package/src/common/constants.js +6 -1
- package/src/common/constants.js.map +1 -1
- package/src/common/decorators/decorator-utils.d.ts +131 -0
- package/src/common/decorators/decorator-utils.js +195 -0
- package/src/common/decorators/decorator-utils.js.map +1 -0
- package/src/common/decorators/front-mcp.decorator.js +3 -2
- package/src/common/decorators/front-mcp.decorator.js.map +1 -1
- package/src/common/decorators/hook.decorator.d.ts +58 -2
- package/src/common/decorators/hook.decorator.js +127 -17
- package/src/common/decorators/hook.decorator.js.map +1 -1
- package/src/common/decorators/plugin.decorator.d.ts +1 -1
- package/src/common/decorators/plugin.decorator.js +11 -10
- package/src/common/decorators/plugin.decorator.js.map +1 -1
- package/src/common/decorators/resource.decorator.d.ts +32 -3
- package/src/common/decorators/resource.decorator.js +46 -4
- package/src/common/decorators/resource.decorator.js.map +1 -1
- package/src/common/decorators/tool.decorator.d.ts +54 -5
- package/src/common/decorators/tool.decorator.js.map +1 -1
- package/src/common/dynamic/dynamic.plugin.d.ts +22 -11
- package/src/common/dynamic/dynamic.plugin.js +7 -1
- package/src/common/dynamic/dynamic.plugin.js.map +1 -1
- package/src/common/entries/prompt.entry.d.ts +46 -2
- package/src/common/entries/prompt.entry.js +10 -0
- package/src/common/entries/prompt.entry.js.map +1 -1
- package/src/common/entries/resource.entry.d.ts +69 -6
- package/src/common/entries/resource.entry.js +27 -3
- package/src/common/entries/resource.entry.js.map +1 -1
- package/src/common/entries/scope.entry.d.ts +5 -1
- package/src/common/entries/scope.entry.js +3 -3
- package/src/common/entries/scope.entry.js.map +1 -1
- package/src/common/flow/flow.utils.d.ts +56 -0
- package/src/common/flow/flow.utils.js +96 -0
- package/src/common/flow/flow.utils.js.map +1 -0
- package/src/common/index.d.ts +2 -2
- package/src/common/index.js +2 -2
- package/src/common/index.js.map +1 -1
- package/src/common/interfaces/execution-context.interface.d.ts +59 -0
- package/src/common/interfaces/execution-context.interface.js +81 -0
- package/src/common/interfaces/execution-context.interface.js.map +1 -0
- package/src/common/interfaces/flow.interface.d.ts +1 -1
- package/src/common/interfaces/flow.interface.js.map +1 -1
- package/src/common/interfaces/index.d.ts +1 -0
- package/src/common/interfaces/index.js +1 -0
- package/src/common/interfaces/index.js.map +1 -1
- package/src/common/interfaces/internal/primary-auth-provider.interface.d.ts +17 -2
- package/src/common/interfaces/internal/primary-auth-provider.interface.js +52 -4
- package/src/common/interfaces/internal/primary-auth-provider.interface.js.map +1 -1
- package/src/common/interfaces/internal/registry.interface.d.ts +16 -2
- package/src/common/interfaces/internal/registry.interface.js.map +1 -1
- package/src/common/interfaces/plugin.interface.js.map +1 -1
- package/src/common/interfaces/prompt.interface.d.ts +53 -4
- package/src/common/interfaces/prompt.interface.js +78 -0
- package/src/common/interfaces/prompt.interface.js.map +1 -1
- package/src/common/interfaces/resource.interface.d.ts +47 -17
- package/src/common/interfaces/resource.interface.js +53 -0
- package/src/common/interfaces/resource.interface.js.map +1 -1
- package/src/common/interfaces/tool.interface.d.ts +39 -22
- package/src/common/interfaces/tool.interface.js +61 -34
- package/src/common/interfaces/tool.interface.js.map +1 -1
- package/src/common/metadata/adapter.metadata.d.ts +1 -9
- package/src/common/metadata/app.metadata.d.ts +425 -730
- package/src/common/metadata/auth-provider.metadata.d.ts +2 -12
- package/src/common/metadata/flow.metadata.d.ts +10 -25
- package/src/common/metadata/front-mcp.metadata.d.ts +602 -1023
- package/src/common/metadata/front-mcp.metadata.js +6 -4
- package/src/common/metadata/front-mcp.metadata.js.map +1 -1
- package/src/common/metadata/hook.metadata.d.ts +1 -1
- package/src/common/metadata/hook.metadata.js.map +1 -1
- package/src/common/metadata/index.d.ts +1 -0
- package/src/common/metadata/index.js +1 -0
- package/src/common/metadata/index.js.map +1 -1
- package/src/common/metadata/logger.metadata.d.ts +1 -9
- package/src/common/metadata/plugin.metadata.d.ts +8 -30
- package/src/common/metadata/prompt.metadata.d.ts +4 -161
- package/src/common/metadata/provider.metadata.d.ts +2 -12
- package/src/common/metadata/resource.metadata.d.ts +6 -98
- package/src/common/metadata/resource.metadata.js +15 -6
- package/src/common/metadata/resource.metadata.js.map +1 -1
- package/src/common/metadata/tool-ui.metadata.d.ts +10 -0
- package/src/common/metadata/tool-ui.metadata.js +12 -0
- package/src/common/metadata/tool-ui.metadata.js.map +1 -0
- package/src/common/metadata/tool.metadata.d.ts +78 -199
- package/src/common/metadata/tool.metadata.js +11 -14
- package/src/common/metadata/tool.metadata.js.map +1 -1
- package/src/common/providers/base-config.provider.d.ts +84 -0
- package/src/common/providers/base-config.provider.js +128 -0
- package/src/common/providers/base-config.provider.js.map +1 -0
- package/src/common/records/plugin.record.d.ts +5 -6
- package/src/common/records/plugin.record.js.map +1 -1
- package/src/common/records/prompt.record.js.map +1 -1
- package/src/common/records/resource.record.d.ts +17 -1
- package/src/common/records/resource.record.js +12 -6
- package/src/common/records/resource.record.js.map +1 -1
- package/src/common/records/tool.record.js.map +1 -1
- package/src/common/schemas/annotated-class.schema.d.ts +9 -9
- package/src/common/schemas/annotated-class.schema.js +92 -27
- package/src/common/schemas/annotated-class.schema.js.map +1 -1
- package/src/common/schemas/http-input.schema.d.ts +6 -30
- package/src/common/schemas/http-output.schema.d.ts +326 -1630
- package/src/common/schemas/http-output.schema.js +39 -1
- package/src/common/schemas/http-output.schema.js.map +1 -1
- package/src/common/tokens/front-mcp.tokens.js +4 -1
- package/src/common/tokens/front-mcp.tokens.js.map +1 -1
- package/src/common/tokens/resource.tokens.d.ts +2 -0
- package/src/common/tokens/resource.tokens.js +4 -1
- package/src/common/tokens/resource.tokens.js.map +1 -1
- package/src/common/tokens/tool.tokens.d.ts +2 -0
- package/src/common/tokens/tool.tokens.js +2 -0
- package/src/common/tokens/tool.tokens.js.map +1 -1
- package/src/common/types/auth/jwt.types.d.ts +5 -31
- package/src/common/types/auth/session.types.d.ts +97 -192
- package/src/common/types/auth/session.types.js +24 -11
- package/src/common/types/auth/session.types.js.map +1 -1
- package/src/common/types/options/auth.options.d.ts +1013 -490
- package/src/common/types/options/auth.options.js +554 -36
- package/src/common/types/options/auth.options.js.map +1 -1
- package/src/common/types/options/http.options.d.ts +1 -9
- package/src/common/types/options/logging.options.d.ts +7 -13
- package/src/common/types/options/logging.options.js +4 -0
- package/src/common/types/options/logging.options.js.map +1 -1
- package/src/common/types/options/server-info.options.d.ts +3 -31
- package/src/common/types/options/session.options.d.ts +90 -10
- package/src/common/types/options/session.options.js +26 -3
- package/src/common/types/options/session.options.js.map +1 -1
- package/src/common/utils/decide-request-intent.utils.d.ts +8 -46
- package/src/common/utils/decide-request-intent.utils.js +88 -23
- package/src/common/utils/decide-request-intent.utils.js.map +1 -1
- package/src/completion/flows/complete.flow.d.ts +74 -0
- package/src/completion/flows/complete.flow.js +199 -0
- package/src/completion/flows/complete.flow.js.map +1 -0
- package/src/errors/authorization-required.error.d.ts +189 -0
- package/src/errors/authorization-required.error.js +274 -0
- package/src/errors/authorization-required.error.js.map +1 -0
- package/src/errors/index.d.ts +2 -1
- package/src/errors/index.js +17 -1
- package/src/errors/index.js.map +1 -1
- package/src/errors/mcp.error.d.ts +101 -1
- package/src/errors/mcp.error.js +147 -2
- package/src/errors/mcp.error.js.map +1 -1
- package/src/flows/flow.instance.js +4 -3
- package/src/flows/flow.instance.js.map +1 -1
- package/src/flows/flow.registry.js.map +1 -1
- package/src/flows/flow.stages.js +14 -11
- package/src/flows/flow.stages.js.map +1 -1
- package/src/front-mcp/front-mcp.providers.d.ts +464 -102
- package/src/front-mcp/front-mcp.providers.js +3 -5
- package/src/front-mcp/front-mcp.providers.js.map +1 -1
- package/src/hooks/hook.instance.d.ts +1 -1
- package/src/hooks/hook.instance.js +5 -2
- package/src/hooks/hook.instance.js.map +1 -1
- package/src/hooks/hook.registry.js +7 -5
- package/src/hooks/hook.registry.js.map +1 -1
- package/src/index.d.ts +28 -9
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
- package/src/logger/instances/instance.logger.js +3 -2
- package/src/logger/instances/instance.logger.js.map +1 -1
- package/src/logger/logger.registry.js +7 -2
- package/src/logger/logger.registry.js.map +1 -1
- package/src/logging/flows/set-level.flow.d.ts +62 -0
- package/src/logging/flows/set-level.flow.js +108 -0
- package/src/logging/flows/set-level.flow.js.map +1 -0
- package/src/mcp-apps/csp.d.ts +111 -0
- package/src/mcp-apps/csp.js +267 -0
- package/src/mcp-apps/csp.js.map +1 -0
- package/src/mcp-apps/index.d.ts +23 -0
- package/src/mcp-apps/index.js +91 -0
- package/src/mcp-apps/index.js.map +1 -0
- package/src/mcp-apps/schemas.d.ts +403 -0
- package/src/mcp-apps/schemas.js +345 -0
- package/src/mcp-apps/schemas.js.map +1 -0
- package/src/mcp-apps/template.d.ts +94 -0
- package/src/mcp-apps/template.js +419 -0
- package/src/mcp-apps/template.js.map +1 -0
- package/src/mcp-apps/types.d.ts +323 -0
- package/src/mcp-apps/types.js +59 -0
- package/src/mcp-apps/types.js.map +1 -0
- package/src/notification/index.d.ts +1 -0
- package/src/notification/index.js +13 -0
- package/src/notification/index.js.map +1 -0
- package/src/notification/notification.service.d.ts +378 -0
- package/src/notification/notification.service.js +727 -0
- package/src/notification/notification.service.js.map +1 -0
- package/src/plugin/plugin.registry.js +12 -9
- package/src/plugin/plugin.registry.js.map +1 -1
- package/src/prompt/flows/get-prompt.flow.d.ts +153 -0
- package/src/prompt/flows/get-prompt.flow.js +214 -0
- package/src/prompt/flows/get-prompt.flow.js.map +1 -0
- package/src/prompt/flows/prompts-list.flow.d.ts +67 -0
- package/src/prompt/flows/prompts-list.flow.js +176 -0
- package/src/prompt/flows/prompts-list.flow.js.map +1 -0
- package/src/prompt/index.d.ts +7 -0
- package/src/prompt/index.js +17 -0
- package/src/prompt/index.js.map +1 -0
- package/src/prompt/prompt.events.d.ts +17 -0
- package/src/prompt/prompt.events.js +25 -0
- package/src/prompt/prompt.events.js.map +1 -0
- package/src/prompt/prompt.instance.d.ts +30 -0
- package/src/prompt/prompt.instance.js +120 -0
- package/src/prompt/prompt.instance.js.map +1 -0
- package/src/prompt/prompt.registry.d.ts +79 -12
- package/src/prompt/prompt.registry.js +360 -15
- package/src/prompt/prompt.registry.js.map +1 -1
- package/src/prompt/prompt.types.d.ts +26 -0
- package/src/prompt/prompt.types.js +11 -0
- package/src/prompt/prompt.types.js.map +1 -0
- package/src/prompt/prompt.utils.d.ts +26 -0
- package/src/prompt/prompt.utils.js +136 -0
- package/src/prompt/prompt.utils.js.map +1 -0
- package/src/provider/provider.registry.d.ts +12 -5
- package/src/provider/provider.registry.js +30 -138
- package/src/provider/provider.registry.js.map +1 -1
- package/src/regsitry/registry.base.d.ts +1 -1
- package/src/regsitry/registry.base.js.map +1 -1
- package/src/resource/flows/read-resource.flow.d.ts +91 -0
- package/src/resource/flows/read-resource.flow.js +270 -0
- package/src/resource/flows/read-resource.flow.js.map +1 -0
- package/src/resource/flows/resource-templates-list.flow.d.ts +64 -0
- package/src/resource/flows/resource-templates-list.flow.js +191 -0
- package/src/resource/flows/resource-templates-list.flow.js.map +1 -0
- package/src/resource/flows/resources-list.flow.d.ts +64 -0
- package/src/resource/flows/resources-list.flow.js +196 -0
- package/src/resource/flows/resources-list.flow.js.map +1 -0
- package/src/resource/flows/subscribe-resource.flow.d.ts +45 -0
- package/src/resource/flows/subscribe-resource.flow.js +123 -0
- package/src/resource/flows/subscribe-resource.flow.js.map +1 -0
- package/src/resource/flows/unsubscribe-resource.flow.d.ts +44 -0
- package/src/resource/flows/unsubscribe-resource.flow.js +107 -0
- package/src/resource/flows/unsubscribe-resource.flow.js.map +1 -0
- package/src/resource/index.d.ts +8 -0
- package/src/resource/index.js +20 -0
- package/src/resource/index.js.map +1 -0
- package/src/resource/resource.events.d.ts +24 -0
- package/src/resource/resource.events.js +17 -0
- package/src/resource/resource.events.js.map +1 -0
- package/src/resource/resource.instance.d.ts +35 -0
- package/src/resource/resource.instance.js +163 -0
- package/src/resource/resource.instance.js.map +1 -0
- package/src/resource/resource.registry.d.ts +106 -12
- package/src/resource/resource.registry.js +449 -13
- package/src/resource/resource.registry.js.map +1 -1
- package/src/resource/resource.types.d.ts +35 -0
- package/src/resource/resource.types.js +11 -0
- package/src/resource/resource.types.js.map +1 -0
- package/src/resource/resource.utils.d.ts +30 -0
- package/src/resource/resource.utils.js +151 -0
- package/src/resource/resource.utils.js.map +1 -0
- package/src/scope/flows/http.request.flow.d.ts +48 -330
- package/src/scope/flows/http.request.flow.js +306 -78
- package/src/scope/flows/http.request.flow.js.map +1 -1
- package/src/scope/scope.instance.d.ts +12 -0
- package/src/scope/scope.instance.js +145 -15
- package/src/scope/scope.instance.js.map +1 -1
- package/src/tool/flows/call-tool.flow.d.ts +64 -1110
- package/src/tool/flows/call-tool.flow.js +303 -15
- package/src/tool/flows/call-tool.flow.js.map +1 -1
- package/src/tool/flows/tools-list.flow.d.ts +32 -473
- package/src/tool/flows/tools-list.flow.js +111 -10
- package/src/tool/flows/tools-list.flow.js.map +1 -1
- package/src/tool/tool.events.d.ts +8 -1
- package/src/tool/tool.events.js.map +1 -1
- package/src/tool/tool.instance.d.ts +3 -1
- package/src/tool/tool.instance.js +17 -3
- package/src/tool/tool.instance.js.map +1 -1
- package/src/tool/tool.registry.d.ts +7 -1
- package/src/tool/tool.registry.js +26 -10
- package/src/tool/tool.registry.js.map +1 -1
- package/src/tool/tool.types.d.ts +4 -4
- package/src/tool/tool.types.js.map +1 -1
- package/src/tool/tool.utils.d.ts +3 -12
- package/src/tool/tool.utils.js +39 -193
- package/src/tool/tool.utils.js.map +1 -1
- package/src/tool/ui/index.d.ts +22 -0
- package/src/tool/ui/index.js +63 -0
- package/src/tool/ui/index.js.map +1 -0
- package/src/tool/ui/platform-adapters.d.ts +10 -0
- package/src/tool/ui/platform-adapters.js +18 -0
- package/src/tool/ui/platform-adapters.js.map +1 -0
- package/src/tool/ui/template-helpers.d.ts +46 -0
- package/src/tool/ui/template-helpers.js +112 -0
- package/src/tool/ui/template-helpers.js.map +1 -0
- package/src/tool/ui/ui-resource-template.d.ts +34 -0
- package/src/tool/ui/ui-resource-template.js +64 -0
- package/src/tool/ui/ui-resource-template.js.map +1 -0
- package/src/tool/ui/ui-resource.handler.d.ts +74 -0
- package/src/tool/ui/ui-resource.handler.js +129 -0
- package/src/tool/ui/ui-resource.handler.js.map +1 -0
- package/src/transport/adapters/transport.local.adapter.d.ts +2 -2
- package/src/transport/adapters/transport.local.adapter.js +28 -7
- package/src/transport/adapters/transport.local.adapter.js.map +1 -1
- package/src/transport/adapters/transport.sse.adapter.d.ts +2 -2
- package/src/transport/adapters/transport.sse.adapter.js +4 -3
- package/src/transport/adapters/transport.sse.adapter.js.map +1 -1
- package/src/transport/adapters/transport.streamable-http.adapter.d.ts +10 -3
- package/src/transport/adapters/transport.streamable-http.adapter.js +54 -8
- package/src/transport/adapters/transport.streamable-http.adapter.js.map +1 -1
- package/src/transport/flows/handle.sse.flow.d.ts +29 -63
- package/src/transport/flows/handle.sse.flow.js +78 -10
- package/src/transport/flows/handle.sse.flow.js.map +1 -1
- package/src/transport/flows/handle.stateless-http.flow.d.ts +29 -0
- package/src/transport/flows/handle.stateless-http.flow.js +102 -0
- package/src/transport/flows/handle.stateless-http.flow.js.map +1 -0
- package/src/transport/flows/handle.streamable-http.flow.d.ts +32 -64
- package/src/transport/flows/handle.streamable-http.flow.js +158 -26
- package/src/transport/flows/handle.streamable-http.flow.js.map +1 -1
- package/src/transport/legacy/legacy.sse.tranporter.d.ts +9 -0
- package/src/transport/legacy/legacy.sse.tranporter.js +17 -2
- package/src/transport/legacy/legacy.sse.tranporter.js.map +1 -1
- package/src/transport/mcp-handlers/call-tool-request.handler.js +27 -1
- package/src/transport/mcp-handlers/call-tool-request.handler.js.map +1 -1
- package/src/transport/mcp-handlers/complete-request.handler.d.ts +69 -0
- package/src/transport/mcp-handlers/complete-request.handler.js +11 -0
- package/src/transport/mcp-handlers/complete-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.d.ts +87 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.js +11 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/index.d.ts +517 -208
- package/src/transport/mcp-handlers/index.js +39 -2
- package/src/transport/mcp-handlers/index.js.map +1 -1
- package/src/transport/mcp-handlers/initialize-request.handler.d.ts +1 -1
- package/src/transport/mcp-handlers/initialize-request.handler.js +73 -7
- package/src/transport/mcp-handlers/initialize-request.handler.js.map +1 -1
- package/src/transport/mcp-handlers/list-prompts-request.handler.d.ts +54 -0
- package/src/transport/mcp-handlers/list-prompts-request.handler.js +11 -0
- package/src/transport/mcp-handlers/list-prompts-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.d.ts +51 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.js +12 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.d.ts +51 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.js +12 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +19 -146
- package/src/transport/mcp-handlers/logging-set-level-request.handler.d.ts +46 -0
- package/src/transport/mcp-handlers/logging-set-level-request.handler.js +34 -0
- package/src/transport/mcp-handlers/logging-set-level-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/mcp-handlers.types.d.ts +3 -7
- package/src/transport/mcp-handlers/mcp-handlers.types.js.map +1 -1
- package/src/transport/mcp-handlers/read-resource-request.handler.d.ts +46 -0
- package/src/transport/mcp-handlers/read-resource-request.handler.js +12 -0
- package/src/transport/mcp-handlers/read-resource-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.d.ts +11 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.js +26 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.js.map +1 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.d.ts +37 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.js +34 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.d.ts +37 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.js +34 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.js.map +1 -0
- package/src/transport/transport.local.js +7 -2
- package/src/transport/transport.local.js.map +1 -1
- package/src/transport/transport.registry.d.ts +30 -0
- package/src/transport/transport.registry.js +84 -1
- package/src/transport/transport.registry.js.map +1 -1
- package/src/transport/transport.types.d.ts +3 -3
- package/src/transport/transport.types.js.map +1 -1
- package/src/utils/content.utils.d.ts +48 -0
- package/src/utils/content.utils.js +194 -0
- package/src/utils/content.utils.js.map +1 -0
- package/src/utils/index.d.ts +8 -0
- package/src/utils/index.js +55 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/lineage.utils.d.ts +40 -0
- package/src/utils/lineage.utils.js +82 -0
- package/src/utils/lineage.utils.js.map +1 -0
- package/src/utils/naming.utils.d.ts +46 -0
- package/src/utils/naming.utils.js +136 -0
- package/src/utils/naming.utils.js.map +1 -0
- package/src/utils/types.utils.d.ts +2 -2
- package/src/utils/types.utils.js.map +1 -1
- package/src/utils/uri-template.utils.d.ts +57 -0
- package/src/utils/uri-template.utils.js +113 -0
- package/src/utils/uri-template.utils.js.map +1 -0
- package/src/utils/uri-validation.utils.d.ts +40 -0
- package/src/utils/uri-validation.utils.js +76 -0
- package/src/utils/uri-validation.utils.js.map +1 -0
- package/src/__test-utils__/fixtures/hook.fixtures.d.ts +0 -46
- package/src/__test-utils__/fixtures/hook.fixtures.js +0 -114
- package/src/__test-utils__/fixtures/hook.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/index.d.ts +0 -7
- package/src/__test-utils__/fixtures/index.js +0 -11
- package/src/__test-utils__/fixtures/index.js.map +0 -1
- package/src/__test-utils__/fixtures/plugin.fixtures.d.ts +0 -46
- package/src/__test-utils__/fixtures/plugin.fixtures.js +0 -127
- package/src/__test-utils__/fixtures/plugin.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/provider.fixtures.d.ts +0 -69
- package/src/__test-utils__/fixtures/provider.fixtures.js +0 -131
- package/src/__test-utils__/fixtures/provider.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/scope.fixtures.d.ts +0 -14
- package/src/__test-utils__/fixtures/scope.fixtures.js +0 -59
- package/src/__test-utils__/fixtures/scope.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/tool.fixtures.d.ts +0 -36
- package/src/__test-utils__/fixtures/tool.fixtures.js +0 -91
- package/src/__test-utils__/fixtures/tool.fixtures.js.map +0 -1
- package/src/__test-utils__/helpers/assertion.helpers.d.ts +0 -45
- package/src/__test-utils__/helpers/assertion.helpers.js +0 -153
- package/src/__test-utils__/helpers/assertion.helpers.js.map +0 -1
- package/src/__test-utils__/helpers/async.helpers.d.ts +0 -48
- package/src/__test-utils__/helpers/async.helpers.js +0 -112
- package/src/__test-utils__/helpers/async.helpers.js.map +0 -1
- package/src/__test-utils__/helpers/index.d.ts +0 -6
- package/src/__test-utils__/helpers/index.js +0 -10
- package/src/__test-utils__/helpers/index.js.map +0 -1
- package/src/__test-utils__/helpers/setup.helpers.d.ts +0 -54
- package/src/__test-utils__/helpers/setup.helpers.js +0 -106
- package/src/__test-utils__/helpers/setup.helpers.js.map +0 -1
- package/src/__test-utils__/index.d.ts +0 -9
- package/src/__test-utils__/index.js +0 -14
- package/src/__test-utils__/index.js.map +0 -1
- package/src/__test-utils__/mocks/flow-instance.mock.d.ts +0 -50
- package/src/__test-utils__/mocks/flow-instance.mock.js +0 -72
- package/src/__test-utils__/mocks/flow-instance.mock.js.map +0 -1
- package/src/__test-utils__/mocks/hook-registry.mock.d.ts +0 -25
- package/src/__test-utils__/mocks/hook-registry.mock.js +0 -65
- package/src/__test-utils__/mocks/hook-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/index.d.ts +0 -8
- package/src/__test-utils__/mocks/index.js +0 -12
- package/src/__test-utils__/mocks/index.js.map +0 -1
- package/src/__test-utils__/mocks/plugin-registry.mock.d.ts +0 -43
- package/src/__test-utils__/mocks/plugin-registry.mock.js +0 -70
- package/src/__test-utils__/mocks/plugin-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/provider-registry.mock.d.ts +0 -39
- package/src/__test-utils__/mocks/provider-registry.mock.js +0 -72
- package/src/__test-utils__/mocks/provider-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/tool-registry.mock.d.ts +0 -43
- package/src/__test-utils__/mocks/tool-registry.mock.js +0 -79
- package/src/__test-utils__/mocks/tool-registry.mock.js.map +0 -1
- package/src/auth/path.utils.d.ts +0 -20
- package/src/auth/path.utils.js +0 -71
- package/src/auth/path.utils.js.map +0 -1
- package/src/common/decorators-old/async-with.decorator.d.ts +0 -10
- package/src/common/decorators-old/async-with.decorator.js +0 -24
- package/src/common/decorators-old/async-with.decorator.js.map +0 -1
- package/src/common/decorators-old/auth-hook.decorator.d.ts +0 -14
- package/src/common/decorators-old/auth-hook.decorator.js +0 -27
- package/src/common/decorators-old/auth-hook.decorator.js.map +0 -1
- package/src/common/decorators-old/session-hook.decorator.d.ts +0 -14
- package/src/common/decorators-old/session-hook.decorator.js +0 -27
- package/src/common/decorators-old/session-hook.decorator.js.map +0 -1
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// auth/flows/auth.verify.flow.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.authVerifyOutputSchema = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("../../common");
|
|
7
|
+
require("reflect-metadata");
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const auth_token_utils_1 = require("../session/utils/auth-token.utils");
|
|
10
|
+
const jwks_1 = require("../jwks");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
const authorization_1 = require("../authorization");
|
|
13
|
+
const authorization_2 = require("../authorization");
|
|
14
|
+
// Input schema
|
|
15
|
+
const inputSchema = common_1.httpRequestInputSchema;
|
|
16
|
+
// State schema for the flow
|
|
17
|
+
const stateSchema = zod_1.z.object({
|
|
18
|
+
baseUrl: zod_1.z.string().min(1),
|
|
19
|
+
authorizationHeader: zod_1.z.string().optional(),
|
|
20
|
+
token: zod_1.z.string().optional(),
|
|
21
|
+
sessionIdHeader: zod_1.z.string().optional(),
|
|
22
|
+
prmUrl: zod_1.z.string(),
|
|
23
|
+
wwwAuthenticateHeader: zod_1.z.string(),
|
|
24
|
+
authMode: zod_1.z.enum(['public', 'transparent', 'orchestrated']).optional(),
|
|
25
|
+
jwtPayload: zod_1.z.object({}).passthrough().optional(),
|
|
26
|
+
user: authorization_2.authUserSchema.optional(),
|
|
27
|
+
});
|
|
28
|
+
// Output schemas
|
|
29
|
+
const UnauthorizedSchema = zod_1.z
|
|
30
|
+
.object({
|
|
31
|
+
kind: zod_1.z.literal('unauthorized'),
|
|
32
|
+
wwwAuthenticateHeader: zod_1.z.string().describe('WWW-Authenticate header per RFC 9728'),
|
|
33
|
+
reason: zod_1.z.string().optional().describe('Human-readable reason for rejection'),
|
|
34
|
+
})
|
|
35
|
+
.describe('401 Unauthorized response');
|
|
36
|
+
const AuthorizedSchema = zod_1.z
|
|
37
|
+
.object({
|
|
38
|
+
kind: zod_1.z.literal('authorized'),
|
|
39
|
+
authorization: zod_1.z.custom().describe('Authorization object'),
|
|
40
|
+
llmContext: authorization_2.llmSafeAuthContextSchema.optional().describe('LLM-safe context (no tokens)'),
|
|
41
|
+
})
|
|
42
|
+
.describe('Authorized response with Authorization object');
|
|
43
|
+
exports.authVerifyOutputSchema = zod_1.z.union([UnauthorizedSchema, AuthorizedSchema]);
|
|
44
|
+
// Flow plan
|
|
45
|
+
const plan = {
|
|
46
|
+
pre: ['parseInput', 'determineAuthMode', 'handlePublicMode', 'requireAuthorizationHeader', 'verifyToken'],
|
|
47
|
+
execute: ['buildAuthorization'],
|
|
48
|
+
};
|
|
49
|
+
const name = 'auth:verify';
|
|
50
|
+
const Stage = (0, common_1.StageHookOf)(name);
|
|
51
|
+
/**
|
|
52
|
+
* Auth Verify Flow
|
|
53
|
+
*
|
|
54
|
+
* New authorization verification flow that supports the three auth modes:
|
|
55
|
+
* - public: Auto-generate anonymous authorization
|
|
56
|
+
* - transparent: Pass-through OAuth tokens from upstream provider
|
|
57
|
+
* - orchestrated: Local auth server with secure token storage
|
|
58
|
+
*
|
|
59
|
+
* This flow creates Authorization objects instead of legacy Session objects.
|
|
60
|
+
*/
|
|
61
|
+
let AuthVerifyFlow = class AuthVerifyFlow extends common_1.FlowBase {
|
|
62
|
+
logger = this.scope.logger.child('AuthVerifyFlow');
|
|
63
|
+
/**
|
|
64
|
+
* Parse request headers and build WWW-Authenticate header
|
|
65
|
+
*/
|
|
66
|
+
async parseInput() {
|
|
67
|
+
const { request } = this.rawInput;
|
|
68
|
+
const entryPath = (0, common_1.normalizeEntryPrefix)(this.scope.entryPath);
|
|
69
|
+
const routeBase = (0, common_1.normalizeScopeBase)(this.scope.routeBase);
|
|
70
|
+
const baseUrl = (0, common_1.getRequestBaseUrl)(request, entryPath);
|
|
71
|
+
// Extract headers
|
|
72
|
+
const authorizationHeader = request.headers?.['authorization'] ?? undefined;
|
|
73
|
+
const sessionIdHeader = request.headers?.['mcp-session-id'] ??
|
|
74
|
+
request.query['sessionId'] ??
|
|
75
|
+
undefined;
|
|
76
|
+
// Build PRM URL and WWW-Authenticate header
|
|
77
|
+
const prmUrl = (0, utils_1.buildPrmUrl)(baseUrl, entryPath, routeBase);
|
|
78
|
+
const wwwAuthenticateHeader = (0, utils_1.buildUnauthorizedHeader)(prmUrl);
|
|
79
|
+
const token = (0, auth_token_utils_1.extractBearerToken)(authorizationHeader);
|
|
80
|
+
this.state.set({
|
|
81
|
+
baseUrl,
|
|
82
|
+
authorizationHeader,
|
|
83
|
+
token,
|
|
84
|
+
sessionIdHeader,
|
|
85
|
+
prmUrl,
|
|
86
|
+
wwwAuthenticateHeader,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Determine which auth mode to use based on scope configuration
|
|
91
|
+
*/
|
|
92
|
+
async determineAuthMode() {
|
|
93
|
+
const authOptions = this.scope.auth?.options;
|
|
94
|
+
// Determine auth mode from options
|
|
95
|
+
let authMode = 'public'; // default
|
|
96
|
+
if (authOptions && 'mode' in authOptions) {
|
|
97
|
+
authMode = authOptions.mode;
|
|
98
|
+
}
|
|
99
|
+
this.logger.debug(`Auth mode determined: ${authMode}`);
|
|
100
|
+
this.state.set('authMode', authMode);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Handle public mode - create anonymous authorization without requiring a token
|
|
104
|
+
*/
|
|
105
|
+
async handlePublicMode() {
|
|
106
|
+
const authOptions = this.scope.auth?.options;
|
|
107
|
+
// Create anonymous authorization
|
|
108
|
+
const publicAccess = authOptions?.['publicAccess'];
|
|
109
|
+
const authorization = authorization_1.PublicAuthorization.create({
|
|
110
|
+
scopes: authOptions?.['anonymousScopes'] ?? ['anonymous'],
|
|
111
|
+
ttlMs: this.parseTtl(authOptions?.['sessionTtl']),
|
|
112
|
+
issuer: authOptions?.['issuer'] ?? this.state.required.baseUrl,
|
|
113
|
+
allowedTools: publicAccess?.['tools'] ?? 'all',
|
|
114
|
+
allowedPrompts: publicAccess?.['prompts'] ?? 'all',
|
|
115
|
+
});
|
|
116
|
+
this.logger.info(`Created anonymous authorization: ${authorization.id}`);
|
|
117
|
+
this.respond({
|
|
118
|
+
kind: 'authorized',
|
|
119
|
+
authorization,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Require authorization header for non-public modes
|
|
124
|
+
*/
|
|
125
|
+
async requireAuthorizationHeader() {
|
|
126
|
+
this.logger.warn('No authorization header provided');
|
|
127
|
+
this.respond({
|
|
128
|
+
kind: 'unauthorized',
|
|
129
|
+
wwwAuthenticateHeader: this.state.required.wwwAuthenticateHeader,
|
|
130
|
+
reason: 'No authorization header provided',
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Verify the JWT token
|
|
135
|
+
*/
|
|
136
|
+
async verifyToken() {
|
|
137
|
+
const jwks = this.get(jwks_1.JwksService);
|
|
138
|
+
const token = this.state.required.token;
|
|
139
|
+
const authMode = this.state.required.authMode;
|
|
140
|
+
const { baseUrl, prmUrl } = this.state.required;
|
|
141
|
+
// Non-JWT tokens are not supported
|
|
142
|
+
if (!(0, auth_token_utils_1.isJwt)(token)) {
|
|
143
|
+
this.logger.warn('Token is not a JWT');
|
|
144
|
+
this.respond({
|
|
145
|
+
kind: 'unauthorized',
|
|
146
|
+
wwwAuthenticateHeader: (0, utils_1.buildInvalidTokenHeader)(prmUrl, 'Token is not a valid JWT'),
|
|
147
|
+
reason: 'Token is not a valid JWT',
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Verify based on auth mode
|
|
152
|
+
let verifyResult;
|
|
153
|
+
if (authMode === 'orchestrated') {
|
|
154
|
+
// Orchestrated: verify against local keys
|
|
155
|
+
verifyResult = await jwks.verifyGatewayToken(token, baseUrl);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// Transparent: verify against upstream provider
|
|
159
|
+
const authOptions = this.scope.auth?.options;
|
|
160
|
+
const issuerUrl = this.scope.auth?.issuer;
|
|
161
|
+
if (!issuerUrl) {
|
|
162
|
+
this.logger.warn('No issuer URL configured for transparent mode');
|
|
163
|
+
this.respond({
|
|
164
|
+
kind: 'unauthorized',
|
|
165
|
+
wwwAuthenticateHeader: (0, utils_1.buildInvalidTokenHeader)(prmUrl, 'Server misconfiguration'),
|
|
166
|
+
reason: 'No issuer URL configured',
|
|
167
|
+
});
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const providerRefs = [
|
|
171
|
+
{
|
|
172
|
+
id: authOptions?.['id'] ?? 'default',
|
|
173
|
+
issuerUrl,
|
|
174
|
+
jwks: authOptions?.['jwks'],
|
|
175
|
+
jwksUri: authOptions?.['jwksUri'],
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
verifyResult = await jwks.verifyTransparentToken(token, providerRefs);
|
|
179
|
+
}
|
|
180
|
+
if (!verifyResult.ok) {
|
|
181
|
+
this.logger.warn(`Token verification failed: ${verifyResult.error}`);
|
|
182
|
+
this.respond({
|
|
183
|
+
kind: 'unauthorized',
|
|
184
|
+
wwwAuthenticateHeader: (0, utils_1.buildInvalidTokenHeader)(prmUrl, verifyResult.error),
|
|
185
|
+
reason: verifyResult.error ?? 'Token verification failed',
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
// Validate audience
|
|
190
|
+
const authOptionsForAudience = this.scope.auth?.options;
|
|
191
|
+
const expectedAudience = authOptionsForAudience?.['expectedAudience'] ??
|
|
192
|
+
(0, utils_1.deriveExpectedAudience)(baseUrl);
|
|
193
|
+
const expectedAudienceArray = Array.isArray(expectedAudience) ? expectedAudience : [expectedAudience];
|
|
194
|
+
const audResult = (0, utils_1.validateAudience)(verifyResult.payload?.aud, {
|
|
195
|
+
expectedAudiences: expectedAudienceArray,
|
|
196
|
+
allowNoAudience: true, // Some tokens may not have audience
|
|
197
|
+
});
|
|
198
|
+
if (!audResult.valid) {
|
|
199
|
+
this.logger.warn(`Audience validation failed: ${audResult.error}`);
|
|
200
|
+
this.respond({
|
|
201
|
+
kind: 'unauthorized',
|
|
202
|
+
wwwAuthenticateHeader: (0, utils_1.buildInvalidTokenHeader)(prmUrl, audResult.error),
|
|
203
|
+
reason: audResult.error,
|
|
204
|
+
});
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
// Check required scopes
|
|
208
|
+
const requiredScopes = authOptionsForAudience?.['requiredScopes'] ?? [];
|
|
209
|
+
if (requiredScopes.length > 0) {
|
|
210
|
+
const tokenScopes = this.parseScopes(verifyResult.payload?.scope);
|
|
211
|
+
const hasAllScopes = requiredScopes.every((s) => tokenScopes.includes(s));
|
|
212
|
+
if (!hasAllScopes) {
|
|
213
|
+
this.logger.warn(`Insufficient scopes. Required: ${requiredScopes.join(', ')}`);
|
|
214
|
+
this.respond({
|
|
215
|
+
kind: 'unauthorized',
|
|
216
|
+
wwwAuthenticateHeader: (0, utils_1.buildInsufficientScopeHeader)(prmUrl, requiredScopes),
|
|
217
|
+
reason: `Missing required scopes: ${requiredScopes.join(', ')}`,
|
|
218
|
+
});
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Store verified payload and user
|
|
223
|
+
const user = (0, auth_token_utils_1.deriveTypedUser)(verifyResult.payload ?? {});
|
|
224
|
+
this.state.set({
|
|
225
|
+
jwtPayload: verifyResult.payload,
|
|
226
|
+
user,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Build the Authorization object based on auth mode
|
|
231
|
+
*/
|
|
232
|
+
async buildAuthorization() {
|
|
233
|
+
const { token, jwtPayload, user, authMode, baseUrl } = this.state.required;
|
|
234
|
+
if (!user) {
|
|
235
|
+
this.respond({
|
|
236
|
+
kind: 'unauthorized',
|
|
237
|
+
wwwAuthenticateHeader: this.state.required.wwwAuthenticateHeader,
|
|
238
|
+
reason: 'Failed to derive user from token',
|
|
239
|
+
});
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
let authorization;
|
|
243
|
+
if (authMode === 'transparent') {
|
|
244
|
+
// Transparent mode: pass-through token
|
|
245
|
+
const authOptions = this.scope.auth?.options;
|
|
246
|
+
// jwtPayload has been verified and should contain sub from the upstream token
|
|
247
|
+
const payload = jwtPayload;
|
|
248
|
+
authorization = authorization_1.TransparentAuthorization.fromVerifiedToken({
|
|
249
|
+
token,
|
|
250
|
+
payload,
|
|
251
|
+
providerId: this.scope.auth?.id ?? 'default',
|
|
252
|
+
providerName: authOptions?.['name'],
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
else if (authMode === 'orchestrated') {
|
|
256
|
+
// Orchestrated mode: local auth server
|
|
257
|
+
// TODO: Retrieve token store from scope configuration
|
|
258
|
+
authorization = authorization_1.OrchestratedAuthorization.create({
|
|
259
|
+
token,
|
|
260
|
+
user: {
|
|
261
|
+
sub: user.sub ?? 'unknown',
|
|
262
|
+
name: user.name,
|
|
263
|
+
email: user.email,
|
|
264
|
+
picture: user.picture,
|
|
265
|
+
},
|
|
266
|
+
scopes: this.parseScopes(jwtPayload?.['scope']),
|
|
267
|
+
claims: jwtPayload,
|
|
268
|
+
expiresAt: jwtPayload?.['exp'] ? jwtPayload['exp'] * 1000 : undefined,
|
|
269
|
+
primaryProviderId: this.scope.auth?.id ?? 'default',
|
|
270
|
+
// tokenStore will be injected by scope
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// Public mode with token (authenticated public)
|
|
275
|
+
authorization = authorization_1.PublicAuthorization.create({
|
|
276
|
+
scopes: this.parseScopes(jwtPayload?.['scope']) || ['anonymous'],
|
|
277
|
+
ttlMs: jwtPayload?.['exp'] ? jwtPayload['exp'] * 1000 - Date.now() : 3600000,
|
|
278
|
+
issuer: baseUrl,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
this.logger.info(`Authorization created: ${authorization.id} (mode: ${authMode})`);
|
|
282
|
+
this.respond({
|
|
283
|
+
kind: 'authorized',
|
|
284
|
+
authorization,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Parse TTL from string or number
|
|
289
|
+
*/
|
|
290
|
+
parseTtl(ttl) {
|
|
291
|
+
if (!ttl)
|
|
292
|
+
return 3600000; // 1 hour default
|
|
293
|
+
if (typeof ttl === 'number')
|
|
294
|
+
return ttl * 1000; // Assume seconds
|
|
295
|
+
// Parse duration string (e.g., '1h', '30m', '1d')
|
|
296
|
+
const match = ttl.match(/^(\d+)(s|m|h|d)$/);
|
|
297
|
+
if (!match)
|
|
298
|
+
return 3600000;
|
|
299
|
+
const [, value, unit] = match;
|
|
300
|
+
const num = parseInt(value, 10);
|
|
301
|
+
switch (unit) {
|
|
302
|
+
case 's':
|
|
303
|
+
return num * 1000;
|
|
304
|
+
case 'm':
|
|
305
|
+
return num * 60 * 1000;
|
|
306
|
+
case 'h':
|
|
307
|
+
return num * 60 * 60 * 1000;
|
|
308
|
+
case 'd':
|
|
309
|
+
return num * 24 * 60 * 60 * 1000;
|
|
310
|
+
default:
|
|
311
|
+
return 3600000;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Parse scopes from JWT claim
|
|
316
|
+
*/
|
|
317
|
+
parseScopes(scope) {
|
|
318
|
+
if (!scope)
|
|
319
|
+
return [];
|
|
320
|
+
if (Array.isArray(scope))
|
|
321
|
+
return scope.map(String);
|
|
322
|
+
if (typeof scope === 'string')
|
|
323
|
+
return scope.split(/\s+/).filter(Boolean);
|
|
324
|
+
return [];
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
tslib_1.__decorate([
|
|
328
|
+
Stage('parseInput'),
|
|
329
|
+
tslib_1.__metadata("design:type", Function),
|
|
330
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
331
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
332
|
+
], AuthVerifyFlow.prototype, "parseInput", null);
|
|
333
|
+
tslib_1.__decorate([
|
|
334
|
+
Stage('determineAuthMode'),
|
|
335
|
+
tslib_1.__metadata("design:type", Function),
|
|
336
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
337
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
338
|
+
], AuthVerifyFlow.prototype, "determineAuthMode", null);
|
|
339
|
+
tslib_1.__decorate([
|
|
340
|
+
Stage('handlePublicMode', {
|
|
341
|
+
filter: ({ state }) => state.authMode === 'public' && !state.token,
|
|
342
|
+
}),
|
|
343
|
+
tslib_1.__metadata("design:type", Function),
|
|
344
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
345
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
346
|
+
], AuthVerifyFlow.prototype, "handlePublicMode", null);
|
|
347
|
+
tslib_1.__decorate([
|
|
348
|
+
Stage('requireAuthorizationHeader', {
|
|
349
|
+
filter: ({ state }) => state.authMode !== 'public' && !state.authorizationHeader,
|
|
350
|
+
}),
|
|
351
|
+
tslib_1.__metadata("design:type", Function),
|
|
352
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
353
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
354
|
+
], AuthVerifyFlow.prototype, "requireAuthorizationHeader", null);
|
|
355
|
+
tslib_1.__decorate([
|
|
356
|
+
Stage('verifyToken', {
|
|
357
|
+
filter: ({ state }) => !!state.token,
|
|
358
|
+
}),
|
|
359
|
+
tslib_1.__metadata("design:type", Function),
|
|
360
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
361
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
362
|
+
], AuthVerifyFlow.prototype, "verifyToken", null);
|
|
363
|
+
tslib_1.__decorate([
|
|
364
|
+
Stage('buildAuthorization'),
|
|
365
|
+
tslib_1.__metadata("design:type", Function),
|
|
366
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
367
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
368
|
+
], AuthVerifyFlow.prototype, "buildAuthorization", null);
|
|
369
|
+
AuthVerifyFlow = tslib_1.__decorate([
|
|
370
|
+
(0, common_1.Flow)({
|
|
371
|
+
name,
|
|
372
|
+
plan,
|
|
373
|
+
inputSchema,
|
|
374
|
+
outputSchema: exports.authVerifyOutputSchema,
|
|
375
|
+
access: 'authorized',
|
|
376
|
+
})
|
|
377
|
+
], AuthVerifyFlow);
|
|
378
|
+
exports.default = AuthVer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QD;AAQK;IAHL,KAAK,CAAC,aAAa,EAAE;QACpB,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK;KACrC,CAAC;;;;iDAuGD;AAMK;IADL,KAAK,CAAC,oBAAoB,CAAC;;;;wDA0D3B;AA3QkB,cAAc;IAPlC,IAAA,aAAI,EAAC;QACJ,IAAI;QACJ,IAAI;QACJ,WAAW;QACX,YAAY,EAAE,8BAAsB;QACpC,MAAM,EAAE,YAAY;KACrB,CAAC;GACmB,cAAc,CAmTlC;kBAnToB,cAAc","sourcesContent":["// auth/flows/auth.verify.flow.ts\n\nimport {\n Flow,\n FlowBase,\n FlowRunOptions,\n StageHookOf,\n httpRequestInputSchema,\n getRequestBaseUrl,\n normalizeEntryPrefix,\n normalizeScopeBase,\n FlowPlan,\n AuthMode,\n} from '../../common';\nimport 'reflect-metadata';\nimport { z } from 'zod';\nimport { deriveTypedUser, extractBearerToken, isJwt } from '../session/utils/auth-token.utils';\nimport { JwksService, ProviderVerifyRef, VerifyResult } from '../jwks';\nimport type { JSONWebKeySet } from 'jose';\nimport {\n buildPrmUrl,\n buildUnauthorizedHeader,\n buildInvalidTokenHeader,\n buildInsufficientScopeHeader,\n validateAudience,\n deriveExpectedAudience,\n} from '../utils';\nimport {\n PublicAuthorization,\n TransparentAuthorization,\n OrchestratedAuthorization,\n Authorization,\n TransparentVerifiedPayload,\n} from '../authorization';\nimport { authUserSchema, llmSafeAuthContextSchema } from '../authorization';\n\n// Input schema\nconst inputSchema = httpRequestInputSchema;\n\n// State schema for the flow\nconst stateSchema = z.object({\n baseUrl: z.string().min(1),\n authorizationHeader: z.string().optional(),\n token: z.string().optional(),\n sessionIdHeader: z.string().optional(),\n prmUrl: z.string(),\n wwwAuthenticateHeader: z.string(),\n authMode: z.enum(['public', 'transparent', 'orchestrated']).optional(),\n jwtPayload: z.object({}).passthrough().optional(),\n user: authUserSchema.optional(),\n});\n\n// Output schemas\nconst UnauthorizedSchema = z\n .object({\n kind: z.literal('unauthorized'),\n wwwAuthenticateHeader: z.string().describe('WWW-Authenticate header per RFC 9728'),\n reason: z.string().optional().describe('Human-readable reason for rejection'),\n })\n .describe('401 Unauthorized response');\n\nconst AuthorizedSchema = z\n .object({\n kind: z.literal('authorized'),\n authorization: z.custom<Authorization>().describe('Authorization object'),\n llmContext: llmSafeAuthContextSchema.optional().describe('LLM-safe context (no tokens)'),\n })\n .describe('Authorized response with Authorization object');\n\nexport const authVerifyOutputSchema = z.union([UnauthorizedSchema, AuthorizedSchema]);\n\nexport type AuthVerifyOutput = z.infer<typeof authVerifyOutputSchema>;\n\n// Flow plan\nconst plan = {\n pre: ['parseInput', 'determineAuthMode', 'handlePublicMode', 'requireAuthorizationHeader', 'verifyToken'],\n execute: ['buildAuthorization'],\n} as const satisfies FlowPlan<string>;\n\n// Declare flow types\ndeclare global {\n interface ExtendFlows {\n 'auth:verify': FlowRunOptions<\n AuthVerifyFlow,\n typeof plan,\n typeof inputSchema,\n typeof authVerifyOutputSchema,\n typeof stateSchema\n >;\n }\n}\n\nconst name = 'auth:verify' as const;\nconst Stage = StageHookOf(name);\n\n/**\n * Auth Verify Flow\n *\n * New authorization verification flow that supports the three auth modes:\n * - public: Auto-generate anonymous authorization\n * - transparent: Pass-through OAuth tokens from upstream provider\n * - orchestrated: Local auth server with secure token storage\n *\n * This flow creates Authorization objects instead of legacy Session objects.\n */\n@Flow({\n name,\n plan,\n inputSchema,\n outputSchema: authVerifyOutputSchema,\n access: 'authorized',\n})\nexport default class AuthVerifyFlow extends FlowBase<typeof name> {\n private logger = this.scope.logger.child('AuthVerifyFlow');\n\n /**\n * Parse request headers and build WWW-Authenticate header\n */\n @Stage('parseInput')\n async parseInput() {\n const { request } = this.rawInput;\n const entryPath = normalizeEntryPrefix(this.scope.entryPath);\n const routeBase = normalizeScopeBase(this.scope.routeBase);\n const baseUrl = getRequestBaseUrl(request, entryPath);\n\n // Extract headers\n const authorizationHeader = (request.headers?.['authorization'] as string | undefined) ?? undefined;\n const sessionIdHeader =\n (request.headers?.['mcp-session-id'] as string | undefined) ??\n (request.query['sessionId'] as string | undefined) ??\n undefined;\n\n // Build PRM URL and WWW-Authenticate header\n const prmUrl = buildPrmUrl(baseUrl, entryPath, routeBase);\n const wwwAuthenticateHeader = buildUnauthorizedHeader(prmUrl);\n\n const token = extractBearerToken(authorizationHeader);\n\n this.state.set({\n baseUrl,\n authorizationHeader,\n token,\n sessionIdHeader,\n prmUrl,\n wwwAuthenticateHeader,\n });\n }\n\n /**\n * Determine which auth mode to use based on scope configuration\n */\n @Stage('determineAuthMode')\n async determineAuthMode() {\n const authOptions = this.scope.auth?.options;\n\n // Determine auth mode from options\n let authMode: AuthMode = 'public'; // default\n\n if (authOptions && 'mode' in authOptions) {\n authMode = authOptions.mode as AuthMode;\n }\n\n this.logger.debug(`Auth mode determined: ${authMode}`);\n this.state.set('authMode', authMode);\n }\n\n /**\n * Handle public mode - create anonymous authorization without requiring a token\n */\n @Stage('handlePublicMode', {\n filter: ({ state }) => state.authMode === 'public' && !state.token,\n })\n async handlePublicMode() {\n const authOptions = this.scope.auth?.options as Record<string, unknown> | undefined;\n\n // Create anonymous authorization\n const publicAccess = authOptions?.['publicAccess'] as Record<string, unknown> | undefined;\n const authorization = PublicAuthorization.create({\n scopes: (authOptions?.['anonymousScopes'] as string[] | undefined) ?? ['anonymous'],\n ttlMs: this.parseTtl(authOptions?.['sessionTtl'] as string | number | undefined),\n issuer: (authOptions?.['issuer'] as string | undefined) ?? this.state.required.baseUrl,\n allowedTools: (publicAccess?.['tools'] as string[] | 'all' | undefined) ?? 'all',\n allowedPrompts: (publicAccess?.['prompts'] as string[] | 'all' | undefined) ?? 'all',\n });\n\n this.logger.info(`Created anonymous authorization: ${authorization.id}`);\n\n this.respond({\n kind: 'authorized',\n authorization,\n });\n }\n\n /**\n * Require authorization header for non-public modes\n */\n @Stage('requireAuthorizationHeader', {\n filter: ({ state }) => state.authMode !== 'public' && !state.authorizationHeader,\n })\n async requireAuthorizationHeader() {\n this.logger.warn('No authorization header provided');\n this.respond({\n kind: 'unauthorized',\n wwwAuthenticateHeader: this.state.required.wwwAuthenticateHeader,\n reason: 'No authorization header provided',\n });\n }\n\n /**\n * Verify the JWT token\n */\n @Stage('verifyToken', {\n filter: ({ state }) => !!state.token,\n })\n async verifyToken() {\n const jwks = this.get(JwksService);\n const token = this.state.required.token;\n const authMode = this.state.required.authMode;\n const { baseUrl, prmUrl } = this.state.required;\n\n // Non-JWT tokens are not supported\n if (!isJwt(token)) {\n this.logger.warn('Token is not a JWT');\n this.respond({\n kind: 'unauthorized',\n wwwAuthenticateHeader: buildInvalidTokenHeader(prmUrl, 'Token is not a valid JWT'),\n reason: 'Token is not a valid JWT',\n });\n return;\n }\n\n // Verify based on auth mode\n let verifyResult: VerifyResult;\n\n if (authMode === 'orchestrated') {\n // Orchestrated: verify against local keys\n verifyResult = await jwks.verifyGatewayToken(token, baseUrl);\n } else {\n // Transparent: verify against upstream provider\n const authOptions = this.scope.auth?.options as Record<string, unknown> | undefined;\n const issuerUrl = this.scope.auth?.issuer;\n if (!issuerUrl) {\n this.logger.warn('No issuer URL configured for transparent mode');\n this.respond({\n kind: 'unauthorized',\n wwwAuthenticateHeader: buildInvalidTokenHeader(prmUrl, 'Server misconfiguration'),\n reason: 'No issuer URL configured',\n });\n return;\n }\n const providerRefs: ProviderVerifyRef[] = [\n {\n id: (authOptions?.['id'] as string | undefined) ?? 'default',\n issuerUrl,\n jwks: authOptions?.['jwks'] as JSONWebKeySet | undefined,\n jwksUri: authOptions?.['jwksUri'] as string | undefined,\n },\n ];\n verifyResult = await jwks.verifyTransparentToken(token, providerRefs);\n }\n\n if (!verifyResult.ok) {\n this.logger.warn(`Token verification failed: ${verifyResult.error}`);\n this.respond({\n kind: 'unauthorized',\n wwwAuthenticateHeader: buildInvalidTokenHeader(prmUrl, verifyResult.error),\n reason: verifyResult.error ?? 'Token verification failed',\n });\n return;\n }\n\n // Validate audience\n const authOptionsForAudience = this.scope.auth?.options as Record<string, unknown> | undefined;\n const expectedAudience =\n (authOptionsForAudience?.['expectedAudience'] as string | string[] | undefined) ??\n deriveExpectedAudience(baseUrl);\n const expectedAudienceArray = Array.isArray(expectedAudience) ? expectedAudience : [expectedAudience];\n\n const audResult = validateAudience(verifyResult.payload?.aud as string | string[] | undefined, {\n expectedAudiences: expectedAudienceArray,\n allowNoAudience: true, // Some tokens may not have audience\n });\n\n if (!audResult.valid) {\n this.logger.warn(`Audience validation failed: ${audResult.error}`);\n this.respond({\n kind: 'unauthorized',\n wwwAuthenticateHeader: buildInvalidTokenHeader(prmUrl, audResult.error),\n reason: audResult.error,\n });\n return;\n }\n\n // Check required scopes\n const requiredScopes = (authOptionsForAudience?.['requiredScopes'] as string[] | undefined) ?? [];\n if (requiredScopes.length > 0) {\n const tokenScopes = this.parseScopes(verifyResult.payload?.scope);\n const hasAllScopes = requiredScopes.every((s: string) => tokenScopes.includes(s));\n\n if (!hasAllScopes) {\n this.logger.warn(`Insufficient scopes. Required: ${requiredScopes.join(', ')}`);\n this.respond({\n kind: 'unauthorized',\n wwwAuthenticateHeader: buildInsufficientScopeHeader(prmUrl, requiredScopes),\n reason: `Missing required scopes: ${requiredScopes.join(', ')}`,\n });\n return;\n }\n }\n\n // Store verified payload and user\n const user = deriveTypedUser(verifyResult.payload ?? {});\n this.state.set({\n jwtPayload: verifyResult.payload,\n user,\n });\n }\n\n /**\n * Build the Authorization object based on auth mode\n */\n @Stage('buildAuthorization')\n async buildAuthorization() {\n const { token, jwtPayload, user, authMode, baseUrl } = this.state.required;\n\n if (!user) {\n this.respond({\n kind: 'unauthorized',\n wwwAuthenticateHeader: this.state.required.wwwAuthenticateHeader,\n reason: 'Failed to derive user from token',\n });\n return;\n }\n\n let authorization: Authorization;\n\n if (authMode === 'transparent') {\n // Transparent mode: pass-through token\n const authOptions = this.scope.auth?.options as Record<string, unknown> | undefined;\n // jwtPayload has been verified and should contain sub from the upstream token\n const payload = jwtPayload as TransparentVerifiedPayload;\n authorization = TransparentAuthorization.fromVerifiedToken({\n token,\n payload,\n providerId: this.scope.auth?.id ?? 'default',\n providerName: authOptions?.['name'] as string | undefined,\n });\n } else if (authMode === 'orchestrated') {\n // Orchestrated mode: local auth server\n // TODO: Retrieve token store from scope configuration\n authorization = OrchestratedAuthorization.create({\n token,\n user: {\n sub: user.sub ?? 'unknown',\n name: user.name,\n email: user.email,\n picture: user.picture,\n },\n scopes: this.parseScopes(jwtPayload?.['scope']),\n claims: jwtPayload,\n expiresAt: jwtPayload?.['exp'] ? (jwtPayload['exp'] as number) * 1000 : undefined,\n primaryProviderId: this.scope.auth?.id ?? 'default',\n // tokenStore will be injected by scope\n });\n } else {\n // Public mode with token (authenticated public)\n authorization = PublicAuthorization.create({\n scopes: this.parseScopes(jwtPayload?.['scope']) || ['anonymous'],\n ttlMs: jwtPayload?.['exp'] ? (jwtPayload['exp'] as number) * 1000 - Date.now() : 3600000,\n issuer: baseUrl,\n });\n }\n\n this.logger.info(`Authorization created: ${authorization.id} (mode: ${authMode})`);\n\n this.respond({\n kind: 'authorized',\n authorization,\n });\n }\n\n /**\n * Parse TTL from string or number\n */\n private parseTtl(ttl?: string | number): number {\n if (!ttl) return 3600000; // 1 hour default\n\n if (typeof ttl === 'number') return ttl * 1000; // Assume seconds\n\n // Parse duration string (e.g., '1h', '30m', '1d')\n const match = ttl.match(/^(\\d+)(s|m|h|d)$/);\n if (!match) return 3600000;\n\n const [, value, unit] = match;\n const num = parseInt(value, 10);\n\n switch (unit) {\n case 's':\n return num * 1000;\n case 'm':\n return num * 60 * 1000;\n case 'h':\n return num * 60 * 60 * 1000;\n case 'd':\n return num * 24 * 60 * 60 * 1000;\n default:\n return 3600000;\n }\n }\n\n /**\n * Parse scopes from JWT claim\n */\n private parseScopes(scope: unknown): string[] {\n if (!scope) return [];\n if (Array.isArray(scope)) return scope.map(String);\n if (typeof scope === 'string') return scope.split(/\\s+/).filter(Boolean);\n return [];\n }\n}\n"]}
|