@undefineds.co/xpod 0.3.18 → 0.3.23
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/config/bun.json +57 -11
- package/config/cloud.json +14 -12
- package/config/local.json +16 -14
- package/config/xpod.json +47 -9
- package/dist/api/matrix/PodMatrixStore.d.ts +4 -7
- package/dist/api/matrix/PodMatrixStore.js +116 -148
- package/dist/api/matrix/PodMatrixStore.js.map +1 -1
- package/dist/api/matrix/types.d.ts +2 -0
- package/dist/api/matrix/types.js.map +1 -1
- package/dist/api/runs/PiAgentRuntimeDriver.d.ts +1 -0
- package/dist/api/runs/PiAgentRuntimeDriver.js +4 -1
- package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -1
- package/dist/components/components.jsonld +3 -0
- package/dist/components/context.jsonld +71 -32
- package/dist/http/SubgraphSparqlHttpHandler.d.ts +1 -0
- package/dist/http/SubgraphSparqlHttpHandler.js +27 -4
- package/dist/http/SubgraphSparqlHttpHandler.js.map +1 -1
- package/dist/http/SubgraphSparqlHttpHandler.jsonld +4 -0
- package/dist/http/vector/VectorHttpHandler.d.ts +5 -1
- package/dist/http/vector/VectorHttpHandler.js +5 -5
- package/dist/http/vector/VectorHttpHandler.js.map +1 -1
- package/dist/http/vector/VectorHttpHandler.jsonld +40 -28
- package/dist/index.d.ts +5 -2
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime/Proxy.d.ts +3 -0
- package/dist/runtime/Proxy.js +31 -7
- package/dist/runtime/Proxy.js.map +1 -1
- package/dist/solidfs/LocalSolidFS.js +31 -124
- package/dist/solidfs/LocalSolidFS.js.map +1 -1
- package/dist/solidfs/SolidFsPathUtils.d.ts +13 -0
- package/dist/solidfs/SolidFsPathUtils.js +114 -0
- package/dist/solidfs/SolidFsPathUtils.js.map +1 -0
- package/dist/solidfs/SolidFsSyncJournal.d.ts +117 -0
- package/dist/solidfs/SolidFsSyncJournal.js +553 -0
- package/dist/solidfs/SolidFsSyncJournal.js.map +1 -0
- package/dist/solidfs/index.d.ts +1 -0
- package/dist/solidfs/index.js +1 -0
- package/dist/solidfs/index.js.map +1 -1
- package/dist/solidfs/types.d.ts +1 -0
- package/dist/solidfs/types.js.map +1 -1
- package/dist/storage/SparqlUpdateResourceStore.js +94 -33
- package/dist/storage/SparqlUpdateResourceStore.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.d.ts +22 -5
- package/dist/storage/accessors/MixDataAccessor.js +376 -61
- package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.jsonld +73 -5
- package/dist/storage/accessors/QuadstoreSparqlDataAccessor.js +32 -10
- package/dist/storage/accessors/QuadstoreSparqlDataAccessor.js.map +1 -1
- package/dist/storage/accessors/QuintStoreSparqlDataAccessor.js +28 -6
- package/dist/storage/accessors/QuintStoreSparqlDataAccessor.js.map +1 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.d.ts +45 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.js +277 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.js.map +1 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.jsonld +161 -0
- package/dist/storage/rdf/Rdf3xIndex.d.ts +122 -0
- package/dist/storage/rdf/Rdf3xIndex.js +2695 -0
- package/dist/storage/rdf/Rdf3xIndex.js.map +1 -0
- package/dist/storage/rdf/Rdf3xIndex.jsonld +528 -0
- package/dist/storage/rdf/Rdf3xSchema.d.ts +20 -0
- package/dist/storage/rdf/Rdf3xSchema.js +65 -0
- package/dist/storage/rdf/Rdf3xSchema.js.map +1 -0
- package/dist/storage/rdf/RdfLocalQueryEngine.d.ts +10 -4
- package/dist/storage/rdf/RdfLocalQueryEngine.js +607 -127
- package/dist/storage/rdf/RdfLocalQueryEngine.js.map +1 -1
- package/dist/storage/rdf/RdfQuadIndex.d.ts +12 -1
- package/dist/storage/rdf/RdfQuadIndex.js +152 -22
- package/dist/storage/rdf/RdfQuadIndex.js.map +1 -1
- package/dist/storage/rdf/RdfQuadIndex.jsonld +36 -4
- package/dist/storage/rdf/RdfSparqlAdapter.d.ts +20 -2
- package/dist/storage/rdf/RdfSparqlAdapter.js +364 -40
- package/dist/storage/rdf/RdfSparqlAdapter.js.map +1 -1
- package/dist/storage/rdf/RdfSparqlAdapter.jsonld +60 -0
- package/dist/storage/rdf/RdfTermDictionary.d.ts +8 -0
- package/dist/storage/rdf/RdfTermDictionary.js +141 -70
- package/dist/storage/rdf/RdfTermDictionary.js.map +1 -1
- package/dist/storage/rdf/RdfTermDictionary.jsonld +24 -0
- package/dist/storage/rdf/RdfTextIndex.js +10 -3
- package/dist/storage/rdf/RdfTextIndex.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.d.ts +15 -6
- package/dist/storage/rdf/SolidRdfEngine.js +218 -25
- package/dist/storage/rdf/SolidRdfEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.jsonld +70 -7
- package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +11 -7
- package/dist/storage/rdf/SolidRdfSparqlEngine.js +60 -47
- package/dist/storage/rdf/SolidRdfSparqlEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +9 -5
- package/dist/storage/rdf/index.d.ts +2 -2
- package/dist/storage/rdf/index.js +3 -3
- package/dist/storage/rdf/index.js.map +1 -1
- package/dist/storage/rdf/models-benchmark.d.ts +12 -1
- package/dist/storage/rdf/models-benchmark.js +549 -32
- package/dist/storage/rdf/models-benchmark.js.map +1 -1
- package/dist/storage/rdf/types.d.ts +81 -7
- package/dist/storage/rdf/types.js.map +1 -1
- package/dist/storage/sparql/CompatibilitySparqlEngine.d.ts +36 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.js +96 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.js.map +1 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.jsonld +123 -0
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.d.ts +35 -0
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js +112 -0
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js.map +1 -0
- package/dist/storage/sparql/SubgraphQueryEngine.d.ts +1 -36
- package/dist/storage/sparql/SubgraphQueryEngine.js +2 -115
- package/dist/storage/sparql/SubgraphQueryEngine.js.map +1 -1
- package/dist/storage/sparql/SubgraphQueryEngine.jsonld +1 -124
- package/dist/terminal/AclPermissionService.d.ts +2 -1
- package/dist/terminal/AclPermissionService.js +26 -3
- package/dist/terminal/AclPermissionService.js.map +1 -1
- package/dist/terminal/TerminalSessionManager.js +25 -3
- package/dist/terminal/TerminalSessionManager.js.map +1 -1
- package/package.json +1 -1
- package/dist/storage/rdf/Rdf3xTripleIndex.d.ts +0 -55
- package/dist/storage/rdf/Rdf3xTripleIndex.js +0 -1235
- package/dist/storage/rdf/Rdf3xTripleIndex.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.AuthModeSelector = exports.LocalPodProvisioningService = exports.ProvisionCodeCodec = exports.ProvisionPodCreator = exports.UrlAwareRedisLocker = exports.ScopedPickWebIdHandler = exports.LoopbackClientIdAdapterFactory = exports.AutoDetectIdentityProviderHandler = exports.AutoDetectOidcHandler = exports.DisabledIdentityProviderHandler = exports.DisabledOidcHandler = exports.SubdomainPodIdentifierStrategy = exports.MultiDomainIdentifierStrategy = exports.SubdomainService = exports.LocalTunnelProvider = exports.CloudflareTunnelProvider = exports.CredentialReaderImpl = exports.CredentialReader = exports.EmbeddingServiceImpl = exports.EmbeddingService = exports.ProviderRegistryImpl = exports.ProviderRegistry = exports.VectorHttpHandler = exports.PostgresVectorStore = exports.SqliteVectorStore = exports.VectorStore = exports.SolidRdfSparqlEngine = exports.SolidRdfEngine = exports.ShadowRdfQuintStore = exports.RdfSparqlAdapter = exports.RdfQuadIndex = exports.RdfTermDictionary = exports.PgQuintStore = exports.SqliteQuintStore = void 0;
|
|
3
|
+
exports.ReactAppViewHandler = exports.PodRoutingHttpHandler = exports.CenterNodeRegistrationService = exports.UsageTrackingStore = exports.ClusterIdentifierStrategy = exports.EdgeNodeModeDetector = exports.AcmeCertificateManager = exports.EdgeNodeCertificateService = exports.EdgeNodeAgent = exports.EdgeNodeHealthProbeService = exports.FrpTunnelManager = exports.NoopEdgeNodeTunnelManager = exports.SimpleEdgeNodeTunnelManager = exports.Dns01CertificateProvisioner = exports.EdgeNodeDnsCoordinator = exports.TencentDnsProvider = exports.PerAccountQuotaStrategy = exports.NoopEntitlementProvider = exports.HttpEntitlementProvider = exports.NoopQuotaService = exports.DrizzleQuotaService = exports.SqliteKeyValueStorage = exports.RedisKeyValueStorage = exports.PostgresKeyValueStorage = exports.ValidatingIdentityProviderHttpHandler = exports.DrizzleIndexedStorage = exports.ReservedSuffixIdentifierGenerator = exports.TerminalHttpHandler = exports.EdgeNodeCertificateHttpHandler = exports.TracingHandler = exports.RouterHttpRoute = exports.RouterHttpHandler = exports.EdgeNodeProxyHttpHandler = exports.EdgeNodeDirectDebugHttpHandler = exports.ClusterWebSocketConfigurator = exports.ClusterIngressRouter = exports.QuotaAdminHttpHandler = exports.SubgraphSparqlHttpHandler = exports.QuintstoreSparqlEngine = exports.QuadstoreSparqlEngine = exports.SubgraphQueryEngine = exports.SparqlUpdateResourceStore = exports.ConfigurableLoggerFactory = exports.MixDataAccessor = exports.SolidRdfDataAccessor = exports.QuintStoreSparqlDataAccessor = exports.QuadstoreSparqlDataAccessor = exports.MinioDataAccessor = exports.RepresentationPartialConvertingStore = exports.AppStaticAssetHandler = void 0;
|
|
4
|
+
exports.AuthModeSelector = exports.LocalPodProvisioningService = exports.ProvisionCodeCodec = exports.ProvisionPodCreator = exports.UrlAwareRedisLocker = exports.ScopedPickWebIdHandler = exports.LoopbackClientIdAdapterFactory = exports.AutoDetectIdentityProviderHandler = exports.AutoDetectOidcHandler = exports.DisabledIdentityProviderHandler = exports.DisabledOidcHandler = exports.SubdomainPodIdentifierStrategy = exports.MultiDomainIdentifierStrategy = exports.SubdomainService = exports.LocalTunnelProvider = exports.CloudflareTunnelProvider = exports.CredentialReaderImpl = exports.CredentialReader = exports.EmbeddingServiceImpl = exports.EmbeddingService = exports.ProviderRegistryImpl = exports.ProviderRegistry = exports.VectorHttpHandler = exports.PostgresVectorStore = exports.SqliteVectorStore = exports.VectorStore = exports.SolidRdfSparqlEngine = exports.SolidRdfEngine = exports.ShadowRdfQuintStore = exports.RdfSparqlAdapter = exports.Rdf3xIndex = exports.RdfQuadIndex = exports.RdfTermDictionary = exports.PgQuintStore = exports.SqliteQuintStore = exports.QuintStore = void 0;
|
|
5
5
|
require("./runtime/configure-drizzle-solid");
|
|
6
6
|
const RepresentationPartialConvertingStore_1 = require("./storage/RepresentationPartialConvertingStore");
|
|
7
7
|
Object.defineProperty(exports, "RepresentationPartialConvertingStore", { enumerable: true, get: function () { return RepresentationPartialConvertingStore_1.RepresentationPartialConvertingStore; } });
|
|
@@ -11,14 +11,17 @@ const QuadstoreSparqlDataAccessor_1 = require("./storage/accessors/QuadstoreSpar
|
|
|
11
11
|
Object.defineProperty(exports, "QuadstoreSparqlDataAccessor", { enumerable: true, get: function () { return QuadstoreSparqlDataAccessor_1.QuadstoreSparqlDataAccessor; } });
|
|
12
12
|
const QuintStoreSparqlDataAccessor_1 = require("./storage/accessors/QuintStoreSparqlDataAccessor");
|
|
13
13
|
Object.defineProperty(exports, "QuintStoreSparqlDataAccessor", { enumerable: true, get: function () { return QuintStoreSparqlDataAccessor_1.QuintStoreSparqlDataAccessor; } });
|
|
14
|
+
const SolidRdfDataAccessor_1 = require("./storage/accessors/SolidRdfDataAccessor");
|
|
15
|
+
Object.defineProperty(exports, "SolidRdfDataAccessor", { enumerable: true, get: function () { return SolidRdfDataAccessor_1.SolidRdfDataAccessor; } });
|
|
14
16
|
const MixDataAccessor_1 = require("./storage/accessors/MixDataAccessor");
|
|
15
17
|
Object.defineProperty(exports, "MixDataAccessor", { enumerable: true, get: function () { return MixDataAccessor_1.MixDataAccessor; } });
|
|
16
18
|
const ConfigurableLoggerFactory_1 = require("./logging/ConfigurableLoggerFactory");
|
|
17
19
|
Object.defineProperty(exports, "ConfigurableLoggerFactory", { enumerable: true, get: function () { return ConfigurableLoggerFactory_1.ConfigurableLoggerFactory; } });
|
|
18
20
|
const SubgraphQueryEngine_1 = require("./storage/sparql/SubgraphQueryEngine");
|
|
19
21
|
Object.defineProperty(exports, "SubgraphQueryEngine", { enumerable: true, get: function () { return SubgraphQueryEngine_1.SubgraphQueryEngine; } });
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "
|
|
22
|
+
const CompatibilitySparqlEngine_1 = require("./storage/sparql/CompatibilitySparqlEngine");
|
|
23
|
+
Object.defineProperty(exports, "QuadstoreSparqlEngine", { enumerable: true, get: function () { return CompatibilitySparqlEngine_1.QuadstoreSparqlEngine; } });
|
|
24
|
+
Object.defineProperty(exports, "QuintstoreSparqlEngine", { enumerable: true, get: function () { return CompatibilitySparqlEngine_1.QuintstoreSparqlEngine; } });
|
|
22
25
|
const SubgraphSparqlHttpHandler_1 = require("./http/SubgraphSparqlHttpHandler");
|
|
23
26
|
Object.defineProperty(exports, "SubgraphSparqlHttpHandler", { enumerable: true, get: function () { return SubgraphSparqlHttpHandler_1.SubgraphSparqlHttpHandler; } });
|
|
24
27
|
const QuotaAdminHttpHandler_1 = require("./http/quota/QuotaAdminHttpHandler");
|
|
@@ -103,6 +106,8 @@ const types_1 = require("./storage/quint/types");
|
|
|
103
106
|
Object.defineProperty(exports, "QuintStore", { enumerable: true, get: function () { return types_1.QuintStore; } });
|
|
104
107
|
const RdfQuadIndex_1 = require("./storage/rdf/RdfQuadIndex");
|
|
105
108
|
Object.defineProperty(exports, "RdfQuadIndex", { enumerable: true, get: function () { return RdfQuadIndex_1.RdfQuadIndex; } });
|
|
109
|
+
const Rdf3xIndex_1 = require("./storage/rdf/Rdf3xIndex");
|
|
110
|
+
Object.defineProperty(exports, "Rdf3xIndex", { enumerable: true, get: function () { return Rdf3xIndex_1.Rdf3xIndex; } });
|
|
106
111
|
const RdfSparqlAdapter_1 = require("./storage/rdf/RdfSparqlAdapter");
|
|
107
112
|
Object.defineProperty(exports, "RdfSparqlAdapter", { enumerable: true, get: function () { return RdfSparqlAdapter_1.RdfSparqlAdapter; } });
|
|
108
113
|
const RdfTermDictionary_1 = require("./storage/rdf/RdfTermDictionary");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,6CAA2C;AAC3C,yGAAsG;AAsIlG,qHAtIK,2EAAoC,OAsIL;AArIxC,6EAA0E;AAsItE,kGAtIK,qCAAiB,OAsIL;AArIrB,iGAA8F;AAsI1F,4GAtIK,yDAA2B,OAsIL;AArI/B,mGAAgG;AAsI5F,6GAtIK,2DAA4B,OAsIL;AArIhC,yEAAsE;AAsIlE,gGAtIK,iCAAe,OAsIL;AArInB,mFAAgF;AAsI5E,0GAtIK,qDAAyB,OAsIL;AArI7B,8EAA0H;AAuItH,oGAvIK,yCAAmB,OAuIL;AACnB,sGAxI0B,2CAAqB,OAwI1B;AACrB,uGAzIiD,4CAAsB,OAyIjD;AAnH1B,gFAA6E;AAoHzE,0GApHK,qDAAyB,OAoHL;AAnH7B,8EAA2E;AAoHvE,sGApHK,6CAAqB,OAoHL;AAnHzB,mFAAgF;AA8G5E,0GA9GK,qDAAyB,OA8GL;AA7G7B,sEAAmE;AAmH/D,qGAnHK,2CAAoB,OAmHL;AAlHxB,sFAAmF;AAmH/E,6GAnHK,2DAA4B,OAmHL;AAlHhC,0FAAuF;AAmHnF,+GAnHK,+DAA8B,OAmHL;AAlHlC,8EAA2E;AAmHvE,yGAnHK,mDAAwB,OAmHL;AAlH5B,gEAA6D;AAmHzD,kGAnHK,qC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HP;AAtH1B,sEAAmE;AAuHjE,oGAvHO,yCAAmB,OAuHP;AAtHrB,mEAAgE;AAuH9D,iGAvHO,mCAAgB,OAuHP;AAtHlB,+EAA4E;AAgI1E,oGAhIO,yCAAmB,OAgIP;AA/HrB,+BAA+B;AAC/B,oGAAiG;AAsH/F,8GAtHO,6DAA6B,OAsHP;AArH/B,sGAAmG;AAsHjG,+GAtHO,+DAA8B,OAsHP;AArHhC,6EAA0E;AAsHxE,oGAtHO,yCAAmB,OAsHP;AArHrB,qGAAkG;AAsHhG,gHAtHO,iEAA+B,OAsHP;AArHjC,iFAA8E;AAsH5E,sGAtHO,6CAAqB,OAsHP;AArHvB,yGAAsG;AAsHpG,kHAtHO,qEAAiC,OAsHP;AArHnC,mGAAgG;AAsH9F,+GAtHO,+DAA8B,OAsHP;AArHhC,mFAAgF;AAsH9E,uGAtHO,+CAAsB,OAsHP;AArHxB,uBAAuB;AACvB,yEAAsE;AAuHpE,oGAvHO,yCAAmB,OAuHP;AAtHrB,uEAAoE;AAuHlE,mGAvHO,uCAAkB,OAuHP;AAtHpB,yFAAsF;AAuHpF,4GAvHO,yDAA2B,OAuHP;AAtH7B,2BAA2B;AAC3B,uEAAoE;AAuHlE,iGAvHO,mCAAgB,OAuHP;AA9FlB,uCAAuC;AACvC,sEAAqE;AAA5D,8HAAA,qBAAqB,OAAA","sourcesContent":["import './runtime/configure-drizzle-solid';\nimport { RepresentationPartialConvertingStore } from './storage/RepresentationPartialConvertingStore';\nimport { MinioDataAccessor } from './storage/accessors/MinioDataAccessor';\nimport { QuadstoreSparqlDataAccessor } from './storage/accessors/QuadstoreSparqlDataAccessor';\nimport { QuintStoreSparqlDataAccessor } from './storage/accessors/QuintStoreSparqlDataAccessor';\nimport { MixDataAccessor } from './storage/accessors/MixDataAccessor';\nimport { ConfigurableLoggerFactory } from './logging/ConfigurableLoggerFactory';\nimport { SubgraphQueryEngine, QuadstoreSparqlEngine, QuintstoreSparqlEngine } from './storage/sparql/SubgraphQueryEngine';\nexport type { SparqlEngine } from './storage/sparql/SubgraphQueryEngine';\nexport type {\n RdfIndexStats,\n RdfIndexSpaceObject,\n RdfIndexMetrics,\n RdfIndexPutOptions,\n RdfPatternQuery,\n RdfQuadIndexOptions,\n RdfQuadIndexScanResult,\n RdfShadowBackfillOptions,\n RdfShadowBackfillResult,\n RdfShadowDiff,\n RdfShadowScanResult,\n RdfSourceInput,\n} from './storage/rdf/types';\nexport type { RdfSparqlCompileResult } from './storage/rdf/RdfSparqlAdapter';\nexport type { ShadowRdfQuintStoreOptions } from './storage/rdf/ShadowRdfQuintStore';\nexport type {\n SolidRdfSparqlEngineOptions,\n SolidRdfSparqlFallback,\n} from './storage/rdf/SolidRdfSparqlEngine';\nimport { SubgraphSparqlHttpHandler } from './http/SubgraphSparqlHttpHandler';\nimport { QuotaAdminHttpHandler } from './http/quota/QuotaAdminHttpHandler';\nimport { SparqlUpdateResourceStore } from './storage/SparqlUpdateResourceStore';\nimport { ClusterIngressRouter } from './http/ClusterIngressRouter';\nimport { ClusterWebSocketConfigurator } from './http/ClusterWebSocketConfigurator';\nimport { EdgeNodeDirectDebugHttpHandler } from './http/EdgeNodeDirectDebugHttpHandler';\nimport { EdgeNodeProxyHttpHandler } from './http/EdgeNodeProxyHttpHandler';\nimport { RouterHttpHandler } from './http/RouterHttpHandler';\nimport { RouterHttpRoute } from './http/RouterHttpRoute';\nimport { TracingHandler } from './http/TracingHandler';\nimport { TerminalHttpHandler } from './http/terminal/TerminalHttpHandler';\nimport { EdgeNodeCertificateHttpHandler } from './http/admin/EdgeNodeCertificateHttpHandler';\nimport { ReservedSuffixIdentifierGenerator } from './pods/ReservedSuffixIdentifierGenerator';\nimport { DrizzleIndexedStorage } from './identity/drizzle/DrizzleIndexedStorage';\nimport { ValidatingIdentityProviderHttpHandler } from './identity/ValidatingIdentityProviderHttpHandler';\nimport { PostgresKeyValueStorage } from './storage/keyvalue/PostgresKeyValueStorage';\nimport { RedisKeyValueStorage } from './storage/keyvalue/RedisKeyValueStorage';\nimport { SqliteKeyValueStorage } from './storage/keyvalue/SqliteKeyValueStorage';\nimport { DrizzleQuotaService } from './quota/DrizzleQuotaService';\nimport { NoopQuotaService } from './quota/NoopQuotaService';\nimport { HttpEntitlementProvider, NoopEntitlementProvider } from './quota/EntitlementProvider';\nimport { PerAccountQuotaStrategy } from './storage/quota/PerAccountQuotaStrategy';\nimport { TencentDnsProvider } from './dns/tencent/TencentDnsProvider';\nimport { EdgeNodeDnsCoordinator } from './edge/EdgeNodeDnsCoordinator';\nimport { Dns01CertificateProvisioner } from './edge/Dns01CertificateProvisioner';\nimport { SimpleEdgeNodeTunnelManager, NoopEdgeNodeTunnelManager } from './edge/EdgeNodeTunnelManager';\nimport { FrpTunnelManager } from './edge/FrpTunnelManager';\nimport { AcmeCertificateManager } from './edge/acme/AcmeCertificateManager';\nimport { EdgeNodeHealthProbeService } from './edge/EdgeNodeHealthProbeService';\nimport { EdgeNodeAgent } from './edge/EdgeNodeAgent';\nimport { EdgeNodeCertificateService } from './service/EdgeNodeCertificateService';\nimport { createBandwidthThrottleTransform } from './util/stream/BandwidthThrottleTransform';\nimport { UsageTrackingStore } from './storage/quota/UsageTrackingStore';\nimport { EdgeNodeModeDetector } from './edge/EdgeNodeModeDetector';\nimport { ClusterIdentifierStrategy } from './util/identifiers/ClusterIdentifierStrategy';\nimport { CenterNodeRegistrationService } from './identity/CenterNodeRegistrationService';\nimport { PodRoutingHttpHandler } from './http/PodRoutingHttpHandler';\nimport { ReactAppViewHandler } from './identity/ReactAppViewHandler';\nimport { SqliteQuintStore } from './storage/quint/SqliteQuintStore';\nimport { PgQuintStore } from './storage/quint/PgQuintStore';\nimport { QuintStore } from './storage/quint/types';\nimport { RdfQuadIndex } from './storage/rdf/RdfQuadIndex';\nimport { RdfSparqlAdapter } from './storage/rdf/RdfSparqlAdapter';\nimport { RdfTermDictionary } from './storage/rdf/RdfTermDictionary';\nimport { ShadowRdfQuintStore } from './storage/rdf/ShadowRdfQuintStore';\nimport { SolidRdfEngine } from './storage/rdf/SolidRdfEngine';\nimport { SolidRdfSparqlEngine } from './storage/rdf/SolidRdfSparqlEngine';\nimport type { EdgeNodeCertificateProvisioner } from './edge/EdgeNodeCertificateProvisioner';\n// Vector components\nimport { SqliteVectorStore, PostgresVectorStore } from './storage/vector/index';\nimport { VectorHttpHandler } from './http/vector/VectorHttpHandler';\nimport { ProviderRegistry } from './ai/service/ProviderRegistry';\nimport { ProviderRegistryImpl } from './ai/service/ProviderRegistryImpl';\nimport { EmbeddingService } from './ai/service/EmbeddingService';\nimport { EmbeddingServiceImpl } from './ai/service/EmbeddingServiceImpl';\nimport { CredentialReader } from './ai/service/CredentialReader';\nimport { CredentialReaderImpl } from './ai/service/CredentialReaderImpl';\nimport { VectorStore } from './storage/vector/VectorStore';\n// Tunnel and Subdomain components\nimport { CloudflareTunnelProvider } from './tunnel/CloudflareTunnelProvider';\nimport { LocalTunnelProvider } from './tunnel/LocalTunnelProvider';\nimport { SubdomainService } from './subdomain/SubdomainService';\nimport { UrlAwareRedisLocker } from './storage/locking/UrlAwareRedisLocker';\n// IdP/SP separation components\nimport { MultiDomainIdentifierStrategy } from './util/identifiers/MultiDomainIdentifierStrategy';\nimport { SubdomainPodIdentifierStrategy } from './util/identifiers/SubdomainPodIdentifierStrategy';\nimport { DisabledOidcHandler } from './identity/oidc/DisabledOidcHandler';\nimport { DisabledIdentityProviderHandler } from './identity/oidc/DisabledIdentityProviderHandler';\nimport { AutoDetectOidcHandler } from './identity/oidc/AutoDetectOidcHandler';\nimport { AutoDetectIdentityProviderHandler } from './identity/oidc/AutoDetectIdentityProviderHandler';\nimport { LoopbackClientIdAdapterFactory } from './identity/oidc/LoopbackClientIdAdapterFactory';\nimport { ScopedPickWebIdHandler } from './identity/oidc/ScopedPickWebIdHandler';\n// Provision components\nimport { ProvisionPodCreator } from './provision/ProvisionPodCreator';\nimport { ProvisionCodeCodec } from './provision/ProvisionCodeCodec';\nimport { LocalPodProvisioningService } from './provision/LocalPodProvisioningService';\n// Authorization components\nimport { AuthModeSelector } from './authorization/AuthModeSelector';\nexport type {\n DnsProvider,\n ListDnsRecordsInput,\n ListableDnsProvider,\n DeleteDnsRecordInput,\n DnsRecordSummary,\n UpsertDnsRecordInput,\n} from './dns/DnsProvider';\nexport type { EdgeNodeCertificateProvisioner } from './edge/EdgeNodeCertificateProvisioner';\nexport type { EdgeNodeTunnelManager } from './edge/interfaces/EdgeNodeTunnelManager';\nexport type { QuotaService, AccountQuota } from './quota/QuotaService';\nexport type { EntitlementProvider, AccountEntitlement } from './quota/EntitlementProvider';\n// Tunnel and Subdomain types\nexport type {\n TunnelProvider,\n TunnelConfig,\n TunnelSetupOptions,\n TunnelStatus,\n} from './tunnel/TunnelProvider';\nexport type {\n SubdomainRegistration,\n ConnectivityResult,\n SubdomainServiceOptions,\n} from './subdomain/SubdomainService';\n// Export the new AppStaticAssetHandler\nexport { AppStaticAssetHandler } from './http/AppStaticAssetHandler';\n\nexport { \n RepresentationPartialConvertingStore,\n MinioDataAccessor, \n QuadstoreSparqlDataAccessor,\n QuintStoreSparqlDataAccessor,\n MixDataAccessor,\n ConfigurableLoggerFactory,\n SparqlUpdateResourceStore,\n SubgraphQueryEngine,\n QuadstoreSparqlEngine,\n QuintstoreSparqlEngine,\n SubgraphSparqlHttpHandler,\n QuotaAdminHttpHandler,\n ClusterIngressRouter,\n ClusterWebSocketConfigurator,\n EdgeNodeDirectDebugHttpHandler,\n EdgeNodeProxyHttpHandler,\n RouterHttpHandler,\n RouterHttpRoute,\n TracingHandler,\n EdgeNodeCertificateHttpHandler,\n TerminalHttpHandler,\n ReservedSuffixIdentifierGenerator,\n DrizzleIndexedStorage,\n ValidatingIdentityProviderHttpHandler,\n PostgresKeyValueStorage,\n RedisKeyValueStorage,\n SqliteKeyValueStorage,\n DrizzleQuotaService,\n NoopQuotaService,\n HttpEntitlementProvider,\n NoopEntitlementProvider,\n PerAccountQuotaStrategy,\n TencentDnsProvider,\n EdgeNodeDnsCoordinator,\n Dns01CertificateProvisioner,\n SimpleEdgeNodeTunnelManager,\n NoopEdgeNodeTunnelManager,\n FrpTunnelManager,\n EdgeNodeHealthProbeService,\n EdgeNodeAgent,\n EdgeNodeCertificateService,\n AcmeCertificateManager,\n EdgeNodeModeDetector,\n ClusterIdentifierStrategy,\n UsageTrackingStore,\n CenterNodeRegistrationService,\n PodRoutingHttpHandler,\n ReactAppViewHandler,\n // Quint exports\n QuintStore,\n SqliteQuintStore,\n PgQuintStore,\n // RDF engine exports\n RdfTermDictionary,\n RdfQuadIndex,\n RdfSparqlAdapter,\n ShadowRdfQuintStore,\n SolidRdfEngine,\n SolidRdfSparqlEngine,\n // Vector exports\n VectorStore,\n SqliteVectorStore,\n PostgresVectorStore,\n VectorHttpHandler,\n // Embedding exports\n ProviderRegistry,\n ProviderRegistryImpl,\n EmbeddingService,\n EmbeddingServiceImpl,\n CredentialReader,\n CredentialReaderImpl,\n // Tunnel and Subdomain exports\n CloudflareTunnelProvider,\n LocalTunnelProvider,\n SubdomainService,\n // IdP/SP separation exports\n MultiDomainIdentifierStrategy,\n SubdomainPodIdentifierStrategy,\n DisabledOidcHandler,\n DisabledIdentityProviderHandler,\n AutoDetectOidcHandler,\n AutoDetectIdentityProviderHandler,\n LoopbackClientIdAdapterFactory,\n ScopedPickWebIdHandler,\n UrlAwareRedisLocker,\n // Provision exports\n ProvisionPodCreator,\n ProvisionCodeCodec,\n LocalPodProvisioningService,\n // Authorization exports\n AuthModeSelector,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,6CAA2C;AAC3C,yGAAsG;AA0IlG,qHA1IK,2EAAoC,OA0IL;AAzIxC,6EAA0E;AA0ItE,kGA1IK,qCAAiB,OA0IL;AAzIrB,iGAA8F;AA0I1F,4GA1IK,yDAA2B,OA0IL;AAzI/B,mGAAgG;AA0I5F,6GA1IK,2DAA4B,OA0IL;AAzIhC,mFAAgF;A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zHO,+CAAsB,OAyHP;AAxHxB,uBAAuB;AACvB,yEAAsE;AA0HpE,oGA1HO,yCAAmB,OA0HP;AAzHrB,uEAAoE;AA0HlE,mGA1HO,uCAAkB,OA0HP;AAzHpB,yFAAsF;AA0HpF,4GA1HO,yDAA2B,OA0HP;AAzH7B,2BAA2B;AAC3B,uEAAoE;AA0HlE,iGA1HO,mCAAgB,OA0HP;AAhGlB,uCAAuC;AACvC,sEAAqE;AAA5D,8HAAA,qBAAqB,OAAA","sourcesContent":["import './runtime/configure-drizzle-solid';\nimport { RepresentationPartialConvertingStore } from './storage/RepresentationPartialConvertingStore';\nimport { MinioDataAccessor } from './storage/accessors/MinioDataAccessor';\nimport { QuadstoreSparqlDataAccessor } from './storage/accessors/QuadstoreSparqlDataAccessor';\nimport { QuintStoreSparqlDataAccessor } from './storage/accessors/QuintStoreSparqlDataAccessor';\nimport { SolidRdfDataAccessor } from './storage/accessors/SolidRdfDataAccessor';\nimport { MixDataAccessor } from './storage/accessors/MixDataAccessor';\nimport { ConfigurableLoggerFactory } from './logging/ConfigurableLoggerFactory';\nimport { SubgraphQueryEngine } from './storage/sparql/SubgraphQueryEngine';\nimport { QuadstoreSparqlEngine, QuintstoreSparqlEngine } from './storage/sparql/CompatibilitySparqlEngine';\nexport type { SparqlEngine } from './storage/sparql/SubgraphQueryEngine';\nexport type {\n RdfIndexStats,\n RdfIndexSpaceObject,\n RdfIndexMetrics,\n RdfIndexPutOptions,\n RdfPatternQuery,\n RdfQuadIndexOptions,\n RdfQuadIndexScanResult,\n RdfShadowBackfillOptions,\n RdfShadowBackfillResult,\n RdfShadowDiff,\n RdfShadowScanResult,\n RdfSourceInput,\n} from './storage/rdf/types';\nexport type { RdfSparqlCompileResult } from './storage/rdf/RdfSparqlAdapter';\nexport type { ShadowRdfQuintStoreOptions } from './storage/rdf/ShadowRdfQuintStore';\nexport type {\n SolidRdfSparqlEngineOptions,\n SolidRdfSparqlFallback,\n} from './storage/rdf/SolidRdfSparqlEngine';\nimport { SubgraphSparqlHttpHandler } from './http/SubgraphSparqlHttpHandler';\nimport { QuotaAdminHttpHandler } from './http/quota/QuotaAdminHttpHandler';\nimport { SparqlUpdateResourceStore } from './storage/SparqlUpdateResourceStore';\nimport { ClusterIngressRouter } from './http/ClusterIngressRouter';\nimport { ClusterWebSocketConfigurator } from './http/ClusterWebSocketConfigurator';\nimport { EdgeNodeDirectDebugHttpHandler } from './http/EdgeNodeDirectDebugHttpHandler';\nimport { EdgeNodeProxyHttpHandler } from './http/EdgeNodeProxyHttpHandler';\nimport { RouterHttpHandler } from './http/RouterHttpHandler';\nimport { RouterHttpRoute } from './http/RouterHttpRoute';\nimport { TracingHandler } from './http/TracingHandler';\nimport { TerminalHttpHandler } from './http/terminal/TerminalHttpHandler';\nimport { EdgeNodeCertificateHttpHandler } from './http/admin/EdgeNodeCertificateHttpHandler';\nimport { ReservedSuffixIdentifierGenerator } from './pods/ReservedSuffixIdentifierGenerator';\nimport { DrizzleIndexedStorage } from './identity/drizzle/DrizzleIndexedStorage';\nimport { ValidatingIdentityProviderHttpHandler } from './identity/ValidatingIdentityProviderHttpHandler';\nimport { PostgresKeyValueStorage } from './storage/keyvalue/PostgresKeyValueStorage';\nimport { RedisKeyValueStorage } from './storage/keyvalue/RedisKeyValueStorage';\nimport { SqliteKeyValueStorage } from './storage/keyvalue/SqliteKeyValueStorage';\nimport { DrizzleQuotaService } from './quota/DrizzleQuotaService';\nimport { NoopQuotaService } from './quota/NoopQuotaService';\nimport { HttpEntitlementProvider, NoopEntitlementProvider } from './quota/EntitlementProvider';\nimport { PerAccountQuotaStrategy } from './storage/quota/PerAccountQuotaStrategy';\nimport { TencentDnsProvider } from './dns/tencent/TencentDnsProvider';\nimport { EdgeNodeDnsCoordinator } from './edge/EdgeNodeDnsCoordinator';\nimport { Dns01CertificateProvisioner } from './edge/Dns01CertificateProvisioner';\nimport { SimpleEdgeNodeTunnelManager, NoopEdgeNodeTunnelManager } from './edge/EdgeNodeTunnelManager';\nimport { FrpTunnelManager } from './edge/FrpTunnelManager';\nimport { AcmeCertificateManager } from './edge/acme/AcmeCertificateManager';\nimport { EdgeNodeHealthProbeService } from './edge/EdgeNodeHealthProbeService';\nimport { EdgeNodeAgent } from './edge/EdgeNodeAgent';\nimport { EdgeNodeCertificateService } from './service/EdgeNodeCertificateService';\nimport { createBandwidthThrottleTransform } from './util/stream/BandwidthThrottleTransform';\nimport { UsageTrackingStore } from './storage/quota/UsageTrackingStore';\nimport { EdgeNodeModeDetector } from './edge/EdgeNodeModeDetector';\nimport { ClusterIdentifierStrategy } from './util/identifiers/ClusterIdentifierStrategy';\nimport { CenterNodeRegistrationService } from './identity/CenterNodeRegistrationService';\nimport { PodRoutingHttpHandler } from './http/PodRoutingHttpHandler';\nimport { ReactAppViewHandler } from './identity/ReactAppViewHandler';\nimport { SqliteQuintStore } from './storage/quint/SqliteQuintStore';\nimport { PgQuintStore } from './storage/quint/PgQuintStore';\nimport { QuintStore } from './storage/quint/types';\nimport { RdfQuadIndex } from './storage/rdf/RdfQuadIndex';\nimport { Rdf3xIndex } from './storage/rdf/Rdf3xIndex';\nimport { RdfSparqlAdapter } from './storage/rdf/RdfSparqlAdapter';\nimport { RdfTermDictionary } from './storage/rdf/RdfTermDictionary';\nimport { ShadowRdfQuintStore } from './storage/rdf/ShadowRdfQuintStore';\nimport { SolidRdfEngine } from './storage/rdf/SolidRdfEngine';\nimport { SolidRdfSparqlEngine } from './storage/rdf/SolidRdfSparqlEngine';\nimport type { EdgeNodeCertificateProvisioner } from './edge/EdgeNodeCertificateProvisioner';\n// Vector components\nimport { SqliteVectorStore, PostgresVectorStore } from './storage/vector/index';\nimport { VectorHttpHandler } from './http/vector/VectorHttpHandler';\nimport { ProviderRegistry } from './ai/service/ProviderRegistry';\nimport { ProviderRegistryImpl } from './ai/service/ProviderRegistryImpl';\nimport { EmbeddingService } from './ai/service/EmbeddingService';\nimport { EmbeddingServiceImpl } from './ai/service/EmbeddingServiceImpl';\nimport { CredentialReader } from './ai/service/CredentialReader';\nimport { CredentialReaderImpl } from './ai/service/CredentialReaderImpl';\nimport { VectorStore } from './storage/vector/VectorStore';\n// Tunnel and Subdomain components\nimport { CloudflareTunnelProvider } from './tunnel/CloudflareTunnelProvider';\nimport { LocalTunnelProvider } from './tunnel/LocalTunnelProvider';\nimport { SubdomainService } from './subdomain/SubdomainService';\nimport { UrlAwareRedisLocker } from './storage/locking/UrlAwareRedisLocker';\n// IdP/SP separation components\nimport { MultiDomainIdentifierStrategy } from './util/identifiers/MultiDomainIdentifierStrategy';\nimport { SubdomainPodIdentifierStrategy } from './util/identifiers/SubdomainPodIdentifierStrategy';\nimport { DisabledOidcHandler } from './identity/oidc/DisabledOidcHandler';\nimport { DisabledIdentityProviderHandler } from './identity/oidc/DisabledIdentityProviderHandler';\nimport { AutoDetectOidcHandler } from './identity/oidc/AutoDetectOidcHandler';\nimport { AutoDetectIdentityProviderHandler } from './identity/oidc/AutoDetectIdentityProviderHandler';\nimport { LoopbackClientIdAdapterFactory } from './identity/oidc/LoopbackClientIdAdapterFactory';\nimport { ScopedPickWebIdHandler } from './identity/oidc/ScopedPickWebIdHandler';\n// Provision components\nimport { ProvisionPodCreator } from './provision/ProvisionPodCreator';\nimport { ProvisionCodeCodec } from './provision/ProvisionCodeCodec';\nimport { LocalPodProvisioningService } from './provision/LocalPodProvisioningService';\n// Authorization components\nimport { AuthModeSelector } from './authorization/AuthModeSelector';\n\nexport type {\n DnsProvider,\n ListDnsRecordsInput,\n ListableDnsProvider,\n DeleteDnsRecordInput,\n DnsRecordSummary,\n UpsertDnsRecordInput,\n} from './dns/DnsProvider';\nexport type { EdgeNodeCertificateProvisioner } from './edge/EdgeNodeCertificateProvisioner';\nexport type { EdgeNodeTunnelManager } from './edge/interfaces/EdgeNodeTunnelManager';\nexport type { QuotaService, AccountQuota } from './quota/QuotaService';\nexport type { EntitlementProvider, AccountEntitlement } from './quota/EntitlementProvider';\n// Tunnel and Subdomain types\nexport type {\n TunnelProvider,\n TunnelConfig,\n TunnelSetupOptions,\n TunnelStatus,\n} from './tunnel/TunnelProvider';\nexport type {\n SubdomainRegistration,\n ConnectivityResult,\n SubdomainServiceOptions,\n} from './subdomain/SubdomainService';\n// Export the new AppStaticAssetHandler\nexport { AppStaticAssetHandler } from './http/AppStaticAssetHandler';\n\nexport { \n RepresentationPartialConvertingStore,\n MinioDataAccessor, \n QuadstoreSparqlDataAccessor,\n QuintStoreSparqlDataAccessor,\n SolidRdfDataAccessor,\n MixDataAccessor,\n ConfigurableLoggerFactory,\n SparqlUpdateResourceStore,\n SubgraphQueryEngine,\n QuadstoreSparqlEngine,\n QuintstoreSparqlEngine,\n SubgraphSparqlHttpHandler,\n QuotaAdminHttpHandler,\n ClusterIngressRouter,\n ClusterWebSocketConfigurator,\n EdgeNodeDirectDebugHttpHandler,\n EdgeNodeProxyHttpHandler,\n RouterHttpHandler,\n RouterHttpRoute,\n TracingHandler,\n EdgeNodeCertificateHttpHandler,\n TerminalHttpHandler,\n ReservedSuffixIdentifierGenerator,\n DrizzleIndexedStorage,\n ValidatingIdentityProviderHttpHandler,\n PostgresKeyValueStorage,\n RedisKeyValueStorage,\n SqliteKeyValueStorage,\n DrizzleQuotaService,\n NoopQuotaService,\n HttpEntitlementProvider,\n NoopEntitlementProvider,\n PerAccountQuotaStrategy,\n TencentDnsProvider,\n EdgeNodeDnsCoordinator,\n Dns01CertificateProvisioner,\n SimpleEdgeNodeTunnelManager,\n NoopEdgeNodeTunnelManager,\n FrpTunnelManager,\n EdgeNodeHealthProbeService,\n EdgeNodeAgent,\n EdgeNodeCertificateService,\n AcmeCertificateManager,\n EdgeNodeModeDetector,\n ClusterIdentifierStrategy,\n UsageTrackingStore,\n CenterNodeRegistrationService,\n PodRoutingHttpHandler,\n ReactAppViewHandler,\n // Quint exports\n QuintStore,\n SqliteQuintStore,\n PgQuintStore,\n // RDF engine exports\n RdfTermDictionary,\n RdfQuadIndex,\n Rdf3xIndex,\n RdfSparqlAdapter,\n ShadowRdfQuintStore,\n SolidRdfEngine,\n SolidRdfSparqlEngine,\n // Vector exports\n VectorStore,\n SqliteVectorStore,\n PostgresVectorStore,\n VectorHttpHandler,\n // Embedding exports\n ProviderRegistry,\n ProviderRegistryImpl,\n EmbeddingService,\n EmbeddingServiceImpl,\n CredentialReader,\n CredentialReaderImpl,\n // Tunnel and Subdomain exports\n CloudflareTunnelProvider,\n LocalTunnelProvider,\n SubdomainService,\n // IdP/SP separation exports\n MultiDomainIdentifierStrategy,\n SubdomainPodIdentifierStrategy,\n DisabledOidcHandler,\n DisabledIdentityProviderHandler,\n AutoDetectOidcHandler,\n AutoDetectIdentityProviderHandler,\n LoopbackClientIdAdapterFactory,\n ScopedPickWebIdHandler,\n UrlAwareRedisLocker,\n // Provision exports\n ProvisionPodCreator,\n ProvisionCodeCodec,\n LocalPodProvisioningService,\n // Authorization exports\n AuthModeSelector,\n};\n"]}
|
package/dist/runtime/Proxy.d.ts
CHANGED
|
@@ -20,7 +20,10 @@ export declare class GatewayProxy {
|
|
|
20
20
|
stop(): Promise<void>;
|
|
21
21
|
private handleRequest;
|
|
22
22
|
private shouldInspectRootMutation;
|
|
23
|
+
private shouldRejectRootResourceMutation;
|
|
24
|
+
private writeRootMutationForbidden;
|
|
23
25
|
private normalizeRootMutationProxyResponse;
|
|
26
|
+
private createRootMutationForbiddenBody;
|
|
24
27
|
private sanitizeProxyResponseHeaders;
|
|
25
28
|
private handleCorsPreflightRequest;
|
|
26
29
|
/**
|
package/dist/runtime/Proxy.js
CHANGED
|
@@ -148,6 +148,10 @@ class GatewayProxy {
|
|
|
148
148
|
}
|
|
149
149
|
// 3. CSS Routing (Default)
|
|
150
150
|
if (this.targets.css) {
|
|
151
|
+
if (this.shouldRejectRootResourceMutation(req)) {
|
|
152
|
+
this.writeRootMutationForbidden(res);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
151
155
|
const interceptedRequest = req;
|
|
152
156
|
interceptedRequest.__xpodInspectRootMutation = this.shouldInspectRootMutation(req);
|
|
153
157
|
this.proxy.web(req, res, {
|
|
@@ -169,6 +173,23 @@ class GatewayProxy {
|
|
|
169
173
|
const segments = pathname.split('/').filter(Boolean);
|
|
170
174
|
return segments.length === 1 && !segments[0].startsWith('.');
|
|
171
175
|
}
|
|
176
|
+
shouldRejectRootResourceMutation(req) {
|
|
177
|
+
const method = (req.method ?? 'GET').toUpperCase();
|
|
178
|
+
if (!['POST', 'PUT', 'PATCH', 'DELETE'].includes(method)) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
const pathname = new URL(req.url ?? '/', 'http://localhost').pathname;
|
|
182
|
+
const segments = pathname.split('/').filter(Boolean);
|
|
183
|
+
return segments.length === 1 && !segments[0].startsWith('.') && !pathname.endsWith('/');
|
|
184
|
+
}
|
|
185
|
+
writeRootMutationForbidden(res) {
|
|
186
|
+
const body = Buffer.from(JSON.stringify(this.createRootMutationForbiddenBody()));
|
|
187
|
+
res.writeHead(403, {
|
|
188
|
+
'Content-Type': 'application/json',
|
|
189
|
+
'Content-Length': String(body.byteLength),
|
|
190
|
+
});
|
|
191
|
+
res.end(body);
|
|
192
|
+
}
|
|
172
193
|
normalizeRootMutationProxyResponse(proxyRes, body) {
|
|
173
194
|
const headers = { ...proxyRes.headers };
|
|
174
195
|
const statusCode = proxyRes.statusCode ?? 500;
|
|
@@ -181,13 +202,7 @@ class GatewayProxy {
|
|
|
181
202
|
if (statusCode === 500 &&
|
|
182
203
|
bodyText.includes('Cannot obtain the parent of') &&
|
|
183
204
|
bodyText.includes('because it is a root container')) {
|
|
184
|
-
const normalizedBody = Buffer.from(JSON.stringify(
|
|
185
|
-
name: 'ForbiddenHttpError',
|
|
186
|
-
message: 'Write to server root is not allowed.',
|
|
187
|
-
statusCode: 403,
|
|
188
|
-
errorCode: 'H403',
|
|
189
|
-
details: { cause: 'root-container-write' },
|
|
190
|
-
}));
|
|
205
|
+
const normalizedBody = Buffer.from(JSON.stringify(this.createRootMutationForbiddenBody()));
|
|
191
206
|
delete headers['content-length'];
|
|
192
207
|
delete headers['transfer-encoding'];
|
|
193
208
|
headers['content-type'] = 'application/json';
|
|
@@ -198,6 +213,15 @@ class GatewayProxy {
|
|
|
198
213
|
headers['content-length'] = String(body.byteLength);
|
|
199
214
|
return { statusCode, headers, body };
|
|
200
215
|
}
|
|
216
|
+
createRootMutationForbiddenBody() {
|
|
217
|
+
return {
|
|
218
|
+
name: 'ForbiddenHttpError',
|
|
219
|
+
message: 'Write to server root is not allowed.',
|
|
220
|
+
statusCode: 403,
|
|
221
|
+
errorCode: 'H403',
|
|
222
|
+
details: { cause: 'root-container-write' },
|
|
223
|
+
};
|
|
224
|
+
}
|
|
201
225
|
sanitizeProxyResponseHeaders(req, proxyRes) {
|
|
202
226
|
const method = (req.method ?? 'GET').toUpperCase();
|
|
203
227
|
const statusCode = proxyRes.statusCode ?? 200;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Proxy.js","sourceRoot":"","sources":["../../src/runtime/Proxy.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAmC;AACnC,gDAAwB;AACxB,iEAAqD;AAErD,iEAA8D;AAK9D,uDAAuD;AACvD,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;IACrE,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE;QACd,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ;QAC3D,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM;KAChE;IACD,cAAc,EAAE;QACd,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe;QACrE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa;QAC1D,WAAW,EAAE,kBAAkB,EAAE,cAAc;KAChD;CACF,CAAC;AAEF,MAAa,YAAY;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rB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;YAC7D,CAAC;YACD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,UAAU;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;IAEO,eAAe,CAAC,MAAoC;QAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,aAAa,CAAC,MAA0B;QAC9C,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO;gBACL,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,QAAQ,EAAE,OAAO;aAClB,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,GAAI,CAAC;IACrB,CAAC;CACF;AApVD,oCAoVC","sourcesContent":["import httpProxy from 'http-proxy';\nimport http from 'http';\nimport { getLoggerFor } from 'global-logger-factory';\nimport type { Supervisor } from '../supervisor/Supervisor';\nimport { nodeRuntimeHost } from './host/node/NodeRuntimeHost';\nimport type { RuntimeHost, RuntimeListenEndpoint } from './host/types';\n\ntype InterceptedRequest = http.IncomingMessage & { __xpodInspectRootMutation?: boolean };\n\n// CORS configuration matching CSS CorsHandler defaults\nconst CORS_CONFIG = {\n methods: ['GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'],\n credentials: true,\n allowedHeaders: [\n 'Authorization', 'Content-Type', 'Accept', 'DPoP', 'Origin',\n 'X-Requested-With', 'If-Match', 'If-None-Match', 'Slug', 'Link',\n ],\n exposedHeaders: [\n 'Accept-Patch', 'Accept-Post', 'Accept-Put', 'Allow', 'Content-Range',\n 'ETag', 'Last-Modified', 'Link', 'Location', 'Updates-Via',\n 'WAC-Allow', 'Www-Authenticate', 'X-Request-Id',\n ],\n};\n\nexport class GatewayProxy {\n private readonly logger = getLoggerFor(this);\n private proxy: httpProxy;\n private server: http.Server;\n private targets: { css?: GatewayProxyTarget; api?: GatewayProxyTarget } = {};\n private readonly runtimeHost: RuntimeHost;\n private readonly listenEndpoint: RuntimeListenEndpoint;\n private readonly exitOnStop: boolean;\n private readonly shutdownHandler?: () => Promise<void>;\n private readonly baseUrl?: string;\n\n constructor(\n port: number | undefined,\n private supervisor: Supervisor,\n bindHost = '0.0.0.0',\n options: GatewayProxyOptions = {},\n ) {\n this.runtimeHost = options.runtimeHost ?? nodeRuntimeHost;\n this.listenEndpoint = options.listenEndpoint ?? this.runtimeHost.createListenEndpoint({\n port,\n host: bindHost,\n socketPath: options.socketPath,\n });\n this.exitOnStop = options.exitOnStop ?? false;\n this.shutdownHandler = options.shutdownHandler;\n this.baseUrl = options.baseUrl;\n this.proxy = httpProxy.createProxyServer({\n xfwd: true,\n });\n\n this.proxy.on('error', (err, _req, res) => {\n this.logger.error('Proxy error:', err);\n if (res && 'writeHead' in res && !res.headersSent) {\n res.writeHead(502, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: 'Service Unavailable', details: err.message }));\n }\n });\n\n this.proxy.on('proxyRes', (proxyRes, req, res) => {\n this.sanitizeProxyResponseHeaders(req, proxyRes);\n const interceptedRequest = req as InterceptedRequest;\n const outgoing = res as http.ServerResponse;\n if (!interceptedRequest.__xpodInspectRootMutation || !outgoing || outgoing.headersSent) {\n return;\n }\n\n const chunks: Buffer[] = [];\n proxyRes.on('data', (chunk) => {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n });\n proxyRes.on('end', () => {\n const originalBody = Buffer.concat(chunks);\n const rewritten = this.normalizeRootMutationProxyResponse(proxyRes, originalBody);\n outgoing.writeHead(rewritten.statusCode, rewritten.headers);\n outgoing.end(rewritten.body);\n });\n });\n\n this.server = http.createServer(this.handleRequest.bind(this));\n\n this.server.on('upgrade', (req, socket, head) => {\n const url = req.url ?? '/';\n\n // Route /ws/* WebSocket connections to API server\n if (url.startsWith('/ws/') && this.targets.api) {\n this.proxy.ws(req, socket, head, { target: this.toProxyTarget(this.targets.api) as any });\n } else if (this.targets.css) {\n this.proxy.ws(req, socket, head, { target: this.toProxyTarget(this.targets.css) as any });\n } else {\n socket.destroy();\n }\n });\n }\n\n public setTargets(targets: { css?: string | GatewayProxyTarget; api?: string | GatewayProxyTarget }): void {\n this.targets = {\n css: this.normalizeTarget(targets.css),\n api: this.normalizeTarget(targets.api),\n };\n }\n\n public async start(): Promise<void> {\n await this.runtimeHost.listen(this.server, this.listenEndpoint);\n this.logger.info(`Listening on ${this.runtimeHost.formatListenEndpoint(this.listenEndpoint)}`);\n }\n\n public stop(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.proxy.close();\n this.runtimeHost.close(this.server, this.listenEndpoint).then(() => {\n resolve();\n }, reject);\n });\n }\n\n private handleRequest(req: http.IncomingMessage, res: http.ServerResponse): void {\n const url = req.url ?? '/';\n const origin = req.headers.origin;\n\n // Store original host for x-forwarded-host before any rewrites\n const originalHost = req.headers.host;\n\n // Set x-forwarded-proto based on CSS_BASE_URL\n const baseUrl = this.baseUrl ?? process.env.CSS_BASE_URL ?? '';\n if (baseUrl.startsWith('https')) {\n req.headers['x-forwarded-proto'] = 'https';\n }\n\n // Rewrite Host header to match CSS_BASE_URL for proper routing\n if (baseUrl) {\n try {\n const parsedBaseUrl = new URL(baseUrl);\n req.headers.host = parsedBaseUrl.host;\n req.headers['x-forwarded-host'] = parsedBaseUrl.host;\n } catch {\n if (!req.headers['x-forwarded-host']) {\n req.headers['x-forwarded-host'] = originalHost;\n }\n }\n } else if (!req.headers['x-forwarded-host']) {\n req.headers['x-forwarded-host'] = originalHost;\n }\n\n this.logger.debug(\n `${req.method} ${url} x-forwarded-proto=${req.headers['x-forwarded-proto']} x-forwarded-host=${req.headers['x-forwarded-host']} host=${req.headers.host}`,\n );\n\n // 1. Internal service endpoints\n if (url.startsWith('/service/')) {\n if (req.method === 'OPTIONS') {\n this.handleCorsPreflightRequest(res, origin);\n return;\n }\n if (origin) {\n this.addCorsHeaders(res, origin);\n }\n void this.handleInternalApi(req, res);\n return;\n }\n\n // 2. API Server Routing (/v1 or /api)\n\n // 2a. Dashboard UI is served by API server under /dashboard/*\n if ((url === '/dashboard' || url.startsWith('/dashboard/')) && this.targets.api) {\n this.proxy.web(req, res, { target: this.toProxyTarget(this.targets.api) as any });\n return;\n }\n\n if ((url.startsWith('/v1/') || url.startsWith('/api/') || url.startsWith('/provision/')) && this.targets.api) {\n this.proxy.web(req, res, { target: this.toProxyTarget(this.targets.api) as any });\n return;\n }\n\n // 3. CSS Routing (Default)\n if (this.targets.css) {\n const interceptedRequest = req as InterceptedRequest;\n interceptedRequest.__xpodInspectRootMutation = this.shouldInspectRootMutation(req);\n this.proxy.web(req, res, {\n target: this.toProxyTarget(this.targets.css) as any,\n ...(interceptedRequest.__xpodInspectRootMutation ? { selfHandleResponse: true } : {}),\n } as any);\n } else {\n res.writeHead(503);\n res.end('CSS Service Not Available');\n }\n }\n\n private shouldInspectRootMutation(req: http.IncomingMessage): boolean {\n const method = (req.method ?? 'GET').toUpperCase();\n if (![ 'POST', 'PUT', 'PATCH', 'DELETE' ].includes(method)) {\n return false;\n }\n\n const pathname = new URL(req.url ?? '/', 'http://localhost').pathname;\n const segments = pathname.split('/').filter(Boolean);\n return segments.length === 1 && !segments[0].startsWith('.');\n }\n\n private normalizeRootMutationProxyResponse(\n proxyRes: http.IncomingMessage,\n body: Buffer,\n ): { statusCode: number; headers: http.OutgoingHttpHeaders; body: Buffer } {\n const headers: http.OutgoingHttpHeaders = { ...proxyRes.headers };\n const statusCode = proxyRes.statusCode ?? 500;\n const contentType = typeof proxyRes.headers['content-type'] === 'string'\n ? proxyRes.headers['content-type']\n : Array.isArray(proxyRes.headers['content-type'])\n ? proxyRes.headers['content-type'][0] ?? ''\n : '';\n const bodyText = contentType.includes('application/json') ? body.toString('utf8') : '';\n\n if (\n statusCode === 500 &&\n bodyText.includes('Cannot obtain the parent of') &&\n bodyText.includes('because it is a root container')\n ) {\n const normalizedBody = Buffer.from(JSON.stringify({\n name: 'ForbiddenHttpError',\n message: 'Write to server root is not allowed.',\n statusCode: 403,\n errorCode: 'H403',\n details: { cause: 'root-container-write' },\n }));\n delete headers['content-length'];\n delete headers['transfer-encoding'];\n headers['content-type'] = 'application/json';\n headers['content-length'] = String(normalizedBody.byteLength);\n return { statusCode: 403, headers, body: normalizedBody };\n }\n\n delete headers['transfer-encoding'];\n headers['content-length'] = String(body.byteLength);\n return { statusCode, headers, body };\n }\n\n private sanitizeProxyResponseHeaders(req: http.IncomingMessage, proxyRes: http.IncomingMessage): void {\n const method = (req.method ?? 'GET').toUpperCase();\n const statusCode = proxyRes.statusCode ?? 200;\n const headers = proxyRes.headers as Record<string, string | string[] | undefined>;\n const transferEncoding = headers['transfer-encoding'];\n const hasTransferEncoding = Array.isArray(transferEncoding)\n ? transferEncoding.some((value) => value.toLowerCase().includes('chunked'))\n : typeof transferEncoding === 'string'\n ? transferEncoding.toLowerCase().includes('chunked')\n : false;\n\n if (method === 'HEAD' || statusCode === 204 || statusCode === 304 || (statusCode >= 100 && statusCode < 200)) {\n delete headers['transfer-encoding'];\n return;\n }\n\n if (hasTransferEncoding && headers['content-length'] !== undefined) {\n delete headers['content-length'];\n }\n }\n\n private handleCorsPreflightRequest(\n res: http.ServerResponse,\n origin: string | undefined,\n ): void {\n this.addCorsHeaders(res, origin);\n res.writeHead(204);\n res.end();\n }\n\n /**\n * Add CORS headers matching CSS CorsHandler configuration\n */\n private addCorsHeaders(res: http.ServerResponse, origin: string | undefined): void {\n res.setHeader('Access-Control-Allow-Origin', origin || '*');\n res.setHeader('Access-Control-Allow-Credentials', String(CORS_CONFIG.credentials));\n res.setHeader('Access-Control-Allow-Methods', CORS_CONFIG.methods.join(', '));\n res.setHeader('Access-Control-Allow-Headers', CORS_CONFIG.allowedHeaders.join(', '));\n res.setHeader('Access-Control-Expose-Headers', CORS_CONFIG.exposedHeaders.join(', '));\n }\n\n private async handleInternalApi(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {\n try {\n const reqUrl = req.url ?? '/';\n const parsed = new URL(reqUrl, 'http://localhost');\n const pathname = parsed.pathname;\n\n if (pathname === '/service/status') {\n const status = this.supervisor.getAllStatus();\n const cssReady = await this.isCssReady();\n const code = cssReady ? 200 : 503;\n res.writeHead(code, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(status));\n return;\n }\n\n if (pathname === '/service/logs') {\n const level = parsed.searchParams.get('level') ?? undefined;\n const source = parsed.searchParams.get('source') ?? undefined;\n const limitValue = parsed.searchParams.get('limit');\n const limit = limitValue ? parseInt(limitValue, 10) : undefined;\n\n const logs = this.supervisor.getLogs({\n level,\n source,\n limit: Number.isFinite(limit as number) ? limit : undefined,\n });\n\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(logs));\n return;\n }\n\n if (pathname === '/service/stop' && req.method === 'POST') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ ok: true }));\n setImmediate(() => {\n const shutdown = this.shutdownHandler ?? (() => this.supervisor.stopAll());\n void shutdown().then(() => {\n if (this.exitOnStop) {\n process.exit(0);\n }\n });\n });\n return;\n }\n\n res.writeHead(404);\n res.end('Not Found');\n } catch (error) {\n this.logger.error('Internal service endpoint failed:', error);\n if (!res.headersSent) {\n res.writeHead(500, { 'Content-Type': 'application/json' });\n }\n res.end(JSON.stringify({ error: 'Internal Server Error' }));\n }\n }\n\n private async isCssReady(): Promise<boolean> {\n if (!this.targets.css) {\n return true;\n }\n\n return this.runtimeHost.isConnectionTargetReady(this.targets.css, 1_500);\n }\n\n private normalizeTarget(target?: string | GatewayProxyTarget): GatewayProxyTarget | undefined {\n if (!target) {\n return undefined;\n }\n if (typeof target === 'string') {\n return { url: target };\n }\n return target;\n }\n\n private toProxyTarget(target: GatewayProxyTarget): string | { socketPath: string; protocol: string } {\n if (target.socketPath) {\n return {\n socketPath: target.socketPath,\n protocol: 'http:',\n };\n }\n return target.url!;\n }\n}\n\nexport interface GatewayProxyTarget {\n url?: string;\n socketPath?: string;\n}\n\nexport interface GatewayProxyOptions {\n socketPath?: string;\n listenEndpoint?: RuntimeListenEndpoint;\n runtimeHost?: RuntimeHost;\n exitOnStop?: boolean;\n shutdownHandler?: () => Promise<void>;\n baseUrl?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Proxy.js","sourceRoot":"","sources":["../../src/runtime/Proxy.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAmC;AACnC,gDAAwB;AACxB,iEAAqD;AAErD,iEAA8D;AAa9D,uDAAuD;AACvD,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;IACrE,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE;QACd,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ;QAC3D,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM;KAChE;IACD,cAAc,EAAE;QACd,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe;QACrE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa;QAC1D,WAAW,EAAE,kBAAkB,EAAE,cAAc;KAChD;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CAAC;gBACrB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;YAC7D,CAAC;YACD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,UAAU;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;IAEO,eAAe,CAAC,MAAoC;QAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,aAAa,CAAC,MAA0B;QAC9C,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO;gBACL,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,QAAQ,EAAE,OAAO;aAClB,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,GAAI,CAAC;IACrB,CAAC;CACF;AAjXD,oCAiXC","sourcesContent":["import httpProxy from 'http-proxy';\nimport http from 'http';\nimport { getLoggerFor } from 'global-logger-factory';\nimport type { Supervisor } from '../supervisor/Supervisor';\nimport { nodeRuntimeHost } from './host/node/NodeRuntimeHost';\nimport type { RuntimeHost, RuntimeListenEndpoint } from './host/types';\n\ntype InterceptedRequest = http.IncomingMessage & { __xpodInspectRootMutation?: boolean };\n\ninterface RootMutationForbiddenBody {\n name: 'ForbiddenHttpError';\n message: string;\n statusCode: 403;\n errorCode: 'H403';\n details: { cause: 'root-container-write' };\n}\n\n// CORS configuration matching CSS CorsHandler defaults\nconst CORS_CONFIG = {\n methods: ['GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'],\n credentials: true,\n allowedHeaders: [\n 'Authorization', 'Content-Type', 'Accept', 'DPoP', 'Origin',\n 'X-Requested-With', 'If-Match', 'If-None-Match', 'Slug', 'Link',\n ],\n exposedHeaders: [\n 'Accept-Patch', 'Accept-Post', 'Accept-Put', 'Allow', 'Content-Range',\n 'ETag', 'Last-Modified', 'Link', 'Location', 'Updates-Via',\n 'WAC-Allow', 'Www-Authenticate', 'X-Request-Id',\n ],\n};\n\nexport class GatewayProxy {\n private readonly logger = getLoggerFor(this);\n private proxy: httpProxy;\n private server: http.Server;\n private targets: { css?: GatewayProxyTarget; api?: GatewayProxyTarget } = {};\n private readonly runtimeHost: RuntimeHost;\n private readonly listenEndpoint: RuntimeListenEndpoint;\n private readonly exitOnStop: boolean;\n private readonly shutdownHandler?: () => Promise<void>;\n private readonly baseUrl?: string;\n\n constructor(\n port: number | undefined,\n private supervisor: Supervisor,\n bindHost = '0.0.0.0',\n options: GatewayProxyOptions = {},\n ) {\n this.runtimeHost = options.runtimeHost ?? nodeRuntimeHost;\n this.listenEndpoint = options.listenEndpoint ?? this.runtimeHost.createListenEndpoint({\n port,\n host: bindHost,\n socketPath: options.socketPath,\n });\n this.exitOnStop = options.exitOnStop ?? false;\n this.shutdownHandler = options.shutdownHandler;\n this.baseUrl = options.baseUrl;\n this.proxy = httpProxy.createProxyServer({\n xfwd: true,\n });\n\n this.proxy.on('error', (err, _req, res) => {\n this.logger.error('Proxy error:', err);\n if (res && 'writeHead' in res && !res.headersSent) {\n res.writeHead(502, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: 'Service Unavailable', details: err.message }));\n }\n });\n\n this.proxy.on('proxyRes', (proxyRes, req, res) => {\n this.sanitizeProxyResponseHeaders(req, proxyRes);\n const interceptedRequest = req as InterceptedRequest;\n const outgoing = res as http.ServerResponse;\n if (!interceptedRequest.__xpodInspectRootMutation || !outgoing || outgoing.headersSent) {\n return;\n }\n\n const chunks: Buffer[] = [];\n proxyRes.on('data', (chunk) => {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n });\n proxyRes.on('end', () => {\n const originalBody = Buffer.concat(chunks);\n const rewritten = this.normalizeRootMutationProxyResponse(proxyRes, originalBody);\n outgoing.writeHead(rewritten.statusCode, rewritten.headers);\n outgoing.end(rewritten.body);\n });\n });\n\n this.server = http.createServer(this.handleRequest.bind(this));\n\n this.server.on('upgrade', (req, socket, head) => {\n const url = req.url ?? '/';\n\n // Route /ws/* WebSocket connections to API server\n if (url.startsWith('/ws/') && this.targets.api) {\n this.proxy.ws(req, socket, head, { target: this.toProxyTarget(this.targets.api) as any });\n } else if (this.targets.css) {\n this.proxy.ws(req, socket, head, { target: this.toProxyTarget(this.targets.css) as any });\n } else {\n socket.destroy();\n }\n });\n }\n\n public setTargets(targets: { css?: string | GatewayProxyTarget; api?: string | GatewayProxyTarget }): void {\n this.targets = {\n css: this.normalizeTarget(targets.css),\n api: this.normalizeTarget(targets.api),\n };\n }\n\n public async start(): Promise<void> {\n await this.runtimeHost.listen(this.server, this.listenEndpoint);\n this.logger.info(`Listening on ${this.runtimeHost.formatListenEndpoint(this.listenEndpoint)}`);\n }\n\n public stop(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.proxy.close();\n this.runtimeHost.close(this.server, this.listenEndpoint).then(() => {\n resolve();\n }, reject);\n });\n }\n\n private handleRequest(req: http.IncomingMessage, res: http.ServerResponse): void {\n const url = req.url ?? '/';\n const origin = req.headers.origin;\n\n // Store original host for x-forwarded-host before any rewrites\n const originalHost = req.headers.host;\n\n // Set x-forwarded-proto based on CSS_BASE_URL\n const baseUrl = this.baseUrl ?? process.env.CSS_BASE_URL ?? '';\n if (baseUrl.startsWith('https')) {\n req.headers['x-forwarded-proto'] = 'https';\n }\n\n // Rewrite Host header to match CSS_BASE_URL for proper routing\n if (baseUrl) {\n try {\n const parsedBaseUrl = new URL(baseUrl);\n req.headers.host = parsedBaseUrl.host;\n req.headers['x-forwarded-host'] = parsedBaseUrl.host;\n } catch {\n if (!req.headers['x-forwarded-host']) {\n req.headers['x-forwarded-host'] = originalHost;\n }\n }\n } else if (!req.headers['x-forwarded-host']) {\n req.headers['x-forwarded-host'] = originalHost;\n }\n\n this.logger.debug(\n `${req.method} ${url} x-forwarded-proto=${req.headers['x-forwarded-proto']} x-forwarded-host=${req.headers['x-forwarded-host']} host=${req.headers.host}`,\n );\n\n // 1. Internal service endpoints\n if (url.startsWith('/service/')) {\n if (req.method === 'OPTIONS') {\n this.handleCorsPreflightRequest(res, origin);\n return;\n }\n if (origin) {\n this.addCorsHeaders(res, origin);\n }\n void this.handleInternalApi(req, res);\n return;\n }\n\n // 2. API Server Routing (/v1 or /api)\n\n // 2a. Dashboard UI is served by API server under /dashboard/*\n if ((url === '/dashboard' || url.startsWith('/dashboard/')) && this.targets.api) {\n this.proxy.web(req, res, { target: this.toProxyTarget(this.targets.api) as any });\n return;\n }\n\n if ((url.startsWith('/v1/') || url.startsWith('/api/') || url.startsWith('/provision/')) && this.targets.api) {\n this.proxy.web(req, res, { target: this.toProxyTarget(this.targets.api) as any });\n return;\n }\n\n // 3. CSS Routing (Default)\n if (this.targets.css) {\n if (this.shouldRejectRootResourceMutation(req)) {\n this.writeRootMutationForbidden(res);\n return;\n }\n\n const interceptedRequest = req as InterceptedRequest;\n interceptedRequest.__xpodInspectRootMutation = this.shouldInspectRootMutation(req);\n this.proxy.web(req, res, {\n target: this.toProxyTarget(this.targets.css) as any,\n ...(interceptedRequest.__xpodInspectRootMutation ? { selfHandleResponse: true } : {}),\n } as any);\n } else {\n res.writeHead(503);\n res.end('CSS Service Not Available');\n }\n }\n\n private shouldInspectRootMutation(req: http.IncomingMessage): boolean {\n const method = (req.method ?? 'GET').toUpperCase();\n if (![ 'POST', 'PUT', 'PATCH', 'DELETE' ].includes(method)) {\n return false;\n }\n\n const pathname = new URL(req.url ?? '/', 'http://localhost').pathname;\n const segments = pathname.split('/').filter(Boolean);\n return segments.length === 1 && !segments[0].startsWith('.');\n }\n\n private shouldRejectRootResourceMutation(req: http.IncomingMessage): boolean {\n const method = (req.method ?? 'GET').toUpperCase();\n if (![ 'POST', 'PUT', 'PATCH', 'DELETE' ].includes(method)) {\n return false;\n }\n\n const pathname = new URL(req.url ?? '/', 'http://localhost').pathname;\n const segments = pathname.split('/').filter(Boolean);\n return segments.length === 1 && !segments[0].startsWith('.') && !pathname.endsWith('/');\n }\n\n private writeRootMutationForbidden(res: http.ServerResponse): void {\n const body = Buffer.from(JSON.stringify(this.createRootMutationForbiddenBody()));\n res.writeHead(403, {\n 'Content-Type': 'application/json',\n 'Content-Length': String(body.byteLength),\n });\n res.end(body);\n }\n\n private normalizeRootMutationProxyResponse(\n proxyRes: http.IncomingMessage,\n body: Buffer,\n ): { statusCode: number; headers: http.OutgoingHttpHeaders; body: Buffer } {\n const headers: http.OutgoingHttpHeaders = { ...proxyRes.headers };\n const statusCode = proxyRes.statusCode ?? 500;\n const contentType = typeof proxyRes.headers['content-type'] === 'string'\n ? proxyRes.headers['content-type']\n : Array.isArray(proxyRes.headers['content-type'])\n ? proxyRes.headers['content-type'][0] ?? ''\n : '';\n const bodyText = contentType.includes('application/json') ? body.toString('utf8') : '';\n\n if (\n statusCode === 500 &&\n bodyText.includes('Cannot obtain the parent of') &&\n bodyText.includes('because it is a root container')\n ) {\n const normalizedBody = Buffer.from(JSON.stringify(this.createRootMutationForbiddenBody()));\n delete headers['content-length'];\n delete headers['transfer-encoding'];\n headers['content-type'] = 'application/json';\n headers['content-length'] = String(normalizedBody.byteLength);\n return { statusCode: 403, headers, body: normalizedBody };\n }\n\n delete headers['transfer-encoding'];\n headers['content-length'] = String(body.byteLength);\n return { statusCode, headers, body };\n }\n\n private createRootMutationForbiddenBody(): RootMutationForbiddenBody {\n return {\n name: 'ForbiddenHttpError',\n message: 'Write to server root is not allowed.',\n statusCode: 403,\n errorCode: 'H403',\n details: { cause: 'root-container-write' },\n };\n }\n\n private sanitizeProxyResponseHeaders(req: http.IncomingMessage, proxyRes: http.IncomingMessage): void {\n const method = (req.method ?? 'GET').toUpperCase();\n const statusCode = proxyRes.statusCode ?? 200;\n const headers = proxyRes.headers as Record<string, string | string[] | undefined>;\n const transferEncoding = headers['transfer-encoding'];\n const hasTransferEncoding = Array.isArray(transferEncoding)\n ? transferEncoding.some((value) => value.toLowerCase().includes('chunked'))\n : typeof transferEncoding === 'string'\n ? transferEncoding.toLowerCase().includes('chunked')\n : false;\n\n if (method === 'HEAD' || statusCode === 204 || statusCode === 304 || (statusCode >= 100 && statusCode < 200)) {\n delete headers['transfer-encoding'];\n return;\n }\n\n if (hasTransferEncoding && headers['content-length'] !== undefined) {\n delete headers['content-length'];\n }\n }\n\n private handleCorsPreflightRequest(\n res: http.ServerResponse,\n origin: string | undefined,\n ): void {\n this.addCorsHeaders(res, origin);\n res.writeHead(204);\n res.end();\n }\n\n /**\n * Add CORS headers matching CSS CorsHandler configuration\n */\n private addCorsHeaders(res: http.ServerResponse, origin: string | undefined): void {\n res.setHeader('Access-Control-Allow-Origin', origin || '*');\n res.setHeader('Access-Control-Allow-Credentials', String(CORS_CONFIG.credentials));\n res.setHeader('Access-Control-Allow-Methods', CORS_CONFIG.methods.join(', '));\n res.setHeader('Access-Control-Allow-Headers', CORS_CONFIG.allowedHeaders.join(', '));\n res.setHeader('Access-Control-Expose-Headers', CORS_CONFIG.exposedHeaders.join(', '));\n }\n\n private async handleInternalApi(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {\n try {\n const reqUrl = req.url ?? '/';\n const parsed = new URL(reqUrl, 'http://localhost');\n const pathname = parsed.pathname;\n\n if (pathname === '/service/status') {\n const status = this.supervisor.getAllStatus();\n const cssReady = await this.isCssReady();\n const code = cssReady ? 200 : 503;\n res.writeHead(code, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(status));\n return;\n }\n\n if (pathname === '/service/logs') {\n const level = parsed.searchParams.get('level') ?? undefined;\n const source = parsed.searchParams.get('source') ?? undefined;\n const limitValue = parsed.searchParams.get('limit');\n const limit = limitValue ? parseInt(limitValue, 10) : undefined;\n\n const logs = this.supervisor.getLogs({\n level,\n source,\n limit: Number.isFinite(limit as number) ? limit : undefined,\n });\n\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(logs));\n return;\n }\n\n if (pathname === '/service/stop' && req.method === 'POST') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ ok: true }));\n setImmediate(() => {\n const shutdown = this.shutdownHandler ?? (() => this.supervisor.stopAll());\n void shutdown().then(() => {\n if (this.exitOnStop) {\n process.exit(0);\n }\n });\n });\n return;\n }\n\n res.writeHead(404);\n res.end('Not Found');\n } catch (error) {\n this.logger.error('Internal service endpoint failed:', error);\n if (!res.headersSent) {\n res.writeHead(500, { 'Content-Type': 'application/json' });\n }\n res.end(JSON.stringify({ error: 'Internal Server Error' }));\n }\n }\n\n private async isCssReady(): Promise<boolean> {\n if (!this.targets.css) {\n return true;\n }\n\n return this.runtimeHost.isConnectionTargetReady(this.targets.css, 1_500);\n }\n\n private normalizeTarget(target?: string | GatewayProxyTarget): GatewayProxyTarget | undefined {\n if (!target) {\n return undefined;\n }\n if (typeof target === 'string') {\n return { url: target };\n }\n return target;\n }\n\n private toProxyTarget(target: GatewayProxyTarget): string | { socketPath: string; protocol: string } {\n if (target.socketPath) {\n return {\n socketPath: target.socketPath,\n protocol: 'http:',\n };\n }\n return target.url!;\n }\n}\n\nexport interface GatewayProxyTarget {\n url?: string;\n socketPath?: string;\n}\n\nexport interface GatewayProxyOptions {\n socketPath?: string;\n listenEndpoint?: RuntimeListenEndpoint;\n runtimeHost?: RuntimeHost;\n exitOnStop?: boolean;\n shutdownHandler?: () => Promise<void>;\n baseUrl?: string;\n}\n"]}
|