@undefineds.co/xpod 0.3.58 → 0.3.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/config/cli.json +88 -0
- package/config/cloud.json +32 -1
- package/config/components-ignore.json +3 -0
- package/config/extensions.local.initializer.json +44 -0
- package/config/resolver.json +86 -0
- package/config/xpod.base.json +4 -0
- package/dist/agents/AgentExecutorFactory.d.ts +3 -3
- package/dist/agents/AgentExecutorFactory.js +28 -15
- package/dist/agents/AgentExecutorFactory.js.map +1 -1
- package/dist/agents/BaseAgentExecutor.d.ts +2 -1
- package/dist/agents/BaseAgentExecutor.js +1 -0
- package/dist/agents/BaseAgentExecutor.js.map +1 -1
- package/dist/agents/ClaudeExecutor.d.ts +3 -1
- package/dist/agents/ClaudeExecutor.js +18 -12
- package/dist/agents/ClaudeExecutor.js.map +1 -1
- package/dist/agents/config/resolve.js +0 -21
- package/dist/agents/config/resolve.js.map +1 -1
- package/dist/agents/config/types.d.ts +2 -7
- package/dist/agents/config/types.js +2 -1
- package/dist/agents/config/types.js.map +1 -1
- package/dist/agents/types.d.ts +18 -0
- package/dist/agents/types.js.map +1 -1
- package/dist/ai/schema/types.d.ts +2 -1
- package/dist/ai/schema/types.js +1 -0
- package/dist/ai/schema/types.js.map +1 -1
- package/dist/ai/service/CredentialReader.d.ts +3 -1
- package/dist/ai/service/CredentialReader.js.map +1 -1
- package/dist/ai/service/CredentialReaderImpl.d.ts +3 -1
- package/dist/ai/service/CredentialReaderImpl.js +24 -2
- package/dist/ai/service/CredentialReaderImpl.js.map +1 -1
- package/dist/ai/service/EmbeddingServiceImpl.js +13 -2
- package/dist/ai/service/EmbeddingServiceImpl.js.map +1 -1
- package/dist/ai/service/ProviderRegistry.d.ts +4 -0
- package/dist/ai/service/ProviderRegistry.js.map +1 -1
- package/dist/ai/service/ProviderRegistry.jsonld +4 -0
- package/dist/ai/service/ProviderRegistryImpl.d.ts +4 -1
- package/dist/ai/service/ProviderRegistryImpl.js +26 -4
- package/dist/ai/service/ProviderRegistryImpl.js.map +1 -1
- package/dist/ai/service/ProviderRegistryImpl.jsonld +12 -0
- package/dist/ai/service/defaultEmbeddingProfile.d.ts +5 -0
- package/dist/ai/service/defaultEmbeddingProfile.js +31 -0
- package/dist/ai/service/defaultEmbeddingProfile.js.map +1 -0
- package/dist/ai/service/index.d.ts +1 -0
- package/dist/ai/service/index.js +1 -0
- package/dist/ai/service/index.js.map +1 -1
- package/dist/ai/service/types.d.ts +1 -0
- package/dist/ai/service/types.js.map +1 -1
- package/dist/api/ApiServer.js +17 -2
- package/dist/api/ApiServer.js.map +1 -1
- package/dist/api/ai-gateway/AiGatewayService.d.ts +106 -0
- package/dist/api/ai-gateway/AiGatewayService.js +527 -0
- package/dist/api/ai-gateway/AiGatewayService.js.map +1 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.d.ts +38 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js +128 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js.map +1 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.d.ts +25 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js +91 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.d.ts +28 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.js +162 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +56 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +143 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.d.ts +26 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js +97 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.d.ts +20 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js +37 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js.map +1 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.d.ts +41 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js +221 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js.map +1 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +54 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +152 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js.map +1 -0
- package/dist/api/ai-gateway/connect/index.d.ts +367 -0
- package/dist/api/ai-gateway/connect/index.js +1061 -0
- package/dist/api/ai-gateway/connect/index.js.map +1 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.d.ts +40 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js +59 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.d.ts +14 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.js +11 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.d.ts +27 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.js +3 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.d.ts +27 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js +145 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.d.ts +13 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js +133 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.d.ts +23 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js +62 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.d.ts +23 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js +173 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/errors.d.ts +21 -0
- package/dist/api/ai-gateway/errors.js +50 -0
- package/dist/api/ai-gateway/errors.js.map +1 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js +111 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.js +99 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.js +232 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/index.d.ts +3 -0
- package/dist/api/ai-gateway/protocol/index.js +10 -0
- package/dist/api/ai-gateway/protocol/index.js.map +1 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.d.ts +7 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js +37 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.d.ts +9 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js +127 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.d.ts +8 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js +47 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.d.ts +8 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js +57 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.d.ts +1 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js +6 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.d.ts +13 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js +34 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +68 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js +288 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.d.ts +88 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js +645 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.d.ts +13 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +48 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js.map +1 -0
- package/dist/api/ai-gateway/providers/index.d.ts +9 -0
- package/dist/api/ai-gateway/providers/index.js +26 -0
- package/dist/api/ai-gateway/providers/index.js.map +1 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js +83 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js +70 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.d.ts +214 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js +511 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/index.d.ts +6 -0
- package/dist/api/ai-gateway/quota/index.js +23 -0
- package/dist/api/ai-gateway/quota/index.js.map +1 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.d.ts +26 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js +67 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/routing/ModelRouter.d.ts +84 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js +274 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js.map +1 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.d.ts +39 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js +122 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.d.ts +49 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.js +66 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.d.ts +25 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js +50 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js.map +1 -0
- package/dist/api/ai-gateway/types.d.ts +112 -0
- package/dist/api/ai-gateway/types.js +305 -0
- package/dist/api/ai-gateway/types.js.map +1 -0
- package/dist/api/auth/AuthContext.d.ts +18 -3
- package/dist/api/auth/AuthContext.js +13 -2
- package/dist/api/auth/AuthContext.js.map +1 -1
- package/dist/api/auth/Authenticator.d.ts +3 -0
- package/dist/api/auth/Authenticator.js.map +1 -1
- package/dist/api/auth/ClientCredentialsAuthenticator.d.ts +2 -6
- package/dist/api/auth/ClientCredentialsAuthenticator.js +12 -30
- package/dist/api/auth/ClientCredentialsAuthenticator.js.map +1 -1
- package/dist/api/auth/SolidTokenAuthenticator.d.ts +2 -0
- package/dist/api/auth/SolidTokenAuthenticator.js +88 -2
- package/dist/api/auth/SolidTokenAuthenticator.js.map +1 -1
- package/dist/api/auth/TokenIdentity.d.ts +6 -0
- package/dist/api/auth/TokenIdentity.js +31 -0
- package/dist/api/auth/TokenIdentity.js.map +1 -0
- package/dist/api/chatkit/ai-provider.d.ts +9 -23
- package/dist/api/chatkit/ai-provider.js +30 -153
- package/dist/api/chatkit/ai-provider.js.map +1 -1
- package/dist/api/chatkit/default-agent.d.ts +24 -15
- package/dist/api/chatkit/default-agent.js +24 -83
- package/dist/api/chatkit/default-agent.js.map +1 -1
- package/dist/api/chatkit/index.d.ts +2 -1
- package/dist/api/chatkit/index.js +3 -1
- package/dist/api/chatkit/index.js.map +1 -1
- package/dist/api/chatkit/pod-store.d.ts +13 -1
- package/dist/api/chatkit/pod-store.js +127 -7
- package/dist/api/chatkit/pod-store.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.d.ts +0 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js +14 -51
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpRunner.js +2 -1
- package/dist/api/chatkit/runtime/AcpRunner.js.map +1 -1
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.d.ts +15 -1
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.js +52 -34
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.js.map +1 -1
- package/dist/api/chatkit/service.d.ts +8 -1
- package/dist/api/chatkit/service.js +46 -5
- package/dist/api/chatkit/service.js.map +1 -1
- package/dist/api/chatkit/store.d.ts +23 -1
- package/dist/api/chatkit/store.js +56 -0
- package/dist/api/chatkit/store.js.map +1 -1
- package/dist/api/chatkit/types.d.ts +1 -0
- package/dist/api/chatkit/types.js.map +1 -1
- package/dist/api/container/common.js +286 -13
- package/dist/api/container/common.js.map +1 -1
- package/dist/api/container/index.js +126 -6
- package/dist/api/container/index.js.map +1 -1
- package/dist/api/container/local.js +50 -6
- package/dist/api/container/local.js.map +1 -1
- package/dist/api/container/rdf.d.ts +15 -0
- package/dist/api/container/rdf.js +90 -0
- package/dist/api/container/rdf.js.map +1 -0
- package/dist/api/container/routes.js +151 -11
- package/dist/api/container/routes.js.map +1 -1
- package/dist/api/container/types.d.ts +96 -0
- package/dist/api/container/types.js.map +1 -1
- package/dist/api/handlers/AdminHandler.d.ts +25 -2
- package/dist/api/handlers/AdminHandler.js +60 -10
- package/dist/api/handlers/AdminHandler.js.map +1 -1
- package/dist/api/handlers/AiClientConfigurationHandler.d.ts +7 -0
- package/dist/api/handlers/AiClientConfigurationHandler.js +202 -0
- package/dist/api/handlers/AiClientConfigurationHandler.js.map +1 -0
- package/dist/api/handlers/AiGatewayHandler.d.ts +23 -0
- package/dist/api/handlers/AiGatewayHandler.js +231 -0
- package/dist/api/handlers/AiGatewayHandler.js.map +1 -0
- package/dist/api/handlers/AiGatewayManagementHandler.d.ts +24 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js +503 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js.map +1 -0
- package/dist/api/handlers/ChatHandler.d.ts +11 -12
- package/dist/api/handlers/ChatHandler.js +12 -219
- package/dist/api/handlers/ChatHandler.js.map +1 -1
- package/dist/api/handlers/DashboardHandler.js +22 -116
- package/dist/api/handlers/DashboardHandler.js.map +1 -1
- package/dist/api/handlers/NetworkSettingsHandler.d.ts +97 -0
- package/dist/api/handlers/NetworkSettingsHandler.js +511 -0
- package/dist/api/handlers/NetworkSettingsHandler.js.map +1 -0
- package/dist/api/handlers/PodSettingsHandler.d.ts +79 -0
- package/dist/api/handlers/PodSettingsHandler.js +162 -0
- package/dist/api/handlers/PodSettingsHandler.js.map +1 -0
- package/dist/api/handlers/ProvisionHandler.d.ts +3 -1
- package/dist/api/handlers/ProvisionHandler.js +22 -87
- package/dist/api/handlers/ProvisionHandler.js.map +1 -1
- package/dist/api/handlers/RdfStatsHandler.d.ts +6 -0
- package/dist/api/handlers/RdfStatsHandler.js +85 -0
- package/dist/api/handlers/RdfStatsHandler.js.map +1 -0
- package/dist/api/handlers/SettingsHandler.d.ts +5 -0
- package/dist/api/handlers/SettingsHandler.js +13 -0
- package/dist/api/handlers/SettingsHandler.js.map +1 -0
- package/dist/api/handlers/StaticSpaHandler.d.ts +8 -0
- package/dist/api/handlers/StaticSpaHandler.js +102 -0
- package/dist/api/handlers/StaticSpaHandler.js.map +1 -0
- package/dist/api/handlers/index.d.ts +1 -0
- package/dist/api/handlers/index.js +1 -0
- package/dist/api/handlers/index.js.map +1 -1
- package/dist/api/http/readBoundedJsonBody.d.ts +14 -0
- package/dist/api/http/readBoundedJsonBody.js +58 -0
- package/dist/api/http/readBoundedJsonBody.js.map +1 -0
- package/dist/api/middleware/AuthMiddleware.d.ts +1 -0
- package/dist/api/middleware/AuthMiddleware.js +33 -4
- package/dist/api/middleware/AuthMiddleware.js.map +1 -1
- package/dist/api/runs/AgentRuntimeTypes.d.ts +18 -3
- package/dist/api/runs/AgentRuntimeTypes.js +61 -0
- package/dist/api/runs/AgentRuntimeTypes.js.map +1 -1
- package/dist/api/runs/InngestRunExecutionBackend.d.ts +28 -3
- package/dist/api/runs/InngestRunExecutionBackend.js +26 -3
- package/dist/api/runs/InngestRunExecutionBackend.js.map +1 -1
- package/dist/api/runs/ManagedRunWorker.d.ts +4 -1
- package/dist/api/runs/ManagedRunWorker.js +39 -8
- package/dist/api/runs/ManagedRunWorker.js.map +1 -1
- package/dist/api/runs/PiAgentRuntimeDriver.d.ts +5 -1
- package/dist/api/runs/PiAgentRuntimeDriver.js +94 -57
- package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -1
- package/dist/api/runs/RdfRunContextRetriever.d.ts +46 -0
- package/dist/api/runs/RdfRunContextRetriever.js +277 -0
- package/dist/api/runs/RdfRunContextRetriever.js.map +1 -0
- package/dist/api/runs/RunExecutionBackend.d.ts +38 -0
- package/dist/api/runs/RunExecutionBackend.js.map +1 -1
- package/dist/api/runs/RunStateCenter.d.ts +18 -3
- package/dist/api/runs/RunStateCenter.js +85 -24
- package/dist/api/runs/RunStateCenter.js.map +1 -1
- package/dist/api/runtime.js +163 -3
- package/dist/api/runtime.js.map +1 -1
- package/dist/api/service/AiClientConfigurationService.d.ts +97 -0
- package/dist/api/service/AiClientConfigurationService.js +379 -0
- package/dist/api/service/AiClientConfigurationService.js.map +1 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.d.ts +86 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.js +349 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.js.map +1 -0
- package/dist/api/service/RdfBenchmarkReportGate.d.ts +78 -0
- package/dist/api/service/RdfBenchmarkReportGate.js +197 -0
- package/dist/api/service/RdfBenchmarkReportGate.js.map +1 -0
- package/dist/api/service/RdfSearchIndexingService.d.ts +113 -0
- package/dist/api/service/RdfSearchIndexingService.js +272 -0
- package/dist/api/service/RdfSearchIndexingService.js.map +1 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.d.ts +27 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js +90 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js.map +1 -0
- package/dist/api/service/RdfStorageStatsService.d.ts +31 -0
- package/dist/api/service/RdfStorageStatsService.js +97 -0
- package/dist/api/service/RdfStorageStatsService.js.map +1 -0
- package/dist/api/service/VectorStoreService.d.ts +2 -0
- package/dist/api/service/VectorStoreService.js +70 -2
- package/dist/api/service/VectorStoreService.js.map +1 -1
- package/dist/api/service/VercelChatService.d.ts +27 -38
- package/dist/api/service/VercelChatService.js +153 -505
- package/dist/api/service/VercelChatService.js.map +1 -1
- package/dist/api/service/provider-http-transport.d.ts +21 -0
- package/dist/api/service/provider-http-transport.js +108 -2
- package/dist/api/service/provider-http-transport.js.map +1 -1
- package/dist/api/service/provider-registry.d.ts +5 -7
- package/dist/api/service/provider-registry.js +81 -64
- package/dist/api/service/provider-registry.js.map +1 -1
- package/dist/api/tasks/InngestTaskScheduler.d.ts +44 -4
- package/dist/api/tasks/TaskMaterializer.d.ts +10 -1
- package/dist/api/tasks/TaskMaterializer.js +39 -4
- package/dist/api/tasks/TaskMaterializer.js.map +1 -1
- package/dist/api/tasks/TaskService.d.ts +5 -1
- package/dist/api/tasks/TaskService.js +3 -0
- package/dist/api/tasks/TaskService.js.map +1 -1
- package/dist/cli/commands/rdf.d.ts +9 -0
- package/dist/cli/commands/rdf.js +66 -1
- package/dist/cli/commands/rdf.js.map +1 -1
- package/dist/cli/commands/start.js +3 -0
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/lib/solid-auth.d.ts +3 -3
- package/dist/cli/lib/solid-auth.js +4 -4
- package/dist/cli/lib/solid-auth.js.map +1 -1
- package/dist/components/components.jsonld +16 -0
- package/dist/components/context.jsonld +815 -28
- package/dist/document/Chunker.jsonld +110 -0
- package/dist/document/{DocumentParser.d.ts → DocumentReader.d.ts} +23 -11
- package/dist/document/{DocumentParser.js → DocumentReader.js} +2 -2
- package/dist/document/DocumentReader.js.map +1 -0
- package/dist/document/DocumentReader.jsonld +82 -0
- package/dist/document/HeadingChunker.jsonld +41 -0
- package/dist/document/{JinaDocumentParser.d.ts → JinaReader.d.ts} +7 -7
- package/dist/document/{JinaDocumentParser.js → JinaReader.js} +12 -12
- package/dist/document/JinaReader.js.map +1 -0
- package/dist/document/JinaReader.jsonld +133 -0
- package/dist/document/L0SourceSummary.d.ts +103 -0
- package/dist/document/L0SourceSummary.js +157 -0
- package/dist/document/L0SourceSummary.js.map +1 -0
- package/dist/document/L0SourceSummary.jsonld +326 -0
- package/dist/document/PaddleOcrReader.d.ts +40 -0
- package/dist/document/PaddleOcrReader.js +53 -0
- package/dist/document/PaddleOcrReader.js.map +1 -0
- package/dist/document/PaddleOcrReader.jsonld +234 -0
- package/dist/document/ReaderAiConfig.d.ts +50 -0
- package/dist/document/ReaderAiConfig.js +109 -0
- package/dist/document/ReaderAiConfig.js.map +1 -0
- package/dist/document/ReaderAiConfig.jsonld +185 -0
- package/dist/document/ReaderPolicy.d.ts +89 -0
- package/dist/document/ReaderPolicy.js +158 -0
- package/dist/document/ReaderPolicy.js.map +1 -0
- package/dist/document/ReaderPolicy.jsonld +218 -0
- package/dist/document/index.d.ts +6 -2
- package/dist/document/index.js +6 -2
- package/dist/document/index.js.map +1 -1
- package/dist/edge/DdnsManager.d.ts +1 -1
- package/dist/edge/DdnsManager.js.map +1 -1
- package/dist/edge/EdgeNodeAgent.d.ts +4 -0
- package/dist/edge/EdgeNodeAgent.js +6 -0
- package/dist/edge/EdgeNodeAgent.js.map +1 -1
- package/dist/edge/EdgeNodeAgent.jsonld +8 -0
- package/dist/edge/EdgeNodeAgentInitializer.d.ts +16 -0
- package/dist/edge/EdgeNodeAgentInitializer.js +51 -0
- package/dist/edge/EdgeNodeAgentInitializer.js.map +1 -1
- package/dist/edge/EdgeNodeAgentInitializer.jsonld +250 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.d.ts +34 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.js +111 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.js.map +1 -0
- package/dist/edge/acme/AcmeCertificateManager.d.ts +14 -1
- package/dist/edge/acme/AcmeCertificateManager.js +67 -7
- package/dist/edge/acme/AcmeCertificateManager.js.map +1 -1
- package/dist/edge/acme/AcmeCertificateManager.jsonld +22 -2
- package/dist/edge/acme/ClusterCertificateManager.d.ts +12 -0
- package/dist/edge/acme/ClusterCertificateManager.js +38 -0
- package/dist/edge/acme/ClusterCertificateManager.js.map +1 -1
- package/dist/extensions/ExtensionRuntime.d.ts +17 -0
- package/dist/extensions/ExtensionRuntime.js +171 -0
- package/dist/extensions/ExtensionRuntime.js.map +1 -0
- package/dist/extensions/PodCredentialResolver.d.ts +23 -0
- package/dist/extensions/PodCredentialResolver.js +139 -0
- package/dist/extensions/PodCredentialResolver.js.map +1 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.js +20 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/types.d.ts +73 -0
- package/dist/extensions/types.js +3 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/http/SubgraphSparqlHttpHandler.d.ts +20 -1
- package/dist/http/SubgraphSparqlHttpHandler.js +324 -43
- package/dist/http/SubgraphSparqlHttpHandler.js.map +1 -1
- package/dist/http/SubgraphSparqlHttpHandler.jsonld +87 -0
- package/dist/identity/drizzle/EdgeNodeRepository.js +3 -2
- package/dist/identity/drizzle/EdgeNodeRepository.js.map +1 -1
- package/dist/identity/drizzle/schema.pg.js +1 -1
- package/dist/identity/drizzle/schema.pg.js.map +1 -1
- package/dist/identity/drizzle/schema.sqlite.js +1 -1
- package/dist/identity/drizzle/schema.sqlite.js.map +1 -1
- package/dist/identity/oidc/ScopedPickWebIdHandler.js +5 -5
- package/dist/identity/oidc/ScopedPickWebIdHandler.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/provision/LocalProvisionState.d.ts +28 -0
- package/dist/provision/LocalProvisionState.js +124 -0
- package/dist/provision/LocalProvisionState.js.map +1 -0
- package/dist/provision/ProvisionCodeCodec.d.ts +7 -3
- package/dist/provision/ProvisionCodeCodec.js +10 -3
- package/dist/provision/ProvisionCodeCodec.js.map +1 -1
- package/dist/provision/ProvisionPodCreator.d.ts +15 -1
- package/dist/provision/ProvisionPodCreator.js +68 -1
- package/dist/provision/ProvisionPodCreator.js.map +1 -1
- package/dist/provision/ProvisionPodCreator.jsonld +31 -0
- package/dist/provision/ServiceAccessTokenCodec.d.ts +45 -0
- package/dist/provision/ServiceAccessTokenCodec.js +86 -0
- package/dist/provision/ServiceAccessTokenCodec.js.map +1 -0
- package/dist/runtime/GatewayAdminProxyAuth.d.ts +29 -0
- package/dist/runtime/GatewayAdminProxyAuth.js +108 -0
- package/dist/runtime/GatewayAdminProxyAuth.js.map +1 -0
- package/dist/runtime/Proxy.d.ts +10 -0
- package/dist/runtime/Proxy.js +64 -6
- package/dist/runtime/Proxy.js.map +1 -1
- package/dist/runtime/XpodRuntime.js +1 -0
- package/dist/runtime/XpodRuntime.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -0
- package/dist/runtime/bootstrap.js +29 -0
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/css-process.d.ts +1 -0
- package/dist/runtime/css-process.js +1 -0
- package/dist/runtime/css-process.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lifecycle.d.ts +3 -1
- package/dist/runtime/lifecycle.js +3 -1
- package/dist/runtime/lifecycle.js.map +1 -1
- package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js +2 -0
- package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js.map +1 -1
- package/dist/runtime/runner/types.d.ts +3 -0
- package/dist/runtime/runner/types.js.map +1 -1
- package/dist/runtime/runtime-types.d.ts +2 -0
- package/dist/runtime/runtime-types.js.map +1 -1
- package/dist/runtime/safe-env.d.ts +15 -0
- package/dist/runtime/safe-env.js +109 -0
- package/dist/runtime/safe-env.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +18 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.d.ts +17 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.js +61 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.js.map +1 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.jsonld +124 -0
- package/dist/security/secret-cell/SecretCellVault.d.ts +55 -0
- package/dist/security/secret-cell/SecretCellVault.js +242 -0
- package/dist/security/secret-cell/SecretCellVault.js.map +1 -0
- package/dist/security/secret-cell/SecretCellVault.jsonld +207 -0
- package/dist/security/secret-cell/index.d.ts +2 -0
- package/dist/security/secret-cell/index.js +11 -0
- package/dist/security/secret-cell/index.js.map +1 -0
- package/dist/solidfs/CompositeSolidFsSyncer.d.ts +18 -0
- package/dist/solidfs/CompositeSolidFsSyncer.js +32 -0
- package/dist/solidfs/CompositeSolidFsSyncer.js.map +1 -0
- package/dist/solidfs/LocalSolidFS.js +25 -1
- package/dist/solidfs/LocalSolidFS.js.map +1 -1
- package/dist/solidfs/RdfIndexSolidFsSyncer.d.ts +41 -2
- package/dist/solidfs/RdfIndexSolidFsSyncer.js +331 -21
- package/dist/solidfs/RdfIndexSolidFsSyncer.js.map +1 -1
- package/dist/solidfs/SolidFsMetaNotes.d.ts +25 -0
- package/dist/solidfs/SolidFsMetaNotes.js +103 -0
- package/dist/solidfs/SolidFsMetaNotes.js.map +1 -0
- package/dist/solidfs/SolidFsSyncJournal.d.ts +2 -2
- package/dist/solidfs/SolidFsSyncJournal.js +9 -4
- package/dist/solidfs/SolidFsSyncJournal.js.map +1 -1
- package/dist/solidfs/SolidFsSyncJournal.jsonld +119 -0
- package/dist/solidfs/WorkspacePrompt.d.ts +13 -0
- package/dist/solidfs/WorkspacePrompt.js +42 -0
- package/dist/solidfs/WorkspacePrompt.js.map +1 -0
- package/dist/solidfs/index.d.ts +3 -0
- package/dist/solidfs/index.js +3 -0
- package/dist/solidfs/index.js.map +1 -1
- package/dist/solidfs/types.d.ts +12 -2
- package/dist/solidfs/types.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.d.ts +36 -4
- package/dist/storage/accessors/MixDataAccessor.js +222 -23
- package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.jsonld +89 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.d.ts +6 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.js +35 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.js.map +1 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.jsonld +20 -0
- package/dist/storage/database/PostgresPoolManager.d.ts +1 -0
- package/dist/storage/database/PostgresPoolManager.js +2 -2
- package/dist/storage/database/PostgresPoolManager.js.map +1 -1
- package/dist/storage/locking/UrlAwareRedisLocker.d.ts +2 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js +65 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js.map +1 -1
- package/dist/storage/locking/UrlAwareRedisLocker.jsonld +19 -0
- package/dist/storage/rdf/PostgresRdfEngine.d.ts +286 -9
- package/dist/storage/rdf/PostgresRdfEngine.js +10773 -2084
- package/dist/storage/rdf/PostgresRdfEngine.js.map +1 -1
- package/dist/storage/rdf/PostgresRdfEngine.jsonld +1693 -89
- package/dist/storage/rdf/PostgresRdfSqlExecutor.d.ts +24 -0
- package/dist/storage/rdf/PostgresRdfSqlExecutor.js +131 -0
- package/dist/storage/rdf/PostgresRdfSqlExecutor.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.d.ts +54 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.js +1255 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.jsonld +487 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.d.ts +46 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.js +1165 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.jsonld +423 -0
- package/dist/storage/rdf/Rdf3xIndex.d.ts +14 -1
- package/dist/storage/rdf/Rdf3xIndex.js +286 -2
- package/dist/storage/rdf/Rdf3xIndex.js.map +1 -1
- package/dist/storage/rdf/Rdf3xIndex.jsonld +36 -0
- package/dist/storage/rdf/Rdf3xSchema.d.ts +5 -1
- package/dist/storage/rdf/Rdf3xSchema.js +17 -3
- package/dist/storage/rdf/Rdf3xSchema.js.map +1 -1
- package/dist/storage/rdf/RdfAccessScope.d.ts +22 -0
- package/dist/storage/rdf/RdfAccessScope.js +345 -0
- package/dist/storage/rdf/RdfAccessScope.js.map +1 -0
- package/dist/storage/rdf/RdfAccessScope.jsonld +45 -0
- package/dist/storage/rdf/RdfFusionRankPlan.d.ts +2 -0
- package/dist/storage/rdf/RdfFusionRankPlan.js +186 -0
- package/dist/storage/rdf/RdfFusionRankPlan.js.map +1 -0
- package/dist/storage/rdf/RdfJoinShape.d.ts +8 -0
- package/dist/storage/rdf/RdfJoinShape.js +31 -0
- package/dist/storage/rdf/RdfJoinShape.js.map +1 -0
- package/dist/storage/rdf/RdfQuadIndex.d.ts +5 -2
- package/dist/storage/rdf/RdfQuadIndex.js +94 -6
- package/dist/storage/rdf/RdfQuadIndex.js.map +1 -1
- package/dist/storage/rdf/RdfQuadIndex.jsonld +12 -0
- package/dist/storage/rdf/RdfQueryExecutor.d.ts +3 -4
- package/dist/storage/rdf/RdfQueryExecutor.js +235 -8
- package/dist/storage/rdf/RdfQueryExecutor.js.map +1 -1
- package/dist/storage/rdf/RdfSearchSourceFilter.d.ts +10 -0
- package/dist/storage/rdf/RdfSearchSourceFilter.js +83 -0
- package/dist/storage/rdf/RdfSearchSourceFilter.js.map +1 -0
- package/dist/storage/rdf/RdfSparqlAdapter.d.ts +27 -1
- package/dist/storage/rdf/RdfSparqlAdapter.js +265 -3
- package/dist/storage/rdf/RdfSparqlAdapter.js.map +1 -1
- package/dist/storage/rdf/RdfSparqlAdapter.jsonld +8 -0
- package/dist/storage/rdf/RdfTermDictionary.d.ts +7 -1
- package/dist/storage/rdf/RdfTermDictionary.js +139 -0
- package/dist/storage/rdf/RdfTermDictionary.js.map +1 -1
- package/dist/storage/rdf/RdfTermDictionary.jsonld +4 -0
- package/dist/storage/rdf/RdfTextIndex.d.ts +45 -2
- package/dist/storage/rdf/RdfTextIndex.js +810 -114
- package/dist/storage/rdf/RdfTextIndex.js.map +1 -1
- package/dist/storage/rdf/RdfTextIndex.jsonld +193 -0
- package/dist/storage/rdf/RdfTextProjection.d.ts +10 -0
- package/dist/storage/rdf/RdfTextProjection.js +258 -0
- package/dist/storage/rdf/RdfTextProjection.js.map +1 -0
- package/dist/storage/rdf/RdfVectorIndex.d.ts +30 -2
- package/dist/storage/rdf/RdfVectorIndex.js +461 -38
- package/dist/storage/rdf/RdfVectorIndex.js.map +1 -1
- package/dist/storage/rdf/RdfVectorIndex.jsonld +163 -0
- package/dist/storage/rdf/SolidRdfEngine.d.ts +12 -9
- package/dist/storage/rdf/SolidRdfEngine.js +48 -22
- package/dist/storage/rdf/SolidRdfEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.jsonld +33 -43
- package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +19 -8
- package/dist/storage/rdf/SolidRdfSparqlEngine.js +674 -44
- package/dist/storage/rdf/SolidRdfSparqlEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +51 -0
- package/dist/storage/rdf/index.d.ts +9 -5
- package/dist/storage/rdf/index.js +42 -1
- package/dist/storage/rdf/index.js.map +1 -1
- package/dist/storage/rdf/models-benchmark.d.ts +264 -2
- package/dist/storage/rdf/models-benchmark.js +4207 -155
- package/dist/storage/rdf/models-benchmark.js.map +1 -1
- package/dist/storage/rdf/types.d.ts +833 -4
- package/dist/storage/rdf/types.js.map +1 -1
- package/dist/storage/rdf/types.jsonld +348 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.d.ts +14 -13
- package/dist/storage/sparql/CompatibilitySparqlEngine.js +24 -24
- package/dist/storage/sparql/CompatibilitySparqlEngine.js.map +1 -1
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.d.ts +14 -13
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js +30 -18
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js.map +1 -1
- package/dist/storage/sparql/SubgraphQueryEngine.d.ts +21 -12
- package/dist/storage/sparql/SubgraphQueryEngine.js +12 -12
- package/dist/storage/sparql/SubgraphQueryEngine.js.map +1 -1
- package/dist/terminal/sandbox/MacOSSandbox.js +2 -1
- package/dist/terminal/sandbox/MacOSSandbox.js.map +1 -1
- package/dist/terminal/sandbox/index.js +2 -1
- package/dist/terminal/sandbox/index.js.map +1 -1
- package/dist/test-utils/no-auth-xpod.js +3 -0
- package/dist/test-utils/no-auth-xpod.js.map +1 -1
- package/dist/tunnel/LocalTunnelProvider.d.ts +3 -0
- package/dist/tunnel/LocalTunnelProvider.js +17 -1
- package/dist/tunnel/LocalTunnelProvider.js.map +1 -1
- package/dist/tunnel/LocalTunnelProvider.jsonld +23 -0
- package/dist/tunnel/SakuraFrpTunnelProvider.d.ts +3 -0
- package/dist/tunnel/SakuraFrpTunnelProvider.js +18 -2
- package/dist/tunnel/SakuraFrpTunnelProvider.js.map +1 -1
- package/dist/tunnel/TunnelProfiles.d.ts +22 -0
- package/dist/tunnel/TunnelProfiles.js +208 -0
- package/dist/tunnel/TunnelProfiles.js.map +1 -0
- package/dist/tunnel/index.d.ts +2 -0
- package/dist/tunnel/index.js +4 -1
- package/dist/tunnel/index.js.map +1 -1
- package/dist/util/identifiers/ClusterIdentifierStrategy.d.ts +3 -0
- package/dist/util/identifiers/ClusterIdentifierStrategy.js +18 -2
- package/dist/util/identifiers/ClusterIdentifierStrategy.js.map +1 -1
- package/dist/util/identifiers/ClusterIdentifierStrategy.jsonld +5 -1
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.d.ts +55 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.js +167 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.js +8 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.d.ts +4 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.js +36 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.d.ts +4 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.js +37 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.js +7 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.js +333 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.d.ts +22 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.js +43 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.d.ts +8 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.js +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.d.ts +120 -0
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.js +414 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.d.ts +32 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.js +212 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.js +90 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.cjs +668 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.d.ts +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.js +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.d.ts +21 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.js +82 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.d.ts +13 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.js +83 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.d.ts +17 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.js +153 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.d.ts +40 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.js +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/controller.d.ts +42 -0
- package/node_modules/@undefineds.co/ai-connection/dist/controller.js +289 -0
- package/node_modules/@undefineds.co/ai-connection/dist/index.d.ts +16 -0
- package/node_modules/@undefineds.co/ai-connection/dist/index.js +41 -0
- package/node_modules/@undefineds.co/ai-connection/dist/manifest.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/manifest.js +18 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.js +133 -0
- package/node_modules/@undefineds.co/ai-connection/package.json +50 -0
- package/node_modules/@undefineds.co/extension-sdk/README.md +299 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/index.d.ts +5 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/index.js +5 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/layout.d.ts +16 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/layout.js +36 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +79 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.d.ts +7 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.js +8 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.d.ts +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.js +49 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.d.ts +11 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.js +9 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.d.ts +38 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.js +132 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react.d.ts +12 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react.js +19 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/testing.d.ts +7 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/testing.js +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +225 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.js +142 -0
- package/node_modules/@undefineds.co/extension-sdk/package.json +49 -0
- package/node_modules/@undefineds.co/shared-ui/dist/badge.d.ts +8 -0
- package/node_modules/@undefineds.co/shared-ui/dist/badge.js +17 -0
- package/node_modules/@undefineds.co/shared-ui/dist/button.d.ts +10 -0
- package/node_modules/@undefineds.co/shared-ui/dist/button.js +30 -0
- package/node_modules/@undefineds.co/shared-ui/dist/card.d.ts +7 -0
- package/node_modules/@undefineds.co/shared-ui/dist/card.js +15 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.d.ts +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.js +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/input.d.ts +4 -0
- package/node_modules/@undefineds.co/shared-ui/dist/input.js +5 -0
- package/node_modules/@undefineds.co/shared-ui/dist/theme.css +121 -0
- package/node_modules/@undefineds.co/shared-ui/dist/utils.d.ts +2 -0
- package/node_modules/@undefineds.co/shared-ui/dist/utils.js +5 -0
- package/node_modules/@undefineds.co/shared-ui/dist/workspace.d.ts +23 -0
- package/node_modules/@undefineds.co/shared-ui/dist/workspace.js +38 -0
- package/node_modules/@undefineds.co/shared-ui/package.json +39 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/index.d.ts +3 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/index.js +3 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.d.ts +45 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.js +147 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/react.d.ts +15 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/react.js +15 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/session.d.ts +42 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/session.js +127 -0
- package/node_modules/@undefineds.co/solid-sdk/package.json +45 -0
- package/package.json +32 -12
- package/static/app/assets/index-BoYHJ6si.js +230 -0
- package/static/app/assets/inrupt-smoke.js +2 -2
- package/static/app/assets/main.css +1 -1
- package/static/app/assets/main.js +9 -9
- package/static/dashboard/assets/NetworkPage-Brt79fuQ.js +2 -0
- package/static/dashboard/assets/PaneListHeader-57nvMwH6.js +1 -0
- package/static/dashboard/assets/PodPage-CM6do1vB.js +2 -0
- package/static/dashboard/assets/ServicesPage-BUNxGJRz.js +1 -0
- package/static/dashboard/assets/card-B9Zjf_2p.js +1 -0
- package/static/dashboard/assets/dashboard-8C6o666W.js +305 -0
- package/static/dashboard/assets/dashboard-CSdewNeA.css +1 -0
- package/static/dashboard/assets/database-DPh9wDY9.js +1 -0
- package/static/dashboard/assets/external-link-VbMQvVMz.js +1 -0
- package/static/dashboard/assets/index-RfiFckzb.js +51 -0
- package/static/dashboard/assets/refresh-cw-BxVxNxNr.js +1 -0
- package/static/dashboard/assets/services-status-context-DKmJ7ISr.js +1 -0
- package/static/dashboard/dashboard.html +2 -2
- package/static/settings/assets/ModelsPage-D_IH7AH3.js +1 -0
- package/static/settings/assets/PaneListHeader-Bgaze006.js +1 -0
- package/static/settings/assets/PodPage-Cy1VNObw.js +2 -0
- package/static/settings/assets/ServicesPage-BsFaxVWC.js +1 -0
- package/static/settings/assets/SettingsPage-UafNWE_p.js +48 -0
- package/static/settings/assets/card-B_bXSIn-.js +1 -0
- package/static/settings/assets/services-status-context-DiX-AbrP.js +1 -0
- package/static/settings/assets/settings-B30oMfZq.js +305 -0
- package/static/settings/assets/settings-CSdewNeA.css +1 -0
- package/static/settings/assets/workspace-layout-Dv1Yn9Ci.js +1 -0
- package/static/settings/auth.html +21 -0
- package/static/settings/reachability.html +221 -0
- package/static/settings/reachability.svg +7 -0
- package/static/settings/reachability.webmanifest +18 -0
- package/static/settings/settings.html +13 -0
- package/static/settings/signal-pod.html +293 -0
- package/static/settings/vite.svg +1 -0
- package/dist/api/service/ai-gateway-transport.d.ts +0 -25
- package/dist/api/service/ai-gateway-transport.js +0 -136
- package/dist/api/service/ai-gateway-transport.js.map +0 -1
- package/dist/api/service/chat-protocol-adapters.d.ts +0 -5
- package/dist/api/service/chat-protocol-adapters.js +0 -146
- package/dist/api/service/chat-protocol-adapters.js.map +0 -1
- package/dist/api/service/chat-routing.d.ts +0 -8
- package/dist/api/service/chat-routing.js +0 -16
- package/dist/api/service/chat-routing.js.map +0 -1
- package/dist/api/service/platform-ai-config.d.ts +0 -10
- package/dist/api/service/platform-ai-config.js +0 -76
- package/dist/api/service/platform-ai-config.js.map +0 -1
- package/dist/document/DocumentParser.js.map +0 -1
- package/dist/document/JinaDocumentParser.js.map +0 -1
- package/static/app/assets/index-C1yksyT4.js +0 -171
- package/static/dashboard/assets/dashboard-BssaVKTn.css +0 -1
- package/static/dashboard/assets/dashboard-Ckuadl3C.js +0 -54
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GatewayApiKeyAuthenticator = exports.DEFAULT_GATEWAY_API_KEY_SCOPES = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const GatewayApiKey_1 = require("./GatewayApiKey");
|
|
6
|
+
const InvocationTokenCodec_1 = require("./InvocationTokenCodec");
|
|
7
|
+
const INVALID_GATEWAY_API_KEY = 'Invalid gateway API key';
|
|
8
|
+
exports.DEFAULT_GATEWAY_API_KEY_SCOPES = ['models:read', 'inference:write'];
|
|
9
|
+
class GatewayApiKeyAuthenticator {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.repository = options.repository;
|
|
12
|
+
this.deployment = options.deployment;
|
|
13
|
+
this.requiredScopes = options.requiredScopes ?? [...exports.DEFAULT_GATEWAY_API_KEY_SCOPES];
|
|
14
|
+
this.invocationTokenCodec = options.invocationTokenCodec;
|
|
15
|
+
this.invocationTokenAudience = options.invocationTokenAudience
|
|
16
|
+
? (0, InvocationTokenCodec_1.requireCanonicalOrigin)(options.invocationTokenAudience, 'audience')
|
|
17
|
+
: undefined;
|
|
18
|
+
this.invocationTokenIssuer = options.invocationTokenIssuer
|
|
19
|
+
? (0, InvocationTokenCodec_1.requireCanonicalOrigin)(options.invocationTokenIssuer, 'issuer')
|
|
20
|
+
: this.invocationTokenAudience;
|
|
21
|
+
this.now = options.now ?? (() => new Date());
|
|
22
|
+
this.maxClockSkewMs = options.maxClockSkewMs ?? 5_000;
|
|
23
|
+
if (!Number.isSafeInteger(this.maxClockSkewMs) || this.maxClockSkewMs < 0 || this.maxClockSkewMs > 30_000) {
|
|
24
|
+
throw new Error('Gateway invocation token clock skew must be between 0 and 30000 milliseconds');
|
|
25
|
+
}
|
|
26
|
+
this.dummyHash = (0, GatewayApiKey_1.hashGatewayApiKeySecret)('xpod-gateway-missing-key-dummy-secret');
|
|
27
|
+
}
|
|
28
|
+
canAuthenticate(request) {
|
|
29
|
+
const bearer = this.readBearer(request);
|
|
30
|
+
return Boolean(bearer
|
|
31
|
+
&& (bearer.startsWith('xpod_inv_v1.') || (0, GatewayApiKey_1.parseGatewayApiKey)(bearer)));
|
|
32
|
+
}
|
|
33
|
+
async authenticate(request) {
|
|
34
|
+
const bearer = this.readBearer(request);
|
|
35
|
+
if (bearer?.startsWith('xpod_inv_v1.')) {
|
|
36
|
+
return this.authenticateInvocationToken(bearer);
|
|
37
|
+
}
|
|
38
|
+
const parsed = bearer ? (0, GatewayApiKey_1.parseGatewayApiKey)(bearer) : undefined;
|
|
39
|
+
if (!parsed) {
|
|
40
|
+
return { success: false, error: INVALID_GATEWAY_API_KEY };
|
|
41
|
+
}
|
|
42
|
+
let record;
|
|
43
|
+
try {
|
|
44
|
+
record = await this.repository.findById(parsed.keyId);
|
|
45
|
+
}
|
|
46
|
+
catch (cause) {
|
|
47
|
+
return infrastructureError(cause);
|
|
48
|
+
}
|
|
49
|
+
if (!record) {
|
|
50
|
+
await (0, GatewayApiKey_1.verifyGatewayApiKeySecret)(parsed.secret, await this.dummyHash);
|
|
51
|
+
return invalidGatewayApiKey();
|
|
52
|
+
}
|
|
53
|
+
const secretMatches = await (0, GatewayApiKey_1.verifyGatewayApiKeySecret)(parsed.secret, record.secretHash);
|
|
54
|
+
if (!secretMatches
|
|
55
|
+
|| parsed.deployment !== this.deployment
|
|
56
|
+
|| record.deployment !== this.deployment
|
|
57
|
+
|| record.revokedAt
|
|
58
|
+
|| isExpired(record, this.now())
|
|
59
|
+
|| !hasRequiredScopes(record.scopes, this.requiredScopes)) {
|
|
60
|
+
return invalidGatewayApiKey();
|
|
61
|
+
}
|
|
62
|
+
const lastUsedAt = this.now();
|
|
63
|
+
try {
|
|
64
|
+
await this.repository.touchLastUsed(record.id, lastUsedAt);
|
|
65
|
+
}
|
|
66
|
+
catch (cause) {
|
|
67
|
+
return infrastructureError(cause);
|
|
68
|
+
}
|
|
69
|
+
const context = {
|
|
70
|
+
type: 'solid',
|
|
71
|
+
webId: record.owner,
|
|
72
|
+
accountId: record.owner,
|
|
73
|
+
viaGatewayApiKey: true,
|
|
74
|
+
gatewayKeyId: record.id,
|
|
75
|
+
gatewayKeyFingerprint: fingerprintGatewayBearer(bearer),
|
|
76
|
+
scopes: record.scopes,
|
|
77
|
+
tokenType: 'Bearer',
|
|
78
|
+
};
|
|
79
|
+
return { success: true, context };
|
|
80
|
+
}
|
|
81
|
+
authenticateInvocationToken(token) {
|
|
82
|
+
const claims = this.invocationTokenCodec?.decode(token);
|
|
83
|
+
if (!claims || !this.validInvocationClaims(claims)) {
|
|
84
|
+
return invalidGatewayApiKey();
|
|
85
|
+
}
|
|
86
|
+
const context = {
|
|
87
|
+
type: 'solid',
|
|
88
|
+
webId: claims.webId,
|
|
89
|
+
accountId: claims.webId,
|
|
90
|
+
viaGatewayApiKey: true,
|
|
91
|
+
internalInvocation: true,
|
|
92
|
+
gatewayKeyId: claims.jti,
|
|
93
|
+
gatewayKeyFingerprint: fingerprintGatewayBearer(token),
|
|
94
|
+
scopes: claims.scopes,
|
|
95
|
+
tokenType: 'Bearer',
|
|
96
|
+
};
|
|
97
|
+
return { success: true, context };
|
|
98
|
+
}
|
|
99
|
+
validInvocationClaims(claims) {
|
|
100
|
+
const now = this.now().getTime();
|
|
101
|
+
return (claims.deployment === this.deployment
|
|
102
|
+
&& (!this.invocationTokenAudience || claims.audience === this.invocationTokenAudience)
|
|
103
|
+
&& (!this.invocationTokenIssuer || claims.issuer === this.invocationTokenIssuer)
|
|
104
|
+
&& claims.issuedAt.getTime() <= now + this.maxClockSkewMs
|
|
105
|
+
&& claims.expiresAt.getTime() > now
|
|
106
|
+
&& hasRequiredScopes(claims.scopes, this.requiredScopes));
|
|
107
|
+
}
|
|
108
|
+
readBearer(request) {
|
|
109
|
+
const authorization = request.headers.authorization;
|
|
110
|
+
if (!authorization?.startsWith('Bearer ')) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
return authorization.slice(7).trim();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.GatewayApiKeyAuthenticator = GatewayApiKeyAuthenticator;
|
|
117
|
+
function fingerprintGatewayBearer(bearer) {
|
|
118
|
+
return `sha256:${(0, node_crypto_1.createHash)('sha256').update(bearer).digest('hex')}`;
|
|
119
|
+
}
|
|
120
|
+
function invalidGatewayApiKey() {
|
|
121
|
+
return {
|
|
122
|
+
success: false,
|
|
123
|
+
error: INVALID_GATEWAY_API_KEY,
|
|
124
|
+
category: 'invalid_credentials',
|
|
125
|
+
statusCode: 401,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function infrastructureError(cause) {
|
|
129
|
+
return {
|
|
130
|
+
success: false,
|
|
131
|
+
error: 'Gateway API key authentication unavailable',
|
|
132
|
+
category: 'service_unavailable',
|
|
133
|
+
statusCode: 503,
|
|
134
|
+
cause,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function isExpired(record, now) {
|
|
138
|
+
return Boolean(record.expiresAt && record.expiresAt.getTime() <= now.getTime());
|
|
139
|
+
}
|
|
140
|
+
function hasRequiredScopes(scopes, requiredScopes) {
|
|
141
|
+
return requiredScopes.every((scope) => scopes.includes(scope));
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=GatewayApiKeyAuthenticator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayApiKeyAuthenticator.js","sourceRoot":"","sources":["../../../../src/api/ai-gateway/auth/GatewayApiKeyAuthenticator.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AAGzC,mDAKyB;AAEzB,iEAAgE;AAuChE,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAC7C,QAAA,8BAA8B,GAAG,CAAC,aAAa,EAAE,iBAAiB,CAA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C,KAAK,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,oBAAoB;IAC3B,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,uBAAuB;QAC9B,QAAQ,EAAE,qBAAqB;QAC/B,UAAU,EAAE,GAAG;KAChB,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,4CAA4C;QACnD,QAAQ,EAAE,qBAAqB;QAC/B,UAAU,EAAE,GAAG;QACf,KAAK;KACN,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,MAA8B,EAAE,GAAS;IAC1D,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAgB,EAAE,cAAwB;IACnE,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import type { IncomingMessage } from 'node:http';\nimport { createHash } from 'node:crypto';\nimport type { Authenticator, AuthResult } from '../../auth/Authenticator';\nimport type { AuthContext, SolidAuthContext } from '../../auth/AuthContext';\nimport {\n type GatewayDeployment,\n hashGatewayApiKeySecret,\n parseGatewayApiKey,\n verifyGatewayApiKeySecret,\n} from './GatewayApiKey';\nimport type { InvocationTokenClaims, InvocationTokenCodec } from './InvocationTokenCodec';\nimport { requireCanonicalOrigin } from './InvocationTokenCodec';\n\nexport interface GatewayAccessKeyRecord {\n id: string;\n owner: string;\n secretHash: string;\n deployment: GatewayDeployment;\n scopes: string[];\n createdAt: Date;\n expiresAt?: Date;\n lastUsedAt?: Date;\n revokedAt?: Date;\n name?: string;\n}\n\nexport interface GatewayAccessKeyRepositoryContext {\n auth?: AuthContext;\n}\n\nexport interface GatewayAccessKeyRepository {\n createKeyId?(owner: string, deployment: GatewayDeployment): string;\n create(record: GatewayAccessKeyRecord, context?: GatewayAccessKeyRepositoryContext): Promise<GatewayAccessKeyRecord>;\n findById(id: string): Promise<GatewayAccessKeyRecord | undefined>;\n listByOwner(owner: string, context?: GatewayAccessKeyRepositoryContext): Promise<GatewayAccessKeyRecord[]>;\n revoke(id: string, revokedAt: Date, context?: GatewayAccessKeyRepositoryContext): Promise<GatewayAccessKeyRecord | undefined>;\n touchLastUsed(id: string, lastUsedAt: Date): Promise<void>;\n}\n\nexport interface GatewayApiKeyAuthenticatorOptions {\n repository: GatewayAccessKeyRepository;\n deployment: GatewayDeployment;\n requiredScopes?: string[];\n invocationTokenCodec?: InvocationTokenCodec;\n invocationTokenAudience?: string;\n invocationTokenIssuer?: string;\n now?: () => Date;\n maxClockSkewMs?: number;\n}\n\nconst INVALID_GATEWAY_API_KEY = 'Invalid gateway API key';\nexport const DEFAULT_GATEWAY_API_KEY_SCOPES = ['models:read', 'inference:write'] as const;\n\nexport class GatewayApiKeyAuthenticator implements Authenticator {\n private readonly repository: GatewayAccessKeyRepository;\n private readonly deployment: GatewayDeployment;\n private readonly requiredScopes: string[];\n private readonly invocationTokenCodec?: InvocationTokenCodec;\n private readonly invocationTokenAudience?: string;\n private readonly invocationTokenIssuer?: string;\n private readonly now: () => Date;\n private readonly maxClockSkewMs: number;\n private readonly dummyHash: Promise<string>;\n\n public constructor(options: GatewayApiKeyAuthenticatorOptions) {\n this.repository = options.repository;\n this.deployment = options.deployment;\n this.requiredScopes = options.requiredScopes ?? [...DEFAULT_GATEWAY_API_KEY_SCOPES];\n this.invocationTokenCodec = options.invocationTokenCodec;\n this.invocationTokenAudience = options.invocationTokenAudience\n ? requireCanonicalOrigin(options.invocationTokenAudience, 'audience')\n : undefined;\n this.invocationTokenIssuer = options.invocationTokenIssuer\n ? requireCanonicalOrigin(options.invocationTokenIssuer, 'issuer')\n : this.invocationTokenAudience;\n this.now = options.now ?? (() => new Date());\n this.maxClockSkewMs = options.maxClockSkewMs ?? 5_000;\n if (!Number.isSafeInteger(this.maxClockSkewMs) || this.maxClockSkewMs < 0 || this.maxClockSkewMs > 30_000) {\n throw new Error('Gateway invocation token clock skew must be between 0 and 30000 milliseconds');\n }\n this.dummyHash = hashGatewayApiKeySecret('xpod-gateway-missing-key-dummy-secret');\n }\n\n public canAuthenticate(request: IncomingMessage): boolean {\n const bearer = this.readBearer(request);\n return Boolean(\n bearer\n && (bearer.startsWith('xpod_inv_v1.') || parseGatewayApiKey(bearer)),\n );\n }\n\n public async authenticate(request: IncomingMessage): Promise<AuthResult> {\n const bearer = this.readBearer(request);\n if (bearer?.startsWith('xpod_inv_v1.')) {\n return this.authenticateInvocationToken(bearer);\n }\n const parsed = bearer ? parseGatewayApiKey(bearer) : undefined;\n if (!parsed) {\n return { success: false, error: INVALID_GATEWAY_API_KEY };\n }\n\n let record: GatewayAccessKeyRecord | undefined;\n try {\n record = await this.repository.findById(parsed.keyId);\n } catch (cause) {\n return infrastructureError(cause);\n }\n if (!record) {\n await verifyGatewayApiKeySecret(parsed.secret, await this.dummyHash);\n return invalidGatewayApiKey();\n }\n\n const secretMatches = await verifyGatewayApiKeySecret(parsed.secret, record.secretHash);\n if (\n !secretMatches\n || parsed.deployment !== this.deployment\n || record.deployment !== this.deployment\n || record.revokedAt\n || isExpired(record, this.now())\n || !hasRequiredScopes(record.scopes, this.requiredScopes)\n ) {\n return invalidGatewayApiKey();\n }\n\n const lastUsedAt = this.now();\n try {\n await this.repository.touchLastUsed(record.id, lastUsedAt);\n } catch (cause) {\n return infrastructureError(cause);\n }\n\n const context: SolidAuthContext = {\n type: 'solid',\n webId: record.owner,\n accountId: record.owner,\n viaGatewayApiKey: true,\n gatewayKeyId: record.id,\n gatewayKeyFingerprint: fingerprintGatewayBearer(bearer!),\n scopes: record.scopes,\n tokenType: 'Bearer',\n };\n return { success: true, context };\n }\n\n private authenticateInvocationToken(token: string): AuthResult {\n const claims = this.invocationTokenCodec?.decode(token);\n if (!claims || !this.validInvocationClaims(claims)) {\n return invalidGatewayApiKey();\n }\n const context: SolidAuthContext = {\n type: 'solid',\n webId: claims.webId,\n accountId: claims.webId,\n viaGatewayApiKey: true,\n internalInvocation: true,\n gatewayKeyId: claims.jti,\n gatewayKeyFingerprint: fingerprintGatewayBearer(token),\n scopes: claims.scopes,\n tokenType: 'Bearer',\n };\n return { success: true, context };\n }\n\n private validInvocationClaims(claims: InvocationTokenClaims): boolean {\n const now = this.now().getTime();\n return (\n claims.deployment === this.deployment\n && (!this.invocationTokenAudience || claims.audience === this.invocationTokenAudience)\n && (!this.invocationTokenIssuer || claims.issuer === this.invocationTokenIssuer)\n && claims.issuedAt.getTime() <= now + this.maxClockSkewMs\n && claims.expiresAt.getTime() > now\n && hasRequiredScopes(claims.scopes, this.requiredScopes)\n );\n }\n\n private readBearer(request: IncomingMessage): string | undefined {\n const authorization = request.headers.authorization;\n if (!authorization?.startsWith('Bearer ')) {\n return undefined;\n }\n return authorization.slice(7).trim();\n }\n}\n\nfunction fingerprintGatewayBearer(bearer: string): string {\n return `sha256:${createHash('sha256').update(bearer).digest('hex')}`;\n}\n\nfunction invalidGatewayApiKey(): AuthResult {\n return {\n success: false,\n error: INVALID_GATEWAY_API_KEY,\n category: 'invalid_credentials',\n statusCode: 401,\n };\n}\n\nfunction infrastructureError(cause: unknown): AuthResult {\n return {\n success: false,\n error: 'Gateway API key authentication unavailable',\n category: 'service_unavailable',\n statusCode: 503,\n cause,\n };\n}\n\nfunction isExpired(record: GatewayAccessKeyRecord, now: Date): boolean {\n return Boolean(record.expiresAt && record.expiresAt.getTime() <= now.getTime());\n}\n\nfunction hasRequiredScopes(scopes: string[], requiredScopes: string[]): boolean {\n return requiredScopes.every((scope) => scopes.includes(scope));\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { GatewayDeployment } from './GatewayApiKey';
|
|
2
|
+
export interface GatewayKeyLocatorPayload {
|
|
3
|
+
owner: string;
|
|
4
|
+
keyId: string;
|
|
5
|
+
deployment: GatewayDeployment;
|
|
6
|
+
}
|
|
7
|
+
export interface GatewayKeyLocatorCodec {
|
|
8
|
+
encode(payload: GatewayKeyLocatorPayload): string;
|
|
9
|
+
decode(locator: string): GatewayKeyLocatorPayload | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface GatewayKeyLocatorSecret {
|
|
12
|
+
kid: string;
|
|
13
|
+
secret: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AesGatewayKeyLocatorCodecOptions {
|
|
16
|
+
active: GatewayKeyLocatorSecret;
|
|
17
|
+
previous?: GatewayKeyLocatorSecret[];
|
|
18
|
+
}
|
|
19
|
+
export declare class AesGatewayKeyLocatorCodec implements GatewayKeyLocatorCodec {
|
|
20
|
+
private readonly active;
|
|
21
|
+
private readonly ring;
|
|
22
|
+
constructor(secretOrOptions: string | AesGatewayKeyLocatorCodecOptions);
|
|
23
|
+
encode(payload: GatewayKeyLocatorPayload): string;
|
|
24
|
+
decode(locator: string): GatewayKeyLocatorPayload | undefined;
|
|
25
|
+
}
|
|
26
|
+
export declare function createGatewayKeyLocator(owner: string, deployment: GatewayDeployment, codec: GatewayKeyLocatorCodec): string;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AesGatewayKeyLocatorCodec = void 0;
|
|
4
|
+
exports.createGatewayKeyLocator = createGatewayKeyLocator;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const PREFIX = 'gakv1';
|
|
7
|
+
const NONCE_BYTES = 12;
|
|
8
|
+
const KEY_BYTES = 32;
|
|
9
|
+
class AesGatewayKeyLocatorCodec {
|
|
10
|
+
constructor(secretOrOptions) {
|
|
11
|
+
this.ring = new Map();
|
|
12
|
+
const options = typeof secretOrOptions === 'string'
|
|
13
|
+
? { active: { kid: 'default', secret: secretOrOptions } }
|
|
14
|
+
: secretOrOptions;
|
|
15
|
+
this.active = normalizeSecret(options.active);
|
|
16
|
+
this.ring.set(this.active.kid, this.active.key);
|
|
17
|
+
for (const previous of options.previous ?? []) {
|
|
18
|
+
const normalized = normalizeSecret(previous);
|
|
19
|
+
if (this.ring.has(normalized.kid)) {
|
|
20
|
+
throw new Error(`Duplicate Gateway key locator key id: ${normalized.kid}`);
|
|
21
|
+
}
|
|
22
|
+
this.ring.set(normalized.kid, normalized.key);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
encode(payload) {
|
|
26
|
+
const nonce = (0, node_crypto_1.randomBytes)(NONCE_BYTES);
|
|
27
|
+
const aad = Buffer.from(`${PREFIX}.${this.active.kid}`);
|
|
28
|
+
const cipher = (0, node_crypto_1.createCipheriv)('aes-256-gcm', this.active.key, nonce);
|
|
29
|
+
cipher.setAAD(aad);
|
|
30
|
+
const plaintext = Buffer.from(JSON.stringify(payload), 'utf8');
|
|
31
|
+
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
32
|
+
const tag = cipher.getAuthTag();
|
|
33
|
+
return [
|
|
34
|
+
PREFIX,
|
|
35
|
+
this.active.kid,
|
|
36
|
+
nonce.toString('base64url'),
|
|
37
|
+
ciphertext.toString('base64url'),
|
|
38
|
+
tag.toString('base64url'),
|
|
39
|
+
].join('.');
|
|
40
|
+
}
|
|
41
|
+
decode(locator) {
|
|
42
|
+
const parts = locator.split('.');
|
|
43
|
+
if (parts.length !== 5 || parts[0] !== PREFIX) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const kid = parts[1];
|
|
47
|
+
const key = this.ring.get(kid);
|
|
48
|
+
if (!key) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const nonce = Buffer.from(parts[2], 'base64url');
|
|
53
|
+
const ciphertext = Buffer.from(parts[3], 'base64url');
|
|
54
|
+
const tag = Buffer.from(parts[4], 'base64url');
|
|
55
|
+
const decipher = (0, node_crypto_1.createDecipheriv)('aes-256-gcm', key, nonce);
|
|
56
|
+
decipher.setAAD(Buffer.from(`${PREFIX}.${kid}`));
|
|
57
|
+
decipher.setAuthTag(tag);
|
|
58
|
+
const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
59
|
+
const parsed = JSON.parse(plaintext.toString('utf8'));
|
|
60
|
+
if (typeof parsed.owner !== 'string'
|
|
61
|
+
|| typeof parsed.keyId !== 'string'
|
|
62
|
+
|| (parsed.deployment !== 'local' && parsed.deployment !== 'cloud')) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
owner: parsed.owner,
|
|
67
|
+
keyId: parsed.keyId,
|
|
68
|
+
deployment: parsed.deployment,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.AesGatewayKeyLocatorCodec = AesGatewayKeyLocatorCodec;
|
|
77
|
+
function normalizeSecret(input) {
|
|
78
|
+
const kid = input.kid.trim();
|
|
79
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(kid)) {
|
|
80
|
+
throw new Error('Gateway key locator key id is invalid');
|
|
81
|
+
}
|
|
82
|
+
if (!input.secret.trim()) {
|
|
83
|
+
throw new Error('Gateway key locator secret is required');
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
kid,
|
|
87
|
+
key: (0, node_crypto_1.createHash)('sha256').update(input.secret).digest().subarray(0, KEY_BYTES),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function createGatewayKeyLocator(owner, deployment, codec) {
|
|
91
|
+
return codec.encode({
|
|
92
|
+
owner,
|
|
93
|
+
deployment,
|
|
94
|
+
keyId: `gak_${(0, node_crypto_1.randomBytes)(18).toString('base64url')}`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=GatewayKeyLocatorCodec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayKeyLocatorCodec.js","sourceRoot":"","sources":["../../../../src/api/ai-gateway/auth/GatewayKeyLocatorCodec.ts"],"names":[],"mappings":";;;AAmHA,0DAUC;AA7HD,6CAAwF;AAwBxF,MAAM,MAAM,GAAG,OAAO,CAAC;AACvB,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAa,yBAAyB;IAIpC,YAAmB,eAA0D;QAF5D,SAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;QAGhD,MAAM,OAAO,GAAG,OAAO,eAAe,KAAK,QAAQ;YACjD,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE;YACzD,CAAC,CAAC,eAAe,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChD,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;YAC9C,MAAM,UAAU,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;YAC7C,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,yCAAyC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;YAC7E,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,OAAiC;Q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AC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAvED,8DAuEC;AAED,SAAS,eAAe,CAAC,KAA8B;IACrD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,mCAAmC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO;QACL,GAAG;QACH,GAAG,EAAE,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC;KAC/E,CAAC;AACJ,CAAC;AAED,SAAgB,uBAAuB,CACrC,KAAa,EACb,UAA6B,EAC7B,KAA6B;IAE7B,OAAO,KAAK,CAAC,MAAM,CAAC;QAClB,KAAK;QACL,UAAU;QACV,KAAK,EAAE,OAAO,IAAA,yBAAW,EAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;KACtD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { createCipheriv, createDecipheriv, createHash, randomBytes } from 'node:crypto';\nimport type { GatewayDeployment } from './GatewayApiKey';\n\nexport interface GatewayKeyLocatorPayload {\n owner: string;\n keyId: string;\n deployment: GatewayDeployment;\n}\n\nexport interface GatewayKeyLocatorCodec {\n encode(payload: GatewayKeyLocatorPayload): string;\n decode(locator: string): GatewayKeyLocatorPayload | undefined;\n}\n\nexport interface GatewayKeyLocatorSecret {\n kid: string;\n secret: string;\n}\n\nexport interface AesGatewayKeyLocatorCodecOptions {\n active: GatewayKeyLocatorSecret;\n previous?: GatewayKeyLocatorSecret[];\n}\n\nconst PREFIX = 'gakv1';\nconst NONCE_BYTES = 12;\nconst KEY_BYTES = 32;\n\nexport class AesGatewayKeyLocatorCodec implements GatewayKeyLocatorCodec {\n private readonly active: { kid: string; key: Buffer };\n private readonly ring = new Map<string, Buffer>();\n\n public constructor(secretOrOptions: string | AesGatewayKeyLocatorCodecOptions) {\n const options = typeof secretOrOptions === 'string'\n ? { active: { kid: 'default', secret: secretOrOptions } }\n : secretOrOptions;\n this.active = normalizeSecret(options.active);\n this.ring.set(this.active.kid, this.active.key);\n for (const previous of options.previous ?? []) {\n const normalized = normalizeSecret(previous);\n if (this.ring.has(normalized.kid)) {\n throw new Error(`Duplicate Gateway key locator key id: ${normalized.kid}`);\n }\n this.ring.set(normalized.kid, normalized.key);\n }\n }\n\n public encode(payload: GatewayKeyLocatorPayload): string {\n const nonce = randomBytes(NONCE_BYTES);\n const aad = Buffer.from(`${PREFIX}.${this.active.kid}`);\n const cipher = createCipheriv('aes-256-gcm', this.active.key, nonce);\n cipher.setAAD(aad);\n const plaintext = Buffer.from(JSON.stringify(payload), 'utf8');\n const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);\n const tag = cipher.getAuthTag();\n return [\n PREFIX,\n this.active.kid,\n nonce.toString('base64url'),\n ciphertext.toString('base64url'),\n tag.toString('base64url'),\n ].join('.');\n }\n\n public decode(locator: string): GatewayKeyLocatorPayload | undefined {\n const parts = locator.split('.');\n if (parts.length !== 5 || parts[0] !== PREFIX) {\n return undefined;\n }\n const kid = parts[1];\n const key = this.ring.get(kid);\n if (!key) {\n return undefined;\n }\n try {\n const nonce = Buffer.from(parts[2], 'base64url');\n const ciphertext = Buffer.from(parts[3], 'base64url');\n const tag = Buffer.from(parts[4], 'base64url');\n const decipher = createDecipheriv('aes-256-gcm', key, nonce);\n decipher.setAAD(Buffer.from(`${PREFIX}.${kid}`));\n decipher.setAuthTag(tag);\n const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]);\n const parsed = JSON.parse(plaintext.toString('utf8')) as Record<string, unknown>;\n if (\n typeof parsed.owner !== 'string'\n || typeof parsed.keyId !== 'string'\n || (parsed.deployment !== 'local' && parsed.deployment !== 'cloud')\n ) {\n return undefined;\n }\n return {\n owner: parsed.owner,\n keyId: parsed.keyId,\n deployment: parsed.deployment,\n };\n } catch {\n return undefined;\n }\n }\n}\n\nfunction normalizeSecret(input: GatewayKeyLocatorSecret): { kid: string; key: Buffer } {\n const kid = input.kid.trim();\n if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(kid)) {\n throw new Error('Gateway key locator key id is invalid');\n }\n if (!input.secret.trim()) {\n throw new Error('Gateway key locator secret is required');\n }\n return {\n kid,\n key: createHash('sha256').update(input.secret).digest().subarray(0, KEY_BYTES),\n };\n}\n\nexport function createGatewayKeyLocator(\n owner: string,\n deployment: GatewayDeployment,\n codec: GatewayKeyLocatorCodec,\n): string {\n return codec.encode({\n owner,\n deployment,\n keyId: `gak_${randomBytes(18).toString('base64url')}`,\n });\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AuthContext, SolidAuthContext } from '../../auth/AuthContext';
|
|
2
|
+
export interface GatewayKeyPrincipal {
|
|
3
|
+
webId: string;
|
|
4
|
+
accountId?: string;
|
|
5
|
+
scopes: string[];
|
|
6
|
+
keyId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function isGatewayApiKeyPrincipal(auth: AuthContext | undefined): auth is SolidAuthContext & {
|
|
9
|
+
viaGatewayApiKey: true;
|
|
10
|
+
gatewayKeyId: string;
|
|
11
|
+
scopes: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare function isInternalGatewayInvocationPrincipal(auth: AuthContext | undefined): auth is SolidAuthContext & {
|
|
14
|
+
viaGatewayApiKey: true;
|
|
15
|
+
internalInvocation: true;
|
|
16
|
+
gatewayKeyId: string;
|
|
17
|
+
scopes: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare function canManageGatewayKeys(auth: AuthContext | undefined): boolean;
|
|
20
|
+
export declare function ownerWebIdForGatewayKeyManagement(auth: AuthContext, requestedOwner: unknown): string | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isGatewayApiKeyPrincipal = isGatewayApiKeyPrincipal;
|
|
4
|
+
exports.isInternalGatewayInvocationPrincipal = isInternalGatewayInvocationPrincipal;
|
|
5
|
+
exports.canManageGatewayKeys = canManageGatewayKeys;
|
|
6
|
+
exports.ownerWebIdForGatewayKeyManagement = ownerWebIdForGatewayKeyManagement;
|
|
7
|
+
function isGatewayApiKeyPrincipal(auth) {
|
|
8
|
+
return auth?.type === 'solid' && auth.viaGatewayApiKey === true;
|
|
9
|
+
}
|
|
10
|
+
function isInternalGatewayInvocationPrincipal(auth) {
|
|
11
|
+
return isGatewayApiKeyPrincipal(auth) && auth.internalInvocation === true;
|
|
12
|
+
}
|
|
13
|
+
function canManageGatewayKeys(auth) {
|
|
14
|
+
if (!auth) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (isGatewayApiKeyPrincipal(auth)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (auth.type === 'solid') {
|
|
21
|
+
return Boolean(auth.webId);
|
|
22
|
+
}
|
|
23
|
+
return hasGatewayKeyManagementScope(auth);
|
|
24
|
+
}
|
|
25
|
+
function ownerWebIdForGatewayKeyManagement(auth, requestedOwner) {
|
|
26
|
+
if (auth.type === 'solid') {
|
|
27
|
+
return auth.webId;
|
|
28
|
+
}
|
|
29
|
+
if (hasGatewayKeyManagementScope(auth) && typeof requestedOwner === 'string' && requestedOwner.trim()) {
|
|
30
|
+
return requestedOwner.trim();
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
function hasGatewayKeyManagementScope(auth) {
|
|
35
|
+
return auth.type === 'service' && auth.scopes.includes('gateway:keys:write');
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=GatewayPrincipal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayPrincipal.js","sourceRoot":"","sources":["../../../../src/api/ai-gateway/auth/GatewayPrincipal.ts"],"names":[],"mappings":";;AASA,4DAMC;AAED,oFAOC;AAED,oDAWC;AAED,8EAWC;AAzCD,SAAgB,wBAAwB,CAAC,IAA6B;IAKpE,OAAO,IAAI,EAAE,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,CAAC;AAClE,CAAC;AAED,SAAgB,oCAAoC,CAAC,IAA6B;IAMhF,OAAO,wBAAwB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI,CAAC;AAC5E,CAAC;AAED,SAAgB,oBAAoB,CAAC,IAA6B;IAChE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,4BAA4B,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,SAAgB,iCAAiC,CAC/C,IAAiB,EACjB,cAAuB;IAEvB,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,IAAI,4BAA4B,CAAC,IAAI,CAAC,IAAI,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC;QACtG,OAAO,cAAc,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,4BAA4B,CAAC,IAAiB;IACrD,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["import type { AuthContext, ServiceAuthContext, SolidAuthContext } from '../../auth/AuthContext';\n\nexport interface GatewayKeyPrincipal {\n webId: string;\n accountId?: string;\n scopes: string[];\n keyId: string;\n}\n\nexport function isGatewayApiKeyPrincipal(auth: AuthContext | undefined): auth is SolidAuthContext & {\n viaGatewayApiKey: true;\n gatewayKeyId: string;\n scopes: string[];\n} {\n return auth?.type === 'solid' && auth.viaGatewayApiKey === true;\n}\n\nexport function isInternalGatewayInvocationPrincipal(auth: AuthContext | undefined): auth is SolidAuthContext & {\n viaGatewayApiKey: true;\n internalInvocation: true;\n gatewayKeyId: string;\n scopes: string[];\n} {\n return isGatewayApiKeyPrincipal(auth) && auth.internalInvocation === true;\n}\n\nexport function canManageGatewayKeys(auth: AuthContext | undefined): boolean {\n if (!auth) {\n return false;\n }\n if (isGatewayApiKeyPrincipal(auth)) {\n return false;\n }\n if (auth.type === 'solid') {\n return Boolean(auth.webId);\n }\n return hasGatewayKeyManagementScope(auth);\n}\n\nexport function ownerWebIdForGatewayKeyManagement(\n auth: AuthContext,\n requestedOwner: unknown,\n): string | undefined {\n if (auth.type === 'solid') {\n return auth.webId;\n }\n if (hasGatewayKeyManagementScope(auth) && typeof requestedOwner === 'string' && requestedOwner.trim()) {\n return requestedOwner.trim();\n }\n return undefined;\n}\n\nfunction hasGatewayKeyManagementScope(auth: AuthContext): auth is ServiceAuthContext {\n return auth.type === 'service' && auth.scopes.includes('gateway:keys:write');\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { GatewayDeployment } from './GatewayApiKey';
|
|
2
|
+
import type { GatewayKeyLocatorSecret } from './GatewayKeyLocatorCodec';
|
|
3
|
+
export interface InvocationTokenClaims {
|
|
4
|
+
version: 1;
|
|
5
|
+
kid: string;
|
|
6
|
+
deployment: GatewayDeployment;
|
|
7
|
+
audience: string;
|
|
8
|
+
issuer: string;
|
|
9
|
+
webId: string;
|
|
10
|
+
scopes: string[];
|
|
11
|
+
issuedAt: Date;
|
|
12
|
+
expiresAt: Date;
|
|
13
|
+
jti: string;
|
|
14
|
+
}
|
|
15
|
+
export interface InvocationTokenInput {
|
|
16
|
+
deployment: GatewayDeployment;
|
|
17
|
+
audience: string;
|
|
18
|
+
issuer: string;
|
|
19
|
+
webId: string;
|
|
20
|
+
scopes: string[];
|
|
21
|
+
issuedAt: Date;
|
|
22
|
+
expiresAt: Date;
|
|
23
|
+
jti?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface InvocationTokenCodec {
|
|
26
|
+
encode(input: InvocationTokenInput): string;
|
|
27
|
+
decode(token: string): InvocationTokenClaims | undefined;
|
|
28
|
+
}
|
|
29
|
+
export interface AesInvocationTokenCodecOptions {
|
|
30
|
+
active: GatewayKeyLocatorSecret;
|
|
31
|
+
previous?: GatewayKeyLocatorSecret[];
|
|
32
|
+
}
|
|
33
|
+
export declare class AesInvocationTokenCodec implements InvocationTokenCodec {
|
|
34
|
+
private readonly active;
|
|
35
|
+
private readonly ring;
|
|
36
|
+
constructor(options: AesInvocationTokenCodecOptions);
|
|
37
|
+
encode(input: InvocationTokenInput): string;
|
|
38
|
+
decode(token: string): InvocationTokenClaims | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare function requireCanonicalOrigin(value: string, name?: string): string;
|
|
41
|
+
export declare function requireCanonicalWebId(value: string): string;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AesInvocationTokenCodec = void 0;
|
|
4
|
+
exports.requireCanonicalOrigin = requireCanonicalOrigin;
|
|
5
|
+
exports.requireCanonicalWebId = requireCanonicalWebId;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const PREFIX = 'xpod_inv_v1';
|
|
8
|
+
const AAD_CONTEXT = 'xpod:gateway:internal-invocation:v1';
|
|
9
|
+
const NONCE_BYTES = 12;
|
|
10
|
+
const KEY_BYTES = 32;
|
|
11
|
+
const MAX_TOKEN_LENGTH = 8_192;
|
|
12
|
+
const MAX_CIPHERTEXT_BYTES = 4_096;
|
|
13
|
+
const MAX_TTL_MS = 15 * 60_000;
|
|
14
|
+
const MAX_SCOPES = 8;
|
|
15
|
+
class AesInvocationTokenCodec {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.ring = new Map();
|
|
18
|
+
this.active = normalizeSecret(options.active);
|
|
19
|
+
this.ring.set(this.active.kid, this.active.key);
|
|
20
|
+
for (const previous of options.previous ?? []) {
|
|
21
|
+
const normalized = normalizeSecret(previous);
|
|
22
|
+
if (this.ring.has(normalized.kid)) {
|
|
23
|
+
throw new Error(`Duplicate invocation token key id: ${normalized.kid}`);
|
|
24
|
+
}
|
|
25
|
+
this.ring.set(normalized.kid, normalized.key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
encode(input) {
|
|
29
|
+
const webId = requireCanonicalWebId(input.webId);
|
|
30
|
+
const audience = requireCanonicalOrigin(input.audience, 'audience');
|
|
31
|
+
const issuer = requireCanonicalOrigin(input.issuer, 'issuer');
|
|
32
|
+
const scopes = requireScopes(input.scopes);
|
|
33
|
+
const issuedAt = requireTimestamp(input.issuedAt, 'issuedAt');
|
|
34
|
+
const expiresAt = requireTimestamp(input.expiresAt, 'expiresAt');
|
|
35
|
+
if (expiresAt <= issuedAt || expiresAt - issuedAt > MAX_TTL_MS) {
|
|
36
|
+
throw new Error(`Invocation token TTL must be between 1 and ${MAX_TTL_MS} milliseconds`);
|
|
37
|
+
}
|
|
38
|
+
const payload = {
|
|
39
|
+
v: 1,
|
|
40
|
+
kid: this.active.kid,
|
|
41
|
+
deployment: input.deployment,
|
|
42
|
+
aud: audience,
|
|
43
|
+
iss: issuer,
|
|
44
|
+
webId,
|
|
45
|
+
scopes,
|
|
46
|
+
iat: issuedAt,
|
|
47
|
+
exp: expiresAt,
|
|
48
|
+
jti: input.jti ?? (0, node_crypto_1.randomBytes)(18).toString('base64url'),
|
|
49
|
+
};
|
|
50
|
+
const nonce = (0, node_crypto_1.randomBytes)(NONCE_BYTES);
|
|
51
|
+
const aad = Buffer.from(`${AAD_CONTEXT}.${this.active.kid}`);
|
|
52
|
+
const cipher = (0, node_crypto_1.createCipheriv)('aes-256-gcm', this.active.key, nonce);
|
|
53
|
+
cipher.setAAD(aad);
|
|
54
|
+
const ciphertext = Buffer.concat([
|
|
55
|
+
cipher.update(JSON.stringify(payload), 'utf8'),
|
|
56
|
+
cipher.final(),
|
|
57
|
+
]);
|
|
58
|
+
const tag = cipher.getAuthTag();
|
|
59
|
+
return [
|
|
60
|
+
PREFIX,
|
|
61
|
+
this.active.kid,
|
|
62
|
+
nonce.toString('base64url'),
|
|
63
|
+
ciphertext.toString('base64url'),
|
|
64
|
+
tag.toString('base64url'),
|
|
65
|
+
].join('.');
|
|
66
|
+
}
|
|
67
|
+
decode(token) {
|
|
68
|
+
if (token.length > MAX_TOKEN_LENGTH) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const parts = token.split('.');
|
|
72
|
+
if (parts.length !== 5 || parts[0] !== PREFIX) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
const kid = parts[1];
|
|
76
|
+
const key = this.ring.get(kid);
|
|
77
|
+
if (!key
|
|
78
|
+
|| !parts.slice(1).every((part) => /^[A-Za-z0-9_-]+$/u.test(part))) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const nonce = decodeCanonicalBase64Url(parts[2]);
|
|
83
|
+
const ciphertext = decodeCanonicalBase64Url(parts[3]);
|
|
84
|
+
const tag = decodeCanonicalBase64Url(parts[4]);
|
|
85
|
+
if (!nonce || !ciphertext || !tag) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
if (nonce.length !== NONCE_BYTES
|
|
89
|
+
|| ciphertext.length === 0
|
|
90
|
+
|| ciphertext.length > MAX_CIPHERTEXT_BYTES
|
|
91
|
+
|| tag.length !== 16) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const decipher = (0, node_crypto_1.createDecipheriv)('aes-256-gcm', key, nonce);
|
|
95
|
+
decipher.setAAD(Buffer.from(`${AAD_CONTEXT}.${kid}`));
|
|
96
|
+
decipher.setAuthTag(tag);
|
|
97
|
+
const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
98
|
+
const parsed = JSON.parse(plaintext.toString('utf8'));
|
|
99
|
+
const keys = Object.keys(parsed).sort();
|
|
100
|
+
if (keys.join(',') !== 'aud,deployment,exp,iat,iss,jti,kid,scopes,v,webId'
|
|
101
|
+
||
|
|
102
|
+
parsed.v !== 1
|
|
103
|
+
|| parsed.kid !== kid
|
|
104
|
+
|| (parsed.deployment !== 'local' && parsed.deployment !== 'cloud')
|
|
105
|
+
|| typeof parsed.aud !== 'string'
|
|
106
|
+
|| typeof parsed.iss !== 'string'
|
|
107
|
+
|| typeof parsed.webId !== 'string'
|
|
108
|
+
|| !Array.isArray(parsed.scopes)
|
|
109
|
+
|| typeof parsed.iat !== 'number'
|
|
110
|
+
|| typeof parsed.exp !== 'number'
|
|
111
|
+
|| typeof parsed.jti !== 'string'
|
|
112
|
+
|| !/^[A-Za-z0-9_-]{16,128}$/u.test(parsed.jti)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const audience = requireCanonicalOrigin(parsed.aud, 'audience');
|
|
116
|
+
const issuer = requireCanonicalOrigin(parsed.iss, 'issuer');
|
|
117
|
+
const webId = requireCanonicalWebId(parsed.webId);
|
|
118
|
+
const scopes = requireScopes(parsed.scopes);
|
|
119
|
+
const issuedAt = requireEpoch(parsed.iat);
|
|
120
|
+
const expiresAt = requireEpoch(parsed.exp);
|
|
121
|
+
if (expiresAt <= issuedAt || expiresAt - issuedAt > MAX_TTL_MS) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
version: 1,
|
|
126
|
+
kid,
|
|
127
|
+
deployment: parsed.deployment,
|
|
128
|
+
audience,
|
|
129
|
+
issuer,
|
|
130
|
+
webId,
|
|
131
|
+
scopes,
|
|
132
|
+
issuedAt: new Date(issuedAt),
|
|
133
|
+
expiresAt: new Date(expiresAt),
|
|
134
|
+
jti: parsed.jti,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.AesInvocationTokenCodec = AesInvocationTokenCodec;
|
|
143
|
+
function requireCanonicalOrigin(value, name = 'origin') {
|
|
144
|
+
let url;
|
|
145
|
+
try {
|
|
146
|
+
url = new URL(value);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
throw new Error(`Invocation token ${name} must be a canonical HTTP(S) origin`);
|
|
150
|
+
}
|
|
151
|
+
if ((url.protocol !== 'https:' && url.protocol !== 'http:')
|
|
152
|
+
|| url.username
|
|
153
|
+
|| url.password
|
|
154
|
+
|| url.pathname !== '/'
|
|
155
|
+
|| url.search
|
|
156
|
+
|| url.hash
|
|
157
|
+
|| url.origin !== value) {
|
|
158
|
+
throw new Error(`Invocation token ${name} must be a canonical HTTP(S) origin`);
|
|
159
|
+
}
|
|
160
|
+
return url.origin;
|
|
161
|
+
}
|
|
162
|
+
function decodeCanonicalBase64Url(value) {
|
|
163
|
+
const decoded = Buffer.from(value, 'base64url');
|
|
164
|
+
return decoded.toString('base64url') === value ? decoded : undefined;
|
|
165
|
+
}
|
|
166
|
+
function normalizeSecret(input) {
|
|
167
|
+
const kid = input.kid.trim();
|
|
168
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u.test(kid)) {
|
|
169
|
+
throw new Error('Invocation token key id is invalid');
|
|
170
|
+
}
|
|
171
|
+
if (!input.secret.trim()) {
|
|
172
|
+
throw new Error('Invocation token secret is required');
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
kid,
|
|
176
|
+
key: (0, node_crypto_1.createHash)('sha256')
|
|
177
|
+
.update(`${AAD_CONTEXT}\0`, 'utf8')
|
|
178
|
+
.update(input.secret, 'utf8')
|
|
179
|
+
.digest()
|
|
180
|
+
.subarray(0, KEY_BYTES),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function requireCanonicalWebId(value) {
|
|
184
|
+
let url;
|
|
185
|
+
try {
|
|
186
|
+
url = new URL(value);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
throw new Error('Invocation token WebID must be a canonical HTTP(S) URL');
|
|
190
|
+
}
|
|
191
|
+
if ((url.protocol !== 'https:' && url.protocol !== 'http:')
|
|
192
|
+
|| url.username
|
|
193
|
+
|| url.password
|
|
194
|
+
|| url.href !== value) {
|
|
195
|
+
throw new Error('Invocation token WebID must be a canonical HTTP(S) URL');
|
|
196
|
+
}
|
|
197
|
+
return url.href;
|
|
198
|
+
}
|
|
199
|
+
function requireScopes(value) {
|
|
200
|
+
if (value.length === 0
|
|
201
|
+
|| value.length > MAX_SCOPES
|
|
202
|
+
|| value.some((scope) => typeof scope !== 'string' || !/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/u.test(scope))
|
|
203
|
+
|| new Set(value).size !== value.length) {
|
|
204
|
+
throw new Error('Invocation token scopes are invalid');
|
|
205
|
+
}
|
|
206
|
+
return [...value];
|
|
207
|
+
}
|
|
208
|
+
function requireTimestamp(value, name) {
|
|
209
|
+
const timestamp = value.getTime();
|
|
210
|
+
if (!Number.isSafeInteger(timestamp) || timestamp < 0) {
|
|
211
|
+
throw new Error(`Invocation token ${name} is invalid`);
|
|
212
|
+
}
|
|
213
|
+
return timestamp;
|
|
214
|
+
}
|
|
215
|
+
function requireEpoch(value) {
|
|
216
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
217
|
+
throw new Error('Invocation token timestamp is invalid');
|
|
218
|
+
}
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=InvocationTokenCodec.js.map
|