@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,10 +1,6 @@
|
|
|
1
|
+
import { resolveSdkAssetsDir } from "../../sdkAssets.js";
|
|
1
2
|
import { serveStatic } from "../../staticFiles.js";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
3
|
//#region src/core/http/stages/static.ts
|
|
5
|
-
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
var BUILTIN_PUBLIC_DIR = path.resolve(__dirname, "../../../public");
|
|
7
|
-
var builtinPublicStage = (ctx) => serveStatic(ctx.req, ctx.res, BUILTIN_PUBLIC_DIR);
|
|
8
4
|
var publicDirStage = (ctx) => ctx.config.publicDir ? serveStatic(ctx.req, ctx.res, ctx.config.publicDir) : false;
|
|
9
5
|
var wellKnownStage = (ctx) => {
|
|
10
6
|
if (!ctx.req.path.startsWith("/.well-known/")) return false;
|
|
@@ -29,5 +25,24 @@ var configStaticStage = (ctx) => {
|
|
|
29
25
|
}
|
|
30
26
|
return false;
|
|
31
27
|
};
|
|
28
|
+
var sdkAssetsDir = resolveSdkAssetsDir();
|
|
29
|
+
/**
|
|
30
|
+
* The SDK bundle, served from this package's own copy.
|
|
31
|
+
*
|
|
32
|
+
* The rendered page is told to fetch `/sdk-assets/plitzi-sdk.js`, and it is this server that puts the URL there — so
|
|
33
|
+
* answering it is this server's job too, not a mount every deployment has to remember to declare. It runs after
|
|
34
|
+
* `configStaticStage`, so a deployment serving its own build (a pinned version, a CDN mirror) still wins by
|
|
35
|
+
* declaring `static: { '/sdk-assets': … }`.
|
|
36
|
+
*/
|
|
37
|
+
var sdkAssetsStage = (ctx) => {
|
|
38
|
+
if (!sdkAssetsDir || !ctx.req.path.startsWith(`/sdk-assets/`)) return false;
|
|
39
|
+
ctx.res.setHeader("Access-Control-Allow-Origin", "*");
|
|
40
|
+
ctx.res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
|
|
41
|
+
const strippedReq = {
|
|
42
|
+
...ctx.req,
|
|
43
|
+
path: ctx.req.path.slice(11) || "/"
|
|
44
|
+
};
|
|
45
|
+
return serveStatic(strippedReq, ctx.res, sdkAssetsDir);
|
|
46
|
+
};
|
|
32
47
|
//#endregion
|
|
33
|
-
export {
|
|
48
|
+
export { configStaticStage, publicDirStage, sdkAssetsStage, wellKnownStage };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RawResponse } from '../../helpers/buildResponseHelpers';
|
|
2
|
+
import { ServerCaches } from '../../helpers/cache';
|
|
3
|
+
import { PluginManager } from '../../plugins/manager';
|
|
4
|
+
import { SSRPageServerConfig, SSRRequest, SSRResponseHelpers, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
5
|
+
import { IncomingMessage } from 'node:http';
|
|
6
|
+
export interface BaseContext {
|
|
7
|
+
raw: IncomingMessage;
|
|
8
|
+
rawRes: RawResponse;
|
|
9
|
+
req: SSRRequest;
|
|
10
|
+
res: SSRResponseHelpers;
|
|
11
|
+
config: SSRServerConfig;
|
|
12
|
+
port: number;
|
|
13
|
+
/** Set by the stage that answers when the path alone does not identify the work (the MCP endpoint serves every
|
|
14
|
+
* JSON-RPC method on the same URL). The dispatcher folds it into the access log. */
|
|
15
|
+
operation?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SSRContext extends BaseContext {
|
|
18
|
+
config: SSRPageServerConfig;
|
|
19
|
+
renderFn: SSRTemplateFn;
|
|
20
|
+
caches: ServerCaches;
|
|
21
|
+
pluginManager: PluginManager;
|
|
22
|
+
}
|
|
23
|
+
export type Stage<C extends BaseContext = BaseContext> = (ctx: C) => boolean | Promise<boolean>;
|
|
24
|
+
/** Where a package built on this one hands its stages to a page server. Slots, not a list, because the ORDER is
|
|
25
|
+
* the pipeline's invariant and cannot be expressed across a package boundary: a stage's slot states what it
|
|
26
|
+
* needs from the pipeline, and the pipeline decides where that lands. `@plitzi/sdk-mcp` is the in-tree
|
|
27
|
+
* consumer. Declared here, with the context types, so the kernel entry can carry it without reaching into the
|
|
28
|
+
* registry — which imports every page stage. */
|
|
29
|
+
export type PipelineExtensions = {
|
|
30
|
+
/** Stages that gate themselves — on a shared secret, a bearer token, or nothing at all — and so must run
|
|
31
|
+
* BEFORE the auth middleware chain. The MCP endpoint, the widget proxy and the draft-preview endpoint. */
|
|
32
|
+
preAuth?: Stage<SSRContext>[];
|
|
33
|
+
/** Stages serving data to an already-identified visitor: after the auth chain, before the page render. */
|
|
34
|
+
data?: Stage<SSRContext>[];
|
|
35
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Where the rendered page is told to fetch the SDK bundle from. Emitted by the render, so it is also served. */
|
|
2
|
+
export declare const SDK_ASSETS_PREFIX = "/sdk-assets";
|
|
3
|
+
/**
|
|
4
|
+
* The SDK's built output, resolved through the module system rather than guessed from `process.cwd()`.
|
|
5
|
+
*
|
|
6
|
+
* The rendered page asks for `/sdk-assets/plitzi-sdk.js` — the server puts that URL there itself — so the server is
|
|
7
|
+
* also what should answer it. It used to be a mount every deployment had to declare, and forgetting it produced no
|
|
8
|
+
* error at all: the asset requests fell through to the page renderer, which answered each one with a 200 and an HTML
|
|
9
|
+
* document. The browser then refused them for their MIME type and the page stayed blank. A missing line of config
|
|
10
|
+
* that looks like a broken SDK is not a choice worth offering.
|
|
11
|
+
*
|
|
12
|
+
* Returns undefined if the SDK is not installed, which is legitimate: a server rendering `ssrOnly` pages, or one
|
|
13
|
+
* whose deployment serves the bundle from a CDN, needs none of this.
|
|
14
|
+
*/
|
|
15
|
+
export declare const resolveSdkAssetsDir: () => string | undefined;
|
|
16
|
+
export declare const sdkAssetVersion: () => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { statSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/core/sdkAssets.ts
|
|
5
|
+
/** Where the rendered page is told to fetch the SDK bundle from. Emitted by the render, so it is also served. */
|
|
6
|
+
var SDK_ASSETS_PREFIX = "/sdk-assets";
|
|
7
|
+
/**
|
|
8
|
+
* The SDK's built output, resolved through the module system rather than guessed from `process.cwd()`.
|
|
9
|
+
*
|
|
10
|
+
* The rendered page asks for `/sdk-assets/plitzi-sdk.js` — the server puts that URL there itself — so the server is
|
|
11
|
+
* also what should answer it. It used to be a mount every deployment had to declare, and forgetting it produced no
|
|
12
|
+
* error at all: the asset requests fell through to the page renderer, which answered each one with a 200 and an HTML
|
|
13
|
+
* document. The browser then refused them for their MIME type and the page stayed blank. A missing line of config
|
|
14
|
+
* that looks like a broken SDK is not a choice worth offering.
|
|
15
|
+
*
|
|
16
|
+
* Returns undefined if the SDK is not installed, which is legitimate: a server rendering `ssrOnly` pages, or one
|
|
17
|
+
* whose deployment serves the bundle from a CDN, needs none of this.
|
|
18
|
+
*/
|
|
19
|
+
var resolveSdkAssetsDir = () => {
|
|
20
|
+
try {
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
return path.dirname(require.resolve("@plitzi/plitzi-sdk/plitzi-sdk.css"));
|
|
23
|
+
} catch {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A cache-buster for the SDK URLs, taken from the bundle's own mtime.
|
|
29
|
+
*
|
|
30
|
+
* The assets are served with a long `Cache-Control`, so something has to change in the URL when the bundle does or
|
|
31
|
+
* browsers keep the old one. Since the version a deployment runs IS the version of this package, the server can work
|
|
32
|
+
* it out — nobody should have to compute it and pass it in, and forgetting to is a stale bundle nobody can explain.
|
|
33
|
+
*/
|
|
34
|
+
var cachedVersion;
|
|
35
|
+
var sdkAssetVersion = () => {
|
|
36
|
+
if (cachedVersion !== void 0) return cachedVersion;
|
|
37
|
+
const dir = resolveSdkAssetsDir();
|
|
38
|
+
try {
|
|
39
|
+
cachedVersion = dir ? Math.floor(statSync(path.join(dir, "plitzi-sdk.js")).mtimeMs).toString(36) : "";
|
|
40
|
+
} catch {
|
|
41
|
+
cachedVersion = "";
|
|
42
|
+
}
|
|
43
|
+
return cachedVersion;
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { SDK_ASSETS_PREFIX, resolveSdkAssetsDir, sdkAssetVersion };
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { buildTransport, protoLabel } from "../transports.js";
|
|
2
2
|
//#region src/core/server/baseServer.ts
|
|
3
|
+
/**
|
|
4
|
+
* What went wrong taking the port, and what to do about it.
|
|
5
|
+
*
|
|
6
|
+
* A server that cannot bind used to surface as an unhandled `error` event: a stack trace through `node:net` naming
|
|
7
|
+
* neither the port nor the server, printed as if the process had crashed at random. It is the first thing a new
|
|
8
|
+
* deployment hits — two roles configured on one port, or a previous run still holding it — so it is worth saying
|
|
9
|
+
* plainly.
|
|
10
|
+
*/
|
|
11
|
+
var bindFailure = (error, port, label) => {
|
|
12
|
+
if (error.code === "EADDRINUSE") return `[${label}] cannot bind port ${port}: already in use. Another server is running, or the previous one has not released it yet — find it with \`lsof -iTCP:${port} -sTCP:LISTEN\`, or start this one on another port.`;
|
|
13
|
+
if (error.code === "EACCES") return `[${label}] cannot bind port ${port}: permission denied. Ports below 1024 need privileges — run elevated, or use a port above 1024 and put a proxy in front.`;
|
|
14
|
+
if (error.code === "EADDRNOTAVAIL") return `[${label}] cannot bind port ${port}: the requested host is not an address of this machine.`;
|
|
15
|
+
return `[${label}] failed to bind port ${port}: ${error.message}`;
|
|
16
|
+
};
|
|
3
17
|
var createHttpServer = (config, makeHandlerForPort, parts) => {
|
|
4
18
|
const { label } = parts;
|
|
5
|
-
const version = config.httpVersion ?? 2;
|
|
19
|
+
const version = config.httpVersion ?? (config.tls ? 2 : 1);
|
|
6
20
|
if (version >= 3 && !config.tls) throw new Error(`[${label}] httpVersion: ${version} requires a tls config with key and cert`);
|
|
7
21
|
let primary;
|
|
8
22
|
let h3;
|
|
@@ -12,16 +26,37 @@ var createHttpServer = (config, makeHandlerForPort, parts) => {
|
|
|
12
26
|
listen(port, host = "0.0.0.0") {
|
|
13
27
|
const handler = makeHandlerForPort(port);
|
|
14
28
|
({primary, h3} = buildTransport(config, handler, port, label));
|
|
29
|
+
primary.on("error", (error) => {
|
|
30
|
+
if (config.onListenError) {
|
|
31
|
+
config.onListenError(error, {
|
|
32
|
+
port,
|
|
33
|
+
host,
|
|
34
|
+
label
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
console.error(bindFailure(error, port, label));
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
process.exit(1);
|
|
41
|
+
});
|
|
15
42
|
primary.listen(port, host, () => {
|
|
16
43
|
console.log(`[${label}] ${protoLabel(version, !!config.tls)} - listening on ${host}:${port}`);
|
|
17
44
|
});
|
|
18
45
|
},
|
|
19
46
|
async close() {
|
|
20
47
|
parts.onDestroy?.();
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
await Promise.all(
|
|
48
|
+
const open = [primary, h3].filter((srv) => srv !== void 0);
|
|
49
|
+
primary = void 0;
|
|
50
|
+
h3 = void 0;
|
|
51
|
+
await Promise.all(open.map((srv) => new Promise((resolve, reject) => {
|
|
52
|
+
srv.close((err) => {
|
|
53
|
+
if (err && err.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
54
|
+
reject(err);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
resolve();
|
|
58
|
+
});
|
|
59
|
+
})));
|
|
25
60
|
}
|
|
26
61
|
};
|
|
27
62
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PipelineExtensions } from '../http/types';
|
|
2
|
+
import { ResolvedServices } from '../services/resolve';
|
|
3
|
+
import { SSRPageServerConfig, SSRServer } from '@plitzi/sdk-shared';
|
|
4
|
+
/** The page-serving machinery: html/rsc caches, the render template and the plugin manager, driving the page
|
|
5
|
+
* pipeline. Which services it mounts is the CALLER's decision — {@link createServer} passes whatever the config
|
|
6
|
+
* enables — so this unit never second-guesses a factory's promise. */
|
|
7
|
+
export declare const createPageServer: (config: SSRPageServerConfig, services: ResolvedServices, extensions?: PipelineExtensions) => SSRServer;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { createHttpServer } from "./baseServer.js";
|
|
2
|
-
import { makeHandler } from "../http/dispatcher.js";
|
|
3
2
|
import { DEFAULT_TTL_MS } from "../../helpers/cache/defaults.js";
|
|
4
3
|
import { buildCacheManager } from "../../helpers/cache/cacheManager.js";
|
|
5
4
|
import { createServerCaches, destroyServerCaches } from "../../helpers/cache/serverCaches.js";
|
|
6
|
-
import { createMemoryDraftStore } from "../../modules/ssr/preview.js";
|
|
7
|
-
import { buildPagePipeline } from "../services/registry.js";
|
|
8
5
|
import normalizePlugins, { normalizePluginSource } from "../../helpers/normalizePlugins.js";
|
|
6
|
+
import { invalidatePluginComponentCache } from "../../modules/ssr/loadPluginComponents.js";
|
|
7
|
+
import { createMemoryDraftStore } from "../../modules/ssr/preview.js";
|
|
9
8
|
import { compileTemplate } from "../../modules/ssr/template.js";
|
|
10
9
|
import { PluginManager } from "../../plugins/manager.js";
|
|
11
|
-
import {
|
|
10
|
+
import { makeHandler } from "../http/dispatcher.js";
|
|
11
|
+
import { buildPagePipeline } from "../services/registry.js";
|
|
12
12
|
//#region src/core/server/pageServer.ts
|
|
13
13
|
/** The page-serving machinery: html/rsc caches, the render template and the plugin manager, driving the page
|
|
14
14
|
* pipeline. Which services it mounts is the CALLER's decision — {@link createServer} passes whatever the config
|
|
15
|
-
* enables
|
|
16
|
-
var createPageServer = (config, services) => {
|
|
15
|
+
* enables — so this unit never second-guesses a factory's promise. */
|
|
16
|
+
var createPageServer = (config, services, extensions) => {
|
|
17
17
|
const { cacheTtlMs: htmlTtlMs = DEFAULT_TTL_MS.html } = config;
|
|
18
18
|
if (config.preview?.enabled && !config.draftStore) config.draftStore = createMemoryDraftStore();
|
|
19
19
|
const caches = createServerCaches(htmlTtlMs, config.rsc?.cacheTtlMs ?? DEFAULT_TTL_MS.rsc);
|
|
@@ -25,9 +25,12 @@ var createPageServer = (config, services) => {
|
|
|
25
25
|
const normalized = normalizePluginSource(source);
|
|
26
26
|
pluginManager.register(`${name}@${normalized.version}`, normalized);
|
|
27
27
|
},
|
|
28
|
-
invalidate: (name, version) =>
|
|
28
|
+
invalidate: async (name, version) => {
|
|
29
|
+
await pluginManager.invalidate(name, version);
|
|
30
|
+
invalidatePluginComponentCache();
|
|
31
|
+
}
|
|
29
32
|
};
|
|
30
|
-
const stages = buildPagePipeline(services);
|
|
33
|
+
const stages = buildPagePipeline(services, extensions);
|
|
31
34
|
const makeHandlerForPort = (port) => {
|
|
32
35
|
const buildContext = (raw, rawRes, req, res) => ({
|
|
33
36
|
raw,
|
|
@@ -40,7 +43,7 @@ var createPageServer = (config, services) => {
|
|
|
40
43
|
caches,
|
|
41
44
|
pluginManager
|
|
42
45
|
});
|
|
43
|
-
return makeHandler("SSR", buildContext, stages);
|
|
46
|
+
return makeHandler("SSR", buildContext, stages, config.compression);
|
|
44
47
|
};
|
|
45
48
|
return createHttpServer(config, makeHandlerForPort, {
|
|
46
49
|
label: "SSR",
|
|
@@ -52,12 +55,5 @@ var createPageServer = (config, services) => {
|
|
|
52
55
|
}
|
|
53
56
|
});
|
|
54
57
|
};
|
|
55
|
-
/** The page server: SSR and RSC, and nothing else. MCP is pinned OFF here even when the config asks for it —
|
|
56
|
-
* what a factory named after a surface mounts must be readable from its name alone. A deployment that wants
|
|
57
|
-
* both surfaces in one process asks {@link createServer} for them; a dedicated MCP server is createMCPServer. */
|
|
58
|
-
var createSSRServer = (config) => createPageServer(config, {
|
|
59
|
-
...resolveServices(config),
|
|
60
|
-
mcp: false
|
|
61
|
-
});
|
|
62
58
|
//#endregion
|
|
63
|
-
export { createPageServer
|
|
59
|
+
export { createPageServer };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SSRContext, Stage } from '../http/types';
|
|
2
|
+
/**
|
|
3
|
+
* Write endpoint for server-driven providers. RSC is read-only, so this is the only path a page has to mutate a
|
|
4
|
+
* connected backend — and it answers POST on its own path alone, never falling through to SSR.
|
|
5
|
+
*
|
|
6
|
+
* Inert unless the consumer supplied the connector lookups: without them there is no manifest to authorize a
|
|
7
|
+
* write against, and guessing would be the whole vulnerability.
|
|
8
|
+
*/
|
|
9
|
+
export declare const actionStage: Stage<SSRContext>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readRawBody } from "../requestParser.js";
|
|
2
|
+
import { handleAction } from "../../modules/actions/handler.js";
|
|
3
|
+
//#region src/core/services/action.ts
|
|
4
|
+
/**
|
|
5
|
+
* Write endpoint for server-driven providers. RSC is read-only, so this is the only path a page has to mutate a
|
|
6
|
+
* connected backend — and it answers POST on its own path alone, never falling through to SSR.
|
|
7
|
+
*
|
|
8
|
+
* Inert unless the consumer supplied the connector lookups: without them there is no manifest to authorize a
|
|
9
|
+
* write against, and guessing would be the whole vulnerability.
|
|
10
|
+
*/
|
|
11
|
+
var actionStage = async (ctx) => {
|
|
12
|
+
const { config, req } = ctx;
|
|
13
|
+
const actionPath = config.action?.path ?? "/_action";
|
|
14
|
+
if (!config.action?.lookups || req.method !== "POST" || req.path !== actionPath) return false;
|
|
15
|
+
ctx.operation = "action";
|
|
16
|
+
req.body = await readRawBody(ctx.raw);
|
|
17
|
+
await handleAction(req, ctx.res, config, config.action.lookups);
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { actionStage };
|
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { oauthGuardStage, oauthStage } from "./oauth.js";
|
|
3
|
-
import { previewStage } from "./preview.js";
|
|
4
|
-
import { widgetProxyStage } from "./proxy.js";
|
|
1
|
+
import { actionStage } from "./action.js";
|
|
5
2
|
import { rscStage } from "./rsc.js";
|
|
6
3
|
import { notFoundStage, ssrStage } from "./ssr.js";
|
|
7
4
|
import { authRoutesStages } from "../http/stages/authRoutes.js";
|
|
8
5
|
import { healthStage } from "../http/stages/health.js";
|
|
9
6
|
import { middlewaresStage } from "../http/stages/middlewares.js";
|
|
10
7
|
import { pluginAssetsStage } from "../http/stages/pluginAssets.js";
|
|
11
|
-
import {
|
|
8
|
+
import { configStaticStage, publicDirStage, sdkAssetsStage, wellKnownStage } from "../http/stages/static.js";
|
|
12
9
|
//#region src/core/services/registry.ts
|
|
13
|
-
var buildPagePipeline = (services) => {
|
|
10
|
+
var buildPagePipeline = (services, extensions = {}) => {
|
|
14
11
|
const stages = [
|
|
15
12
|
healthStage,
|
|
16
|
-
builtinPublicStage,
|
|
17
13
|
publicDirStage,
|
|
18
14
|
wellKnownStage,
|
|
19
15
|
pluginAssetsStage,
|
|
20
16
|
...authRoutesStages,
|
|
21
|
-
configStaticStage
|
|
17
|
+
configStaticStage,
|
|
18
|
+
sdkAssetsStage
|
|
22
19
|
];
|
|
23
|
-
|
|
24
|
-
stages.push(previewStage);
|
|
20
|
+
stages.push(...extensions.preAuth ?? []);
|
|
25
21
|
stages.push(middlewaresStage);
|
|
26
22
|
if (services.rsc) stages.push(rscStage);
|
|
23
|
+
stages.push(actionStage);
|
|
24
|
+
stages.push(...extensions.data ?? []);
|
|
27
25
|
stages.push(services.ssr ? ssrStage : notFoundStage);
|
|
28
26
|
return stages;
|
|
29
27
|
};
|
|
30
|
-
var buildMCPPipeline = () => [
|
|
31
|
-
healthStage,
|
|
32
|
-
configStaticStage,
|
|
33
|
-
widgetProxyStage,
|
|
34
|
-
oauthStage,
|
|
35
|
-
oauthGuardStage,
|
|
36
|
-
mcpOnlyStage
|
|
37
|
-
];
|
|
38
28
|
//#endregion
|
|
39
|
-
export {
|
|
29
|
+
export { buildPagePipeline };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ServerServices, SSRServerConfig } from '@plitzi/sdk-shared';
|
|
2
2
|
export type ResolvedServices = Required<ServerServices>;
|
|
3
3
|
export declare const resolveServices: (config: SSRServerConfig) => ResolvedServices;
|
|
4
|
+
export declare const resolveRscEndpoint: (config: SSRServerConfig) => string | undefined;
|
|
@@ -3,10 +3,12 @@ var resolveServices = (config) => {
|
|
|
3
3
|
const services = config.services ?? {};
|
|
4
4
|
return {
|
|
5
5
|
ssr: services.ssr ?? true,
|
|
6
|
-
rsc: services.rsc ?? !!config.adapters.getRscData
|
|
7
|
-
mcp: services.mcp ?? config.mcpAi?.enabled ?? false,
|
|
8
|
-
ai: services.ai ?? false
|
|
6
|
+
rsc: services.rsc ?? !!config.adapters.getRscData
|
|
9
7
|
};
|
|
10
8
|
};
|
|
9
|
+
var resolveRscEndpoint = (config) => {
|
|
10
|
+
if (!resolveServices(config).rsc || !(config.rsc?.enabled ?? true) || !config.adapters.getRscData) return;
|
|
11
|
+
return config.rsc?.path ?? "/_rsc";
|
|
12
|
+
};
|
|
11
13
|
//#endregion
|
|
12
|
-
export { resolveServices };
|
|
14
|
+
export { resolveRscEndpoint, resolveServices };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { resolveRscEndpoint } from "./resolve.js";
|
|
1
2
|
import { handleRsc } from "../../modules/rsc/handler.js";
|
|
2
3
|
//#region src/core/services/rsc.ts
|
|
3
4
|
var rscStage = async (ctx) => {
|
|
4
5
|
const { config, req } = ctx;
|
|
5
|
-
const rscPath = config
|
|
6
|
-
if (!
|
|
6
|
+
const rscPath = resolveRscEndpoint(config);
|
|
7
|
+
if (!rscPath || req.method !== "GET" || req.path !== rscPath) return false;
|
|
7
8
|
ctx.operation = "rsc";
|
|
8
9
|
await handleRsc(req, ctx.res, config, ctx.pluginManager, ctx.caches.rsc);
|
|
9
10
|
return true;
|
package/dist/core/staticFiles.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getCacheControl, getMimeType } from "./mimeTypes.js";
|
|
2
|
-
import path from "node:path";
|
|
3
2
|
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
//#region src/core/staticFiles.ts
|
|
5
5
|
var buildEtag = (stat) => `"${stat.mtimeMs.toString(36)}-${stat.size.toString(36)}"`;
|
|
6
6
|
var serveFile = (req, res, filePath, stat) => {
|
|
@@ -4,6 +4,9 @@ import { IncomingMessage } from 'node:http';
|
|
|
4
4
|
export type CloseableServer = {
|
|
5
5
|
close: (cb?: (err?: Error) => void) => unknown;
|
|
6
6
|
listen: (port: number, host: string, cb: () => void) => unknown;
|
|
7
|
+
/** Bind failures arrive here. Without a listener Node throws the `error` event as an uncaught exception, which
|
|
8
|
+
* is how a taken port used to read as a crash in `node:net` rather than as this server not starting. */
|
|
9
|
+
on: (event: 'error', listener: (error: NodeJS.ErrnoException) => void) => unknown;
|
|
7
10
|
};
|
|
8
11
|
export type Handler = (req: IncomingMessage, res: RawResponse) => void;
|
|
9
12
|
export declare const tlsOptions: (config: SSRServerConfig, label?: string) => {
|
package/dist/core/transports.js
CHANGED
|
@@ -35,12 +35,13 @@ var buildTransport = (config, handler, port, label = "Server") => {
|
|
|
35
35
|
console.warn(`[${label}] HTTP/3 unavailable — start Node.js with --experimental-quic (requires Node ≥ 23). Falling back to HTTP/2.`);
|
|
36
36
|
}
|
|
37
37
|
})();
|
|
38
|
-
} else if (version >= 2)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
} else if (version >= 2) {
|
|
39
|
+
if (config.tls) primary = http2.createSecureServer({
|
|
40
|
+
...tlsOptions(config, label),
|
|
41
|
+
allowHTTP1: true
|
|
42
|
+
}, handler);
|
|
43
|
+
else primary = http.createServer(handler);
|
|
44
|
+
} else if (config.tls) primary = https.createServer(tlsOptions(config, label), handler);
|
|
44
45
|
else primary = http.createServer(handler);
|
|
45
46
|
return {
|
|
46
47
|
primary,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The auth kernel as ready-made request handlers. Import as `@plitzi/sdk-server/handlers`.
|
|
3
|
+
*
|
|
4
|
+
* **No framework is imported here, and none is assumed.** The request, response and router are described by the
|
|
5
|
+
* handful of properties these functions touch (see `AuthedRequest`, `JsonResponse`, `RouterLike`), so an Express,
|
|
6
|
+
* Connect or Koa object satisfies them as it stands, and a bare `node:http` server satisfies them with a few lines
|
|
7
|
+
* of its own. Tying this package to one framework would be the wrong trade — but so is leaving every deployment to
|
|
8
|
+
* rediscover the same twenty lines, one of which has a real trap in it (`hostname` and spreads, see below).
|
|
9
|
+
*
|
|
10
|
+
* A deployment with a router:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createAuthMiddleware, mountAuthRoutes } from '@plitzi/sdk-server/handlers';
|
|
14
|
+
*
|
|
15
|
+
* app.use(createAuthMiddleware(auth.identity, policy));
|
|
16
|
+
*
|
|
17
|
+
* const router = Router();
|
|
18
|
+
* mountAuthRoutes(router, { api: auth.api, cookies: auth.cookies });
|
|
19
|
+
* app.use('/auth', router);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* A deployment without one — `createAuthRouteHandlers` is a list, and dispatching it is yours:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { createAuthRouteHandlers } from '@plitzi/sdk-server/handlers';
|
|
26
|
+
*
|
|
27
|
+
* const routes = createAuthRouteHandlers({ api: auth.api, cookies: auth.cookies });
|
|
28
|
+
*
|
|
29
|
+
* http.createServer(async (raw, rawRes) => {
|
|
30
|
+
* const req = parseRequest(raw); // from @plitzi/sdk-server/kernel
|
|
31
|
+
* const route = routes.find(r => r.method === req.method && `/auth${r.path}` === req.path);
|
|
32
|
+
* if (route) {
|
|
33
|
+
* await route.handle(req, jsonResponse(rawRes));
|
|
34
|
+
* }
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Everything a deployment must decide — its accounts, its policy, its cookie naming — stays `createAuth`'s. What is
|
|
39
|
+
* here is only what is the same for everyone.
|
|
40
|
+
*
|
|
41
|
+
* `req.user` and `req.grant` are what the guard resolved. To have those typed across your own routers, declare them
|
|
42
|
+
* once in your app rather than expecting them from here — a library augmenting its consumer's globals only merges
|
|
43
|
+
* when both resolve the identical copy of the framework's types, and two installs do not:
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* declare module 'express-serve-static-core' {
|
|
47
|
+
* interface Request {
|
|
48
|
+
* user?: Actor;
|
|
49
|
+
* grant?: Grant;
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export { createAuthRouteHandlers, mountAuthRoutes } from './core/handlers/authRouteHandlers';
|
|
55
|
+
export { createAuthMiddleware } from './core/handlers/authMiddleware';
|
|
56
|
+
export type { AuthRouteHandlersOptions } from './core/handlers/authRouteHandlers';
|
|
57
|
+
export type { AuthMiddlewareOptions } from './core/handlers/authMiddleware';
|
|
58
|
+
export type { AuthedRequest, JsonResponse, HttpRoute, RouteHandler, RouterLike } from './core/handlers/types';
|
package/dist/handlers.js
ADDED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ResolvedCompression } from './compress';
|
|
1
2
|
import { SSRResponseHelpers } from '@plitzi/sdk-shared';
|
|
2
3
|
export type RawResponse = {
|
|
3
4
|
headersSent: boolean;
|
|
@@ -9,4 +10,4 @@ export type RawResponse = {
|
|
|
9
10
|
write(chunk: string | Buffer): unknown;
|
|
10
11
|
end(chunk?: string | Buffer): unknown;
|
|
11
12
|
};
|
|
12
|
-
export declare const buildResponseHelpers: (raw: RawResponse, acceptEncoding?: string) => SSRResponseHelpers;
|
|
13
|
+
export declare const buildResponseHelpers: (raw: RawResponse, acceptEncoding?: string, compression?: ResolvedCompression) => SSRResponseHelpers;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { compressBody, selectEncoding } from "./compress.js";
|
|
1
|
+
import { DEFAULT_COMPRESSION, compressBody, selectEncoding } from "./compress.js";
|
|
2
2
|
//#region src/helpers/buildResponseHelpers.ts
|
|
3
|
-
var buildResponseHelpers = (raw, acceptEncoding) => {
|
|
3
|
+
var buildResponseHelpers = (raw, acceptEncoding, compression = DEFAULT_COMPRESSION) => {
|
|
4
4
|
let statusCode = 200;
|
|
5
|
-
const encoding = selectEncoding(acceptEncoding);
|
|
5
|
+
const encoding = selectEncoding(acceptEncoding, compression);
|
|
6
|
+
/**
|
|
7
|
+
* `Cache-Control: no-transform` means what it says, and this server is one of the parties it addresses.
|
|
8
|
+
*
|
|
9
|
+
* A stage sets it on a response whose body must reach the client byte for byte — the OAuth token endpoint above
|
|
10
|
+
* all, where a credential travels beside a value the caller chose (the `scope` it echoes back). Compressing the
|
|
11
|
+
* two together is the shape a BREACH-style attack needs, and the stage that knows this is the one that has
|
|
12
|
+
* already said so in a header.
|
|
13
|
+
*/
|
|
14
|
+
const transformable = () => !String(raw.getHeaders()["cache-control"]).includes("no-transform");
|
|
6
15
|
const writeSend = (body) => {
|
|
7
|
-
const compressed = compressBody(body, encoding);
|
|
16
|
+
const compressed = transformable() ? compressBody(body, encoding, compression) : body;
|
|
8
17
|
if (compressed !== body) {
|
|
9
18
|
raw.setHeader("Content-Encoding", encoding);
|
|
10
19
|
raw.setHeader("Vary", "Accept-Encoding");
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OfflineDataLoader } from './offlineDataLoader';
|
|
2
|
+
import { Server, SSRRequest, SSRServerConfig } from '@plitzi/sdk-shared';
|
|
3
|
+
export declare const buildServerInfo: (req: SSRRequest, config: SSRServerConfig, loadOfflineData: OfflineDataLoader) => Promise<Partial<Server>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveRscEndpoint } from "../core/services/resolve.js";
|
|
1
2
|
//#region src/helpers/buildServerInfo.ts
|
|
2
3
|
var getEnvironment = (env = "production", server) => {
|
|
3
4
|
switch (env) {
|
|
@@ -28,7 +29,7 @@ var getEnvironment = (env = "production", server) => {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
|
-
var buildServerInfo = async (req, config) => {
|
|
32
|
+
var buildServerInfo = async (req, config, loadOfflineData) => {
|
|
32
33
|
const accessToken = req.query["access-token"];
|
|
33
34
|
const origin = `${req.protocol}://${req.hostname}`;
|
|
34
35
|
const user = req.ctx.user;
|
|
@@ -44,8 +45,29 @@ var buildServerInfo = async (req, config) => {
|
|
|
44
45
|
},
|
|
45
46
|
authenticated: !!user,
|
|
46
47
|
skipAuth: !!accessToken,
|
|
47
|
-
user: user ? {
|
|
48
|
-
|
|
48
|
+
user: user ? {
|
|
49
|
+
details: {
|
|
50
|
+
id: user.id,
|
|
51
|
+
username: user.username,
|
|
52
|
+
email: user.email,
|
|
53
|
+
verified: user.verified,
|
|
54
|
+
permissions: user.permissions,
|
|
55
|
+
roles: user.roles
|
|
56
|
+
},
|
|
57
|
+
accessToken: user.token,
|
|
58
|
+
expiresAt: user.expiresAt
|
|
59
|
+
} : void 0,
|
|
60
|
+
ssr: {
|
|
61
|
+
rscPath: resolveRscEndpoint(config),
|
|
62
|
+
rscData: await config.adapters.getRscData?.({
|
|
63
|
+
req,
|
|
64
|
+
spaceId,
|
|
65
|
+
environment,
|
|
66
|
+
revision,
|
|
67
|
+
user,
|
|
68
|
+
loadOfflineData
|
|
69
|
+
})
|
|
70
|
+
}
|
|
49
71
|
});
|
|
50
72
|
};
|
|
51
73
|
//#endregion
|
|
@@ -4,4 +4,8 @@ export declare const buildHtmlCacheKey: (accessToken: string | undefined, spaceI
|
|
|
4
4
|
search: string;
|
|
5
5
|
}) => string;
|
|
6
6
|
export declare const buildOfflineDataCacheKey: (spaceId: number, environment: string, revision: number) => string;
|
|
7
|
-
export declare const buildRscCacheKey: (spaceId: number, environment: string, revision: number, userId: string | number | undefined, idsParam: string | undefined
|
|
7
|
+
export declare const buildRscCacheKey: (spaceId: number, environment: string, revision: number, userId: string | number | undefined, idsParam: string | undefined, req: {
|
|
8
|
+
hostname: string;
|
|
9
|
+
path: string;
|
|
10
|
+
search: string;
|
|
11
|
+
}) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/helpers/cache/keys.ts
|
|
2
2
|
var buildHtmlCacheKey = (accessToken = "anonymous", spaceId, environment, revision, req) => `${accessToken}\0${spaceId ?? 1}\0${environment}\0${revision}\0${req.hostname}\0${req.path}\0${req.search}`;
|
|
3
3
|
var buildOfflineDataCacheKey = (spaceId, environment, revision) => `${spaceId}|${environment}|${revision}`;
|
|
4
|
-
var buildRscCacheKey = (spaceId, environment, revision, userId, idsParam) => `${spaceId}
|
|
4
|
+
var buildRscCacheKey = (spaceId, environment, revision, userId, idsParam, req) => `${spaceId}\0${environment}\0${revision}\0${userId ?? "anon"}\0${idsParam ?? ""}\0${req.hostname}\0${req.path}\0${req.search}`;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { buildHtmlCacheKey, buildOfflineDataCacheKey, buildRscCacheKey };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SSRCompressionConfig } from '@plitzi/sdk-shared';
|
|
2
|
+
export type ContentEncoding = 'br' | 'gzip' | 'identity';
|
|
3
|
+
/** What the server does when the deployment says nothing: Brotli where the client takes it, gzip otherwise. */
|
|
4
|
+
export declare const DEFAULT_COMPRESSION: {
|
|
5
|
+
encodings: ("br" | "gzip")[];
|
|
6
|
+
threshold: number;
|
|
7
|
+
brotliQuality: number;
|
|
8
|
+
gzipLevel: number;
|
|
9
|
+
};
|
|
10
|
+
export type ResolvedCompression = typeof DEFAULT_COMPRESSION;
|
|
11
|
+
/**
|
|
12
|
+
* The deployment's compression policy, with the gaps filled in. `false` means never compress, and is expressed as
|
|
13
|
+
* an empty encoding list so there is one shape downstream rather than a boolean to re-test at every use.
|
|
14
|
+
*/
|
|
15
|
+
export declare const resolveCompression: (config?: SSRCompressionConfig | false) => ResolvedCompression;
|
|
16
|
+
/** The first encoding this server prefers that the client actually takes. `*` counts as taking anything. */
|
|
17
|
+
export declare const selectEncoding: (acceptEncoding: string | undefined, compression?: ResolvedCompression) => ContentEncoding;
|
|
18
|
+
export declare const compressBody: (body: string, encoding: ContentEncoding, compression?: ResolvedCompression) => Buffer | string;
|