@frontmcp/sdk 1.12.0-rc.1 → 1.12.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/agent/agent.instance.d.ts +3 -0
- package/agent/agent.instance.d.ts.map +1 -1
- package/agent/agent.registry.d.ts.map +1 -1
- package/agent/flows/call-agent.flow.d.ts +1 -1
- package/agent/flows/call-agent.flow.d.ts.map +1 -1
- package/answer/answer-budget.d.ts.map +1 -1
- package/answer/client-profile.d.ts.map +1 -1
- package/auth/auth-ui/auth-ui.registry.d.ts.map +1 -1
- package/auth/auth.registry.d.ts.map +1 -1
- package/auth/authorized-apps.utils.d.ts +8 -0
- package/auth/authorized-apps.utils.d.ts.map +1 -1
- package/auth/flows/form-body.utils.d.ts.map +1 -1
- package/auth/flows/oauth.authorize.flow.d.ts +3 -1
- package/auth/flows/oauth.authorize.flow.d.ts.map +1 -1
- package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
- package/auth/flows/oauth.register.flow.d.ts +5 -0
- package/auth/flows/oauth.register.flow.d.ts.map +1 -1
- package/auth/flows/oauth.token.flow.d.ts +3 -2
- package/auth/flows/oauth.token.flow.d.ts.map +1 -1
- package/auth/session/session-store.factory.d.ts.map +1 -1
- package/browser/agent/agent.instance.mjs +4 -0
- package/browser/agent/agent.registry.mjs +2 -2
- package/browser/agent/flows/call-agent.flow.mjs +10 -6
- package/browser/answer/answer-budget.mjs +35 -7
- package/browser/answer/client-profile.mjs +3 -3
- package/browser/auth/auth-ui/auth-ui.registry.mjs +8 -0
- package/browser/auth/auth.registry.mjs +4 -0
- package/browser/auth/authorized-apps.utils.mjs +5 -0
- package/browser/auth/flows/form-body.utils.mjs +4 -2
- package/browser/auth/flows/oauth.authorize.flow.mjs +38 -6
- package/browser/auth/flows/oauth.callback.flow.mjs +30 -16
- package/browser/auth/flows/oauth.register.flow.mjs +17 -5
- package/browser/auth/flows/oauth.token.flow.mjs +17 -8
- package/browser/auth/session/session-store.factory.mjs +5 -1
- package/browser/builtin/authorities/authorities-not-configured.mjs +5 -0
- package/browser/channel/channel-notification.service.mjs +16 -12
- package/browser/channel/channel.instance.mjs +9 -12
- package/browser/channel/channel.utils.mjs +18 -3
- package/browser/channel/flows/send-channel-notification.flow.mjs +4 -2
- package/browser/common/metadata/app.metadata.mjs +2 -1
- package/browser/common/metadata/event.metadata.mjs +10 -10
- package/browser/common/schemas/http-output.schema.mjs +6 -1
- package/browser/common/types/options/metrics/schema.mjs +2 -1
- package/browser/common/utils/content-disposition.utils.mjs +7 -0
- package/browser/common/utils/forward-headers.utils.mjs +5 -5
- package/browser/common/utils/issuer-subject.utils.mjs +17 -0
- package/browser/completion/flows/complete.flow.mjs +9 -1
- package/browser/context/frontmcp-context.mjs +5 -1
- package/browser/direct/connect.mjs +14 -4
- package/browser/direct/direct-server.mjs +3 -1
- package/browser/duty/duty.lifecycle.mjs +5 -3
- package/browser/duty/lease-store.mjs +6 -2
- package/browser/elicitation/flows/elicitation-request.flow.mjs +3 -2
- package/browser/elicitation/flows/elicitation-result.flow.mjs +5 -4
- package/browser/elicitation/questions/question-scope.helper.mjs +4 -2
- package/browser/elicitation/store/elicitation-store.factory.mjs +17 -9
- package/browser/elicitation/store/encrypted-elicitation.store.mjs +1 -1
- package/browser/elicitation/store/storage-elicitation.store.mjs +83 -63
- package/browser/errors/error-handler.mjs +4 -4
- package/browser/errors/event.errors.mjs +3 -1
- package/browser/errors/misconfiguration.mjs +7 -1
- package/browser/errors/transport.errors.mjs +1 -1
- package/browser/esm-loader/esm-cache.mjs +5 -1
- package/browser/esm-loader/esm-module-loader.mjs +6 -6
- package/browser/esm-loader/version-resolver.mjs +1 -1
- package/browser/event/event-scope.helper.mjs +13 -5
- package/browser/event/flows/event-poll.flow.mjs +1 -1
- package/browser/event/flows/event-publish-http.flow.mjs +5 -2
- package/browser/event/flows/event-stream.flow.mjs +1 -1
- package/browser/ext-apps/ext-apps.handler.mjs +26 -14
- package/browser/flows/flow.registry.mjs +2 -1
- package/browser/front-mcp/authorities-rules.check.mjs +16 -0
- package/browser/front-mcp/front-mcp.mjs +8 -2
- package/browser/index.cjs +2035 -1340
- package/browser/job/execution/job-execution.manager.mjs +5 -5
- package/browser/job/job-permission.guard.mjs +7 -0
- package/browser/job/job-run-access.mjs +12 -2
- package/browser/job/tools/list-jobs.tool.mjs +2 -7
- package/browser/job/tools/remove-job.tool.mjs +6 -0
- package/browser/job/tools/update-job.tool.mjs +3 -0
- package/browser/logger/instances/instance.console-logger.mjs +14 -4
- package/browser/logger/instances/instance.file-logger.mjs +3 -2
- package/browser/logger/session-id-hash.mjs +8 -0
- package/browser/metrics/metrics.service.mjs +2 -1
- package/browser/offload/offload-worker.globals.mjs +3 -3
- package/browser/offload/worker-jobs.mjs +9 -2
- package/browser/offload/worker-resources.mjs +7 -1
- package/browser/plugin/enforced-metadata.check.mjs +24 -7
- package/browser/prompt/flows/get-prompt.flow.mjs +10 -3
- package/browser/prompt/flows/prompts-list.flow.mjs +1 -1
- package/browser/provider/provider.registry.mjs +21 -10
- package/browser/remote-mcp/mcp-client.service.mjs +4 -3
- package/browser/remote-mcp/remote-entries.mjs +15 -1
- package/browser/remote-mcp/remote-oauth.mjs +29 -2
- package/browser/resource/flows/read-resource.flow.mjs +23 -13
- package/browser/resource/flows/resource-templates-list.flow.mjs +1 -1
- package/browser/resource/flows/resources-list.flow.mjs +1 -1
- package/browser/resource/flows/subscribe-resource.flow.mjs +9 -1
- package/browser/resource/resource.instance.mjs +10 -1
- package/browser/scope/flows/http.request.flow.mjs +15 -3
- package/browser/scope/optional-dependency.util.mjs +1 -13
- package/browser/scope/scope.instance.mjs +39 -30
- package/browser/server/security/replaceable-directory.mjs +7 -2
- package/browser/server/security/resolve-allowed-hosts.mjs +3 -3
- package/browser/server/server.validation.mjs +3 -5
- package/browser/skill/cache/skill-http-cache.catalog.mjs +18 -0
- package/browser/skill/flows/http/llm-full-txt.flow.mjs +3 -2
- package/browser/skill/flows/http/llm-txt.flow.mjs +3 -2
- package/browser/skill/flows/load-skill.flow.mjs +10 -3
- package/browser/skill/hooks/skill-tool.hook.mjs +7 -7
- package/browser/skill/sep-2640/sep-2640.resource-helpers.mjs +29 -10
- package/browser/skill/session/skill-session.manager.mjs +32 -35
- package/browser/skill/session/skill-session.types.mjs +2 -0
- package/browser/skill/skill-authorities.helper.mjs +11 -4
- package/browser/skill/skill-directory-loader.mjs +15 -1
- package/browser/skill/skill-filter.helper.mjs +35 -7
- package/browser/skill/skill-md-parser.mjs +17 -2
- package/browser/skill/skill.instance.mjs +7 -0
- package/browser/storage/sqlite-on-edge.mjs +28 -0
- package/browser/task/store/task-store.factory.mjs +8 -3
- package/browser/tool/flows/call-tool.flow.mjs +29 -14
- package/browser/tool/flows/tools-list.flow.mjs +1 -4
- package/browser/transport/adapters/transport.local.adapter.mjs +3 -2
- package/browser/transport/event-stores/event-store.factory.mjs +5 -1
- package/browser/transport/event-stores/redis.event-store.mjs +13 -9
- package/browser/transport/flows/handle.streamable-http.flow.mjs +13 -6
- package/browser/transport/in-memory-server.mjs +5 -3
- package/browser/transport/mcp-20260728/client/mcp-stateless.client.mjs +25 -6
- package/browser/transport/mcp-20260728/dispatcher.mjs +4 -9
- package/browser/transport/mcp-handlers/index.mjs +19 -1
- package/browser/transport/mcp-handlers/skills-list-request.handler.mjs +2 -1
- package/browser/transport/mcp-handlers/skills-mcp.types.mjs +3 -1
- package/browser/transport/web-fetch-handler.mjs +3 -3
- package/browser/transport/web-response.renderer.mjs +5 -4
- package/browser/transport/web-standard-mcp.mjs +2 -2
- package/browser/worker/worker.lifecycle.mjs +7 -4
- package/browser/workflow/tools/list-workflows.tool.mjs +6 -7
- package/browser/workflow/tools/register-workflow.tool.mjs +3 -2
- package/browser/workflow/tools/remove-workflow.tool.mjs +6 -0
- package/browser/workflow/tools/runtime-workflow.limits.mjs +5 -0
- package/browser/workflow/tools/update-workflow.tool.mjs +6 -2
- package/browser/workflow/trigger/workflow-webhook.routes.mjs +15 -6
- package/browser/workflow/trigger/workflow-webhook.signature.mjs +5 -8
- package/builtin/authorities/authorities-not-configured.d.ts +3 -0
- package/builtin/authorities/authorities-not-configured.d.ts.map +1 -0
- package/channel/channel-notification.service.d.ts +8 -3
- package/channel/channel-notification.service.d.ts.map +1 -1
- package/channel/channel.instance.d.ts +10 -8
- package/channel/channel.instance.d.ts.map +1 -1
- package/channel/channel.utils.d.ts +6 -1
- package/channel/channel.utils.d.ts.map +1 -1
- package/channel/flows/send-channel-notification.flow.d.ts +1 -1
- package/channel/flows/send-channel-notification.flow.d.ts.map +1 -1
- package/common/entries/channel.entry.d.ts +1 -1
- package/common/entries/channel.entry.d.ts.map +1 -1
- package/common/metadata/app.metadata.d.ts +11 -3
- package/common/metadata/app.metadata.d.ts.map +1 -1
- package/common/metadata/channel.metadata.d.ts +7 -4
- package/common/metadata/channel.metadata.d.ts.map +1 -1
- package/common/metadata/duty.metadata.d.ts +1 -1
- package/common/metadata/duty.metadata.d.ts.map +1 -1
- package/common/metadata/event.metadata.d.ts +15 -12
- package/common/metadata/event.metadata.d.ts.map +1 -1
- package/common/metadata/front-mcp.metadata.d.ts +59 -59
- package/common/metadata/worker.metadata.d.ts +1 -1
- package/common/metadata/worker.metadata.d.ts.map +1 -1
- package/common/schemas/http-output.schema.d.ts +1 -1
- package/common/schemas/http-output.schema.d.ts.map +1 -1
- package/common/types/options/http/interfaces.d.ts +3 -2
- package/common/types/options/http/interfaces.d.ts.map +1 -1
- package/common/types/options/metrics/interfaces.d.ts +3 -2
- package/common/types/options/metrics/interfaces.d.ts.map +1 -1
- package/common/types/options/metrics/schema.d.ts +1 -1
- package/common/types/options/metrics/schema.d.ts.map +1 -1
- package/common/utils/content-disposition.utils.d.ts +6 -0
- package/common/utils/content-disposition.utils.d.ts.map +1 -0
- package/common/utils/issuer-subject.utils.d.ts +8 -0
- package/common/utils/issuer-subject.utils.d.ts.map +1 -0
- package/completion/flows/complete.flow.d.ts.map +1 -1
- package/context/frontmcp-context.d.ts +5 -1
- package/context/frontmcp-context.d.ts.map +1 -1
- package/direct/connect.d.ts.map +1 -1
- package/direct/direct-server.d.ts.map +1 -1
- package/duty/duty.lifecycle.d.ts +1 -1
- package/duty/duty.lifecycle.d.ts.map +1 -1
- package/duty/lease-store.d.ts +4 -2
- package/duty/lease-store.d.ts.map +1 -1
- package/elicitation/flows/elicitation-request.flow.d.ts.map +1 -1
- package/elicitation/flows/elicitation-result.flow.d.ts.map +1 -1
- package/elicitation/questions/question-scope.helper.d.ts +4 -1
- package/elicitation/questions/question-scope.helper.d.ts.map +1 -1
- package/elicitation/store/elicitation-store.factory.d.ts.map +1 -1
- package/elicitation/store/elicitation.store.d.ts +8 -8
- package/elicitation/store/storage-elicitation.store.d.ts +11 -11
- package/elicitation/store/storage-elicitation.store.d.ts.map +1 -1
- package/errors/duty.errors.d.ts +1 -1
- package/errors/duty.errors.d.ts.map +1 -1
- package/errors/error-handler.d.ts.map +1 -1
- package/errors/event.errors.d.ts +9 -2
- package/errors/event.errors.d.ts.map +1 -1
- package/errors/misconfiguration.d.ts +10 -0
- package/errors/misconfiguration.d.ts.map +1 -1
- package/errors/worker.errors.d.ts +1 -1
- package/esm/index.mjs +62 -58
- package/esm-loader/esm-cache.d.ts.map +1 -1
- package/esm-loader/esm-module-loader.d.ts.map +1 -1
- package/event/event-scope.helper.d.ts.map +1 -1
- package/event/flows/event-publish-http.flow.d.ts +3 -2
- package/event/flows/event-publish-http.flow.d.ts.map +1 -1
- package/ext-apps/ext-apps.handler.d.ts +3 -0
- package/ext-apps/ext-apps.handler.d.ts.map +1 -1
- package/flows/flow.registry.d.ts.map +1 -1
- package/front-mcp/authorities-rules.check.d.ts +2 -1
- package/front-mcp/authorities-rules.check.d.ts.map +1 -1
- package/front-mcp/front-mcp.d.ts +3 -0
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/index.js +68 -64
- package/job/execution/job-execution.manager.d.ts.map +1 -1
- package/job/job-permission.guard.d.ts +2 -0
- package/job/job-permission.guard.d.ts.map +1 -1
- package/job/job-run-access.d.ts +7 -3
- package/job/job-run-access.d.ts.map +1 -1
- package/job/store/job-state.interface.d.ts +2 -0
- package/job/store/job-state.interface.d.ts.map +1 -1
- package/job/tools/list-jobs.tool.d.ts.map +1 -1
- package/job/tools/remove-job.tool.d.ts.map +1 -1
- package/job/tools/update-job.tool.d.ts.map +1 -1
- package/logger/instances/instance.console-logger.d.ts +1 -1
- package/logger/instances/instance.console-logger.d.ts.map +1 -1
- package/logger/instances/instance.file-logger.d.ts +2 -1
- package/logger/instances/instance.file-logger.d.ts.map +1 -1
- package/logger/session-id-hash.d.ts +3 -0
- package/logger/session-id-hash.d.ts.map +1 -0
- package/metrics/metrics.service.d.ts.map +1 -1
- package/offload/offload-worker.globals.d.ts +2 -2
- package/offload/offload-worker.globals.d.ts.map +1 -1
- package/offload/worker-jobs.d.ts.map +1 -1
- package/package.json +10 -10
- package/plugin/enforced-metadata.check.d.ts +3 -3
- package/plugin/enforced-metadata.check.d.ts.map +1 -1
- package/prompt/flows/get-prompt.flow.d.ts +1 -0
- package/prompt/flows/get-prompt.flow.d.ts.map +1 -1
- package/prompt/flows/prompts-list.flow.d.ts +2 -1
- package/prompt/flows/prompts-list.flow.d.ts.map +1 -1
- package/provider/provider.registry.d.ts +2 -0
- package/provider/provider.registry.d.ts.map +1 -1
- package/provider/provider.utils.d.ts +2 -2
- package/provider/provider.utils.d.ts.map +1 -1
- package/remote-mcp/mcp-client.service.d.ts.map +1 -1
- package/remote-mcp/mcp-client.types.d.ts +2 -0
- package/remote-mcp/mcp-client.types.d.ts.map +1 -1
- package/remote-mcp/remote-entries.d.ts.map +1 -1
- package/remote-mcp/remote-oauth.d.ts +4 -2
- package/remote-mcp/remote-oauth.d.ts.map +1 -1
- package/resource/flows/read-resource.flow.d.ts +1 -0
- package/resource/flows/read-resource.flow.d.ts.map +1 -1
- package/resource/flows/resource-templates-list.flow.d.ts.map +1 -1
- package/resource/flows/resources-list.flow.d.ts +2 -1
- package/resource/flows/resources-list.flow.d.ts.map +1 -1
- package/resource/flows/subscribe-resource.flow.d.ts.map +1 -1
- package/resource/resource.instance.d.ts.map +1 -1
- package/scope/flows/http.request.flow.d.ts +2 -0
- package/scope/flows/http.request.flow.d.ts.map +1 -1
- package/scope/optional-dependency.util.d.ts +1 -12
- package/scope/optional-dependency.util.d.ts.map +1 -1
- package/scope/scope.instance.d.ts.map +1 -1
- package/server/security/replaceable-directory.d.ts +4 -1
- package/server/security/replaceable-directory.d.ts.map +1 -1
- package/server/security/resolve-allowed-hosts.d.ts.map +1 -1
- package/server/server.validation.d.ts.map +1 -1
- package/shared/shared-endpoint.d.ts.map +1 -1
- package/skill/cache/skill-http-cache.catalog.d.ts +6 -0
- package/skill/cache/skill-http-cache.catalog.d.ts.map +1 -0
- package/skill/flows/http/llm-full-txt.flow.d.ts.map +1 -1
- package/skill/flows/http/llm-txt.flow.d.ts.map +1 -1
- package/skill/flows/load-skill.flow.d.ts.map +1 -1
- package/skill/hooks/skill-tool.hook.d.ts +2 -0
- package/skill/hooks/skill-tool.hook.d.ts.map +1 -1
- package/skill/sep-2640/sep-2640.resource-helpers.d.ts +5 -4
- package/skill/sep-2640/sep-2640.resource-helpers.d.ts.map +1 -1
- package/skill/session/skill-session.manager.d.ts +2 -0
- package/skill/session/skill-session.manager.d.ts.map +1 -1
- package/skill/session/skill-session.types.d.ts +6 -0
- package/skill/session/skill-session.types.d.ts.map +1 -1
- package/skill/skill-authorities.helper.d.ts +4 -5
- package/skill/skill-authorities.helper.d.ts.map +1 -1
- package/skill/skill-directory-loader.d.ts.map +1 -1
- package/skill/skill-filter.helper.d.ts +15 -15
- package/skill/skill-filter.helper.d.ts.map +1 -1
- package/skill/skill-md-parser.d.ts.map +1 -1
- package/skill/skill.instance.d.ts +5 -0
- package/skill/skill.instance.d.ts.map +1 -1
- package/storage/sqlite-on-edge.d.ts +5 -0
- package/storage/sqlite-on-edge.d.ts.map +1 -0
- package/task/store/task-store.factory.d.ts.map +1 -1
- package/tool/flows/call-tool.flow.d.ts +5 -2
- package/tool/flows/call-tool.flow.d.ts.map +1 -1
- package/tool/flows/tools-list.flow.d.ts +2 -1
- package/tool/flows/tools-list.flow.d.ts.map +1 -1
- package/transport/adapters/transport.local.adapter.d.ts.map +1 -1
- package/transport/event-stores/event-store.factory.d.ts.map +1 -1
- package/transport/event-stores/redis.event-store.d.ts.map +1 -1
- package/transport/flows/handle.streamable-http.flow.d.ts.map +1 -1
- package/transport/in-memory-server.d.ts.map +1 -1
- package/transport/mcp-20260728/client/mcp-stateless.client.d.ts +8 -2
- package/transport/mcp-20260728/client/mcp-stateless.client.d.ts.map +1 -1
- package/transport/mcp-20260728/dispatcher.d.ts +3 -1
- package/transport/mcp-20260728/dispatcher.d.ts.map +1 -1
- package/transport/mcp-handlers/index.d.ts +32 -24
- package/transport/mcp-handlers/index.d.ts.map +1 -1
- package/transport/mcp-handlers/skills-list-request.handler.d.ts.map +1 -1
- package/transport/mcp-handlers/skills-mcp.types.d.ts +2 -0
- package/transport/mcp-handlers/skills-mcp.types.d.ts.map +1 -1
- package/transport/web-fetch-handler.d.ts +10 -8
- package/transport/web-fetch-handler.d.ts.map +1 -1
- package/transport/web-response.renderer.d.ts.map +1 -1
- package/worker/worker.lifecycle.d.ts +2 -2
- package/worker/worker.lifecycle.d.ts.map +1 -1
- package/workflow/tools/list-workflows.tool.d.ts.map +1 -1
- package/workflow/tools/register-workflow.tool.d.ts.map +1 -1
- package/workflow/tools/remove-workflow.tool.d.ts.map +1 -1
- package/workflow/tools/runtime-workflow.limits.d.ts +3 -0
- package/workflow/tools/runtime-workflow.limits.d.ts.map +1 -0
- package/workflow/tools/update-workflow.tool.d.ts.map +1 -1
- package/workflow/trigger/workflow-webhook.signature.d.ts +8 -5
- package/workflow/trigger/workflow-webhook.signature.d.ts.map +1 -1
|
@@ -46,7 +46,12 @@ import { oauthBasePath } from "../../flows/flow.http-path.mjs";
|
|
|
46
46
|
import { authUiExtraPath, buildAuthUiPage, buildConsentState } from "../auth-ui/index.mjs";
|
|
47
47
|
import { initialAuthorizedApps, withoutSkippedApps } from "../authorized-apps.utils.mjs";
|
|
48
48
|
import { projectConsentTools } from "../consent-tools.helper.mjs";
|
|
49
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
answerFederatedStep,
|
|
51
|
+
FEDERATED_STEP_FIELD,
|
|
52
|
+
getConfiguredProviders,
|
|
53
|
+
renderFederatedStep
|
|
54
|
+
} from "../federated-steps.mjs";
|
|
50
55
|
import { requiredProviderIds } from "../required-providers.utils.mjs";
|
|
51
56
|
import { parseFormBody } from "./form-body.utils.mjs";
|
|
52
57
|
import {
|
|
@@ -362,7 +367,7 @@ var OauthCallbackFlow = class extends FlowBase {
|
|
|
362
367
|
const excludedTools = consentConfig?.excludedTools ?? [];
|
|
363
368
|
const availableToolIds = pendingAuth.consent?.availableToolIds ?? [];
|
|
364
369
|
const effectiveFederated = isFederated || !!pendingAuth.federatedLogin;
|
|
365
|
-
const consentGateApplies = consentEnabled &&
|
|
370
|
+
const consentGateApplies = consentEnabled && (isIncremental || !effectiveFederated);
|
|
366
371
|
const rememberConsent = consentConfig?.rememberConsent ?? true;
|
|
367
372
|
const signIn = userSub ? { sub: userSub, email, name: name2, claims: this.state.customClaims, credentials: this.state.credentials } : void 0;
|
|
368
373
|
let finalSelectedTools = availableToolIds;
|
|
@@ -517,8 +522,28 @@ var OauthCallbackFlow = class extends FlowBase {
|
|
|
517
522
|
if (!isFederated || !selectedProviders || selectedProviders.length === 0) {
|
|
518
523
|
return;
|
|
519
524
|
}
|
|
520
|
-
this.logger.info(`Starting federated auth with ${selectedProviders.length} providers`);
|
|
521
525
|
const localAuth = this.scope.auth;
|
|
526
|
+
const upstreamProviders = selectedProviders.filter((id) => id !== "__parent__");
|
|
527
|
+
const unconfigured = upstreamProviders.filter((id) => !localAuth.getProviderConfig(id));
|
|
528
|
+
if (unconfigured.length === upstreamProviders.length && getConfiguredProviders(this.scope.metadata.auth).length === 0) {
|
|
529
|
+
this.logger.info("No selected provider signs in upstream here; continuing with this server sign-in");
|
|
530
|
+
this.state.set({ isFederated: false, selectedProviders: void 0, skippedProviders: void 0 });
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
if (unconfigured.length > 0) {
|
|
534
|
+
this.logger.warn(`Federated auth refused: no upstream sign-in is configured for ${unconfigured.join(", ")}`);
|
|
535
|
+
this.respond(
|
|
536
|
+
this.htmlPage(
|
|
537
|
+
this.renderErrorPage(
|
|
538
|
+
"invalid_request",
|
|
539
|
+
`Provider(s) ${unconfigured.join(", ")} cannot be linked on this server. Choose other providers.`
|
|
540
|
+
),
|
|
541
|
+
400
|
|
542
|
+
)
|
|
543
|
+
);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
this.logger.info(`Starting federated auth with ${upstreamProviders.length} providers`);
|
|
522
547
|
const sessionStore = localAuth.federatedSessionStore;
|
|
523
548
|
if (!sessionStore || typeof sessionStore.store !== "function" || typeof sessionStore.update !== "function" || typeof sessionStore.delete !== "function") {
|
|
524
549
|
this.logger.error("Federated session store not configured");
|
|
@@ -546,14 +571,14 @@ var OauthCallbackFlow = class extends FlowBase {
|
|
|
546
571
|
challenge: codeChallenge,
|
|
547
572
|
method: "S256"
|
|
548
573
|
},
|
|
549
|
-
providerIds:
|
|
574
|
+
providerIds: upstreamProviders,
|
|
550
575
|
// The provider callback checks the same browser binding.
|
|
551
576
|
signinBinding: this.state.signinBinding,
|
|
552
577
|
authorizedAppIds
|
|
553
578
|
});
|
|
554
579
|
await sessionStore.store(federatedSession);
|
|
555
580
|
this.logger.info(`Created federated session: ${federatedSession.id}`);
|
|
556
|
-
const firstProviderId =
|
|
581
|
+
const firstProviderId = upstreamProviders[0];
|
|
557
582
|
const verifier = generateCodeVerifier();
|
|
558
583
|
const challenge = sha256Base64url(verifier);
|
|
559
584
|
const pkce = {
|
|
@@ -564,17 +589,6 @@ var OauthCallbackFlow = class extends FlowBase {
|
|
|
564
589
|
const providerState = `federated:${federatedSession.id}:${randomUUID()}`;
|
|
565
590
|
startNextProvider(federatedSession, pkce, providerState);
|
|
566
591
|
await sessionStore.update(federatedSession);
|
|
567
|
-
const providerConfig = localAuth.getProviderConfig(firstProviderId);
|
|
568
|
-
if (!providerConfig) {
|
|
569
|
-
this.logger.warn(`Provider ${firstProviderId} not configured, falling back to normal auth`);
|
|
570
|
-
await sessionStore.delete(federatedSession.id);
|
|
571
|
-
this.state.set({
|
|
572
|
-
isFederated: false,
|
|
573
|
-
selectedProviders: void 0,
|
|
574
|
-
skippedProviders: void 0
|
|
575
|
-
});
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
592
|
const redirectUrl = await localAuth.buildProviderAuthorizeUrl(firstProviderId, {
|
|
579
593
|
state: providerState,
|
|
580
594
|
codeChallenge: pkce.challenge,
|
|
@@ -59,6 +59,14 @@ var plan = {
|
|
|
59
59
|
};
|
|
60
60
|
var name = "oauth:register";
|
|
61
61
|
var Stage = StageHookOf(name);
|
|
62
|
+
function registrationValidationError(error) {
|
|
63
|
+
const redirectUriRefused = error.issues.some((issue) => issue.path[0] === "redirect_uris" && issue.path.length > 1);
|
|
64
|
+
const problems = error.issues.map((issue) => `${issue.path.join(".") || "body"}: ${issue.message}`);
|
|
65
|
+
return {
|
|
66
|
+
error: redirectUriRefused ? "invalid_redirect_uri" : "invalid_client_metadata",
|
|
67
|
+
error_description: problems.join("; ")
|
|
68
|
+
};
|
|
69
|
+
}
|
|
62
70
|
function extractBearer(headers) {
|
|
63
71
|
const raw = headers?.["authorization"] ?? headers?.["Authorization"];
|
|
64
72
|
if (typeof raw !== "string") return void 0;
|
|
@@ -67,6 +75,8 @@ function extractBearer(headers) {
|
|
|
67
75
|
}
|
|
68
76
|
var OauthRegisterFlow = class extends FlowBase {
|
|
69
77
|
registered;
|
|
78
|
+
/** Why the request's client metadata failed validation; answered once the caller is allowed to register. */
|
|
79
|
+
invalidMetadata;
|
|
70
80
|
/** The local AS primary auth, which owns the DCR client registry (#462). */
|
|
71
81
|
get localAuth() {
|
|
72
82
|
return this.scope.auth;
|
|
@@ -80,11 +90,9 @@ var OauthRegisterFlow = class extends FlowBase {
|
|
|
80
90
|
async parseInput() {
|
|
81
91
|
const dcrEnabled = this.localAuth.isDcrEnabled?.() ?? true;
|
|
82
92
|
const { request } = this.rawInput;
|
|
83
|
-
const parsed = registrationRequestSchema.
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
dcrEnabled
|
|
87
|
-
});
|
|
93
|
+
const parsed = registrationRequestSchema.safeParse(request.body || {});
|
|
94
|
+
this.invalidMetadata = parsed.error;
|
|
95
|
+
this.state.set(parsed.success ? { body: parsed.data, dcrEnabled } : { dcrEnabled });
|
|
88
96
|
}
|
|
89
97
|
async validateInput() {
|
|
90
98
|
const { request } = this.rawInput;
|
|
@@ -116,6 +124,10 @@ var OauthRegisterFlow = class extends FlowBase {
|
|
|
116
124
|
return;
|
|
117
125
|
}
|
|
118
126
|
}
|
|
127
|
+
if (this.invalidMetadata) {
|
|
128
|
+
this.respond(httpRespond.json(registrationValidationError(this.invalidMetadata), { status: 400 }));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
119
131
|
const { redirect_uris, token_endpoint_auth_method, grant_types, response_types } = this.state.required.body;
|
|
120
132
|
if (!response_types.includes("code")) {
|
|
121
133
|
this.respond(
|
|
@@ -381,17 +381,19 @@ var OauthTokenFlow = class extends FlowBase {
|
|
|
381
381
|
return computeResource(this.rawInput.request, this.scope.entryPath, this.scope.routeBase);
|
|
382
382
|
}
|
|
383
383
|
/**
|
|
384
|
-
* The request's client assertion, and what its `aud` may name (RFC 7523 \u00a73):
|
|
385
|
-
* authorization server metadata advertises it
|
|
384
|
+
* The request's client assertion, and what its `aud` may name (RFC 7523 \u00a73): the issuer, the token endpoint on
|
|
385
|
+
* the issuer's origin, and the token endpoint as the authorization server metadata advertises it for this
|
|
386
|
+
* request when the request's Host is the issuer's host. A Host naming another server never sets the audience.
|
|
386
387
|
*/
|
|
387
388
|
clientAssertion(body, localAuth) {
|
|
388
389
|
const { request } = this.rawInput;
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
390
|
+
const issuer = localAuth.issuerFor(request);
|
|
391
|
+
const tokenPath = `${oauthBasePath(this.scope)}/oauth/token`;
|
|
392
|
+
const requestEndpoint = `${getRequestBaseUrl(request)}${tokenPath}`;
|
|
393
|
+
const issuerUrl = parseUrl(issuer);
|
|
394
|
+
const audiences = issuerUrl ? [`${issuerUrl.origin}${tokenPath}`, issuer] : [issuer];
|
|
395
|
+
if (issuerUrl && parseUrl(requestEndpoint)?.host === issuerUrl.host) audiences.push(requestEndpoint);
|
|
396
|
+
return { type: body.client_assertion_type, assertion: body.client_assertion, audiences };
|
|
395
397
|
}
|
|
396
398
|
};
|
|
397
399
|
__decorateClass([
|
|
@@ -442,6 +444,13 @@ OauthTokenFlow = __decorateClass([
|
|
|
442
444
|
}
|
|
443
445
|
})
|
|
444
446
|
], OauthTokenFlow);
|
|
447
|
+
function parseUrl(value) {
|
|
448
|
+
try {
|
|
449
|
+
return new URL(value);
|
|
450
|
+
} catch {
|
|
451
|
+
return void 0;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
445
454
|
export {
|
|
446
455
|
OauthTokenFlow,
|
|
447
456
|
OauthTokenFlow as default
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
isVercelKvProvider
|
|
17
17
|
} from "../../common/index.mjs";
|
|
18
18
|
import { VercelKvAsyncInitRequiredError } from "../../errors/sdk.errors.mjs";
|
|
19
|
+
import { requireOptionalModule } from "../../scope/optional-dependency.util.mjs";
|
|
19
20
|
function isSqliteSessionStoreOptions(options) {
|
|
20
21
|
return typeof options === "object" && options !== null && "sqlite" in options && !!options.sqlite;
|
|
21
22
|
}
|
|
@@ -82,7 +83,10 @@ function createSessionStoreSync(options, logger) {
|
|
|
82
83
|
);
|
|
83
84
|
}
|
|
84
85
|
function createSqliteSessionStore(options, logger) {
|
|
85
|
-
const { SqliteSessionStore } =
|
|
86
|
+
const { SqliteSessionStore } = requireOptionalModule(
|
|
87
|
+
"@frontmcp/storage-sqlite",
|
|
88
|
+
() => __require("@frontmcp/storage-sqlite")
|
|
89
|
+
);
|
|
86
90
|
logger?.info("[SessionStoreFactory] Creating SQLite session store", { path: options.path });
|
|
87
91
|
return new SqliteSessionStore(options);
|
|
88
92
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
hasExpiredCaller,
|
|
4
4
|
isChannelCapableSession
|
|
5
5
|
} from "../notification/notification.service.mjs";
|
|
6
|
-
import { CHANNEL_NOTIFICATION_METHOD, channelMetaOf } from "./channel.utils.mjs";
|
|
6
|
+
import { CHANNEL_NOTIFICATION_METHOD, channelMetaOf, channelMetaValuesOf } from "./channel.utils.mjs";
|
|
7
7
|
var ChannelNotificationService = class {
|
|
8
8
|
/**
|
|
9
9
|
* @param defaultMeta - The server's `channels.defaultMeta`, added under every notification's own meta.
|
|
@@ -49,15 +49,18 @@ var ChannelNotificationService = class {
|
|
|
49
49
|
this.logger.verbose(`No subscribers for channel "${channelName}", notification buffered only`);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
const recipients = new Set(
|
|
53
|
+
subscribers.filter((sessionId) => {
|
|
54
|
+
const registered = this.notificationService.getRegisteredServer(sessionId);
|
|
55
|
+
return registered !== void 0 && isChannelCapableSession(registered) && !hasExpiredCaller(registered);
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
if (recipients.size > 0) {
|
|
59
|
+
this.notificationService.sendCustomNotification(
|
|
60
|
+
CHANNEL_NOTIFICATION_METHOD,
|
|
61
|
+
{ content, meta: safeMeta },
|
|
62
|
+
(session) => recipients.has(session.sessionId)
|
|
63
|
+
);
|
|
61
64
|
}
|
|
62
65
|
this.logger.verbose(`Sent channel "${channelName}" notification to ${subscribers.length} subscriber(s)`);
|
|
63
66
|
}
|
|
@@ -135,11 +138,12 @@ var ChannelNotificationService = class {
|
|
|
135
138
|
*
|
|
136
139
|
* @param channelName - The channel name (becomes the `source` attribute)
|
|
137
140
|
* @param content - The notification content
|
|
138
|
-
* @param additionalMeta - Additional metadata to include
|
|
141
|
+
* @param additionalMeta - Additional metadata to include; a value that is not a string is sent as one
|
|
139
142
|
*/
|
|
140
143
|
async send(channelName, content, additionalMeta) {
|
|
141
144
|
if (!this.sendThroughFlow) {
|
|
142
|
-
|
|
145
|
+
const ownMeta = channelMetaValuesOf(additionalMeta ?? {});
|
|
146
|
+
this.sendToSubscribedSessions(content, { ...this.serverMeta, ...ownMeta, source: channelName });
|
|
143
147
|
return;
|
|
144
148
|
}
|
|
145
149
|
try {
|
|
@@ -17,7 +17,7 @@ var ChannelInstance = class extends ChannelEntry {
|
|
|
17
17
|
_serviceContext;
|
|
18
18
|
/** Ends the watch of a file-watcher source's paths; set while the channel is connected */
|
|
19
19
|
_stopFileWatch;
|
|
20
|
-
/**
|
|
20
|
+
/** The channel's latest global notifications, kept for `replayBufferedEvents()` when replay is enabled */
|
|
21
21
|
_replayBuffer = [];
|
|
22
22
|
/** Maximum replay buffer size */
|
|
23
23
|
_maxReplayEvents;
|
|
@@ -149,7 +149,7 @@ var ChannelInstance = class extends ChannelEntry {
|
|
|
149
149
|
* (appropriate for global events like webhooks, file changes, etc.).
|
|
150
150
|
*
|
|
151
151
|
* @param content - The notification content
|
|
152
|
-
* @param meta - Additional metadata
|
|
152
|
+
* @param meta - Additional metadata; a value that is not a string is sent as one
|
|
153
153
|
* @param targetSessionId - If set, deliver ONLY to this session
|
|
154
154
|
*/
|
|
155
155
|
async pushNotification(content, meta, targetSessionId) {
|
|
@@ -178,11 +178,13 @@ var ChannelInstance = class extends ChannelEntry {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
181
|
+
* Send the buffered notifications to one session, each with `replayed: 'true'` in its meta.
|
|
182
|
+
* Nothing in the SDK calls it when a session connects: call it yourself, such as from a tool the session calls.
|
|
183
|
+
* Each call sends the whole buffer again.
|
|
183
184
|
*
|
|
184
185
|
* @param sessionId - The session to replay events to
|
|
185
|
-
* @returns
|
|
186
|
+
* @returns How many the session was sent: none when it is not connected, cannot take the channel, or its
|
|
187
|
+
* credentials have expired
|
|
186
188
|
*/
|
|
187
189
|
replayBufferedEvents(sessionId) {
|
|
188
190
|
if (!this.replayEnabled || this._replayBuffer.length === 0 || !this._channelNotificationService) {
|
|
@@ -190,13 +192,8 @@ var ChannelInstance = class extends ChannelEntry {
|
|
|
190
192
|
}
|
|
191
193
|
let count = 0;
|
|
192
194
|
for (const notification of this._replayBuffer) {
|
|
193
|
-
const replayMeta = {
|
|
194
|
-
|
|
195
|
-
source: notification.meta?.["source"] ?? this.name,
|
|
196
|
-
replayed: "true"
|
|
197
|
-
};
|
|
198
|
-
this._channelNotificationService.sendToSession(sessionId, notification.content, replayMeta);
|
|
199
|
-
count++;
|
|
195
|
+
const replayMeta = { ...notification.meta, replayed: "true" };
|
|
196
|
+
if (this._channelNotificationService.sendToSession(sessionId, notification.content, replayMeta)) count++;
|
|
200
197
|
}
|
|
201
198
|
return count;
|
|
202
199
|
}
|
|
@@ -13,12 +13,26 @@ function channelCapabilitiesOf(scope) {
|
|
|
13
13
|
return { experimental: { "claude/channel": {} } };
|
|
14
14
|
}
|
|
15
15
|
var UNSAFE_META_KEY_CHARACTERS = /[^A-Za-z0-9_]/g;
|
|
16
|
+
function metaValueOf(value) {
|
|
17
|
+
if (typeof value !== "object") return String(value);
|
|
18
|
+
try {
|
|
19
|
+
return JSON.stringify(value) ?? String(value);
|
|
20
|
+
} catch {
|
|
21
|
+
return String(value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function channelMetaValuesOf(meta) {
|
|
25
|
+
const values = {};
|
|
26
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
27
|
+
if (value !== void 0 && value !== null) values[key] = metaValueOf(value);
|
|
28
|
+
}
|
|
29
|
+
return values;
|
|
30
|
+
}
|
|
16
31
|
function channelMetaOf(meta) {
|
|
17
32
|
const safeMeta = {};
|
|
18
|
-
for (const [key, value] of Object.entries(meta)) {
|
|
33
|
+
for (const [key, value] of Object.entries(channelMetaValuesOf(meta))) {
|
|
19
34
|
const safeKey = key.replace(UNSAFE_META_KEY_CHARACTERS, "_");
|
|
20
|
-
if (safeKey
|
|
21
|
-
safeMeta[safeKey] = String(value);
|
|
35
|
+
if (safeKey !== "") safeMeta[safeKey] = value;
|
|
22
36
|
}
|
|
23
37
|
return safeMeta;
|
|
24
38
|
}
|
|
@@ -57,6 +71,7 @@ export {
|
|
|
57
71
|
CHANNEL_NOTIFICATION_METHOD,
|
|
58
72
|
channelCapabilitiesOf,
|
|
59
73
|
channelMetaOf,
|
|
74
|
+
channelMetaValuesOf,
|
|
60
75
|
normalizeChannel,
|
|
61
76
|
normalizeChannels,
|
|
62
77
|
servesClaudeCodeChannels
|
|
@@ -13,10 +13,12 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
13
13
|
import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
14
14
|
import { Flow, FlowBase, FlowHooksOf } from "../../common/index.mjs";
|
|
15
15
|
import { InvalidInputError } from "../../errors/index.mjs";
|
|
16
|
+
import { channelMetaValuesOf } from "../channel.utils.mjs";
|
|
16
17
|
var inputSchema = z.object({
|
|
17
18
|
channelName: z.string().min(1),
|
|
18
19
|
content: z.string().min(1),
|
|
19
|
-
|
|
20
|
+
/** Values of any type: `parseInput` turns them into strings (see `channelMetaValuesOf`). */
|
|
21
|
+
meta: z.record(z.string(), z.unknown()).optional(),
|
|
20
22
|
/** Deliver to this session only (session-scoped events such as agent and job completions). */
|
|
21
23
|
targetSessionId: z.string().min(1).optional()
|
|
22
24
|
});
|
|
@@ -51,7 +53,7 @@ var SendChannelNotificationFlow = class extends FlowBase {
|
|
|
51
53
|
this.state.set({
|
|
52
54
|
channelName: data.channelName,
|
|
53
55
|
content: data.content,
|
|
54
|
-
meta: data.meta,
|
|
56
|
+
meta: data.meta && channelMetaValuesOf(data.meta),
|
|
55
57
|
targetSessionId: data.targetSessionId
|
|
56
58
|
});
|
|
57
59
|
this.logger.verbose("parseInput:done");
|
|
@@ -98,7 +98,8 @@ var remoteAuthConfigSchema = z.discriminatedUnion("mode", [
|
|
|
98
98
|
clientId: z.string().min(1).optional(),
|
|
99
99
|
clientSecret: z.string().min(1).optional(),
|
|
100
100
|
scope: z.string().optional(),
|
|
101
|
-
tokenUrl: z.string().url().optional()
|
|
101
|
+
tokenUrl: z.string().url().optional(),
|
|
102
|
+
issuer: z.string().url().optional()
|
|
102
103
|
}).refine((auth) => auth.clientId === void 0 === (auth.clientSecret === void 0), {
|
|
103
104
|
message: "remoteAuth oauth needs both clientId and clientSecret, or neither"
|
|
104
105
|
})
|
|
@@ -54,7 +54,7 @@ var eventsStoreSchema = z.object({
|
|
|
54
54
|
redis: redisOptionsSchema.optional(),
|
|
55
55
|
sqlite: sqliteOptionsSchema.extend({ path: z.string().min(1) }).optional(),
|
|
56
56
|
keyPrefix: z.string().min(1).optional()
|
|
57
|
-
}).refine((store) => !(store.redis && store.sqlite), { message: "events.store takes redis or sqlite, not both" });
|
|
57
|
+
}).strict().refine((store) => !(store.redis && store.sqlite), { message: "events.store takes redis or sqlite, not both" });
|
|
58
58
|
var eventSubscriptionsSchema = z.object({
|
|
59
59
|
defaultTtlMs: positiveIntegerSchema.optional().default(36e5),
|
|
60
60
|
maxTtlMs: positiveIntegerSchema.optional().default(864e5),
|
|
@@ -63,14 +63,14 @@ var eventSubscriptionsSchema = z.object({
|
|
|
63
63
|
maxPerPrincipal: positiveIntegerSchema.optional().default(100),
|
|
64
64
|
reauthorizeEveryMs: positiveIntegerSchema.optional().default(3e5),
|
|
65
65
|
suspendedTtlMs: positiveIntegerSchema.optional().default(6048e5)
|
|
66
|
-
}).refine((ttl) => ttl.minTtlMs <= ttl.defaultTtlMs && ttl.defaultTtlMs <= ttl.maxTtlMs, {
|
|
66
|
+
}).strict().refine((ttl) => ttl.minTtlMs <= ttl.defaultTtlMs && ttl.defaultTtlMs <= ttl.maxTtlMs, {
|
|
67
67
|
message: "events.subscriptions needs minTtlMs <= defaultTtlMs <= maxTtlMs; set the three together"
|
|
68
68
|
});
|
|
69
69
|
var eventsWebhookVerificationSchema = z.object({
|
|
70
70
|
cacheTtlMs: positiveIntegerSchema.optional().default(36e5),
|
|
71
71
|
timeoutMs: positiveIntegerSchema.optional().default(1e4),
|
|
72
72
|
maxAttemptsPerHost: positiveIntegerSchema.optional().default(10)
|
|
73
|
-
});
|
|
73
|
+
}).strict();
|
|
74
74
|
var eventsWebhookDeliverySchema = z.object({
|
|
75
75
|
timeoutMs: positiveIntegerSchema.optional().default(1e4),
|
|
76
76
|
maxAttempts: positiveIntegerSchema.optional().default(5),
|
|
@@ -78,7 +78,7 @@ var eventsWebhookDeliverySchema = z.object({
|
|
|
78
78
|
backoffMs: positiveIntegerSchema.optional().default(1e3),
|
|
79
79
|
maxBackoffMs: positiveIntegerSchema.optional().default(6e4),
|
|
80
80
|
concurrency: positiveIntegerSchema.optional().default(16)
|
|
81
|
-
}).refine((delivery) => delivery.backoffMs <= delivery.maxBackoffMs, {
|
|
81
|
+
}).strict().refine((delivery) => delivery.backoffMs <= delivery.maxBackoffMs, {
|
|
82
82
|
message: "events.webhook.delivery needs backoffMs <= maxBackoffMs"
|
|
83
83
|
});
|
|
84
84
|
var eventsWebhookSchema = z.object({
|
|
@@ -88,7 +88,7 @@ var eventsWebhookSchema = z.object({
|
|
|
88
88
|
verification: eventsWebhookVerificationSchema.optional().transform((verification) => verification ?? eventsWebhookVerificationSchema.parse({})),
|
|
89
89
|
delivery: eventsWebhookDeliverySchema.optional().transform((delivery) => delivery ?? eventsWebhookDeliverySchema.parse({})),
|
|
90
90
|
rotationGraceMs: positiveIntegerSchema.optional().default(3e5)
|
|
91
|
-
});
|
|
91
|
+
}).strict();
|
|
92
92
|
var PUBLISH_ENDPOINT_PATH = /^\/[^?#\s*(){}:]*$/;
|
|
93
93
|
var eventsPublishEndpointSchema = z.object({
|
|
94
94
|
enabled: z.boolean().optional().default(false),
|
|
@@ -100,22 +100,22 @@ var eventsPublishEndpointSchema = z.object({
|
|
|
100
100
|
authorities: z.custom((rule) => typeof rule === "string" || typeof rule === "object" && rule !== null, {
|
|
101
101
|
message: "events.publishEndpoint.authorities must be a profile name, a list of names or a policy"
|
|
102
102
|
}).optional()
|
|
103
|
-
}).refine((endpoint) => endpoint.secret === void 0 || endpoint.authorities === void 0, {
|
|
103
|
+
}).strict().refine((endpoint) => endpoint.secret === void 0 || endpoint.authorities === void 0, {
|
|
104
104
|
message: "events.publishEndpoint takes secret or authorities, not both: a signed request names no caller for a rule to check"
|
|
105
105
|
});
|
|
106
106
|
var eventsBufferSchema = z.object({
|
|
107
107
|
maxAgeMs: positiveIntegerSchema.optional().default(6e5),
|
|
108
108
|
maxEvents: positiveIntegerSchema.optional().default(1e4)
|
|
109
|
-
});
|
|
109
|
+
}).strict();
|
|
110
110
|
var eventsPollSchema = z.object({
|
|
111
111
|
enabled: z.boolean().optional().default(true),
|
|
112
112
|
nextPollMs: positiveIntegerSchema.optional().default(3e4),
|
|
113
113
|
maxEvents: positiveIntegerSchema.optional().default(100)
|
|
114
|
-
});
|
|
114
|
+
}).strict();
|
|
115
115
|
var eventsPushSchema = z.object({
|
|
116
116
|
enabled: z.boolean().optional().default(true),
|
|
117
117
|
heartbeatMs: positiveIntegerSchema.optional().default(25e3)
|
|
118
|
-
});
|
|
118
|
+
}).strict();
|
|
119
119
|
var eventsConfigSchema = z.object({
|
|
120
120
|
enabled: z.boolean().optional(),
|
|
121
121
|
compat: z.enum(["auto", "sep-3415", "sketch"]).optional().default("auto"),
|
|
@@ -127,7 +127,7 @@ var eventsConfigSchema = z.object({
|
|
|
127
127
|
poll: eventsPollSchema.optional().transform((poll) => poll ?? eventsPollSchema.parse({})),
|
|
128
128
|
push: eventsPushSchema.optional().transform((push) => push ?? eventsPushSchema.parse({})),
|
|
129
129
|
bridge: z.boolean().optional().default(true)
|
|
130
|
-
}).refine((config) => !config.subscriptions.allowNoExpiry || Boolean(config.store?.redis ?? config.store?.sqlite), {
|
|
130
|
+
}).strict().refine((config) => !config.subscriptions.allowNoExpiry || Boolean(config.store?.redis ?? config.store?.sqlite), {
|
|
131
131
|
message: "events.subscriptions.allowNoExpiry needs events.store.redis or events.store.sqlite"
|
|
132
132
|
});
|
|
133
133
|
export {
|
|
@@ -182,7 +182,12 @@ function challengeHeaders(challenge) {
|
|
|
182
182
|
}
|
|
183
183
|
var NO_STORE_HEADERS = { "Cache-Control": "no-store", Pragma: "no-cache" };
|
|
184
184
|
function withHttpHeaders(output, headers) {
|
|
185
|
-
if (output.kind === "next" || output.kind === "consumed"
|
|
185
|
+
if (output.kind === "next" || output.kind === "consumed") return output;
|
|
186
|
+
if (output.kind === "web-response") {
|
|
187
|
+
const response = new Response(output.response.body, output.response);
|
|
188
|
+
for (const [name, value] of Object.entries(headers)) response.headers.set(name, value);
|
|
189
|
+
return { ...output, response };
|
|
190
|
+
}
|
|
186
191
|
return { ...output, headers: { ...output.headers, ...headers } };
|
|
187
192
|
}
|
|
188
193
|
var httpRespond = {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// libs/sdk/src/common/utils/content-disposition.utils.ts
|
|
2
|
+
function serializeContentDisposition(disposition, filename) {
|
|
3
|
+
return filename ? `${disposition}; filename="${filename.replace(/["\\]/g, "\\$&")}"` : disposition;
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
serializeContentDisposition
|
|
7
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// libs/sdk/src/common/utils/forward-headers.utils.ts
|
|
2
|
-
import {
|
|
2
|
+
import { createGlobMatcher } from "@frontmcp/utils";
|
|
3
3
|
var HOP_BY_HOP_HEADERS = [
|
|
4
4
|
"connection",
|
|
5
5
|
"keep-alive",
|
|
@@ -38,16 +38,16 @@ function refusedHeadersMatchedBy(glob) {
|
|
|
38
38
|
const lowerGlob = glob.toLowerCase();
|
|
39
39
|
const literalStart = lowerGlob.split(/[*?]/)[0];
|
|
40
40
|
const families = REFUSED_PREFIXES.filter((prefix) => literalStart.startsWith(prefix)).map((prefix) => `${prefix}*`);
|
|
41
|
-
const
|
|
42
|
-
return [...families, ...REFUSED_HEADERS.filter((name) =>
|
|
41
|
+
const matches = createGlobMatcher(lowerGlob);
|
|
42
|
+
return [...families, ...REFUSED_HEADERS.filter((name) => matches(name))];
|
|
43
43
|
}
|
|
44
44
|
function createHeaderForwarder(globs) {
|
|
45
45
|
if (!globs || globs.length === 0) return void 0;
|
|
46
|
-
const matchers = globs.map((glob) =>
|
|
46
|
+
const matchers = globs.map((glob) => createGlobMatcher(glob.toLowerCase()));
|
|
47
47
|
return (name) => {
|
|
48
48
|
if (name.length > MAX_HEADER_NAME_LENGTH) return false;
|
|
49
49
|
const lowerName = name.toLowerCase();
|
|
50
|
-
return !isRefusedForwardHeader(lowerName) && matchers.some((
|
|
50
|
+
return !isRefusedForwardHeader(lowerName) && matchers.some((matches) => matches(lowerName));
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
export {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// libs/sdk/src/common/utils/issuer-subject.utils.ts
|
|
2
|
+
import { base64urlEncode } from "@frontmcp/utils";
|
|
3
|
+
function resolveIssuer(authInfo) {
|
|
4
|
+
const user = asRecord(authInfo?.["user"]) ?? asRecord(asRecord(authInfo?.["extra"])?.["user"]);
|
|
5
|
+
const issuer = user?.["iss"];
|
|
6
|
+
return typeof issuer === "string" ? issuer : "";
|
|
7
|
+
}
|
|
8
|
+
function issuerSubjectKey(issuer, subject) {
|
|
9
|
+
return issuer ? `${base64urlEncode(new TextEncoder().encode(issuer))}:${subject}` : subject;
|
|
10
|
+
}
|
|
11
|
+
function asRecord(value) {
|
|
12
|
+
return value && typeof value === "object" ? value : void 0;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
issuerSubjectKey,
|
|
16
|
+
resolveIssuer
|
|
17
|
+
};
|
|
@@ -16,6 +16,7 @@ import { CompleteRequestSchema, CompleteResultSchema } from "@frontmcp/protocol"
|
|
|
16
16
|
import { assertAppLoaded, loadAppOfPlaceholder } from "../../app/lazy/lazy-placeholders.mjs";
|
|
17
17
|
import { loadRemoteAppCapabilities } from "../../app/remote-capabilities.utils.mjs";
|
|
18
18
|
import { enforcePublicAccess, publicAccessFor } from "../../auth/public-access.utils.mjs";
|
|
19
|
+
import { AUTHORITIES_NOT_CONFIGURED } from "../../builtin/authorities/authorities-not-configured.mjs";
|
|
19
20
|
import {
|
|
20
21
|
buildPartitionContext,
|
|
21
22
|
Flow,
|
|
@@ -184,9 +185,16 @@ var CompleteFlow = class extends FlowBase {
|
|
|
184
185
|
const ctxBuilder = this.scope.authoritiesContextBuilder;
|
|
185
186
|
const { prompt, resource } = this.state;
|
|
186
187
|
const entry = prompt ?? resource;
|
|
187
|
-
if (!
|
|
188
|
+
if (!entry) return;
|
|
188
189
|
const authorities = entry.metadata["authorities"];
|
|
189
190
|
if (!authorities) return;
|
|
191
|
+
if (!engine || !ctxBuilder) {
|
|
192
|
+
throw new AuthorityDeniedError({
|
|
193
|
+
entryType: prompt ? "Prompt" : "Resource",
|
|
194
|
+
entryName: entry.fullName || entry.name,
|
|
195
|
+
deniedBy: AUTHORITIES_NOT_CONFIGURED
|
|
196
|
+
});
|
|
197
|
+
}
|
|
190
198
|
const evaluationContext = ctxBuilder.build(this.authInfo ?? {});
|
|
191
199
|
const result = await engine.evaluate(authorities, evaluationContext);
|
|
192
200
|
if (result.granted) return;
|
|
@@ -30,7 +30,11 @@ var FrontMcpContext = class {
|
|
|
30
30
|
// =====================
|
|
31
31
|
/** Unique request identifier (UUID v4) */
|
|
32
32
|
requestId;
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* The session id the request names: over HTTP, the client's `mcp-session-id` header (a fresh `anon:` id when it
|
|
35
|
+
* sends none). Only its length and characters are checked, so it does not prove a session; key per-session state
|
|
36
|
+
* on {@link verifiedSessionId}.
|
|
37
|
+
*/
|
|
34
38
|
sessionId;
|
|
35
39
|
/** Scope identifier */
|
|
36
40
|
scopeId;
|
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
import "reflect-metadata";
|
|
3
3
|
import { getDecoratorConfig } from "../common/index.mjs";
|
|
4
4
|
import { PLATFORM_CLIENT_INFO } from "./llm-platform.mjs";
|
|
5
|
-
var
|
|
5
|
+
var instanceCaches = /* @__PURE__ */ new Map();
|
|
6
6
|
var instanceClients = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
function
|
|
7
|
+
function instanceCacheOf(mode) {
|
|
8
|
+
let cache = instanceCaches.get(mode);
|
|
9
|
+
if (!cache) {
|
|
10
|
+
cache = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
instanceCaches.set(mode, cache);
|
|
12
|
+
}
|
|
13
|
+
return cache;
|
|
14
|
+
}
|
|
15
|
+
function getInstance(config, mode = "full") {
|
|
8
16
|
let resolvedConfig = config;
|
|
9
17
|
if (typeof config === "function") {
|
|
10
18
|
const stored = getDecoratorConfig(config);
|
|
@@ -13,6 +21,7 @@ function getInstance(config, mode) {
|
|
|
13
21
|
}
|
|
14
22
|
}
|
|
15
23
|
const cacheKey = resolvedConfig;
|
|
24
|
+
const instanceCache = instanceCacheOf(mode);
|
|
16
25
|
let instancePromise = instanceCache.get(cacheKey);
|
|
17
26
|
if (!instancePromise) {
|
|
18
27
|
instancePromise = (async () => {
|
|
@@ -30,8 +39,9 @@ function getInstance(config, mode) {
|
|
|
30
39
|
}
|
|
31
40
|
return { cacheKey, instancePromise };
|
|
32
41
|
}
|
|
33
|
-
function joinInstance(config, mode) {
|
|
42
|
+
function joinInstance(config, mode = "full") {
|
|
34
43
|
const { cacheKey, instancePromise } = getInstance(config, mode);
|
|
44
|
+
const instanceCache = instanceCacheOf(mode);
|
|
35
45
|
instanceClients.set(instancePromise, (instanceClients.get(instancePromise) ?? 0) + 1);
|
|
36
46
|
const release = async () => {
|
|
37
47
|
const remaining = (instanceClients.get(instancePromise) ?? 1) - 1;
|
|
@@ -90,7 +100,7 @@ async function connectVercelAI(config, options) {
|
|
|
90
100
|
});
|
|
91
101
|
}
|
|
92
102
|
function clearScopeCache() {
|
|
93
|
-
|
|
103
|
+
instanceCaches = /* @__PURE__ */ new Map();
|
|
94
104
|
}
|
|
95
105
|
export {
|
|
96
106
|
clearScopeCache,
|
|
@@ -66,7 +66,9 @@ var DirectMcpServerImpl = class {
|
|
|
66
66
|
return withMcpSurface(this.scope, {
|
|
67
67
|
authInfo,
|
|
68
68
|
metadata: options?.metadata,
|
|
69
|
-
...platformEnv !== void 0 ? { platformEnv } : {}
|
|
69
|
+
...platformEnv !== void 0 ? { platformEnv } : {},
|
|
70
|
+
// Its own request with its own caller, also when made while another request runs
|
|
71
|
+
ownRequest: true
|
|
70
72
|
});
|
|
71
73
|
}
|
|
72
74
|
/**
|