@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,130 @@
|
|
|
1
|
+
import { AuthorizationBase } from './authorization.class';
|
|
2
|
+
import { AuthorizationCreateCtx } from './authorization.types';
|
|
3
|
+
import { AuthMode } from '../../common';
|
|
4
|
+
/**
|
|
5
|
+
* Verified JWT payload from transparent auth provider
|
|
6
|
+
*/
|
|
7
|
+
export interface TransparentVerifiedPayload {
|
|
8
|
+
/** Subject identifier */
|
|
9
|
+
sub: string;
|
|
10
|
+
/** Issuer */
|
|
11
|
+
iss?: string;
|
|
12
|
+
/** Audience */
|
|
13
|
+
aud?: string | string[];
|
|
14
|
+
/** Expiration (seconds since epoch) */
|
|
15
|
+
exp?: number;
|
|
16
|
+
/** Issued at (seconds since epoch) */
|
|
17
|
+
iat?: number;
|
|
18
|
+
/** Scopes (space-separated or array) */
|
|
19
|
+
scope?: string | string[];
|
|
20
|
+
/** Display name */
|
|
21
|
+
name?: string;
|
|
22
|
+
/** Email */
|
|
23
|
+
email?: string;
|
|
24
|
+
/** Picture URL */
|
|
25
|
+
picture?: string;
|
|
26
|
+
/** Additional claims */
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Context for creating a TransparentAuthorization
|
|
31
|
+
*/
|
|
32
|
+
export interface TransparentAuthorizationCreateCtx {
|
|
33
|
+
/**
|
|
34
|
+
* The original bearer token (passed through to downstream)
|
|
35
|
+
*/
|
|
36
|
+
token: string;
|
|
37
|
+
/**
|
|
38
|
+
* Verified JWT payload from the upstream provider
|
|
39
|
+
*/
|
|
40
|
+
payload: TransparentVerifiedPayload;
|
|
41
|
+
/**
|
|
42
|
+
* Provider ID for this authorization
|
|
43
|
+
*/
|
|
44
|
+
providerId: string;
|
|
45
|
+
/**
|
|
46
|
+
* Provider name for display/logging
|
|
47
|
+
*/
|
|
48
|
+
providerName?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Precomputed authorization projections
|
|
51
|
+
*/
|
|
52
|
+
authorizedTools?: AuthorizationCreateCtx['authorizedTools'];
|
|
53
|
+
authorizedToolIds?: string[];
|
|
54
|
+
authorizedPrompts?: AuthorizationCreateCtx['authorizedPrompts'];
|
|
55
|
+
authorizedPromptIds?: string[];
|
|
56
|
+
authorizedApps?: AuthorizationCreateCtx['authorizedApps'];
|
|
57
|
+
authorizedAppIds?: string[];
|
|
58
|
+
authorizedResources?: string[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* TransparentAuthorization - Pass-through OAuth tokens
|
|
62
|
+
*
|
|
63
|
+
* In transparent mode:
|
|
64
|
+
* - The client's token is forwarded directly to downstream services
|
|
65
|
+
* - Token validation happens via the upstream provider's JWKS
|
|
66
|
+
* - getToken() returns the original bearer token
|
|
67
|
+
* - Ideal when the auth server is the source of truth
|
|
68
|
+
*/
|
|
69
|
+
export declare class TransparentAuthorization extends AuthorizationBase {
|
|
70
|
+
readonly mode: AuthMode;
|
|
71
|
+
/**
|
|
72
|
+
* Provider ID that issued the token
|
|
73
|
+
*/
|
|
74
|
+
readonly providerId: string;
|
|
75
|
+
/**
|
|
76
|
+
* Provider display name
|
|
77
|
+
*/
|
|
78
|
+
readonly providerName?: string;
|
|
79
|
+
private constructor();
|
|
80
|
+
/**
|
|
81
|
+
* Create a TransparentAuthorization from a verified JWT
|
|
82
|
+
*
|
|
83
|
+
* @param ctx - Creation context with token and verified payload
|
|
84
|
+
* @returns A new TransparentAuthorization instance
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const auth = TransparentAuthorization.fromVerifiedToken({
|
|
89
|
+
* token: bearerToken,
|
|
90
|
+
* payload: verifiedClaims,
|
|
91
|
+
* providerId: 'auth0',
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Pass token through to downstream
|
|
95
|
+
* const token = await auth.getToken();
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
static fromVerifiedToken(ctx: TransparentAuthorizationCreateCtx): TransparentAuthorization;
|
|
99
|
+
/**
|
|
100
|
+
* Get the original bearer token for pass-through
|
|
101
|
+
*
|
|
102
|
+
* In transparent mode, the same token is returned regardless of providerId
|
|
103
|
+
* since only one provider (the upstream) issued the token.
|
|
104
|
+
*
|
|
105
|
+
* @param _providerId - Ignored in transparent mode
|
|
106
|
+
* @returns The original bearer token
|
|
107
|
+
*/
|
|
108
|
+
getToken(_providerId?: string): Promise<string>;
|
|
109
|
+
/**
|
|
110
|
+
* Parse scope claim from JWT payload
|
|
111
|
+
*/
|
|
112
|
+
private static parseScopes;
|
|
113
|
+
/**
|
|
114
|
+
* Generate authorization ID from token signature
|
|
115
|
+
* Uses SHA-256 fingerprint of the token signature for uniqueness
|
|
116
|
+
*/
|
|
117
|
+
private static generateAuthorizationId;
|
|
118
|
+
/**
|
|
119
|
+
* Get the issuer from the token claims
|
|
120
|
+
*/
|
|
121
|
+
get issuer(): string | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Get the audience from the token claims
|
|
124
|
+
*/
|
|
125
|
+
get audience(): string | string[] | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Check if the token was issued for a specific audience
|
|
128
|
+
*/
|
|
129
|
+
hasAudience(aud: string): boolean;
|
|
130
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// auth/authorization/transparent.authorization.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TransparentAuthorization = void 0;
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const authorization_class_1 = require("./authorization.class");
|
|
7
|
+
/**
|
|
8
|
+
* TransparentAuthorization - Pass-through OAuth tokens
|
|
9
|
+
*
|
|
10
|
+
* In transparent mode:
|
|
11
|
+
* - The client's token is forwarded directly to downstream services
|
|
12
|
+
* - Token validation happens via the upstream provider's JWKS
|
|
13
|
+
* - getToken() returns the original bearer token
|
|
14
|
+
* - Ideal when the auth server is the source of truth
|
|
15
|
+
*/
|
|
16
|
+
class TransparentAuthorization extends authorization_class_1.AuthorizationBase {
|
|
17
|
+
mode = 'transparent';
|
|
18
|
+
/**
|
|
19
|
+
* Provider ID that issued the token
|
|
20
|
+
*/
|
|
21
|
+
providerId;
|
|
22
|
+
/**
|
|
23
|
+
* Provider display name
|
|
24
|
+
*/
|
|
25
|
+
providerName;
|
|
26
|
+
constructor(ctx) {
|
|
27
|
+
super(ctx);
|
|
28
|
+
this.providerId = ctx.providerId;
|
|
29
|
+
this.providerName = ctx.providerName;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a TransparentAuthorization from a verified JWT
|
|
33
|
+
*
|
|
34
|
+
* @param ctx - Creation context with token and verified payload
|
|
35
|
+
* @returns A new TransparentAuthorization instance
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const auth = TransparentAuthorization.fromVerifiedToken({
|
|
40
|
+
* token: bearerToken,
|
|
41
|
+
* payload: verifiedClaims,
|
|
42
|
+
* providerId: 'auth0',
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* // Pass token through to downstream
|
|
46
|
+
* const token = await auth.getToken();
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
static fromVerifiedToken(ctx) {
|
|
50
|
+
const { token, payload, providerId, providerName, ...projections } = ctx;
|
|
51
|
+
// Extract user identity from payload
|
|
52
|
+
const user = {
|
|
53
|
+
sub: payload.sub,
|
|
54
|
+
name: payload.name,
|
|
55
|
+
email: payload.email,
|
|
56
|
+
picture: payload.picture,
|
|
57
|
+
anonymous: false,
|
|
58
|
+
};
|
|
59
|
+
// Parse scopes from payload
|
|
60
|
+
const scopes = TransparentAuthorization.parseScopes(payload.scope);
|
|
61
|
+
// Calculate expiration from JWT exp claim
|
|
62
|
+
const expiresAt = payload.exp ? payload.exp * 1000 : undefined;
|
|
63
|
+
// Generate authorization ID from token signature fingerprint
|
|
64
|
+
const id = TransparentAuthorization.generateAuthorizationId(token);
|
|
65
|
+
// Create provider snapshot for this authorization
|
|
66
|
+
const providerSnapshot = {
|
|
67
|
+
id: providerId,
|
|
68
|
+
exp: expiresAt,
|
|
69
|
+
payload: payload,
|
|
70
|
+
embedMode: 'plain', // transparent mode keeps token in memory
|
|
71
|
+
token, // the original token
|
|
72
|
+
};
|
|
73
|
+
return new TransparentAuthorization({
|
|
74
|
+
id,
|
|
75
|
+
isAnonymous: false,
|
|
76
|
+
user,
|
|
77
|
+
claims: payload,
|
|
78
|
+
expiresAt,
|
|
79
|
+
scopes,
|
|
80
|
+
token,
|
|
81
|
+
providerId,
|
|
82
|
+
providerName,
|
|
83
|
+
authorizedProviders: { [providerId]: providerSnapshot },
|
|
84
|
+
authorizedProviderIds: [providerId],
|
|
85
|
+
...projections,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the original bearer token for pass-through
|
|
90
|
+
*
|
|
91
|
+
* In transparent mode, the same token is returned regardless of providerId
|
|
92
|
+
* since only one provider (the upstream) issued the token.
|
|
93
|
+
*
|
|
94
|
+
* @param _providerId - Ignored in transparent mode
|
|
95
|
+
* @returns The original bearer token
|
|
96
|
+
*/
|
|
97
|
+
async getToken(_providerId) {
|
|
98
|
+
if (!this.token) {
|
|
99
|
+
throw new Error('TransparentAuthorization: Token not available');
|
|
100
|
+
}
|
|
101
|
+
return this.token;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Parse scope claim from JWT payload
|
|
105
|
+
*/
|
|
106
|
+
static parseScopes(scope) {
|
|
107
|
+
if (!scope)
|
|
108
|
+
return [];
|
|
109
|
+
if (Array.isArray(scope))
|
|
110
|
+
return scope;
|
|
111
|
+
return scope.split(/\s+/).filter(Boolean);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Generate authorization ID from token signature
|
|
115
|
+
* Uses SHA-256 fingerprint of the token signature for uniqueness
|
|
116
|
+
*/
|
|
117
|
+
static generateAuthorizationId(token) {
|
|
118
|
+
const parts = token.split('.');
|
|
119
|
+
const signature = parts[2] || token;
|
|
120
|
+
return (0, crypto_1.createHash)('sha256').update(signature).digest('hex').substring(0, 16);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get the issuer from the token claims
|
|
124
|
+
*/
|
|
125
|
+
get issuer() {
|
|
126
|
+
return this.claims?.['iss'];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get the audience from the token claims
|
|
130
|
+
*/
|
|
131
|
+
get audience() {
|
|
132
|
+
return this.claims?.['aud'];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Check if the token was issued for a specific audience
|
|
136
|
+
*/
|
|
137
|
+
hasAudience(aud) {
|
|
138
|
+
const tokenAud = this.audience;
|
|
139
|
+
if (!tokenAud)
|
|
140
|
+
return false;
|
|
141
|
+
if (Array.isArray(tokenAud))
|
|
142
|
+
return tokenAud.includes(aud);
|
|
143
|
+
return tokenAud === aud;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.TransparentAuthorization = TransparentAuthorization;
|
|
147
|
+
//# sourceMappingURL=transparent.authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transparent.authorization.js","sourceRoot":"","sources":["../../../../src/auth/authorization/transparent.authorization.ts"],"names":[],"mappings":"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","sourcesContent":["// auth/authorization/transparent.authorization.ts\n\nimport { createHash } from 'crypto';\nimport { AuthorizationBase } from './authorization.class';\nimport { AuthorizationCreateCtx, AuthUser } from './authorization.types';\nimport { ProviderSnapshot } from '../session/session.types';\nimport { AuthMode } from '../../common';\n\n/**\n * Verified JWT payload from transparent auth provider\n */\nexport interface TransparentVerifiedPayload {\n /** Subject identifier */\n sub: string;\n /** Issuer */\n iss?: string;\n /** Audience */\n aud?: string | string[];\n /** Expiration (seconds since epoch) */\n exp?: number;\n /** Issued at (seconds since epoch) */\n iat?: number;\n /** Scopes (space-separated or array) */\n scope?: string | string[];\n /** Display name */\n name?: string;\n /** Email */\n email?: string;\n /** Picture URL */\n picture?: string;\n /** Additional claims */\n [key: string]: unknown;\n}\n\n/**\n * Context for creating a TransparentAuthorization\n */\nexport interface TransparentAuthorizationCreateCtx {\n /**\n * The original bearer token (passed through to downstream)\n */\n token: string;\n\n /**\n * Verified JWT payload from the upstream provider\n */\n payload: TransparentVerifiedPayload;\n\n /**\n * Provider ID for this authorization\n */\n providerId: string;\n\n /**\n * Provider name for display/logging\n */\n providerName?: string;\n\n /**\n * Precomputed authorization projections\n */\n authorizedTools?: AuthorizationCreateCtx['authorizedTools'];\n authorizedToolIds?: string[];\n authorizedPrompts?: AuthorizationCreateCtx['authorizedPrompts'];\n authorizedPromptIds?: string[];\n authorizedApps?: AuthorizationCreateCtx['authorizedApps'];\n authorizedAppIds?: string[];\n authorizedResources?: string[];\n}\n\n/**\n * TransparentAuthorization - Pass-through OAuth tokens\n *\n * In transparent mode:\n * - The client's token is forwarded directly to downstream services\n * - Token validation happens via the upstream provider's JWKS\n * - getToken() returns the original bearer token\n * - Ideal when the auth server is the source of truth\n */\nexport class TransparentAuthorization extends AuthorizationBase {\n readonly mode: AuthMode = 'transparent';\n\n /**\n * Provider ID that issued the token\n */\n readonly providerId: string;\n\n /**\n * Provider display name\n */\n readonly providerName?: string;\n\n private constructor(\n ctx: AuthorizationCreateCtx & {\n providerId: string;\n providerName?: string;\n },\n ) {\n super(ctx);\n this.providerId = ctx.providerId;\n this.providerName = ctx.providerName;\n }\n\n /**\n * Create a TransparentAuthorization from a verified JWT\n *\n * @param ctx - Creation context with token and verified payload\n * @returns A new TransparentAuthorization instance\n *\n * @example\n * ```typescript\n * const auth = TransparentAuthorization.fromVerifiedToken({\n * token: bearerToken,\n * payload: verifiedClaims,\n * providerId: 'auth0',\n * });\n *\n * // Pass token through to downstream\n * const token = await auth.getToken();\n * ```\n */\n static fromVerifiedToken(ctx: TransparentAuthorizationCreateCtx): TransparentAuthorization {\n const { token, payload, providerId, providerName, ...projections } = ctx;\n\n // Extract user identity from payload\n const user: AuthUser = {\n sub: payload.sub,\n name: payload.name,\n email: payload.email,\n picture: payload.picture,\n anonymous: false,\n };\n\n // Parse scopes from payload\n const scopes = TransparentAuthorization.parseScopes(payload.scope);\n\n // Calculate expiration from JWT exp claim\n const expiresAt = payload.exp ? payload.exp * 1000 : undefined;\n\n // Generate authorization ID from token signature fingerprint\n const id = TransparentAuthorization.generateAuthorizationId(token);\n\n // Create provider snapshot for this authorization\n const providerSnapshot: ProviderSnapshot = {\n id: providerId,\n exp: expiresAt,\n payload: payload as Record<string, unknown>,\n embedMode: 'plain', // transparent mode keeps token in memory\n token, // the original token\n };\n\n return new TransparentAuthorization({\n id,\n isAnonymous: false,\n user,\n claims: payload as Record<string, unknown>,\n expiresAt,\n scopes,\n token,\n providerId,\n providerName,\n authorizedProviders: { [providerId]: providerSnapshot },\n authorizedProviderIds: [providerId],\n ...projections,\n });\n }\n\n /**\n * Get the original bearer token for pass-through\n *\n * In transparent mode, the same token is returned regardless of providerId\n * since only one provider (the upstream) issued the token.\n *\n * @param _providerId - Ignored in transparent mode\n * @returns The original bearer token\n */\n async getToken(_providerId?: string): Promise<string> {\n if (!this.token) {\n throw new Error('TransparentAuthorization: Token not available');\n }\n return this.token;\n }\n\n /**\n * Parse scope claim from JWT payload\n */\n private static parseScopes(scope: string | string[] | undefined): string[] {\n if (!scope) return [];\n if (Array.isArray(scope)) return scope;\n return scope.split(/\\s+/).filter(Boolean);\n }\n\n /**\n * Generate authorization ID from token signature\n * Uses SHA-256 fingerprint of the token signature for uniqueness\n */\n private static generateAuthorizationId(token: string): string {\n const parts = token.split('.');\n const signature = parts[2] || token;\n return createHash('sha256').update(signature).digest('hex').substring(0, 16);\n }\n\n /**\n * Get the issuer from the token claims\n */\n get issuer(): string | undefined {\n return this.claims?.['iss'] as string | undefined;\n }\n\n /**\n * Get the audience from the token claims\n */\n get audience(): string | string[] | undefined {\n return this.claims?.['aud'] as string | string[] | undefined;\n }\n\n /**\n * Check if the token was issued for a specific audience\n */\n hasAudience(aud: string): boolean {\n const tokenAud = this.audience;\n if (!tokenAud) return false;\n if (Array.isArray(tokenAud)) return tokenAud.includes(aud);\n return tokenAud === aud;\n }\n}\n"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent Flow Types and Schemas
|
|
3
|
+
*
|
|
4
|
+
* Defines types for the tool consent flow that allows users to select
|
|
5
|
+
* which MCP tools they want to expose to the LLM.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { consentConfigSchema } from '../../common';
|
|
9
|
+
export { consentConfigSchema };
|
|
10
|
+
/**
|
|
11
|
+
* Tool consent item schema - represents a tool available for consent
|
|
12
|
+
*/
|
|
13
|
+
export declare const consentToolItemSchema: z.ZodObject<{
|
|
14
|
+
id: z.ZodString;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
description: z.ZodOptional<z.ZodString>;
|
|
17
|
+
appId: z.ZodString;
|
|
18
|
+
appName: z.ZodString;
|
|
19
|
+
defaultSelected: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
+
requiredScopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
category: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/**
|
|
24
|
+
* Consent selection schema - user's tool selection
|
|
25
|
+
*/
|
|
26
|
+
export declare const consentSelectionSchema: z.ZodObject<{
|
|
27
|
+
selectedTools: z.ZodArray<z.ZodString>;
|
|
28
|
+
allSelected: z.ZodBoolean;
|
|
29
|
+
consentedAt: z.ZodString;
|
|
30
|
+
consentVersion: z.ZodDefault<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/**
|
|
33
|
+
* Consent page state schema - stored in pending authorization
|
|
34
|
+
*/
|
|
35
|
+
export declare const consentStateSchema: z.ZodObject<{
|
|
36
|
+
enabled: z.ZodBoolean;
|
|
37
|
+
availableTools: z.ZodArray<z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
description: z.ZodOptional<z.ZodString>;
|
|
41
|
+
appId: z.ZodString;
|
|
42
|
+
appName: z.ZodString;
|
|
43
|
+
defaultSelected: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
requiredScopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
category: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
preselectedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
groupByApp: z.ZodDefault<z.ZodBoolean>;
|
|
49
|
+
customMessage: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/**
|
|
52
|
+
* Auth provider item for federated login UI
|
|
53
|
+
*/
|
|
54
|
+
export declare const federatedProviderItemSchema: z.ZodObject<{
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
name: z.ZodString;
|
|
57
|
+
description: z.ZodOptional<z.ZodString>;
|
|
58
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
59
|
+
type: z.ZodEnum<{
|
|
60
|
+
remote: "remote";
|
|
61
|
+
transparent: "transparent";
|
|
62
|
+
local: "local";
|
|
63
|
+
}>;
|
|
64
|
+
providerUrl: z.ZodOptional<z.ZodString>;
|
|
65
|
+
appIds: z.ZodArray<z.ZodString>;
|
|
66
|
+
appNames: z.ZodArray<z.ZodString>;
|
|
67
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
68
|
+
isPrimary: z.ZodBoolean;
|
|
69
|
+
isOptional: z.ZodDefault<z.ZodBoolean>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
/**
|
|
72
|
+
* Federated login state schema
|
|
73
|
+
*/
|
|
74
|
+
export declare const federatedLoginStateSchema: z.ZodObject<{
|
|
75
|
+
providers: z.ZodArray<z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
name: z.ZodString;
|
|
78
|
+
description: z.ZodOptional<z.ZodString>;
|
|
79
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
80
|
+
type: z.ZodEnum<{
|
|
81
|
+
remote: "remote";
|
|
82
|
+
transparent: "transparent";
|
|
83
|
+
local: "local";
|
|
84
|
+
}>;
|
|
85
|
+
providerUrl: z.ZodOptional<z.ZodString>;
|
|
86
|
+
appIds: z.ZodArray<z.ZodString>;
|
|
87
|
+
appNames: z.ZodArray<z.ZodString>;
|
|
88
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
89
|
+
isPrimary: z.ZodBoolean;
|
|
90
|
+
isOptional: z.ZodDefault<z.ZodBoolean>;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
primaryProviderId: z.ZodOptional<z.ZodString>;
|
|
93
|
+
allowSkip: z.ZodDefault<z.ZodBoolean>;
|
|
94
|
+
preselectedProviders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
/**
|
|
97
|
+
* Federated login selection schema
|
|
98
|
+
*/
|
|
99
|
+
export declare const federatedSelectionSchema: z.ZodObject<{
|
|
100
|
+
selectedProviders: z.ZodArray<z.ZodString>;
|
|
101
|
+
skippedProviders: z.ZodArray<z.ZodString>;
|
|
102
|
+
providerMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
export type ConsentToolItem = z.infer<typeof consentToolItemSchema>;
|
|
105
|
+
export type ConsentSelection = z.infer<typeof consentSelectionSchema>;
|
|
106
|
+
export type ConsentState = z.infer<typeof consentStateSchema>;
|
|
107
|
+
export type ConsentConfig = z.infer<typeof consentConfigSchema>;
|
|
108
|
+
export type ConsentConfigInput = z.input<typeof consentConfigSchema>;
|
|
109
|
+
export type FederatedProviderItem = z.infer<typeof federatedProviderItemSchema>;
|
|
110
|
+
export type FederatedLoginState = z.infer<typeof federatedLoginStateSchema>;
|
|
111
|
+
export type FederatedSelection = z.infer<typeof federatedSelectionSchema>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.federatedSelectionSchema = exports.federatedLoginStateSchema = exports.federatedProviderItemSchema = exports.consentStateSchema = exports.consentSelectionSchema = exports.consentToolItemSchema = exports.consentConfigSchema = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Consent Flow Types and Schemas
|
|
6
|
+
*
|
|
7
|
+
* Defines types for the tool consent flow that allows users to select
|
|
8
|
+
* which MCP tools they want to expose to the LLM.
|
|
9
|
+
*/
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const common_1 = require("../../common");
|
|
12
|
+
Object.defineProperty(exports, "consentConfigSchema", { enumerable: true, get: function () { return common_1.consentConfigSchema; } });
|
|
13
|
+
// ============================================
|
|
14
|
+
// Consent Configuration Schemas
|
|
15
|
+
// ============================================
|
|
16
|
+
/**
|
|
17
|
+
* Tool consent item schema - represents a tool available for consent
|
|
18
|
+
*/
|
|
19
|
+
exports.consentToolItemSchema = zod_1.z.object({
|
|
20
|
+
/** Tool ID (e.g., 'slack:send_message') */
|
|
21
|
+
id: zod_1.z.string().min(1),
|
|
22
|
+
/** Tool name for display */
|
|
23
|
+
name: zod_1.z.string().min(1),
|
|
24
|
+
/** Tool description */
|
|
25
|
+
description: zod_1.z.string().optional(),
|
|
26
|
+
/** App ID this tool belongs to */
|
|
27
|
+
appId: zod_1.z.string().min(1),
|
|
28
|
+
/** App name for display */
|
|
29
|
+
appName: zod_1.z.string().min(1),
|
|
30
|
+
/** Whether the tool is selected by default */
|
|
31
|
+
defaultSelected: zod_1.z.boolean().default(true),
|
|
32
|
+
/** Whether this tool requires specific scopes */
|
|
33
|
+
requiredScopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
34
|
+
/** Category for grouping (e.g., 'read', 'write', 'admin') */
|
|
35
|
+
category: zod_1.z.string().optional(),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Consent selection schema - user's tool selection
|
|
39
|
+
*/
|
|
40
|
+
exports.consentSelectionSchema = zod_1.z.object({
|
|
41
|
+
/** Selected tool IDs */
|
|
42
|
+
selectedTools: zod_1.z.array(zod_1.z.string()),
|
|
43
|
+
/** Whether all tools were selected */
|
|
44
|
+
allSelected: zod_1.z.boolean(),
|
|
45
|
+
/** Timestamp when consent was given */
|
|
46
|
+
consentedAt: zod_1.z.string().datetime(),
|
|
47
|
+
/** Consent version for tracking changes */
|
|
48
|
+
consentVersion: zod_1.z.string().default('1.0'),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Consent page state schema - stored in pending authorization
|
|
52
|
+
*/
|
|
53
|
+
exports.consentStateSchema = zod_1.z.object({
|
|
54
|
+
/** Whether consent flow is enabled */
|
|
55
|
+
enabled: zod_1.z.boolean(),
|
|
56
|
+
/** Available tools for consent */
|
|
57
|
+
availableTools: zod_1.z.array(exports.consentToolItemSchema),
|
|
58
|
+
/** Pre-selected tools (from previous consent or defaults) */
|
|
59
|
+
preselectedTools: zod_1.z.array(zod_1.z.string()).optional(),
|
|
60
|
+
/** Whether to show all tools or group by app */
|
|
61
|
+
groupByApp: zod_1.z.boolean().default(true),
|
|
62
|
+
/** Custom consent message */
|
|
63
|
+
customMessage: zod_1.z.string().optional(),
|
|
64
|
+
});
|
|
65
|
+
// ============================================
|
|
66
|
+
// Federated Login Schemas
|
|
67
|
+
// ============================================
|
|
68
|
+
/**
|
|
69
|
+
* Auth provider item for federated login UI
|
|
70
|
+
*/
|
|
71
|
+
exports.federatedProviderItemSchema = zod_1.z.object({
|
|
72
|
+
/** Provider ID (derived or explicit) */
|
|
73
|
+
id: zod_1.z.string().min(1),
|
|
74
|
+
/** Provider display name */
|
|
75
|
+
name: zod_1.z.string().min(1),
|
|
76
|
+
/** Provider description */
|
|
77
|
+
description: zod_1.z.string().optional(),
|
|
78
|
+
/** Provider icon URL or emoji */
|
|
79
|
+
icon: zod_1.z.string().optional(),
|
|
80
|
+
/** Provider type */
|
|
81
|
+
type: zod_1.z.enum(['local', 'remote', 'transparent']),
|
|
82
|
+
/** OAuth provider URL (for remote providers) */
|
|
83
|
+
providerUrl: zod_1.z.string().url().optional(),
|
|
84
|
+
/** Apps using this provider */
|
|
85
|
+
appIds: zod_1.z.array(zod_1.z.string()),
|
|
86
|
+
/** App names using this provider */
|
|
87
|
+
appNames: zod_1.z.array(zod_1.z.string()),
|
|
88
|
+
/** Scopes required by this provider */
|
|
89
|
+
scopes: zod_1.z.array(zod_1.z.string()),
|
|
90
|
+
/** Whether this is the primary/parent provider */
|
|
91
|
+
isPrimary: zod_1.z.boolean(),
|
|
92
|
+
/** Whether this provider is optional (can be skipped) */
|
|
93
|
+
isOptional: zod_1.z.boolean().default(false),
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Federated login state schema
|
|
97
|
+
*/
|
|
98
|
+
exports.federatedLoginStateSchema = zod_1.z.object({
|
|
99
|
+
/** All available providers */
|
|
100
|
+
providers: zod_1.z.array(exports.federatedProviderItemSchema),
|
|
101
|
+
/** Primary provider ID (if any) */
|
|
102
|
+
primaryProviderId: zod_1.z.string().optional(),
|
|
103
|
+
/** Whether user can skip optional providers */
|
|
104
|
+
allowSkip: zod_1.z.boolean().default(true),
|
|
105
|
+
/** Pre-selected provider IDs (from previous session) */
|
|
106
|
+
preselectedProviders: zod_1.z.array(zod_1.z.string()).optional(),
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* Federated login selection schema
|
|
110
|
+
*/
|
|
111
|
+
exports.federatedSelectionSchema = zod_1.z.object({
|
|
112
|
+
/** Selected provider IDs */
|
|
113
|
+
selectedProviders: zod_1.z.array(zod_1.z.string()),
|
|
114
|
+
/** Skipped provider IDs */
|
|
115
|
+
skippedProviders: zod_1.z.array(zod_1.z.string()),
|
|
116
|
+
/** Provider-specific metadata */
|
|
117
|
+
providerMetadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=consent.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent.types.js","sourceRoot":"","sources":["../../../../src/auth/consent/consent.types.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Consent Flow Types and Schemas\n *\n * Defines types for the tool consent flow that allows users to select\n * which MCP tools they want to expose to the LLM.\n */\nimport { z } from 'zod';\nimport { consentConfigSchema } from '../../common';\n\n// Re-export schema for tests\nexport { consentConfigSchema };\n\n// ============================================\n// Consent Configuration Schemas\n// ============================================\n\n/**\n * Tool consent item schema - represents a tool available for consent\n */\nexport const consentToolItemSchema = z.object({\n /** Tool ID (e.g., 'slack:send_message') */\n id: z.string().min(1),\n /** Tool name for display */\n name: z.string().min(1),\n /** Tool description */\n description: z.string().optional(),\n /** App ID this tool belongs to */\n appId: z.string().min(1),\n /** App name for display */\n appName: z.string().min(1),\n /** Whether the tool is selected by default */\n defaultSelected: z.boolean().default(true),\n /** Whether this tool requires specific scopes */\n requiredScopes: z.array(z.string()).optional(),\n /** Category for grouping (e.g., 'read', 'write', 'admin') */\n category: z.string().optional(),\n});\n\n/**\n * Consent selection schema - user's tool selection\n */\nexport const consentSelectionSchema = z.object({\n /** Selected tool IDs */\n selectedTools: z.array(z.string()),\n /** Whether all tools were selected */\n allSelected: z.boolean(),\n /** Timestamp when consent was given */\n consentedAt: z.string().datetime(),\n /** Consent version for tracking changes */\n consentVersion: z.string().default('1.0'),\n});\n\n/**\n * Consent page state schema - stored in pending authorization\n */\nexport const consentStateSchema = z.object({\n /** Whether consent flow is enabled */\n enabled: z.boolean(),\n /** Available tools for consent */\n availableTools: z.array(consentToolItemSchema),\n /** Pre-selected tools (from previous consent or defaults) */\n preselectedTools: z.array(z.string()).optional(),\n /** Whether to show all tools or group by app */\n groupByApp: z.boolean().default(true),\n /** Custom consent message */\n customMessage: z.string().optional(),\n});\n// ============================================\n// Federated Login Schemas\n// ============================================\n\n/**\n * Auth provider item for federated login UI\n */\nexport const federatedProviderItemSchema = z.object({\n /** Provider ID (derived or explicit) */\n id: z.string().min(1),\n /** Provider display name */\n name: z.string().min(1),\n /** Provider description */\n description: z.string().optional(),\n /** Provider icon URL or emoji */\n icon: z.string().optional(),\n /** Provider type */\n type: z.enum(['local', 'remote', 'transparent']),\n /** OAuth provider URL (for remote providers) */\n providerUrl: z.string().url().optional(),\n /** Apps using this provider */\n appIds: z.array(z.string()),\n /** App names using this provider */\n appNames: z.array(z.string()),\n /** Scopes required by this provider */\n scopes: z.array(z.string()),\n /** Whether this is the primary/parent provider */\n isPrimary: z.boolean(),\n /** Whether this provider is optional (can be skipped) */\n isOptional: z.boolean().default(false),\n});\n\n/**\n * Federated login state schema\n */\nexport const federatedLoginStateSchema = z.object({\n /** All available providers */\n providers: z.array(federatedProviderItemSchema),\n /** Primary provider ID (if any) */\n primaryProviderId: z.string().optional(),\n /** Whether user can skip optional providers */\n allowSkip: z.boolean().default(true),\n /** Pre-selected provider IDs (from previous session) */\n preselectedProviders: z.array(z.string()).optional(),\n});\n\n/**\n * Federated login selection schema\n */\nexport const federatedSelectionSchema = z.object({\n /** Selected provider IDs */\n selectedProviders: z.array(z.string()),\n /** Skipped provider IDs */\n skippedProviders: z.array(z.string()),\n /** Provider-specific metadata */\n providerMetadata: z.record(z.string(), z.unknown()).optional(),\n});\n\n// ============================================\n// Type Exports\n// ============================================\n\nexport type ConsentToolItem = z.infer<typeof consentToolItemSchema>;\nexport type ConsentSelection = z.infer<typeof consentSelectionSchema>;\nexport type ConsentState = z.infer<typeof consentStateSchema>;\nexport type ConsentConfig = z.infer<typeof consentConfigSchema>;\nexport type ConsentConfigInput = z.input<typeof consentConfigSchema>;\n\nexport type FederatedProviderItem = z.infer<typeof federatedProviderItemSchema>;\nexport type FederatedLoginState = z.infer<typeof federatedLoginStateSchema>;\nexport type FederatedSelection = z.infer<typeof federatedSelectionSchema>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { consentToolItemSchema, consentSelectionSchema, consentStateSchema, federatedProviderItemSchema, federatedLoginStateSchema, federatedSelectionSchema, ConsentToolItem, ConsentSelection, ConsentState, ConsentConfig, ConsentConfigInput, FederatedProviderItem, FederatedLoginState, FederatedSelection, } from './consent.types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.federatedSelectionSchema = exports.federatedLoginStateSchema = exports.federatedProviderItemSchema = exports.consentStateSchema = exports.consentSelectionSchema = exports.consentToolItemSchema = void 0;
|
|
4
|
+
// Consent Module Exports
|
|
5
|
+
var consent_types_1 = require("./consent.types");
|
|
6
|
+
// Schemas
|
|
7
|
+
Object.defineProperty(exports, "consentToolItemSchema", { enumerable: true, get: function () { return consent_types_1.consentToolItemSchema; } });
|
|
8
|
+
Object.defineProperty(exports, "consentSelectionSchema", { enumerable: true, get: function () { return consent_types_1.consentSelectionSchema; } });
|
|
9
|
+
Object.defineProperty(exports, "consentStateSchema", { enumerable: true, get: function () { return consent_types_1.consentStateSchema; } });
|
|
10
|
+
Object.defineProperty(exports, "federatedProviderItemSchema", { enumerable: true, get: function () { return consent_types_1.federatedProviderItemSchema; } });
|
|
11
|
+
Object.defineProperty(exports, "federatedLoginStateSchema", { enumerable: true, get: function () { return consent_types_1.federatedLoginStateSchema; } });
|
|
12
|
+
Object.defineProperty(exports, "federatedSelectionSchema", { enumerable: true, get: function () { return consent_types_1.federatedSelectionSchema; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/auth/consent/index.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,iDAiByB;AAhBvB,UAAU;AACV,sHAAA,qBAAqB,OAAA;AACrB,uHAAA,sBAAsB,OAAA;AACtB,mHAAA,kBAAkB,OAAA;AAClB,4HAAA,2BAA2B,OAAA;AAC3B,0HAAA,yBAAyB,OAAA;AACzB,yHAAA,wBAAwB,OAAA","sourcesContent":["// Consent Module Exports\nexport {\n // Schemas\n consentToolItemSchema,\n consentSelectionSchema,\n consentStateSchema,\n federatedProviderItemSchema,\n federatedLoginStateSchema,\n federatedSelectionSchema,\n // Types\n ConsentToolItem,\n ConsentSelection,\n ConsentState,\n ConsentConfig,\n ConsentConfigInput,\n FederatedProviderItem,\n FederatedLoginState,\n FederatedSelection,\n} from './consent.types';\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Provider Detection
|
|
3
|
+
*
|
|
4
|
+
* Detects unique auth providers across nested apps and determines
|
|
5
|
+
* if orchestrated mode is required at the parent scope level.
|
|
6
|
+
*
|
|
7
|
+
* When multiple apps have different auth providers, the parent MUST
|
|
8
|
+
* use orchestrated mode to properly manage tokens for each provider.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { AuthOptions } from '../../common';
|
|
12
|
+
/**
|
|
13
|
+
* Schema for a detected auth provider
|
|
14
|
+
*/
|
|
15
|
+
export declare const detectedAuthProviderSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
providerUrl: z.ZodOptional<z.ZodString>;
|
|
18
|
+
mode: z.ZodEnum<{
|
|
19
|
+
public: "public";
|
|
20
|
+
transparent: "transparent";
|
|
21
|
+
orchestrated: "orchestrated";
|
|
22
|
+
}>;
|
|
23
|
+
appIds: z.ZodArray<z.ZodString>;
|
|
24
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
25
|
+
isParentProvider: z.ZodBoolean;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
/**
|
|
28
|
+
* Schema for auth provider detection result
|
|
29
|
+
*/
|
|
30
|
+
export declare const authProviderDetectionResultSchema: z.ZodObject<{
|
|
31
|
+
providers: z.ZodMap<z.ZodString, z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
providerUrl: z.ZodOptional<z.ZodString>;
|
|
34
|
+
mode: z.ZodEnum<{
|
|
35
|
+
public: "public";
|
|
36
|
+
transparent: "transparent";
|
|
37
|
+
orchestrated: "orchestrated";
|
|
38
|
+
}>;
|
|
39
|
+
appIds: z.ZodArray<z.ZodString>;
|
|
40
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
41
|
+
isParentProvider: z.ZodBoolean;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
requiresOrchestration: z.ZodBoolean;
|
|
44
|
+
parentProviderId: z.ZodOptional<z.ZodString>;
|
|
45
|
+
childProviderIds: z.ZodArray<z.ZodString>;
|
|
46
|
+
uniqueProviderCount: z.ZodNumber;
|
|
47
|
+
validationErrors: z.ZodArray<z.ZodString>;
|
|
48
|
+
warnings: z.ZodArray<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type DetectedAuthProvider = z.infer<typeof detectedAuthProviderSchema>;
|
|
51
|
+
export type AuthProviderDetectionResult = z.infer<typeof authProviderDetectionResultSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* App auth info for detection (minimal interface)
|
|
54
|
+
*/
|
|
55
|
+
export interface AppAuthInfo {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
auth?: AuthOptions;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Derive a stable provider ID from auth options
|
|
62
|
+
*/
|
|
63
|
+
export declare function deriveProviderId(options: AuthOptions): string;
|
|
64
|
+
/**
|
|
65
|
+
* Detect all unique auth providers across parent and apps
|
|
66
|
+
*
|
|
67
|
+
* @param parentAuth - Parent scope's auth options (may be undefined)
|
|
68
|
+
* @param apps - Array of app auth info
|
|
69
|
+
* @returns Detection result with providers, validation, and requirements
|
|
70
|
+
*/
|
|
71
|
+
export declare function detectAuthProviders(parentAuth: AuthOptions | undefined, apps: AppAuthInfo[]): AuthProviderDetectionResult;
|
|
72
|
+
/**
|
|
73
|
+
* Check if a specific app requires orchestration
|
|
74
|
+
* (i.e., has a different provider than parent)
|
|
75
|
+
*/
|
|
76
|
+
export declare function appRequiresOrchestration(appAuth: AuthOptions | undefined, parentAuth: AuthOptions | undefined): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Get all OAuth scopes needed for a provider across all apps
|
|
79
|
+
*/
|
|
80
|
+
export declare function getProviderScopes(detection: AuthProviderDetectionResult, providerId: string): string[];
|
|
81
|
+
/**
|
|
82
|
+
* Get apps that use a specific provider
|
|
83
|
+
*/
|
|
84
|
+
export declare function getProviderApps(detection: AuthProviderDetectionResult, providerId: string): string[];
|