@frontmcp/sdk 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +110 -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 +336 -1632
- 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 +89 -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 +77 -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 +248 -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 +78 -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 +110 -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 +83 -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 +83 -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 +60 -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 +59 -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 +161 -1112
- 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 +51 -474
- package/src/tool/flows/tools-list.flow.js +121 -40
- 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 +95 -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 +138 -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 +922 -207
- 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 +80 -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 +82 -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 +82 -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 +47 -145
- package/src/transport/mcp-handlers/logging-set-level-request.handler.d.ts +66 -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 +72 -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 +57 -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 +57 -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
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
3
|
<picture>
|
|
4
|
-
<source width="400" media="(prefers-color-scheme: dark)" srcset="docs/assets/logo/frontmcp.dark.svg">
|
|
5
|
-
<source width="400" media="(prefers-color-scheme: light)" srcset="docs/assets/logo/frontmcp.light.svg">
|
|
6
|
-
<img width="400" alt="FrontMCP Logo" src="docs/assets/logo/frontmcp.light.svg">
|
|
4
|
+
<source width="400" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/agentfront/frontmcp/refs/heads/main/docs/live/assets/logo/frontmcp.dark.svg">
|
|
5
|
+
<source width="400" media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/agentfront/frontmcp/refs/heads/main/docs/live/assets/logo/frontmcp.light.svg">
|
|
6
|
+
<img width="400" alt="FrontMCP Logo" src="https://raw.githubusercontent.com/agentfront/frontmcp/refs/heads/main/docs/live/assets/logo/frontmcp.light.svg">
|
|
7
7
|
</picture>
|
|
8
8
|
<hr>
|
|
9
9
|
|
|
@@ -84,7 +84,13 @@ export default class Server {}
|
|
|
84
84
|
|
|
85
85
|
## Installation
|
|
86
86
|
|
|
87
|
-
**
|
|
87
|
+
**Prerequisites:**
|
|
88
|
+
|
|
89
|
+
- **Node.js**: Minimum version 22 (LTS) | Recommended version 24 (Active LTS)
|
|
90
|
+
- _This framework is developed and tested on Node.js 24_
|
|
91
|
+
- **npm**: ≥ 10 (or pnpm/yarn equivalent)
|
|
92
|
+
|
|
93
|
+
For detailed setup instructions, see the [Installation Guide][1].
|
|
88
94
|
|
|
89
95
|
### Option A — New project (recommended)
|
|
90
96
|
|
|
@@ -98,7 +104,7 @@ installs required dev deps. ([Installation - FrontMCP][1])
|
|
|
98
104
|
### Option B — Add to an existing project
|
|
99
105
|
|
|
100
106
|
```bash
|
|
101
|
-
npm i -D frontmcp @types/node@^
|
|
107
|
+
npm i -D frontmcp @types/node@^22
|
|
102
108
|
npx frontmcp init
|
|
103
109
|
```
|
|
104
110
|
|
|
@@ -295,31 +301,37 @@ FrontMCP][3])
|
|
|
295
301
|
|
|
296
302
|
### Servers
|
|
297
303
|
|
|
298
|
-
`@FrontMcp({...})
|
|
299
|
-
minimal
|
|
304
|
+
The FrontMCP server is defined with a single decorator: `@FrontMcp({...})`. It configures **info**, **apps**, **http**,
|
|
305
|
+
**logging**, **session**, and optional **auth**. Start minimal and scale up with providers and plugins.
|
|
306
|
+
([The FrontMCP Server - FrontMCP][5])
|
|
300
307
|
|
|
301
308
|
### Apps
|
|
302
309
|
|
|
303
|
-
|
|
304
|
-
|
|
310
|
+
Apps are the **organizational units** for capabilities. Each app groups related **tools**, **resources**, and **prompts**
|
|
311
|
+
into a cohesive domain, along with **providers**, **adapters**, and **plugins**. With `splitByApp: true`, apps get
|
|
312
|
+
isolated scopes and auth surfaces. ([Apps - FrontMCP][6])
|
|
305
313
|
|
|
306
314
|
### Tools
|
|
307
315
|
|
|
308
|
-
|
|
309
|
-
|
|
316
|
+
Tools are **typed actions** that execute operations with side effects. They're the primary way to enable an AI model to
|
|
317
|
+
interact with external systems—calling APIs, modifying data, performing calculations, or triggering workflows. Use the
|
|
318
|
+
class `@Tool` decorator or inline `tool({...})(handler)` with Zod schemas. ([Tools - FrontMCP][4])
|
|
310
319
|
|
|
311
320
|
### Resources
|
|
312
321
|
|
|
313
|
-
|
|
322
|
+
Resources expose **readable data** to an AI model's context. Unlike tools that execute actions with side effects,
|
|
323
|
+
resources are designed for read-only data retrieval—configuration files, user profiles, documents, or any content
|
|
324
|
+
the model needs to reference. ([Resources - FrontMCP][7])
|
|
314
325
|
|
|
315
326
|
### Prompts
|
|
316
327
|
|
|
317
|
-
|
|
328
|
+
Prompts provide **reusable message templates** for AI interactions. They return MCP `GetPromptResult` with typed
|
|
329
|
+
arguments, enabling consistent conversation patterns. ([Prompts - FrontMCP][8])
|
|
318
330
|
|
|
319
331
|
### Providers / Adapters / Plugins
|
|
320
332
|
|
|
321
|
-
Inject shared services, generate tools from OpenAPI, and add cross‑cutting behavior like caching and hooks.
|
|
322
|
-
OpenAPI Adapter - FrontMCP][9])
|
|
333
|
+
Inject shared services, generate tools from OpenAPI specs, and add cross‑cutting behavior like caching and hooks.
|
|
334
|
+
([Add OpenAPI Adapter - FrontMCP][9])
|
|
323
335
|
|
|
324
336
|
---
|
|
325
337
|
|
|
@@ -442,7 +454,7 @@ See [LICENSE](./LICENSE).
|
|
|
442
454
|
[7]: https://docs.agentfront.dev/docs/servers/resources 'Resources - FrontMCP'
|
|
443
455
|
[8]: https://docs.agentfront.dev/docs/servers/prompts 'Prompts - FrontMCP'
|
|
444
456
|
[9]: https://docs.agentfront.dev/docs/guides/add-openapi-adapter 'Add OpenAPI Adapter - FrontMCP'
|
|
445
|
-
[10]: https://docs.agentfront.dev/docs/
|
|
446
|
-
[11]: https://docs.agentfront.dev/docs/
|
|
447
|
-
[12]: https://docs.agentfront.dev/docs/
|
|
457
|
+
[10]: https://docs.agentfront.dev/docs/authentication/overview 'Authentication - FrontMCP'
|
|
458
|
+
[11]: https://docs.agentfront.dev/docs/authentication/remote 'Remote OAuth - FrontMCP'
|
|
459
|
+
[12]: https://docs.agentfront.dev/docs/authentication/local 'Local OAuth - FrontMCP'
|
|
448
460
|
[13]: https://docs.agentfront.dev/docs/deployment/production-build 'Production Build - FrontMCP'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "FrontMCP SDK",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"homepage": "https://docs.agentfront.dev",
|
|
@@ -31,21 +31,36 @@
|
|
|
31
31
|
"types": "./src/index.d.ts",
|
|
32
32
|
"import": "./src/index.js",
|
|
33
33
|
"default": "./src/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./mcp-apps": {
|
|
36
|
+
"types": "./src/mcp-apps/index.d.ts",
|
|
37
|
+
"import": "./src/mcp-apps/index.js",
|
|
38
|
+
"default": "./src/mcp-apps/index.js"
|
|
34
39
|
}
|
|
35
40
|
},
|
|
36
41
|
"peerDependencies": {
|
|
37
|
-
"zod": "^
|
|
42
|
+
"zod": "^4.0.0",
|
|
43
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
44
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"react": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"react-dom": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
38
53
|
},
|
|
39
54
|
"dependencies": {
|
|
40
|
-
"@
|
|
55
|
+
"@frontmcp/ui": "0.5.1",
|
|
56
|
+
"@modelcontextprotocol/sdk": "1.24.3",
|
|
41
57
|
"axios": "^1.6.0",
|
|
42
58
|
"ioredis": "^5.8.0",
|
|
43
59
|
"jose": "^6.1.0",
|
|
44
60
|
"openapi-mcp-generator": "^3.2.0",
|
|
45
61
|
"reflect-metadata": "^0.2.2",
|
|
46
62
|
"rxjs": "^7.8.0",
|
|
47
|
-
"
|
|
48
|
-
"zod-to-json-schema": "^3.25.0",
|
|
63
|
+
"vectoriadb": "^2.0.1",
|
|
49
64
|
"tslib": "^2.3.0"
|
|
50
65
|
},
|
|
51
66
|
"devDependencies": {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { AppType, AppEntry, AppRecord } from '../common';
|
|
2
|
+
import { AppType, AppEntry, AppRecord, EntryOwnerRef } from '../common';
|
|
3
3
|
import ProviderRegistry from '../provider/provider.registry';
|
|
4
4
|
import { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';
|
|
5
5
|
export default class AppRegistry extends RegistryAbstract<AppEntry, AppRecord, AppType[]> {
|
|
6
|
-
|
|
6
|
+
private readonly owner;
|
|
7
|
+
constructor(globalProviders: ProviderRegistry, list: AppType[], owner: EntryOwnerRef);
|
|
7
8
|
protected buildMap(list: AppType[]): RegistryBuildMapResult<AppRecord>;
|
|
8
9
|
protected buildGraph(): void;
|
|
9
10
|
/** Instantiate adapters, run fetch/transform, and populate registries. */
|
package/src/app/app.registry.js
CHANGED
|
@@ -7,8 +7,10 @@ const regsitry_1 = require("../regsitry");
|
|
|
7
7
|
const token_utils_1 = require("../utils/token.utils");
|
|
8
8
|
const instances_1 = require("./instances");
|
|
9
9
|
class AppRegistry extends regsitry_1.RegistryAbstract {
|
|
10
|
-
|
|
10
|
+
owner;
|
|
11
|
+
constructor(globalProviders, list, owner) {
|
|
11
12
|
super('AppRegistry', globalProviders, list);
|
|
13
|
+
this.owner = owner;
|
|
12
14
|
}
|
|
13
15
|
buildMap(list) {
|
|
14
16
|
const tokens = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.registry.js","sourceRoot":"","sources":["../../../src/app/app.registry.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"app.registry.js","sourceRoot":"","sources":["../../../src/app/app.registry.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,sCAAwF;AACxF,2CAA6D;AAE7D,0CAAuE;AACvE,sDAAiD;AACjD,2CAAkE;AAElE,MAAqB,WAAY,SAAQ,2BAAgD;IACtE,KAAK,CAAgB;IAEtC,YAAY,eAAiC,EAAE,IAAe,EAAE,KAAoB;QAClF,KAAK,CAAC,aAAa,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAES,QAAQ,CAAC,IAAe;QAChC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAS,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAoB,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;QAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,GAAG,GAAG,IAAA,wBAAY,EAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACvB,KAAK,CAAC,G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I,6BAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YACnD,CAAC;iBAAM,CAAC;gBACN,iCAAiC;gBACjC,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;YACtC,CAAC;YAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;CACF;AA5DD,8BA4DC","sourcesContent":["import 'reflect-metadata';\nimport { AppType, Token, AppEntry, AppKind, AppRecord, EntryOwnerRef } from '../common';\nimport { appDiscoveryDeps, normalizeApp } from './app.utils';\nimport ProviderRegistry from '../provider/provider.registry';\nimport { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';\nimport { tokenName } from '../utils/token.utils';\nimport { AppLocalInstance, AppRemoteInstance } from './instances';\n\nexport default class AppRegistry extends RegistryAbstract<AppEntry, AppRecord, AppType[]> {\n private readonly owner: EntryOwnerRef;\n\n constructor(globalProviders: ProviderRegistry, list: AppType[], owner: EntryOwnerRef) {\n super('AppRegistry', globalProviders, list);\n this.owner = owner;\n }\n\n protected buildMap(list: AppType[]): RegistryBuildMapResult<AppRecord> {\n const tokens = new Set<Token>();\n const defs = new Map<Token, AppRecord>();\n const graph = new Map<Token, Set<Token>>();\n for (const raw of list) {\n const rec = normalizeApp(raw);\n const provide = rec.provide;\n tokens.add(provide);\n defs.set(provide, rec);\n graph.set(provide, new Set());\n }\n return { tokens, defs, graph };\n }\n\n protected buildGraph() {\n for (const token of this.tokens) {\n const rec = this.defs.get(token)!;\n const deps = appDiscoveryDeps(rec);\n for (const d of deps) {\n if (!this.providers.get(d)) {\n throw new Error(`App ${tokenName(token)} depends on ${tokenName(d)}, which is not registered.`);\n }\n this.graph.get(token)!.add(d);\n }\n }\n }\n\n /** Instantiate adapters, run fetch/transform, and populate registries. */\n protected async initialize(): Promise<void> {\n const readyArr: Promise<void>[] = [];\n for (const token of this.tokens) {\n const rec = this.defs.get(token)!;\n\n let app: AppEntry;\n if (rec.kind === AppKind.LOCAL_CLASS) {\n app = new AppLocalInstance(rec, this.providers);\n } else if (rec.kind === AppKind.REMOTE_VALUE) {\n app = new AppRemoteInstance(rec, this.providers);\n } else {\n // TODO: use specific error class\n throw Error('Invalid adapter kind');\n }\n\n this.instances.set(token, app);\n readyArr.push(app.ready);\n }\n await Promise.all(readyArr);\n }\n\n getApps(): AppEntry[] {\n return [...this.instances.values()];\n }\n}\n"]}
|
|
@@ -40,8 +40,8 @@ class AppLocalInstance extends common_1.AppEntry {
|
|
|
40
40
|
this.appAdapters = new adapter_regsitry_1.default(this.appProviders, this.metadata.adapters ?? []);
|
|
41
41
|
await this.appAdapters.ready;
|
|
42
42
|
this.appTools = new tool_registry_1.default(this.appProviders, this.metadata.tools ?? [], appOwner);
|
|
43
|
-
this.appResources = new resource_registry_1.default(this.appProviders, this.metadata.resources ?? []);
|
|
44
|
-
this.appPrompts = new prompt_registry_1.default(this.appProviders, this.metadata.prompts ?? []);
|
|
43
|
+
this.appResources = new resource_registry_1.default(this.appProviders, this.metadata.resources ?? [], appOwner);
|
|
44
|
+
this.appPrompts = new prompt_registry_1.default(this.appProviders, this.metadata.prompts ?? [], appOwner);
|
|
45
45
|
await Promise.all([this.appTools.ready, this.appResources.ready, this.appPrompts.ready]);
|
|
46
46
|
}
|
|
47
47
|
get providers() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.local.instance.js","sourceRoot":"","sources":["../../../../src/app/instances/app.local.instance.ts"],"names":[],"mappings":";;;;AAAA,yCAAqE;AACrE,2DAAwD;AACxD,iGAAgE;AAChE,qFAAoD;AACpD,iGAA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AED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AAlED,4CAkEC","sourcesContent":["import { AppEntry, AppRecord, LocalAppMetadata } from '../../common';\nimport { idFromString } from '../../utils/string.utils';\nimport ProviderRegistry from '../../provider/provider.registry';\nimport ToolRegistry from '../../tool/tool.registry';\nimport ResourceRegistry from '../../resource/resource.registry';\nimport PromptRegistry from '../../prompt/prompt.registry';\nimport AdapterRegistry from '../../adapter/adapter.regsitry';\nimport PluginRegistry from '../../plugin/plugin.registry';\n\nexport class AppLocalInstance extends AppEntry<LocalAppMetadata> {\n override readonly id: string;\n\n private scopeProviders: ProviderRegistry;\n private appProviders: ProviderRegistry;\n private appPlugins: PluginRegistry;\n private appAdapters: AdapterRegistry;\n private appTools: ToolRegistry;\n private appResources: ResourceRegistry;\n private appPrompts: PromptRegistry;\n\n constructor(record: AppRecord, scopeProviders: ProviderRegistry) {\n super(record);\n this.scopeProviders = scopeProviders;\n this.id = this.metadata.id ?? idFromString(this.metadata.name);\n this.ready = this.initialize();\n }\n\n protected async initialize() {\n this.appProviders = new ProviderRegistry(this.metadata.providers ?? [], this.scopeProviders);\n await this.appProviders.ready; // wait for providers to be ready\n // this.authProviders = new AuthRegistry(this.providers, this.metadata.authProviders ?? []);\n // await this.authProviders.ready; // wait for providers to be ready\n\n const appOwner = {\n kind: 'app' as const,\n id: this.id,\n ref: this.token,\n };\n\n this.appPlugins = new PluginRegistry(this.appProviders, this.metadata.plugins ?? [], appOwner);\n await this.appPlugins.ready; // wait for plugins and it's providers/adapters/tools/resource/prompts to be ready\n\n this.appAdapters = new AdapterRegistry(this.appProviders, this.metadata.adapters ?? []);\n await this.appAdapters.ready;\n\n this.appTools = new ToolRegistry(this.appProviders, this.metadata.tools ?? [], appOwner);\n this.appResources = new ResourceRegistry(this.appProviders, this.metadata.resources ?? [], appOwner);\n this.appPrompts = new PromptRegistry(this.appProviders, this.metadata.prompts ?? [], appOwner);\n\n await Promise.all([this.appTools.ready, this.appResources.ready, this.appPrompts.ready]);\n }\n\n get providers(): Readonly<ProviderRegistry> {\n return this.appProviders;\n }\n\n get adapters(): Readonly<AdapterRegistry> {\n return this.appAdapters;\n }\n\n get plugins(): Readonly<PluginRegistry> {\n return this.appPlugins;\n }\n\n get tools(): Readonly<ToolRegistry> {\n return this.appTools;\n }\n\n get resources(): Readonly<ResourceRegistry> {\n return this.appResources;\n }\n\n get prompts(): Readonly<PromptRegistry> {\n return this.appPrompts;\n }\n}\n"]}
|
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';
|
|
3
3
|
import ProviderRegistry from '../provider/provider.registry';
|
|
4
|
-
import {
|
|
4
|
+
import { FrontMcpAuth, AuthProviderType, AuthProviderEntry, AuthRegistryInterface, AuthProviderRecord, EntryOwnerRef, ScopeEntry, AuthOptionsInput } from '../common';
|
|
5
|
+
import { AuthProviderDetectionResult } from './detection';
|
|
5
6
|
export declare class AuthRegistry extends RegistryAbstract<AuthProviderEntry, AuthProviderRecord, AuthProviderType[]> implements AuthRegistryInterface {
|
|
6
7
|
private readonly primary?;
|
|
7
|
-
|
|
8
|
+
private readonly parsedOptions;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private readonly owner;
|
|
11
|
+
/**
|
|
12
|
+
* Detection result for auth providers across the scope hierarchy
|
|
13
|
+
*/
|
|
14
|
+
readonly detection: AuthProviderDetectionResult;
|
|
15
|
+
/**
|
|
16
|
+
* Whether this scope requires orchestrated mode
|
|
17
|
+
*/
|
|
18
|
+
readonly requiresOrchestration: boolean;
|
|
19
|
+
constructor(scope: ScopeEntry, providers: ProviderRegistry, metadata: AuthProviderType[], owner: EntryOwnerRef, primaryInput?: AuthOptionsInput);
|
|
20
|
+
/**
|
|
21
|
+
* Extract AppAuthInfo from scope metadata
|
|
22
|
+
*/
|
|
23
|
+
private extractAppAuthInfo;
|
|
24
|
+
/**
|
|
25
|
+
* Get app metadata from AppType (handles both class and value types)
|
|
26
|
+
*/
|
|
27
|
+
private getAppMetadata;
|
|
28
|
+
/**
|
|
29
|
+
* Log detection results for debugging
|
|
30
|
+
*/
|
|
31
|
+
private logDetectionResults;
|
|
32
|
+
/**
|
|
33
|
+
* Validate configuration and throw if invalid
|
|
34
|
+
*/
|
|
35
|
+
private validateConfiguration;
|
|
36
|
+
/**
|
|
37
|
+
* Create the appropriate primary auth provider based on parsed options
|
|
38
|
+
*/
|
|
39
|
+
private createPrimaryAuth;
|
|
8
40
|
protected buildMap(list: AuthProviderType[]): RegistryBuildMapResult<AuthProviderRecord>;
|
|
9
41
|
protected buildGraph(): void;
|
|
10
42
|
protected initialize(): Promise<void>;
|
|
@@ -6,39 +6,167 @@ require("reflect-metadata");
|
|
|
6
6
|
const regsitry_1 = require("../regsitry");
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const auth_utils_1 = require("./auth.utils");
|
|
9
|
-
const
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
10
|
const instance_remote_primary_auth_1 = require("./instances/instance.remote-primary-auth");
|
|
11
11
|
const instance_local_primary_auth_1 = require("./instances/instance.local-primary-auth");
|
|
12
|
+
const detection_1 = require("./detection");
|
|
13
|
+
const errors_1 = require("../errors");
|
|
14
|
+
/**
|
|
15
|
+
* Default auth options when none provided - public mode with all tools open
|
|
16
|
+
*/
|
|
17
|
+
const DEFAULT_AUTH_OPTIONS = {
|
|
18
|
+
mode: 'orchestrated',
|
|
19
|
+
type: 'local',
|
|
20
|
+
allowDefaultPublic: true,
|
|
21
|
+
};
|
|
12
22
|
class AuthRegistry extends regsitry_1.RegistryAbstract {
|
|
13
23
|
primary;
|
|
14
|
-
|
|
24
|
+
parsedOptions;
|
|
25
|
+
logger;
|
|
26
|
+
owner;
|
|
27
|
+
/**
|
|
28
|
+
* Detection result for auth providers across the scope hierarchy
|
|
29
|
+
*/
|
|
30
|
+
detection;
|
|
31
|
+
/**
|
|
32
|
+
* Whether this scope requires orchestrated mode
|
|
33
|
+
*/
|
|
34
|
+
requiresOrchestration;
|
|
35
|
+
constructor(scope, providers, metadata, owner, primaryInput) {
|
|
15
36
|
super('AuthRegistry', providers, metadata, false);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
37
|
+
this.owner = owner;
|
|
38
|
+
this.logger = providers.get(common_1.FrontMcpLogger).child('AuthRegistry');
|
|
39
|
+
// Parse input with defaults applied
|
|
40
|
+
this.parsedOptions = (0, common_1.parseAuthOptions)(primaryInput ?? DEFAULT_AUTH_OPTIONS);
|
|
41
|
+
// Detect auth providers across all apps in this scope
|
|
42
|
+
const appAuthInfos = this.extractAppAuthInfo(scope);
|
|
43
|
+
this.detection = (0, detection_1.detectAuthProviders)(this.parsedOptions, appAuthInfos);
|
|
44
|
+
this.requiresOrchestration = this.detection.requiresOrchestration;
|
|
45
|
+
// Log detection results
|
|
46
|
+
this.logDetectionResults();
|
|
47
|
+
// Validate configuration and throw if invalid
|
|
48
|
+
this.validateConfiguration();
|
|
49
|
+
// Create the appropriate primary auth provider based on mode
|
|
50
|
+
this.primary = this.createPrimaryAuth(scope, providers, this.parsedOptions);
|
|
51
|
+
const primaryRecord = {
|
|
52
|
+
kind: common_1.AuthProviderKind.PRIMARY,
|
|
53
|
+
provide: common_1.FrontMcpAuth,
|
|
54
|
+
useValue: this.primary,
|
|
55
|
+
metadata: this.parsedOptions,
|
|
56
|
+
};
|
|
36
57
|
this.tokens.add(common_1.FrontMcpAuth);
|
|
37
58
|
this.defs.set(common_1.FrontMcpAuth, primaryRecord);
|
|
38
59
|
this.graph.set(common_1.FrontMcpAuth, new Set());
|
|
39
60
|
this.buildGraph();
|
|
40
61
|
this.ready = this.initialize();
|
|
41
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Extract AppAuthInfo from scope metadata
|
|
65
|
+
*/
|
|
66
|
+
extractAppAuthInfo(scope) {
|
|
67
|
+
const apps = scope.metadata.apps || [];
|
|
68
|
+
const result = [];
|
|
69
|
+
for (const app of apps) {
|
|
70
|
+
// Handle both class-based and value-based app definitions
|
|
71
|
+
const appMeta = this.getAppMetadata(app);
|
|
72
|
+
if (appMeta) {
|
|
73
|
+
result.push({
|
|
74
|
+
id: appMeta.id || appMeta.name,
|
|
75
|
+
name: appMeta.name,
|
|
76
|
+
auth: appMeta.auth,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get app metadata from AppType (handles both class and value types)
|
|
84
|
+
*/
|
|
85
|
+
getAppMetadata(app) {
|
|
86
|
+
// Value type: has metadata directly
|
|
87
|
+
if (typeof app === 'object' && 'name' in app) {
|
|
88
|
+
const appValue = app;
|
|
89
|
+
return {
|
|
90
|
+
id: appValue.id,
|
|
91
|
+
name: appValue.name,
|
|
92
|
+
auth: appValue.auth,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Class type: check for metadata decorator
|
|
96
|
+
if (typeof app === 'function') {
|
|
97
|
+
const metadata = Reflect.getMetadata('frontmcp:app', app);
|
|
98
|
+
if (metadata) {
|
|
99
|
+
return {
|
|
100
|
+
id: metadata.id,
|
|
101
|
+
name: metadata.name,
|
|
102
|
+
auth: metadata.auth,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Log detection results for debugging
|
|
110
|
+
*/
|
|
111
|
+
logDetectionResults() {
|
|
112
|
+
const { providers, uniqueProviderCount, requiresOrchestration, warnings } = this.detection;
|
|
113
|
+
if (uniqueProviderCount > 1) {
|
|
114
|
+
this.logger.info(`Detected ${uniqueProviderCount} unique auth providers: ${[...providers.keys()].join(', ')}`);
|
|
115
|
+
}
|
|
116
|
+
if (requiresOrchestration) {
|
|
117
|
+
this.logger.info(`Orchestration required: Multiple auth providers detected across apps`);
|
|
118
|
+
}
|
|
119
|
+
// Log warnings
|
|
120
|
+
for (const warning of warnings) {
|
|
121
|
+
this.logger.warn(warning);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Validate configuration and throw if invalid
|
|
126
|
+
*/
|
|
127
|
+
validateConfiguration() {
|
|
128
|
+
const { validationErrors } = this.detection;
|
|
129
|
+
if (validationErrors.length > 0) {
|
|
130
|
+
// Log all errors
|
|
131
|
+
for (const error of validationErrors) {
|
|
132
|
+
this.logger.error(`[AuthRegistry] ${error}`);
|
|
133
|
+
}
|
|
134
|
+
// Throw with first error (most important)
|
|
135
|
+
throw new errors_1.AuthConfigurationError(`Invalid auth configuration: ${validationErrors[0]}`, {
|
|
136
|
+
errors: validationErrors,
|
|
137
|
+
suggestion: `1. Change your parent auth mode from 'transparent' to 'orchestrated'\n` +
|
|
138
|
+
`2. Example:\n` +
|
|
139
|
+
` auth: {\n` +
|
|
140
|
+
` mode: 'orchestrated',\n` +
|
|
141
|
+
` type: 'local', // or 'remote' with your provider config\n` +
|
|
142
|
+
` }`,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create the appropriate primary auth provider based on parsed options
|
|
148
|
+
*/
|
|
149
|
+
createPrimaryAuth(scope, providers, options) {
|
|
150
|
+
if ((0, common_1.isPublicMode)(options)) {
|
|
151
|
+
return new instance_local_primary_auth_1.LocalPrimaryAuth(scope, providers, options);
|
|
152
|
+
}
|
|
153
|
+
if ((0, common_1.isTransparentMode)(options)) {
|
|
154
|
+
return new instance_remote_primary_auth_1.RemotePrimaryAuth(scope, providers, options);
|
|
155
|
+
}
|
|
156
|
+
if ((0, common_1.isOrchestratedMode)(options)) {
|
|
157
|
+
if ((0, common_1.isOrchestratedLocal)(options)) {
|
|
158
|
+
return new instance_local_primary_auth_1.LocalPrimaryAuth(scope, providers, options);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// Orchestrated remote: local auth server proxying to remote provider
|
|
162
|
+
// TODO: Store remote config for upstream OAuth flows
|
|
163
|
+
return new instance_local_primary_auth_1.LocalPrimaryAuth(scope, providers, options);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Fallback (should never reach here) - create public mode with defaults
|
|
167
|
+
const defaultOptions = (0, common_1.parseAuthOptions)({ mode: 'public' });
|
|
168
|
+
return new instance_local_primary_auth_1.LocalPrimaryAuth(scope, providers, defaultOptions);
|
|
169
|
+
}
|
|
42
170
|
buildMap(list) {
|
|
43
171
|
const tokens = new Set();
|
|
44
172
|
const defs = new Map();
|
|
@@ -55,12 +183,19 @@ class AuthRegistry extends regsitry_1.RegistryAbstract {
|
|
|
55
183
|
buildGraph() {
|
|
56
184
|
for (const token of this.tokens) {
|
|
57
185
|
const rec = this.defs.get(token);
|
|
186
|
+
if (!rec) {
|
|
187
|
+
throw new errors_1.DependencyNotFoundError('AuthRegistry', (0, utils_1.tokenName)(token));
|
|
188
|
+
}
|
|
58
189
|
const deps = (0, auth_utils_1.authDiscoveryDeps)(rec);
|
|
59
190
|
for (const d of deps) {
|
|
60
191
|
if (!this.providers.get(d)) {
|
|
61
|
-
throw new
|
|
192
|
+
throw new errors_1.DependencyNotFoundError('AuthRegistry', `${(0, utils_1.tokenName)(d)} (required by ${(0, utils_1.tokenName)(token)})`);
|
|
193
|
+
}
|
|
194
|
+
const graphEntry = this.graph.get(token);
|
|
195
|
+
if (!graphEntry) {
|
|
196
|
+
throw new errors_1.DependencyNotFoundError('AuthRegistry', `graph entry for ${(0, utils_1.tokenName)(token)}`);
|
|
62
197
|
}
|
|
63
|
-
|
|
198
|
+
graphEntry.add(d);
|
|
64
199
|
}
|
|
65
200
|
}
|
|
66
201
|
}
|
|
@@ -71,6 +206,9 @@ class AuthRegistry extends regsitry_1.RegistryAbstract {
|
|
|
71
206
|
return Promise.resolve();
|
|
72
207
|
}
|
|
73
208
|
getPrimary() {
|
|
209
|
+
if (!this.primary) {
|
|
210
|
+
throw new errors_1.DependencyNotFoundError('AuthRegistry', 'primary auth provider');
|
|
211
|
+
}
|
|
74
212
|
return this.primary;
|
|
75
213
|
}
|
|
76
214
|
getAuthProviders() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.registry.js","sourceRoot":"","sources":["../../../src/auth/auth.registry.ts"],"names":[],"mappings":";;;AAAA,wBAAwB;AACxB,4BAA0B;AAC1B,0CAAqE;AAErE,sCAMmB;AACnB,6CAA8D;AAC9D,sDAA+C;AAC/C,2FAA2E;AAC3E,yFAAyE;AAEzE,MAAa,YAAa,SAAQ,2BAA2E;IAC1F,OAAO,CAAgB;IAExC,YAAY,KAAiB,EAAE,SAA2B,EAAE,QAA4B,EAAE,KAAoB,EAAE,OAAqB;QACnI,KAAK,CAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAElD,IAAI,aAAgC,CAAC;QACrC,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,gDAAiB,CAAC,KAAK,EAAC,SA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AC;IAED,gBAAgB;QACd,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;CACF;AA9ED,oCA8EC","sourcesContent":["// auth/auth.registry.ts\nimport 'reflect-metadata';\nimport {RegistryAbstract, RegistryBuildMapResult} from '../regsitry';\nimport ProviderRegistry from '../provider/provider.registry';\nimport {\n AuthOptions,\n FrontMcpAuth,\n AuthProviderType,\n Token, AuthProviderEntry, AuthRegistryInterface, AuthProviderRecord, AuthProviderKind, EntryOwnerRef,\n PrimaryAuthRecord, ScopeEntry,\n} from '../common';\nimport {authDiscoveryDeps, normalizeAuth} from './auth.utils';\nimport {tokenName} from '../utils/token.utils';\nimport {RemotePrimaryAuth} from './instances/instance.remote-primary-auth';\nimport {LocalPrimaryAuth} from './instances/instance.local-primary-auth';\n\nexport class AuthRegistry extends RegistryAbstract<AuthProviderEntry, AuthProviderRecord, AuthProviderType[]> implements AuthRegistryInterface {\n private readonly primary?: FrontMcpAuth;\n\n constructor(scope: ScopeEntry, providers: ProviderRegistry, metadata: AuthProviderType[], owner: EntryOwnerRef, primary?: AuthOptions) {\n super('AuthRegistry', providers, metadata, false);\n\n let primaryRecord: PrimaryAuthRecord;\n if (primary) {\n this.primary = primary.type === 'remote' ? new RemotePrimaryAuth(scope,providers, primary) : new LocalPrimaryAuth(scope,providers, primary);\n primaryRecord = {\n kind: AuthProviderKind.PRIMARY,\n provide: FrontMcpAuth,\n useValue: this.primary,\n metadata: primary,\n }\n } else {\n const defaultMetadata: AuthOptions = {type: 'local', id: 'local', name: 'default-auth', allowAnonymous: true}\n this.primary = new LocalPrimaryAuth(scope,providers, defaultMetadata);\n primaryRecord = {\n kind: AuthProviderKind.PRIMARY,\n provide: FrontMcpAuth,\n useValue: this.primary,\n metadata: defaultMetadata,\n }\n }\n this.tokens.add(FrontMcpAuth);\n this.defs.set(FrontMcpAuth, primaryRecord)\n this.graph.set(FrontMcpAuth, new Set())\n\n this.buildGraph();\n this.ready = this.initialize();\n }\n\n protected override buildMap(list: AuthProviderType[]): RegistryBuildMapResult<AuthProviderRecord> {\n const tokens = new Set<Token>();\n const defs = new Map<Token, AuthProviderRecord>();\n const graph = new Map<Token, Set<Token>>();\n\n for (const raw of list) {\n const rec = normalizeAuth(raw);\n const provide = rec.provide;\n tokens.add(provide);\n defs.set(provide, rec);\n graph.set(provide, new Set());\n }\n\n return {tokens, defs, graph};\n }\n\n protected buildGraph() {\n for (const token of this.tokens) {\n const rec = this.defs.get(token)!;\n const deps = authDiscoveryDeps(rec);\n\n for (const d of deps) {\n if (!this.providers.get(d)) {\n throw new Error(`AuthProvider ${tokenName(token)} depends on ${tokenName(d)}, which is not registered.`);\n }\n this.graph.get(token)!.add(d);\n }\n }\n }\n\n protected async initialize(): Promise<void> {\n if (this.primary) {\n await this.primary.ready;\n }\n return Promise.resolve();\n }\n\n\n getPrimary(): FrontMcpAuth {\n return this.primary!;\n }\n\n getAuthProviders(): AuthProviderEntry[] {\n return [...this.instances.values()];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth.registry.js","sourceRoot":"","sources":["../../../src/auth/auth.registry.ts"],"names":[],"mappings":";;;AAAA,wBAAwB;AACxB,4BAA0B;AAC1B,0CAAuE;AAEvE,sCAqBmB;AACnB,6CAAgE;AAChE,oCAAqC;AACrC,2FAA6E;AAC7E,yFAA2E;AAC3E,2CAA4F;AAC5F,sCAA4E;AAE5E;;GAEG;AACH,MAAM,oBAAoB,GAAqB;IAC7C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,OAAO;IACb,kBAAkB,EAAE,IAAI;CACzB,CAAC;AAEF,MAAa,YACX,SAAQ,2BAA2E;IAGlE,OAAO,CAAgB;IACvB,aAAa,CAAc;IAC3B,MAAM,CAAiB;IACvB,KAAK,CAAgB;IAEtC;;OAEG;IACM,SAAS,CAA8B;IAEhD;;OAEG;IACM,qBAAqB,CAAU;IAExC,YACE,KAAiB,EACjB,SAA2B,EAC3B,QAA4B,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AES,KAAK,CAAC,UAAU;QACxB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC3B,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,gCAAuB,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,gBAAgB;QACd,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;CACF;AAjPD,oCAiPC","sourcesContent":["// auth/auth.registry.ts\nimport 'reflect-metadata';\nimport { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';\nimport ProviderRegistry from '../provider/provider.registry';\nimport {\n FrontMcpAuth,\n FrontMcpLogger,\n AuthProviderType,\n Token,\n AuthProviderEntry,\n AuthRegistryInterface,\n AuthProviderRecord,\n AuthProviderKind,\n EntryOwnerRef,\n PrimaryAuthRecord,\n ScopeEntry,\n AuthOptions,\n AuthOptionsInput,\n parseAuthOptions,\n isPublicMode,\n isTransparentMode,\n isOrchestratedMode,\n isOrchestratedLocal,\n PublicAuthOptions,\n AppType,\n} from '../common';\nimport { authDiscoveryDeps, normalizeAuth } from './auth.utils';\nimport { tokenName } from '../utils';\nimport { RemotePrimaryAuth } from './instances/instance.remote-primary-auth';\nimport { LocalPrimaryAuth } from './instances/instance.local-primary-auth';\nimport { detectAuthProviders, AuthProviderDetectionResult, AppAuthInfo } from './detection';\nimport { DependencyNotFoundError, AuthConfigurationError } from '../errors';\n\n/**\n * Default auth options when none provided - public mode with all tools open\n */\nconst DEFAULT_AUTH_OPTIONS: AuthOptionsInput = {\n mode: 'orchestrated',\n type: 'local',\n allowDefaultPublic: true,\n};\n\nexport class AuthRegistry\n extends RegistryAbstract<AuthProviderEntry, AuthProviderRecord, AuthProviderType[]>\n implements AuthRegistryInterface\n{\n private readonly primary?: FrontMcpAuth;\n private readonly parsedOptions: AuthOptions;\n private readonly logger: FrontMcpLogger;\n private readonly owner: EntryOwnerRef;\n\n /**\n * Detection result for auth providers across the scope hierarchy\n */\n readonly detection: AuthProviderDetectionResult;\n\n /**\n * Whether this scope requires orchestrated mode\n */\n readonly requiresOrchestration: boolean;\n\n constructor(\n scope: ScopeEntry,\n providers: ProviderRegistry,\n metadata: AuthProviderType[],\n owner: EntryOwnerRef,\n primaryInput?: AuthOptionsInput,\n ) {\n super('AuthRegistry', providers, metadata, false);\n\n this.owner = owner;\n this.logger = providers.get(FrontMcpLogger).child('AuthRegistry');\n\n // Parse input with defaults applied\n this.parsedOptions = parseAuthOptions(primaryInput ?? DEFAULT_AUTH_OPTIONS);\n\n // Detect auth providers across all apps in this scope\n const appAuthInfos = this.extractAppAuthInfo(scope);\n this.detection = detectAuthProviders(this.parsedOptions, appAuthInfos);\n this.requiresOrchestration = this.detection.requiresOrchestration;\n\n // Log detection results\n this.logDetectionResults();\n\n // Validate configuration and throw if invalid\n this.validateConfiguration();\n\n // Create the appropriate primary auth provider based on mode\n this.primary = this.createPrimaryAuth(scope, providers, this.parsedOptions);\n\n const primaryRecord: PrimaryAuthRecord = {\n kind: AuthProviderKind.PRIMARY,\n provide: FrontMcpAuth,\n useValue: this.primary,\n metadata: this.parsedOptions,\n };\n\n this.tokens.add(FrontMcpAuth);\n this.defs.set(FrontMcpAuth, primaryRecord);\n this.graph.set(FrontMcpAuth, new Set());\n\n this.buildGraph();\n this.ready = this.initialize();\n }\n\n /**\n * Extract AppAuthInfo from scope metadata\n */\n private extractAppAuthInfo(scope: ScopeEntry): AppAuthInfo[] {\n const apps = scope.metadata.apps || [];\n const result: AppAuthInfo[] = [];\n\n for (const app of apps) {\n // Handle both class-based and value-based app definitions\n const appMeta = this.getAppMetadata(app);\n if (appMeta) {\n result.push({\n id: appMeta.id || appMeta.name,\n name: appMeta.name,\n auth: appMeta.auth,\n });\n }\n }\n\n return result;\n }\n\n /**\n * Get app metadata from AppType (handles both class and value types)\n */\n private getAppMetadata(app: AppType): { id?: string; name: string; auth?: AuthOptions } | undefined {\n // Value type: has metadata directly\n if (typeof app === 'object' && 'name' in app) {\n const appValue = app as { id?: string; name: string; auth?: AuthOptions };\n return {\n id: appValue.id,\n name: appValue.name,\n auth: appValue.auth,\n };\n }\n\n // Class type: check for metadata decorator\n if (typeof app === 'function') {\n const metadata = Reflect.getMetadata('frontmcp:app', app);\n if (metadata) {\n return {\n id: metadata.id,\n name: metadata.name,\n auth: metadata.auth,\n };\n }\n }\n\n return undefined;\n }\n\n /**\n * Log detection results for debugging\n */\n private logDetectionResults(): void {\n const { providers, uniqueProviderCount, requiresOrchestration, warnings } = this.detection;\n\n if (uniqueProviderCount > 1) {\n this.logger.info(`Detected ${uniqueProviderCount} unique auth providers: ${[...providers.keys()].join(', ')}`);\n }\n\n if (requiresOrchestration) {\n this.logger.info(`Orchestration required: Multiple auth providers detected across apps`);\n }\n\n // Log warnings\n for (const warning of warnings) {\n this.logger.warn(warning);\n }\n }\n\n /**\n * Validate configuration and throw if invalid\n */\n private validateConfiguration(): void {\n const { validationErrors } = this.detection;\n\n if (validationErrors.length > 0) {\n // Log all errors\n for (const error of validationErrors) {\n this.logger.error(`[AuthRegistry] ${error}`);\n }\n\n // Throw with first error (most important)\n throw new AuthConfigurationError(`Invalid auth configuration: ${validationErrors[0]}`, {\n errors: validationErrors,\n suggestion:\n `1. Change your parent auth mode from 'transparent' to 'orchestrated'\\n` +\n `2. Example:\\n` +\n ` auth: {\\n` +\n ` mode: 'orchestrated',\\n` +\n ` type: 'local', // or 'remote' with your provider config\\n` +\n ` }`,\n });\n }\n }\n\n /**\n * Create the appropriate primary auth provider based on parsed options\n */\n private createPrimaryAuth(scope: ScopeEntry, providers: ProviderRegistry, options: AuthOptions): FrontMcpAuth {\n if (isPublicMode(options)) {\n return new LocalPrimaryAuth(scope, providers, options);\n }\n\n if (isTransparentMode(options)) {\n return new RemotePrimaryAuth(scope, providers, options);\n }\n\n if (isOrchestratedMode(options)) {\n if (isOrchestratedLocal(options)) {\n return new LocalPrimaryAuth(scope, providers, options);\n } else {\n // Orchestrated remote: local auth server proxying to remote provider\n // TODO: Store remote config for upstream OAuth flows\n return new LocalPrimaryAuth(scope, providers, options);\n }\n }\n\n // Fallback (should never reach here) - create public mode with defaults\n const defaultOptions = parseAuthOptions({ mode: 'public' }) as PublicAuthOptions;\n return new LocalPrimaryAuth(scope, providers, defaultOptions);\n }\n\n protected override buildMap(list: AuthProviderType[]): RegistryBuildMapResult<AuthProviderRecord> {\n const tokens = new Set<Token>();\n const defs = new Map<Token, AuthProviderRecord>();\n const graph = new Map<Token, Set<Token>>();\n\n for (const raw of list) {\n const rec = normalizeAuth(raw);\n const provide = rec.provide;\n tokens.add(provide);\n defs.set(provide, rec);\n graph.set(provide, new Set());\n }\n\n return { tokens, defs, graph };\n }\n\n protected buildGraph() {\n for (const token of this.tokens) {\n const rec = this.defs.get(token);\n if (!rec) {\n throw new DependencyNotFoundError('AuthRegistry', tokenName(token));\n }\n const deps = authDiscoveryDeps(rec);\n\n for (const d of deps) {\n if (!this.providers.get(d)) {\n throw new DependencyNotFoundError('AuthRegistry', `${tokenName(d)} (required by ${tokenName(token)})`);\n }\n const graphEntry = this.graph.get(token);\n if (!graphEntry) {\n throw new DependencyNotFoundError('AuthRegistry', `graph entry for ${tokenName(token)}`);\n }\n graphEntry.add(d);\n }\n }\n }\n\n protected async initialize(): Promise<void> {\n if (this.primary) {\n await this.primary.ready;\n }\n return Promise.resolve();\n }\n\n getPrimary(): FrontMcpAuth {\n if (!this.primary) {\n throw new DependencyNotFoundError('AuthRegistry', 'primary auth provider');\n }\n return this.primary;\n }\n\n getAuthProviders(): AuthProviderEntry[] {\n return [...this.instances.values()];\n }\n}\n"]}
|
package/src/auth/auth.utils.js
CHANGED
|
@@ -4,18 +4,17 @@ exports.collectAuthMetadata = collectAuthMetadata;
|
|
|
4
4
|
exports.normalizeAuth = normalizeAuth;
|
|
5
5
|
exports.authDiscoveryDeps = authDiscoveryDeps;
|
|
6
6
|
// auth/auth.utils.ts
|
|
7
|
-
const
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
8
|
const common_1 = require("../common");
|
|
9
|
-
const metadata_utils_1 = require("../utils/metadata.utils");
|
|
10
9
|
function collectAuthMetadata(cls) {
|
|
11
10
|
return Object.entries(common_1.FrontMcpAuthProviderTokens).reduce((metadata, [key, token]) => {
|
|
12
11
|
return Object.assign(metadata, {
|
|
13
|
-
[key]: (0,
|
|
12
|
+
[key]: (0, utils_1.getMetadata)(token, cls),
|
|
14
13
|
});
|
|
15
14
|
}, {});
|
|
16
15
|
}
|
|
17
16
|
function normalizeAuth(item) {
|
|
18
|
-
if ((0,
|
|
17
|
+
if ((0, utils_1.isClass)(item)) {
|
|
19
18
|
// read McpAuthMetadata from class
|
|
20
19
|
const metadata = collectAuthMetadata(item);
|
|
21
20
|
return { kind: common_1.AuthProviderKind.CLASS_TOKEN, provide: item, metadata };
|
|
@@ -27,8 +26,8 @@ function normalizeAuth(item) {
|
|
|
27
26
|
throw new Error(`Auth '${name}' is missing 'provide'.`);
|
|
28
27
|
}
|
|
29
28
|
if (useClass) {
|
|
30
|
-
if (!(0,
|
|
31
|
-
throw new Error(`'useClass' on auth '${(0,
|
|
29
|
+
if (!(0, utils_1.isClass)(useClass)) {
|
|
30
|
+
throw new Error(`'useClass' on auth '${(0, utils_1.tokenName)(provide)}' must be a class.`);
|
|
32
31
|
}
|
|
33
32
|
return {
|
|
34
33
|
kind: common_1.AuthProviderKind.CLASS,
|
|
@@ -39,7 +38,7 @@ function normalizeAuth(item) {
|
|
|
39
38
|
}
|
|
40
39
|
if (useFactory) {
|
|
41
40
|
if (typeof useFactory !== 'function') {
|
|
42
|
-
throw new Error(`'useFactory' on auth '${(0,
|
|
41
|
+
throw new Error(`'useFactory' on auth '${(0, utils_1.tokenName)(provide)}' must be a function.`);
|
|
43
42
|
}
|
|
44
43
|
const inj = typeof inject === 'function' ? inject : () => [];
|
|
45
44
|
return {
|
|
@@ -77,9 +76,9 @@ function authDiscoveryDeps(rec) {
|
|
|
77
76
|
return [...rec.inject()];
|
|
78
77
|
}
|
|
79
78
|
case common_1.AuthProviderKind.CLASS:
|
|
80
|
-
return (0,
|
|
79
|
+
return (0, utils_1.depsOfClass)(rec.useClass, 'discovery');
|
|
81
80
|
case common_1.AuthProviderKind.CLASS_TOKEN:
|
|
82
|
-
return (0,
|
|
81
|
+
return (0, utils_1.depsOfClass)(rec.provide, 'discovery');
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
//# sourceMappingURL=auth.utils.js.map
|