@plitzi/sdk-server 0.32.24 → 0.33.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/CHANGELOG.md +22 -0
- package/README.md +326 -162
- package/dist/adapters/authAdapters.d.ts +21 -0
- package/dist/adapters/authAdapters.js +12 -0
- package/dist/adapters/jsonAdapters.d.ts +15 -0
- package/dist/adapters/jsonAdapters.js +9 -4
- package/dist/core/auth/api.d.ts +148 -0
- package/dist/core/auth/api.js +286 -0
- package/dist/core/auth/authorize.d.ts +96 -0
- package/dist/core/auth/authorize.js +92 -0
- package/dist/core/auth/createAuth.d.ts +165 -0
- package/dist/core/auth/createAuth.js +105 -0
- package/dist/core/auth/credentials.d.ts +29 -0
- package/dist/core/auth/credentials.js +48 -0
- package/dist/core/auth/domains.d.ts +41 -0
- package/dist/core/auth/domains.js +78 -0
- package/dist/core/auth/identity.d.ts +108 -0
- package/dist/core/auth/identity.js +164 -0
- package/dist/core/auth/oauth/client.d.ts +5 -0
- package/dist/core/auth/oauth/client.js +47 -0
- package/dist/core/auth/oauth/index.d.ts +78 -0
- package/dist/core/auth/oauth/index.js +113 -0
- package/dist/core/auth/oauth/providers/github.d.ts +2 -0
- package/dist/core/auth/oauth/providers/github.js +48 -0
- package/dist/core/auth/oauth/providers/google.d.ts +2 -0
- package/dist/core/auth/oauth/providers/google.js +30 -0
- package/dist/core/auth/oauth/state.d.ts +23 -0
- package/dist/core/auth/oauth/state.js +55 -0
- package/dist/core/auth/oauth/types.d.ts +51 -0
- package/dist/core/auth/oauth/types.js +13 -0
- package/dist/core/auth/routes.d.ts +50 -0
- package/dist/core/auth/routes.js +129 -0
- package/dist/core/auth/session.d.ts +128 -0
- package/dist/core/auth/session.js +165 -0
- package/dist/core/auth/spaceTokens.d.ts +137 -0
- package/dist/core/auth/spaceTokens.js +212 -0
- package/dist/core/auth/tokens.d.ts +151 -0
- package/dist/core/auth/tokens.js +221 -0
- package/dist/core/createServer.d.ts +29 -0
- package/dist/core/createServer.js +28 -14
- package/dist/core/handlers/authMiddleware.d.ts +27 -0
- package/dist/core/handlers/authMiddleware.js +38 -0
- package/dist/core/handlers/authRouteHandlers.d.ts +46 -0
- package/dist/core/handlers/authRouteHandlers.js +75 -0
- package/dist/core/handlers/types.d.ts +37 -0
- package/dist/{src/core → core}/http/dispatcher.d.ts +2 -2
- package/dist/core/http/dispatcher.js +8 -6
- package/dist/core/http/navigation.d.ts +11 -0
- package/dist/core/http/navigation.js +16 -0
- package/dist/core/http/securityHeaders.js +6 -4
- package/dist/core/http/stages/authApi.d.ts +17 -0
- package/dist/core/http/stages/authApi.js +66 -0
- package/dist/core/http/stages/authRoutes.js +40 -11
- package/dist/core/http/stages/exchangeRoute.d.ts +15 -0
- package/dist/core/http/stages/exchangeRoute.js +67 -0
- package/dist/core/http/stages/health.d.ts +11 -0
- package/dist/core/http/stages/health.js +25 -3
- package/dist/core/http/stages/middlewares.d.ts +2 -0
- package/dist/core/http/stages/static.d.ts +13 -0
- package/dist/core/http/stages/static.js +21 -6
- package/dist/core/http/types.d.ts +35 -0
- package/dist/{modules/mcp/constants.js → core/previewToken.js} +1 -1
- package/dist/core/sdkAssets.d.ts +16 -0
- package/dist/core/sdkAssets.js +46 -0
- package/dist/core/server/baseServer.js +40 -5
- package/dist/core/server/pageServer.d.ts +7 -0
- package/dist/core/server/pageServer.js +13 -17
- package/dist/core/services/action.d.ts +9 -0
- package/dist/core/services/action.js +21 -0
- package/dist/core/services/registry.d.ts +3 -0
- package/dist/core/services/registry.js +9 -19
- package/dist/{src/core → core}/services/resolve.d.ts +1 -0
- package/dist/core/services/resolve.js +6 -4
- package/dist/core/services/rsc.js +3 -2
- package/dist/core/staticFiles.js +1 -1
- package/dist/{src/core → core}/transports.d.ts +3 -0
- package/dist/core/transports.js +7 -6
- package/dist/handlers.d.ts +58 -0
- package/dist/handlers.js +3 -0
- package/dist/{src/helpers → helpers}/buildResponseHelpers.d.ts +2 -1
- package/dist/helpers/buildResponseHelpers.js +13 -4
- package/dist/helpers/buildServerInfo.d.ts +3 -0
- package/dist/helpers/buildServerInfo.js +25 -3
- package/dist/{src/helpers → helpers}/cache/keys.d.ts +5 -1
- package/dist/helpers/cache/keys.js +1 -1
- package/dist/helpers/compress.d.ts +18 -0
- package/dist/helpers/compress.js +47 -11
- package/dist/helpers/offlineDataLoader.d.ts +11 -0
- package/dist/helpers/offlineDataLoader.js +15 -0
- package/dist/helpers/resolveDebugMode.d.ts +10 -0
- package/dist/helpers/resolveDebugMode.js +13 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +9 -20
- package/dist/kernel.d.ts +41 -0
- package/dist/kernel.js +22 -0
- package/dist/middlewares/spaceDeployment.d.ts +2 -0
- package/dist/middlewares/spaceDeployment.js +2 -1
- package/dist/modules/actions/handler.d.ts +11 -0
- package/dist/modules/actions/handler.js +77 -0
- package/dist/modules/connectors/engine.d.ts +42 -0
- package/dist/modules/connectors/engine.js +221 -0
- package/dist/modules/connectors/getByPath.d.ts +8 -0
- package/dist/modules/connectors/getByPath.js +21 -0
- package/dist/modules/connectors/index.d.ts +7 -0
- package/dist/modules/connectors/projection.d.ts +18 -0
- package/dist/modules/connectors/projection.js +108 -0
- package/dist/modules/connectors/resolver.d.ts +18 -0
- package/dist/modules/connectors/resolver.js +68 -0
- package/dist/modules/connectors/types.d.ts +19 -0
- package/dist/{src/modules → modules}/rsc/handler.d.ts +2 -2
- package/dist/modules/rsc/handler.js +54 -2
- package/dist/modules/rsc/resolveRscData.d.ts +35 -0
- package/dist/modules/rsc/resolveRscData.js +74 -0
- package/dist/{src/modules → modules}/ssr/Component.d.ts +4 -1
- package/dist/modules/ssr/Component.js +10 -3
- package/dist/modules/ssr/buildBody.d.ts +9 -0
- package/dist/modules/ssr/handler.d.ts +4 -0
- package/dist/modules/ssr/handler.js +18 -1
- package/dist/{src/modules → modules}/ssr/loadPluginComponents.d.ts +5 -2
- package/dist/modules/ssr/loadPluginComponents.js +20 -2
- package/dist/{src/modules → modules}/ssr/prepareRender.d.ts +2 -2
- package/dist/modules/ssr/prepareRender.js +24 -7
- package/dist/modules/ssr/preview.d.ts +10 -0
- package/dist/modules/ssr/preview.js +5 -78
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.d.ts +5 -0
- package/dist/modules/ssr/streamBody.js +1 -1
- package/dist/modules/ssr/template.d.ts +2 -0
- package/dist/modules/ssr/template.js +1 -1
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/manager.js +12 -8
- package/dist/ssr.d.ts +15 -0
- package/dist/ssr.js +4 -0
- package/package.json +29 -25
- package/dist/.gitkeep +0 -0
- package/dist/core/server/mcpServer.js +0 -29
- package/dist/core/services/mcp.js +0 -27
- package/dist/core/services/oauth.js +0 -116
- package/dist/core/services/preview.js +0 -37
- package/dist/core/services/proxy.js +0 -12
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -7
- package/dist/modules/ai/AIEngine.js +0 -120
- package/dist/modules/ai/toolkit.js +0 -59
- package/dist/modules/mcp/apps/example/view/index.tsx +0 -70
- package/dist/modules/mcp/apps/index.js +0 -16
- package/dist/modules/mcp/apps/render/index.js +0 -17
- package/dist/modules/mcp/apps/render/styles.js +0 -54
- package/dist/modules/mcp/apps/render/view/heldBatch.ts +0 -107
- package/dist/modules/mcp/apps/render/view/index.tsx +0 -314
- package/dist/modules/mcp/apps/render/view/streamProgress.ts +0 -137
- package/dist/modules/mcp/apps/shared/assets.js +0 -10
- package/dist/modules/mcp/apps/shared/bundle.js +0 -23
- package/dist/modules/mcp/apps/shared/page.js +0 -34
- package/dist/modules/mcp/apps/shared/registerApp.js +0 -43
- package/dist/modules/mcp/apps/shared/resolve.js +0 -5
- package/dist/modules/mcp/apps/shared/shell.ejs +0 -59
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +0 -23
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -204
- package/dist/modules/mcp/catalogs/builtinComponents.js +0 -170
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
- package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
- package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -98
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -144
- package/dist/modules/mcp/catalogs/observed.js +0 -90
- package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
- package/dist/modules/mcp/catalogs/registry.js +0 -89
- package/dist/modules/mcp/handler.js +0 -83
- package/dist/modules/mcp/helpers/agentPrompt.js +0 -104
- package/dist/modules/mcp/helpers/computeVersion.js +0 -16
- package/dist/modules/mcp/helpers/guide.js +0 -467
- package/dist/modules/mcp/helpers/interactions.js +0 -123
- package/dist/modules/mcp/helpers/log.js +0 -64
- package/dist/modules/mcp/helpers/opResult.js +0 -18
- package/dist/modules/mcp/helpers/space.js +0 -300
- package/dist/modules/mcp/helpers/uris.js +0 -44
- package/dist/modules/mcp/previewClient.js +0 -31
- package/dist/modules/mcp/proxy/config.js +0 -46
- package/dist/modules/mcp/proxy/fetch.js +0 -91
- package/dist/modules/mcp/proxy/grant.js +0 -65
- package/dist/modules/mcp/proxy/guard.js +0 -38
- package/dist/modules/mcp/proxy/handler.js +0 -68
- package/dist/modules/mcp/proxy/rewrite.js +0 -72
- package/dist/modules/mcp/proxy/sign.js +0 -15
- package/dist/modules/mcp/proxy/types.js +0 -9
- package/dist/modules/mcp/resources/canonical.js +0 -30
- package/dist/modules/mcp/resources/core.js +0 -18
- package/dist/modules/mcp/resources/envelope.js +0 -14
- package/dist/modules/mcp/resources/primer.js +0 -31
- package/dist/modules/mcp/resources/register.js +0 -190
- package/dist/modules/mcp/resources/renderGuide.js +0 -451
- package/dist/modules/mcp/resources/router.js +0 -37
- package/dist/modules/mcp/resources/schema.js +0 -43
- package/dist/modules/mcp/resources/style.js +0 -34
- package/dist/modules/mcp/screenshotClient.js +0 -47
- package/dist/modules/mcp/server.js +0 -113
- package/dist/modules/mcp/tools/apply/dispatch.js +0 -105
- package/dist/modules/mcp/tools/apply/index.js +0 -150
- package/dist/modules/mcp/tools/apply/writeResult.js +0 -37
- package/dist/modules/mcp/tools/index.js +0 -24
- package/dist/modules/mcp/tools/operations/index.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +0 -32
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +0 -36
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +0 -29
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +0 -58
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +0 -148
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +0 -65
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +0 -30
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +0 -49
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +0 -52
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +0 -44
- package/dist/modules/mcp/tools/operations/schema/operations.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +0 -25
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +0 -75
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/shared.js +0 -122
- package/dist/modules/mcp/tools/operations/schema/translator.js +0 -215
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +0 -18
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +0 -42
- package/dist/modules/mcp/tools/operations/schema/write.js +0 -109
- package/dist/modules/mcp/tools/operations/schemaIds.js +0 -54
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +0 -21
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +0 -28
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +0 -24
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +0 -40
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/operations.js +0 -29
- package/dist/modules/mcp/tools/operations/style/shared.js +0 -59
- package/dist/modules/mcp/tools/operations/style/translator.js +0 -101
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +0 -22
- package/dist/modules/mcp/tools/operations/style/write.js +0 -108
- package/dist/modules/mcp/tools/preview.js +0 -37
- package/dist/modules/mcp/tools/read.js +0 -51
- package/dist/modules/mcp/tools/render.js +0 -184
- package/dist/modules/mcp/tools/screenshot.js +0 -83
- package/dist/modules/mcp/tools/search.js +0 -115
- package/dist/modules/mcp/tools/shared/expandOperations.js +0 -44
- package/dist/modules/mcp/tools/shared/tool.js +0 -33
- package/dist/modules/mcp/tools/shared/validator/audit.js +0 -124
- package/dist/modules/mcp/tools/shared/validator/batch.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/bindings.js +0 -70
- package/dist/modules/mcp/tools/shared/validator/context.js +0 -35
- package/dist/modules/mcp/tools/shared/validator/css.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/elements.js +0 -68
- package/dist/modules/mcp/tools/shared/validator/index.js +0 -246
- package/dist/modules/mcp/tools/shared/validator/interactions.js +0 -103
- package/dist/modules/mcp/tools/shared/validator/refs.js +0 -28
- package/dist/modules/mcp/tools/validate.js +0 -47
- package/dist/modules/oauth/authorize.js +0 -177
- package/dist/modules/oauth/challenge.js +0 -33
- package/dist/modules/oauth/consentPage.js +0 -118
- package/dist/modules/oauth/metadata.js +0 -69
- package/dist/modules/oauth/params.js +0 -5
- package/dist/modules/oauth/pkce.js +0 -15
- package/dist/modules/oauth/records.js +0 -46
- package/dist/modules/oauth/register.js +0 -55
- package/dist/modules/oauth/respond.js +0 -44
- package/dist/modules/oauth/token.js +0 -100
- package/dist/public/.gitkeep +0 -0
- package/dist/src/adapters/jsonAdapters.d.ts +0 -7
- package/dist/src/core/createServer.d.ts +0 -14
- package/dist/src/core/http/stages/health.d.ts +0 -2
- package/dist/src/core/http/stages/middlewares.d.ts +0 -2
- package/dist/src/core/http/stages/static.d.ts +0 -5
- package/dist/src/core/http/types.d.ts +0 -22
- package/dist/src/core/server/mcpServer.d.ts +0 -2
- package/dist/src/core/server/pageServer.d.ts +0 -10
- package/dist/src/core/services/mcp.d.ts +0 -3
- package/dist/src/core/services/oauth.d.ts +0 -18
- package/dist/src/core/services/preview.d.ts +0 -2
- package/dist/src/core/services/proxy.d.ts +0 -2
- package/dist/src/core/services/registry.d.ts +0 -4
- package/dist/src/helpers/buildServerInfo.d.ts +0 -2
- package/dist/src/helpers/compress.d.ts +0 -3
- package/dist/src/index.d.ts +0 -15
- package/dist/src/mcp.d.ts +0 -14
- package/dist/src/middlewares/spaceDeployment.d.ts +0 -2
- package/dist/src/modules/ai/AIEngine.d.ts +0 -20
- package/dist/src/modules/ai/index.d.ts +0 -4
- package/dist/src/modules/ai/toolkit.d.ts +0 -17
- package/dist/src/modules/mcp/apps/example/index.d.ts +0 -8
- package/dist/src/modules/mcp/apps/index.d.ts +0 -11
- package/dist/src/modules/mcp/apps/render/index.d.ts +0 -4
- package/dist/src/modules/mcp/apps/render/styles.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/assets.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/bundle.d.ts +0 -4
- package/dist/src/modules/mcp/apps/shared/index.d.ts +0 -3
- package/dist/src/modules/mcp/apps/shared/page.d.ts +0 -2
- package/dist/src/modules/mcp/apps/shared/registerApp.d.ts +0 -5
- package/dist/src/modules/mcp/apps/shared/resolve.d.ts +0 -1
- package/dist/src/modules/mcp/apps/shared/zodEnglishOnly.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -23
- package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -20
- package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
- package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +0 -18
- package/dist/src/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
- package/dist/src/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -19
- package/dist/src/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
- package/dist/src/modules/mcp/catalogs/index.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/observed.d.ts +0 -48
- package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +0 -42
- package/dist/src/modules/mcp/catalogs/registry.d.ts +0 -35
- package/dist/src/modules/mcp/e2e/index.d.ts +0 -6
- package/dist/src/modules/mcp/e2e/mcpEndpoint.d.ts +0 -27
- package/dist/src/modules/mcp/e2e/postMessageChannel.d.ts +0 -22
- package/dist/src/modules/mcp/e2e/renderingHost.d.ts +0 -34
- package/dist/src/modules/mcp/handler.d.ts +0 -22
- package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +0 -1
- package/dist/src/modules/mcp/helpers/guide.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/index.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/interactions.d.ts +0 -30
- package/dist/src/modules/mcp/helpers/log.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/opResult.d.ts +0 -13
- package/dist/src/modules/mcp/helpers/space.d.ts +0 -115
- package/dist/src/modules/mcp/helpers/uris.d.ts +0 -28
- package/dist/src/modules/mcp/index.d.ts +0 -13
- package/dist/src/modules/mcp/previewClient.d.ts +0 -13
- package/dist/src/modules/mcp/proxy/config.d.ts +0 -17
- package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/grant.d.ts +0 -23
- package/dist/src/modules/mcp/proxy/guard.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/handler.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/index.d.ts +0 -7
- package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -13
- package/dist/src/modules/mcp/proxy/sign.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/types.d.ts +0 -45
- package/dist/src/modules/mcp/resources/canonical.d.ts +0 -6
- package/dist/src/modules/mcp/resources/core.d.ts +0 -5
- package/dist/src/modules/mcp/resources/envelope.d.ts +0 -10
- package/dist/src/modules/mcp/resources/index.d.ts +0 -8
- package/dist/src/modules/mcp/resources/primer.d.ts +0 -7
- package/dist/src/modules/mcp/resources/register.d.ts +0 -10
- package/dist/src/modules/mcp/resources/renderGuide.d.ts +0 -10
- package/dist/src/modules/mcp/resources/router.d.ts +0 -10
- package/dist/src/modules/mcp/resources/schema.d.ts +0 -5
- package/dist/src/modules/mcp/resources/style.d.ts +0 -5
- package/dist/src/modules/mcp/screenshotClient.d.ts +0 -13
- package/dist/src/modules/mcp/server.d.ts +0 -31
- package/dist/src/modules/mcp/tests/helpers.d.ts +0 -13
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +0 -6
- package/dist/src/modules/mcp/tools/apply/index.d.ts +0 -470
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +0 -8
- package/dist/src/modules/mcp/tools/index.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/index.d.ts +0 -928
- package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +0 -17
- package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +0 -25
- package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +0 -10
- package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +0 -22
- package/dist/src/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +0 -55
- package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +0 -21
- package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +0 -229
- package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +0 -14
- package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +0 -34
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +0 -92
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +0 -42
- package/dist/src/modules/mcp/tools/operations/schemaIds.d.ts +0 -6
- package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +0 -41
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +0 -264
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +0 -116
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +0 -20
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +0 -12
- package/dist/src/modules/mcp/tools/preview.d.ts +0 -465
- package/dist/src/modules/mcp/tools/read.d.ts +0 -9
- package/dist/src/modules/mcp/tools/render.d.ts +0 -499
- package/dist/src/modules/mcp/tools/render.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/screenshot.d.ts +0 -470
- package/dist/src/modules/mcp/tools/search.d.ts +0 -15
- package/dist/src/modules/mcp/tools/shared/expandOperations.d.ts +0 -13
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +0 -72
- package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +0 -5
- package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +0 -6
- package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +0 -38
- package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +0 -7
- package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +0 -3
- package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +0 -4
- package/dist/src/modules/mcp/tools/validate.d.ts +0 -467
- package/dist/src/modules/mcp/types/aiSchema.d.ts +0 -218
- package/dist/src/modules/mcp/types/appTypes.d.ts +0 -26
- package/dist/src/modules/mcp/types/index.d.ts +0 -5
- package/dist/src/modules/mcp/types/previewTypes.d.ts +0 -25
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +0 -29
- package/dist/src/modules/mcp/types/toolTypes.d.ts +0 -138
- package/dist/src/modules/oauth/authorize.d.ts +0 -7
- package/dist/src/modules/oauth/challenge.d.ts +0 -11
- package/dist/src/modules/oauth/consentPage.d.ts +0 -7
- package/dist/src/modules/oauth/metadata.d.ts +0 -40
- package/dist/src/modules/oauth/params.d.ts +0 -5
- package/dist/src/modules/oauth/pkce.d.ts +0 -6
- package/dist/src/modules/oauth/records.d.ts +0 -71
- package/dist/src/modules/oauth/register.d.ts +0 -5
- package/dist/src/modules/oauth/respond.d.ts +0 -13
- package/dist/src/modules/oauth/token.d.ts +0 -5
- package/dist/src/modules/ssr/buildBody.d.ts +0 -9
- package/dist/src/modules/ssr/handler.d.ts +0 -4
- package/dist/src/modules/ssr/preview.d.ts +0 -16
- package/dist/src/modules/ssr/streamBody.d.ts +0 -5
- package/dist/src/modules/ssr/template.d.ts +0 -6
- package/dist/src/standalone/alias-loader.d.mts +0 -2
- package/dist/src/standalone/plugins/ClientInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/ServerInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/SharedInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/styles.d.ts +0 -5
- package/dist/src/standalone/register-alias.d.mts +0 -1
- package/dist/src/standalone/server.d.ts +0 -1
- package/dist/src/standalone/stubs/react-syntax-highlighter.d.mts +0 -31
- package/skills/plitzi-render/SKILL.md +0 -174
- /package/dist/{src/core/http/dispatcher.test.d.ts → core/auth/api.test.d.ts} +0 -0
- /package/dist/{src/core/server/mcpServer.test.d.ts → core/auth/authorize.test.d.ts} +0 -0
- /package/dist/{src/modules/ai/toolkit.test.d.ts → core/auth/createAuth.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/apps.test.d.ts → core/auth/domains.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/render/styles.test.d.ts → core/auth/identity.test.d.ts} +0 -0
- /package/dist/{src/modules → core/auth}/oauth/oauth.test.d.ts +0 -0
- /package/dist/{src/modules/mcp/catalogs/builtinTransformers.test.d.ts → core/auth/routes.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts → core/auth/session.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/connector.test.d.ts → core/auth/spaceTokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/host.test.d.ts → core/auth/tokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/oauthConnector.test.d.ts → core/createServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/helpers/log.test.d.ts → core/handlers/handlers.test.d.ts} +0 -0
- /package/dist/{src/core → core}/health.d.ts +0 -0
- /package/dist/{src/modules/mcp/mcp.bench.d.ts → core/http/dispatcher.test.d.ts} +0 -0
- /package/dist/{src/core → core}/http/securityHeaders.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/authRoutes.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/pluginAssets.d.ts +0 -0
- /package/dist/{src/core → core}/mimeTypes.d.ts +0 -0
- /package/dist/{src/modules/mcp/constants.d.ts → core/previewToken.d.ts} +0 -0
- /package/dist/{src/core → core}/requestParser.d.ts +0 -0
- /package/dist/{src/core → core}/server/baseServer.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/endpoint.test.d.ts → core/server/baseServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/proxy/proxy.test.d.ts → core/services/resolve.test.d.ts} +0 -0
- /package/dist/{src/core → core}/services/rsc.d.ts +0 -0
- /package/dist/{src/core → core}/services/ssr.d.ts +0 -0
- /package/dist/{src/core → core}/staticFiles.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/wiring.test.d.ts → helpers/buildResponseHelpers.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/TtlCache.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/cacheManager.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/defaults.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/index.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/apply.test.d.ts → helpers/cache/keys.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/serverCaches.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/bindings.test.d.ts → helpers/compress.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/escapeJson.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/metrics.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/normalizePlugins.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/css.test.d.ts → helpers/offlineDataLoader.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/readCookie.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/interactions.test.d.ts → helpers/resolveDebugMode.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/runMiddlewares.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/serverLog.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/auth.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/basicAuth.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/pages.test.d.ts → middlewares/spaceDeployment.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/reads.test.d.ts → modules/actions/handler.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/schemaIds.test.d.ts → modules/connectors/engine.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/search.test.d.ts → modules/connectors/projection.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/skill.test.d.ts → modules/connectors/resolver.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/styles.test.d.ts → modules/rsc/resolveRscData.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/applySSRResult.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/tools.test.d.ts → modules/ssr/loadPluginComponents.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/validation.test.d.ts → modules/ssr/metering.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/registerExternalPlugins.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/compile.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/copy.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/detect.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/manager.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.test.d.ts +0 -0
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { renderConsentPage } from "./consentPage.js";
|
|
2
|
-
import { AUTHORIZE_PATH } from "./metadata.js";
|
|
3
|
-
import { field, optionalField } from "./params.js";
|
|
4
|
-
import { randomId } from "./pkce.js";
|
|
5
|
-
import { dropPending, getClient, getPending, putCode, putPending } from "./records.js";
|
|
6
|
-
import { redirectWithCode, redirectWithError, sendErrorPage, sendHtml } from "./respond.js";
|
|
7
|
-
//#region src/modules/oauth/authorize.ts
|
|
8
|
-
var DEFAULT_CODE_TTL_SECONDS = 60;
|
|
9
|
-
var DEFAULT_GUEST_LABEL = "Continue without an account";
|
|
10
|
-
var DEFAULT_GUEST_USER = {
|
|
11
|
-
id: "guest",
|
|
12
|
-
label: "Guest"
|
|
13
|
-
};
|
|
14
|
-
var guestView = (guest) => ({
|
|
15
|
-
label: guest.label ?? DEFAULT_GUEST_LABEL,
|
|
16
|
-
description: guest.target.description
|
|
17
|
-
});
|
|
18
|
-
var hiddenFieldsFor = (request, pendingId) => {
|
|
19
|
-
const hidden = {
|
|
20
|
-
client_id: request.clientId,
|
|
21
|
-
redirect_uri: request.redirectUri,
|
|
22
|
-
code_challenge: request.challenge,
|
|
23
|
-
code_challenge_method: "S256"
|
|
24
|
-
};
|
|
25
|
-
if (request.state !== void 0) hidden["state"] = request.state;
|
|
26
|
-
if (request.scope !== void 0) hidden["scope"] = request.scope;
|
|
27
|
-
if (pendingId !== void 0) hidden["pending"] = pendingId;
|
|
28
|
-
return hidden;
|
|
29
|
-
};
|
|
30
|
-
var renderConsent = async (config, res, view) => {
|
|
31
|
-
const html = await (config.renderConsent ?? renderConsentPage)(view);
|
|
32
|
-
sendHtml(res, 200, html);
|
|
33
|
-
};
|
|
34
|
-
/** Validates the parts of an authorization request that decide WHERE a failure may be reported. Until the client
|
|
35
|
-
* and its redirect target check out, nothing may be sent back to the client. */
|
|
36
|
-
var resolveRequest = async (config, res, params) => {
|
|
37
|
-
const clientId = field(params, "client_id");
|
|
38
|
-
const redirectUri = field(params, "redirect_uri");
|
|
39
|
-
const client = clientId ? await getClient(config.adapters.store, clientId) : void 0;
|
|
40
|
-
if (!client) {
|
|
41
|
-
sendErrorPage(res, "Unknown client", "This application is not registered with the server, or its registration expired.");
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!redirectUri || !client.redirectUris.includes(redirectUri)) {
|
|
45
|
-
sendErrorPage(res, "Invalid redirect", "The application asked to be sent back to an address it did not register.");
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const state = optionalField(params, "state");
|
|
49
|
-
const responseType = field(params, "response_type");
|
|
50
|
-
if (responseType && responseType !== "code") {
|
|
51
|
-
redirectWithError(res, redirectUri, "unsupported_response_type", "Only the authorization code flow is supported.", state);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const challenge = field(params, "code_challenge");
|
|
55
|
-
const method = field(params, "code_challenge_method");
|
|
56
|
-
if (!challenge || method !== "S256") {
|
|
57
|
-
redirectWithError(res, redirectUri, "invalid_request", "PKCE with code_challenge_method=S256 is required.", state);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
clientId,
|
|
62
|
-
redirectUri,
|
|
63
|
-
challenge,
|
|
64
|
-
state,
|
|
65
|
-
scope: optionalField(params, "scope")
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
/** Consent granted: mint the bearer now, park it behind a one-shot code and send the browser back. Minting here
|
|
69
|
-
* rather than at redemption keeps a failure the user can act on — no space, revoked access — on this screen. */
|
|
70
|
-
var completeGrant = async (config, res, request, user, target) => {
|
|
71
|
-
const issued = await config.adapters.issueToken(user, target);
|
|
72
|
-
if (!issued) {
|
|
73
|
-
redirectWithError(res, request.redirectUri, "access_denied", "The account may not grant access to this resource.", request.state);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const code = randomId();
|
|
77
|
-
await putCode(config.adapters.store, code, {
|
|
78
|
-
clientId: request.clientId,
|
|
79
|
-
redirectUri: request.redirectUri,
|
|
80
|
-
challenge: request.challenge,
|
|
81
|
-
token: issued.token,
|
|
82
|
-
expiresInSeconds: issued.expiresInSeconds,
|
|
83
|
-
scope: request.scope,
|
|
84
|
-
user,
|
|
85
|
-
target
|
|
86
|
-
}, config.codeTtlSeconds ?? DEFAULT_CODE_TTL_SECONDS);
|
|
87
|
-
redirectWithCode(res, request.redirectUri, code, request.state);
|
|
88
|
-
};
|
|
89
|
-
/** GET /authorize — the entry point a host opens in the user's browser. */
|
|
90
|
-
var handleAuthorizeStart = async (config, res, params) => {
|
|
91
|
-
const request = await resolveRequest(config, res, params);
|
|
92
|
-
if (!request) return;
|
|
93
|
-
await renderConsent(config, res, {
|
|
94
|
-
step: "credentials",
|
|
95
|
-
action: AUTHORIZE_PATH,
|
|
96
|
-
hidden: hiddenFieldsFor(request),
|
|
97
|
-
targets: [],
|
|
98
|
-
guest: config.guest ? guestView(config.guest) : void 0,
|
|
99
|
-
branding: config.branding ?? {}
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
/** POST /authorize — both steps of the form land here: the credentials submit, and the grant submit that carries
|
|
103
|
-
* the `pending` id proving the credentials step already passed. */
|
|
104
|
-
var handleAuthorizeSubmit = async (config, res, params) => {
|
|
105
|
-
const request = await resolveRequest(config, res, params);
|
|
106
|
-
if (!request) return;
|
|
107
|
-
const pendingId = optionalField(params, "pending");
|
|
108
|
-
if (pendingId) {
|
|
109
|
-
const pending = await getPending(config.adapters.store, pendingId);
|
|
110
|
-
if (!pending || pending.clientId !== request.clientId) {
|
|
111
|
-
redirectWithError(res, request.redirectUri, "access_denied", "The sign-in expired. Try connecting again.", request.state);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const targets = await config.adapters.grantTargets(pending.user);
|
|
115
|
-
const chosen = targets.find((target) => target.value === field(params, "target"));
|
|
116
|
-
if (!chosen) {
|
|
117
|
-
await renderConsent(config, res, {
|
|
118
|
-
step: "target",
|
|
119
|
-
action: AUTHORIZE_PATH,
|
|
120
|
-
hidden: hiddenFieldsFor(request, pendingId),
|
|
121
|
-
targets,
|
|
122
|
-
user: pending.user,
|
|
123
|
-
error: "Choose what to grant access to.",
|
|
124
|
-
branding: config.branding ?? {}
|
|
125
|
-
});
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
await dropPending(config.adapters.store, pendingId);
|
|
129
|
-
await completeGrant(config, res, request, pending.user, chosen);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const { guest } = config;
|
|
133
|
-
if (guest && optionalField(params, "guest")) {
|
|
134
|
-
await completeGrant(config, res, request, guest.user ?? DEFAULT_GUEST_USER, guest.target);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const user = await config.adapters.authenticate({
|
|
138
|
-
username: field(params, "username"),
|
|
139
|
-
password: field(params, "password")
|
|
140
|
-
});
|
|
141
|
-
if (!user) {
|
|
142
|
-
await renderConsent(config, res, {
|
|
143
|
-
step: "credentials",
|
|
144
|
-
action: AUTHORIZE_PATH,
|
|
145
|
-
hidden: hiddenFieldsFor(request),
|
|
146
|
-
targets: [],
|
|
147
|
-
guest: guest ? guestView(guest) : void 0,
|
|
148
|
-
error: "Those credentials did not match an account.",
|
|
149
|
-
branding: config.branding ?? {}
|
|
150
|
-
});
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const targets = await config.adapters.grantTargets(user);
|
|
154
|
-
if (targets.length === 0) {
|
|
155
|
-
redirectWithError(res, request.redirectUri, "access_denied", "This account has nothing to grant access to.", request.state);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const nextPendingId = randomId();
|
|
159
|
-
await putPending(config.adapters.store, nextPendingId, {
|
|
160
|
-
clientId: request.clientId,
|
|
161
|
-
redirectUri: request.redirectUri,
|
|
162
|
-
challenge: request.challenge,
|
|
163
|
-
state: request.state,
|
|
164
|
-
scope: request.scope,
|
|
165
|
-
user
|
|
166
|
-
});
|
|
167
|
-
await renderConsent(config, res, {
|
|
168
|
-
step: "target",
|
|
169
|
-
action: AUTHORIZE_PATH,
|
|
170
|
-
hidden: hiddenFieldsFor(request, nextPendingId),
|
|
171
|
-
targets,
|
|
172
|
-
user,
|
|
173
|
-
branding: config.branding ?? {}
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
//#endregion
|
|
177
|
-
export { handleAuthorizeStart, handleAuthorizeSubmit };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { resourceMetadataUrl, scopesOf } from "./metadata.js";
|
|
2
|
-
import { sendJson } from "./respond.js";
|
|
3
|
-
//#region src/modules/oauth/challenge.ts
|
|
4
|
-
/** The credential on an MCP request. `Authorization: Bearer` is what RFC 6750 defines and what a remote host
|
|
5
|
-
* sends; `x-access-token` is the platform's own header, which the builder and the CLI already use — a request
|
|
6
|
-
* carrying either presents a credential, and the same verification decides whether it is a good one. */
|
|
7
|
-
var bearerOf = (req) => {
|
|
8
|
-
const header = req.headers["x-access-token"] ?? req.headers.authorization ?? "";
|
|
9
|
-
return (Array.isArray(header) ? header[0] ?? "" : header).replace(/^Bearer\s+/i, "").trim();
|
|
10
|
-
};
|
|
11
|
-
var parameter = (name, value) => `${name}="${value.replace(/"/gu, "")}"`;
|
|
12
|
-
/** RFC 6750 §3 — the answer to an MCP request that presents no usable credential, and the only thing that starts
|
|
13
|
-
* an authorization flow: a host runs OAuth off a 401 whose `WWW-Authenticate` names the resource metadata, and
|
|
14
|
-
* IGNORES the header on a 200. Answering such a request with the anonymous surface instead is what leaves a
|
|
15
|
-
* connector unable to attach the grant it just completed — the flow succeeds and the host still reports that
|
|
16
|
-
* authorization failed. `scope` states what to ask for, so consent is not widened to everything advertised. */
|
|
17
|
-
var sendChallenge = (config, req, res, description) => {
|
|
18
|
-
const params = [
|
|
19
|
-
parameter("error", "invalid_token"),
|
|
20
|
-
parameter("error_description", description),
|
|
21
|
-
parameter("resource_metadata", resourceMetadataUrl(config, req)),
|
|
22
|
-
parameter("scope", scopesOf(config).join(" "))
|
|
23
|
-
];
|
|
24
|
-
res.setHeader("WWW-Authenticate", `Bearer ${params.join(", ")}`);
|
|
25
|
-
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
26
|
-
res.setHeader("Access-Control-Expose-Headers", "WWW-Authenticate");
|
|
27
|
-
sendJson(res, 401, {
|
|
28
|
-
error: "invalid_token",
|
|
29
|
-
error_description: description
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
export { bearerOf, sendChallenge };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
//#region src/modules/oauth/consentPage.ts
|
|
2
|
-
var escapeHtml = (value) => value.replace(/[&<>"']/gu, (character) => {
|
|
3
|
-
switch (character) {
|
|
4
|
-
case "&": return "&";
|
|
5
|
-
case "<": return "<";
|
|
6
|
-
case ">": return ">";
|
|
7
|
-
case "\"": return """;
|
|
8
|
-
default: return "'";
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var STYLES = `
|
|
12
|
-
:root { color-scheme: light dark; --bg: #f6f7f9; --panel: #ffffff; --ink: #16181d; --muted: #6b7280;
|
|
13
|
-
--line: #e2e5ea; --accent: #2563eb; --danger: #b91c1c; }
|
|
14
|
-
@media (prefers-color-scheme: dark) {
|
|
15
|
-
:root { --bg: #0f1115; --panel: #171a21; --ink: #e8eaee; --muted: #9aa1ad; --line: #262b35;
|
|
16
|
-
--accent: #60a5fa; --danger: #f87171; }
|
|
17
|
-
}
|
|
18
|
-
* { box-sizing: border-box; }
|
|
19
|
-
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
|
|
20
|
-
background: var(--bg); color: var(--ink);
|
|
21
|
-
font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
|
|
22
|
-
main { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
|
|
23
|
-
border-radius: 14px; padding: 32px; }
|
|
24
|
-
img.logo { display: block; height: 32px; margin-bottom: 20px; }
|
|
25
|
-
h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
|
|
26
|
-
p.lede { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
|
|
27
|
-
label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
|
|
28
|
-
input[type="text"], input[type="password"] { width: 100%; margin-bottom: 16px; padding: 10px 12px;
|
|
29
|
-
border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
|
|
30
|
-
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
31
|
-
ul.targets { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
|
|
32
|
-
ul.targets label { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px;
|
|
33
|
-
border: 1px solid var(--line); border-radius: 8px; font-weight: 400; cursor: pointer; }
|
|
34
|
-
ul.targets strong { display: block; font-weight: 500; }
|
|
35
|
-
ul.targets span { color: var(--muted); font-size: 13px; }
|
|
36
|
-
button { width: 100%; padding: 11px 16px; border: 0; border-radius: 8px; background: var(--accent);
|
|
37
|
-
color: #fff; font: inherit; font-weight: 500; cursor: pointer; }
|
|
38
|
-
button.guest { margin-top: 10px; background: transparent; color: var(--accent);
|
|
39
|
-
border: 1px solid var(--line); }
|
|
40
|
-
p.error { margin: 0 0 16px; padding: 10px 12px; border-radius: 8px; color: var(--danger);
|
|
41
|
-
border: 1px solid currentColor; font-size: 14px; }
|
|
42
|
-
p.note { margin: 10px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
|
|
43
|
-
`;
|
|
44
|
-
var hiddenFields = (hidden) => Object.entries(hidden).map(([name, value]) => `<input type="hidden" name="${escapeHtml(name)}" value="${escapeHtml(value)}">`).join("\n ");
|
|
45
|
-
var guestButton = (guest) => {
|
|
46
|
-
const note = guest.description ? `\n <p class="note">${escapeHtml(guest.description)}</p>` : "";
|
|
47
|
-
return `\n <button class="guest" type="submit" name="guest" value="1" formnovalidate>${escapeHtml(guest.label)}</button>${note}`;
|
|
48
|
-
};
|
|
49
|
-
var credentialsFields = (view) => `<label for="username">Email or username</label>
|
|
50
|
-
<input id="username" name="username" type="text" autocomplete="username" autocapitalize="none"
|
|
51
|
-
spellcheck="false" required autofocus>
|
|
52
|
-
<label for="password">Password</label>
|
|
53
|
-
<input id="password" name="password" type="password" autocomplete="current-password" required>
|
|
54
|
-
<button type="submit">Sign in</button>${view.guest ? guestButton(view.guest) : ""}`;
|
|
55
|
-
var targetFields = (view) => {
|
|
56
|
-
return `<ul class="targets">
|
|
57
|
-
${view.targets.map((target, index) => {
|
|
58
|
-
const description = target.description ? `<span>${escapeHtml(target.description)}</span>` : "";
|
|
59
|
-
return `<li><label>
|
|
60
|
-
<input type="radio" name="target" value="${escapeHtml(target.value)}"${index === 0 ? " checked" : ""}>
|
|
61
|
-
<span><strong>${escapeHtml(target.label)}</strong>${description}</span>
|
|
62
|
-
</label></li>`;
|
|
63
|
-
}).join("\n ")}
|
|
64
|
-
</ul>
|
|
65
|
-
<button type="submit">Allow access</button>`;
|
|
66
|
-
};
|
|
67
|
-
/** The built-in consent screen: a credentials step, then a step to pick what the client gets access to. Replace it
|
|
68
|
-
* wholesale via `oauth.renderConsent` — the field names read back here are the contract, not the markup. */
|
|
69
|
-
var renderConsentPage = (view) => {
|
|
70
|
-
const productName = view.branding.productName ?? "Plitzi";
|
|
71
|
-
const logo = view.branding.logoUrl ? `<img class="logo" src="${escapeHtml(view.branding.logoUrl)}" alt="${escapeHtml(productName)}">` : "";
|
|
72
|
-
const error = view.error ? `<p class="error">${escapeHtml(view.error)}</p>` : "";
|
|
73
|
-
const lede = view.step === "credentials" ? `Sign in to connect ${escapeHtml(productName)}.` : `Signed in as ${escapeHtml(view.user?.label ?? "")}. Choose what to grant access to.`;
|
|
74
|
-
return `<!doctype html>
|
|
75
|
-
<html lang="en">
|
|
76
|
-
<head>
|
|
77
|
-
<meta charset="utf-8">
|
|
78
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
79
|
-
<meta name="robots" content="noindex">
|
|
80
|
-
<link rel="icon" href="data:,">
|
|
81
|
-
<title>${escapeHtml(productName)}</title>
|
|
82
|
-
<style>${STYLES}${view.branding.css ?? ""}</style>
|
|
83
|
-
</head>
|
|
84
|
-
<body>
|
|
85
|
-
<main>
|
|
86
|
-
${logo}
|
|
87
|
-
<h1>${escapeHtml(productName)}</h1>
|
|
88
|
-
<p class="lede">${lede}</p>
|
|
89
|
-
${error}
|
|
90
|
-
<form method="post" action="${escapeHtml(view.action)}">
|
|
91
|
-
${hiddenFields(view.hidden)}
|
|
92
|
-
${view.step === "credentials" ? credentialsFields(view) : targetFields(view)}
|
|
93
|
-
</form>
|
|
94
|
-
</main>
|
|
95
|
-
</body>
|
|
96
|
-
</html>`;
|
|
97
|
-
};
|
|
98
|
-
/** The dead end for a request that cannot be redirected back — a bad `redirect_uri` or an unknown client. Bouncing
|
|
99
|
-
* those to the client would make this server an open redirector, so the user is told here instead. */
|
|
100
|
-
var renderErrorPage = (title, detail) => `<!doctype html>
|
|
101
|
-
<html lang="en">
|
|
102
|
-
<head>
|
|
103
|
-
<meta charset="utf-8">
|
|
104
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
105
|
-
<meta name="robots" content="noindex">
|
|
106
|
-
<link rel="icon" href="data:,">
|
|
107
|
-
<title>${escapeHtml(title)}</title>
|
|
108
|
-
<style>${STYLES}</style>
|
|
109
|
-
</head>
|
|
110
|
-
<body>
|
|
111
|
-
<main>
|
|
112
|
-
<h1>${escapeHtml(title)}</h1>
|
|
113
|
-
<p class="lede">${escapeHtml(detail)}</p>
|
|
114
|
-
</main>
|
|
115
|
-
</body>
|
|
116
|
-
</html>`;
|
|
117
|
-
//#endregion
|
|
118
|
-
export { renderConsentPage, renderErrorPage };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { requestOrigin } from "../../core/requestParser.js";
|
|
2
|
-
//#region src/modules/oauth/metadata.ts
|
|
3
|
-
var AUTHORIZE_PATH = "/authorize";
|
|
4
|
-
var TOKEN_PATH = "/token";
|
|
5
|
-
var REGISTER_PATH = "/register";
|
|
6
|
-
var PROTECTED_RESOURCE_PATH = "/.well-known/oauth-protected-resource";
|
|
7
|
-
var AUTHORIZATION_SERVER_PATH = "/.well-known/oauth-authorization-server";
|
|
8
|
-
var DEFAULT_SCOPES = ["plitzi"];
|
|
9
|
-
/** The identifier the two documents agree on. This server is both the protected resource and its own
|
|
10
|
-
* authorization server, so one origin names both. Derived from the request unless pinned, which keeps a
|
|
11
|
-
* deployment correct across its dev, staging and production hosts without per-environment config. */
|
|
12
|
-
var issuerOf = (config, req) => config.issuer ?? requestOrigin(req);
|
|
13
|
-
var scopesOf = (config) => config.scopes ?? DEFAULT_SCOPES;
|
|
14
|
-
var canonicalPath = (path) => path.replace(/\/+$/, "");
|
|
15
|
-
/** Where the challenge points a host, for an MCP endpoint served at `req.path`. RFC 9728 §3.1 appends the
|
|
16
|
-
* resource's own path to the well-known path, and a host that reads the document back expects its `resource` to
|
|
17
|
-
* name the URL it was configured with — so a server mounted at /mcp must be pointed at the suffixed document,
|
|
18
|
-
* not the bare one. */
|
|
19
|
-
var resourceMetadataUrl = (config, req) => `${issuerOf(config, req)}${PROTECTED_RESOURCE_PATH}${canonicalPath(req.path)}`;
|
|
20
|
-
/** RFC 9728. The document Claude Desktop asks for FIRST, and the one whose absence ends the flow before anything
|
|
21
|
-
* else is tried — a 404 here is what a host reports as `mcp_auth_start_failed`.
|
|
22
|
-
*
|
|
23
|
-
* `resource` echoes the path the document was asked for: Claude requires it to match the server URL the user
|
|
24
|
-
* typed, path included, and a dedicated MCP server answers JSON-RPC on every path — so `/.well-known/…/mcp`
|
|
25
|
-
* describes `https://host/mcp` while the bare path describes the origin.
|
|
26
|
-
*
|
|
27
|
-
* A server mounted at the ORIGIN is `https://host/`, WITH the trailing slash: a host parses the URL the user
|
|
28
|
-
* typed before it does anything with it, and an empty path renders as `/` — Claude's connector was observed
|
|
29
|
-
* asking for exactly `resource=https%3A%2F%2Fhost%2F`, so that is the form the document must claim.
|
|
30
|
-
*
|
|
31
|
-
* It does NOT make a bare-origin connector work, and nothing here can. Claude's remote-connector service will
|
|
32
|
-
* not open a session against an MCP endpoint whose URL has no path: the whole grant succeeds — discovery,
|
|
33
|
-
* registration, consent, a 200 from /token with the scope it asked for — and then it reports
|
|
34
|
-
* `McpAuthorizationError` ("the integration rejected the credentials it just issued") without ever presenting
|
|
35
|
-
* the bearer. Verified against the same deployment, minutes apart: at /mcp the token is followed by
|
|
36
|
-
* `initialize`, at / nothing follows it, in the ingress log as well as this server's. Claiming `https://host/mcp`
|
|
37
|
-
* from the bare document would only fail sooner — a client checks that the resource it is handed is no MORE
|
|
38
|
-
* specific than the URL it holds. Publish the connector URL WITH its path. */
|
|
39
|
-
var protectedResourceMetadata = (config, req) => {
|
|
40
|
-
const issuer = issuerOf(config, req);
|
|
41
|
-
return {
|
|
42
|
-
resource: `${issuer}${canonicalPath(req.path.slice(37)) || "/"}`,
|
|
43
|
-
authorization_servers: [issuer],
|
|
44
|
-
scopes_supported: scopesOf(config),
|
|
45
|
-
bearer_methods_supported: ["header"]
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
/** RFC 8414. Public clients with PKCE only: a desktop host stores no secret, so `none` is the sole endpoint auth
|
|
49
|
-
* method and S256 the sole challenge method. `offline_access` is advertised whenever refresh grants are issued,
|
|
50
|
-
* which is the signal a host looks for before asking for one. */
|
|
51
|
-
var authorizationServerMetadata = (config, req) => {
|
|
52
|
-
const issuer = issuerOf(config, req);
|
|
53
|
-
const refreshes = config.refreshTtlSeconds !== 0;
|
|
54
|
-
const grantTypes = refreshes ? ["authorization_code", "refresh_token"] : ["authorization_code"];
|
|
55
|
-
const scopes = refreshes ? [...scopesOf(config), "offline_access"] : scopesOf(config);
|
|
56
|
-
return {
|
|
57
|
-
issuer,
|
|
58
|
-
authorization_endpoint: `${issuer}${AUTHORIZE_PATH}`,
|
|
59
|
-
token_endpoint: `${issuer}${TOKEN_PATH}`,
|
|
60
|
-
registration_endpoint: `${issuer}${REGISTER_PATH}`,
|
|
61
|
-
response_types_supported: ["code"],
|
|
62
|
-
grant_types_supported: grantTypes,
|
|
63
|
-
code_challenge_methods_supported: ["S256"],
|
|
64
|
-
token_endpoint_auth_methods_supported: ["none"],
|
|
65
|
-
scopes_supported: scopes
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
//#endregion
|
|
69
|
-
export { AUTHORIZATION_SERVER_PATH, AUTHORIZE_PATH, PROTECTED_RESOURCE_PATH, REGISTER_PATH, TOKEN_PATH, authorizationServerMetadata, issuerOf, protectedResourceMetadata, resourceMetadataUrl, scopesOf };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
-
//#region src/modules/oauth/pkce.ts
|
|
3
|
-
/** An unguessable, URL-safe identifier for the values this layer hands out (codes, refresh tokens, client ids).
|
|
4
|
-
* 256 bits from the CSPRNG, so they are also unguessable by anyone who collects a few of them. */
|
|
5
|
-
var randomId = () => randomBytes(32).toString("base64url");
|
|
6
|
-
/** RFC 7636 S256, the only method this server accepts — `plain` puts the verifier on the wire, and a public
|
|
7
|
-
* client on a desktop host has no other proof it is the one that started the flow. */
|
|
8
|
-
var verifyChallenge = (verifier, challenge) => {
|
|
9
|
-
if (!verifier || !challenge) return false;
|
|
10
|
-
const computed = Buffer.from(createHash("sha256").update(verifier).digest("base64url"));
|
|
11
|
-
const expected = Buffer.from(challenge);
|
|
12
|
-
return computed.length === expected.length && timingSafeEqual(computed, expected);
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { randomId, verifyChallenge };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
//#region src/modules/oauth/records.ts
|
|
2
|
-
var CLIENT_TTL_SECONDS = 7776e3;
|
|
3
|
-
var PENDING_TTL_SECONDS = 600;
|
|
4
|
-
var keyOf = (kind, id) => `oauth:${kind}:${id}`;
|
|
5
|
-
var readJson = async (store, kind, id) => {
|
|
6
|
-
const raw = await store.get(keyOf(kind, id));
|
|
7
|
-
if (!raw) return;
|
|
8
|
-
try {
|
|
9
|
-
return JSON.parse(raw);
|
|
10
|
-
} catch {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var writeJson = async (store, kind, id, value, ttlSeconds) => {
|
|
15
|
-
await store.put(keyOf(kind, id), JSON.stringify(value), ttlSeconds);
|
|
16
|
-
};
|
|
17
|
-
var putClient = (store, client) => writeJson(store, "client", client.clientId, client, CLIENT_TTL_SECONDS);
|
|
18
|
-
var getClient = (store, clientId) => readJson(store, "client", clientId);
|
|
19
|
-
/** The id already handed out for an identical registration. Keyed by what the client asked to be registered AS,
|
|
20
|
-
* so the same request always resolves to the same client — see handleRegister for why that matters. */
|
|
21
|
-
var getClientByFingerprint = async (store, fingerprint) => {
|
|
22
|
-
const clientId = await store.get(keyOf("clientfp", fingerprint));
|
|
23
|
-
return clientId ? getClient(store, clientId) : void 0;
|
|
24
|
-
};
|
|
25
|
-
var putClientFingerprint = async (store, fingerprint, clientId) => {
|
|
26
|
-
await store.put(keyOf("clientfp", fingerprint), clientId, CLIENT_TTL_SECONDS);
|
|
27
|
-
};
|
|
28
|
-
var putPending = (store, id, pending) => writeJson(store, "pending", id, pending, PENDING_TTL_SECONDS);
|
|
29
|
-
var getPending = (store, id) => readJson(store, "pending", id);
|
|
30
|
-
var dropPending = async (store, id) => {
|
|
31
|
-
await store.drop(keyOf("pending", id));
|
|
32
|
-
};
|
|
33
|
-
var putCode = (store, code, record, ttlSeconds) => writeJson(store, "code", code, record, ttlSeconds);
|
|
34
|
-
var getCode = (store, code) => readJson(store, "code", code);
|
|
35
|
-
var dropCode = async (store, code) => {
|
|
36
|
-
await store.drop(keyOf("code", code));
|
|
37
|
-
};
|
|
38
|
-
var putRefresh = (store, token, record, ttlSeconds) => writeJson(store, "refresh", token, record, ttlSeconds);
|
|
39
|
-
var getRefresh = (store, token) => readJson(store, "refresh", token);
|
|
40
|
-
var dropRefresh = async (store, token) => {
|
|
41
|
-
await store.drop(keyOf("refresh", token));
|
|
42
|
-
};
|
|
43
|
-
var putAccess = (store, token, record, ttlSeconds) => writeJson(store, "access", token, record, ttlSeconds);
|
|
44
|
-
var getAccess = (store, token) => readJson(store, "access", token);
|
|
45
|
-
//#endregion
|
|
46
|
-
export { dropCode, dropPending, dropRefresh, getAccess, getClient, getClientByFingerprint, getCode, getPending, getRefresh, putAccess, putClient, putClientFingerprint, putCode, putPending, putRefresh };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { randomId } from "./pkce.js";
|
|
2
|
-
import { getClientByFingerprint, putClient, putClientFingerprint } from "./records.js";
|
|
3
|
-
import { sendErrorJson, sendJson } from "./respond.js";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
|
-
//#region src/modules/oauth/register.ts
|
|
6
|
-
var isUsableRedirectUri = (value) => {
|
|
7
|
-
let url;
|
|
8
|
-
try {
|
|
9
|
-
url = new URL(value);
|
|
10
|
-
} catch {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
if (url.protocol === "https:") return true;
|
|
14
|
-
return url.protocol === "http:" && (url.hostname === "localhost" || url.hostname === "127.0.0.1");
|
|
15
|
-
};
|
|
16
|
-
var stringList = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
17
|
-
var nowSeconds = () => Math.floor(Date.now() / 1e3);
|
|
18
|
-
var fingerprintOf = (clientName, redirectUris) => createHash("sha256").update(JSON.stringify([clientName, [...redirectUris].sort()])).digest("base64url");
|
|
19
|
-
/** RFC 7591 dynamic client registration. A remote host has no way to be configured into this server ahead of
|
|
20
|
-
* time, so it registers itself on first connect; the record it gets back is only ever used to pin the redirect
|
|
21
|
-
* target, since a public client authenticates with PKCE rather than with credentials. */
|
|
22
|
-
var handleRegister = async (config, res, body) => {
|
|
23
|
-
if (typeof body !== "object" || body === null) {
|
|
24
|
-
sendErrorJson(res, 400, "invalid_request", "Expected a JSON client metadata object.");
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const metadata = body;
|
|
28
|
-
const redirectUris = stringList(metadata["redirect_uris"]).filter(isUsableRedirectUri);
|
|
29
|
-
if (redirectUris.length === 0) {
|
|
30
|
-
sendErrorJson(res, 400, "invalid_request", "redirect_uris must list at least one https (or loopback) URI.");
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const clientName = typeof metadata["client_name"] === "string" ? metadata["client_name"] : "MCP client";
|
|
34
|
-
const { store } = config.adapters;
|
|
35
|
-
const fingerprint = fingerprintOf(clientName, redirectUris);
|
|
36
|
-
const client = await getClientByFingerprint(store, fingerprint) ?? {
|
|
37
|
-
clientId: randomId(),
|
|
38
|
-
clientName,
|
|
39
|
-
redirectUris,
|
|
40
|
-
issuedAt: nowSeconds()
|
|
41
|
-
};
|
|
42
|
-
await putClient(store, client);
|
|
43
|
-
await putClientFingerprint(store, fingerprint, client.clientId);
|
|
44
|
-
sendJson(res, 201, {
|
|
45
|
-
client_id: client.clientId,
|
|
46
|
-
client_id_issued_at: client.issuedAt,
|
|
47
|
-
client_name: clientName,
|
|
48
|
-
redirect_uris: redirectUris,
|
|
49
|
-
grant_types: config.refreshTtlSeconds === 0 ? ["authorization_code"] : ["authorization_code", "refresh_token"],
|
|
50
|
-
response_types: ["code"],
|
|
51
|
-
token_endpoint_auth_method: "none"
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
//#endregion
|
|
55
|
-
export { handleRegister };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { renderErrorPage } from "./consentPage.js";
|
|
2
|
-
//#region src/modules/oauth/respond.ts
|
|
3
|
-
var sendJson = (res, status, body) => {
|
|
4
|
-
res.setStatus(status);
|
|
5
|
-
res.setHeader("Content-Type", "application/json");
|
|
6
|
-
res.setHeader("Cache-Control", "no-store, no-transform");
|
|
7
|
-
res.send(JSON.stringify(body));
|
|
8
|
-
};
|
|
9
|
-
var sendHtml = (res, status, html) => {
|
|
10
|
-
res.setStatus(status);
|
|
11
|
-
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
12
|
-
res.setHeader("Cache-Control", "no-store, no-transform");
|
|
13
|
-
res.send(html);
|
|
14
|
-
};
|
|
15
|
-
var sendErrorJson = (res, status, error, description) => sendJson(res, status, {
|
|
16
|
-
error,
|
|
17
|
-
error_description: description
|
|
18
|
-
});
|
|
19
|
-
/** Shown when the authorization request itself is unusable — an unknown client, a `redirect_uri` that is not
|
|
20
|
-
* registered. Redirecting those back would turn the endpoint into an open redirector. */
|
|
21
|
-
var sendErrorPage = (res, title, detail) => sendHtml(res, 400, renderErrorPage(title, detail));
|
|
22
|
-
/** The other half of RFC 6749 error handling: once the redirect target is known to be legitimate, failures go
|
|
23
|
-
* back to the client so the host can report them, carrying `state` so it can match the response to its request. */
|
|
24
|
-
var redirectWithError = (res, redirectUri, error, description, state) => {
|
|
25
|
-
const url = new URL(redirectUri);
|
|
26
|
-
url.searchParams.set("error", error);
|
|
27
|
-
url.searchParams.set("error_description", description);
|
|
28
|
-
if (state !== void 0) url.searchParams.set("state", state);
|
|
29
|
-
res.setStatus(302);
|
|
30
|
-
res.setHeader("Location", url.toString());
|
|
31
|
-
res.setHeader("Cache-Control", "no-store, no-transform");
|
|
32
|
-
res.end();
|
|
33
|
-
};
|
|
34
|
-
var redirectWithCode = (res, redirectUri, code, state) => {
|
|
35
|
-
const url = new URL(redirectUri);
|
|
36
|
-
url.searchParams.set("code", code);
|
|
37
|
-
if (state !== void 0) url.searchParams.set("state", state);
|
|
38
|
-
res.setStatus(302);
|
|
39
|
-
res.setHeader("Location", url.toString());
|
|
40
|
-
res.setHeader("Cache-Control", "no-store, no-transform");
|
|
41
|
-
res.end();
|
|
42
|
-
};
|
|
43
|
-
//#endregion
|
|
44
|
-
export { redirectWithCode, redirectWithError, sendErrorJson, sendErrorPage, sendHtml, sendJson };
|