@1mcp/agent 0.39.0-beta.3 → 0.39.0-beta.4
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/build/admin/assets/{admin-OAuthServicesWorkspace-D_GlqLxL.js → admin-OAuthServicesWorkspace-CKR1HA-8.js} +1 -1
- package/build/admin/assets/{admin-console-CMRxMjQo.js → admin-console-OfHKqRm-.js} +3 -3
- package/build/admin/index.html +1 -1
- package/build/auth/oauthAuthority.d.ts +149 -0
- package/build/auth/oauthAuthority.d.ts.map +1 -0
- package/build/auth/oauthAuthority.js +101 -0
- package/build/auth/oauthAuthority.js.map +1 -0
- package/build/auth/oauthAuthorizationFlow.d.ts +7 -1
- package/build/auth/oauthAuthorizationFlow.d.ts.map +1 -1
- package/build/auth/oauthAuthorizationFlow.js +60 -74
- package/build/auth/oauthAuthorizationFlow.js.map +1 -1
- package/build/auth/oauthEndpointFetch.d.ts +20 -0
- package/build/auth/oauthEndpointFetch.d.ts.map +1 -0
- package/build/auth/oauthEndpointFetch.js +246 -0
- package/build/auth/oauthEndpointFetch.js.map +1 -0
- package/build/auth/sessionTypes.d.ts +1 -1
- package/build/auth/storage/clientSessionRepository.d.ts +19 -0
- package/build/auth/storage/clientSessionRepository.d.ts.map +1 -1
- package/build/auth/storage/clientSessionRepository.js +178 -0
- package/build/auth/storage/clientSessionRepository.js.map +1 -1
- package/build/auth/storage/fileStorageService.d.ts +9 -1
- package/build/auth/storage/fileStorageService.d.ts.map +1 -1
- package/build/auth/storage/fileStorageService.js +32 -5
- package/build/auth/storage/fileStorageService.js.map +1 -1
- package/build/auth/storage/inboundOAuthStorage.d.ts +14 -0
- package/build/auth/storage/inboundOAuthStorage.d.ts.map +1 -0
- package/build/auth/storage/inboundOAuthStorage.js +29 -0
- package/build/auth/storage/inboundOAuthStorage.js.map +1 -0
- package/build/auth/storage/nativeCredentialStore.d.ts +44 -0
- package/build/auth/storage/nativeCredentialStore.d.ts.map +1 -0
- package/build/auth/storage/nativeCredentialStore.js +177 -0
- package/build/auth/storage/nativeCredentialStore.js.map +1 -0
- package/build/auth/storage/oauthStorageService.d.ts +8 -1
- package/build/auth/storage/oauthStorageService.d.ts.map +1 -1
- package/build/auth/storage/oauthStorageService.js +69 -47
- package/build/auth/storage/oauthStorageService.js.map +1 -1
- package/build/auth/storage/protectedRecordStorage.d.ts +129 -0
- package/build/auth/storage/protectedRecordStorage.d.ts.map +1 -0
- package/build/auth/storage/protectedRecordStorage.js +1139 -0
- package/build/auth/storage/protectedRecordStorage.js.map +1 -0
- package/build/auth/storage/sessionRepository.d.ts.map +1 -1
- package/build/auth/storage/sessionRepository.js +10 -0
- package/build/auth/storage/sessionRepository.js.map +1 -1
- package/build/auth/storage/upstreamOAuthStorage.d.ts +15 -0
- package/build/auth/storage/upstreamOAuthStorage.d.ts.map +1 -0
- package/build/auth/storage/upstreamOAuthStorage.js +25 -0
- package/build/auth/storage/upstreamOAuthStorage.js.map +1 -0
- package/build/auth/storage/upstreamOAuthStoragePath.d.ts +3 -0
- package/build/auth/storage/upstreamOAuthStoragePath.d.ts.map +1 -0
- package/build/auth/storage/upstreamOAuthStoragePath.js +8 -0
- package/build/auth/storage/upstreamOAuthStoragePath.js.map +1 -0
- package/build/commands/auth/exportOAuthCredentials.d.ts +9 -0
- package/build/commands/auth/exportOAuthCredentials.d.ts.map +1 -0
- package/build/commands/auth/exportOAuthCredentials.js +71 -0
- package/build/commands/auth/exportOAuthCredentials.js.map +1 -0
- package/build/commands/auth/exportUpstreamCredentials.d.ts +5 -0
- package/build/commands/auth/exportUpstreamCredentials.d.ts.map +1 -0
- package/build/commands/auth/exportUpstreamCredentials.js +6 -0
- package/build/commands/auth/exportUpstreamCredentials.js.map +1 -0
- package/build/commands/auth/index.d.ts.map +1 -1
- package/build/commands/auth/index.js +23 -1
- package/build/commands/auth/index.js.map +1 -1
- package/build/commands/inspect/inspectUtils.d.ts.map +1 -1
- package/build/commands/inspect/inspectUtils.js +2 -3
- package/build/commands/inspect/inspectUtils.js.map +1 -1
- package/build/commands/run/runUtils.js +2 -2
- package/build/commands/run/runUtils.js.map +1 -1
- package/build/commands/serve/index.d.ts +5 -0
- package/build/commands/serve/index.d.ts.map +1 -1
- package/build/commands/serve/index.js +5 -0
- package/build/commands/serve/index.js.map +1 -1
- package/build/commands/serve/serveBackground.d.ts.map +1 -1
- package/build/commands/serve/serveBackground.js +1 -0
- package/build/commands/serve/serveBackground.js.map +1 -1
- package/build/config/configLoader.d.ts.map +1 -1
- package/build/config/configLoader.js +13 -0
- package/build/config/configLoader.js.map +1 -1
- package/build/config/configManager.d.ts.map +1 -1
- package/build/config/configManager.js +44 -2
- package/build/config/configManager.js.map +1 -1
- package/build/config/configWatcher.d.ts.map +1 -1
- package/build/config/configWatcher.js +3 -1
- package/build/config/configWatcher.js.map +1 -1
- package/build/config/envProcessor.d.ts.map +1 -1
- package/build/config/envProcessor.js +3 -1
- package/build/config/envProcessor.js.map +1 -1
- package/build/config/mcpConfigManager.d.ts.map +1 -1
- package/build/config/mcpConfigManager.js +4 -1
- package/build/config/mcpConfigManager.js.map +1 -1
- package/build/config/projectConfigLoader.d.ts.map +1 -1
- package/build/config/projectConfigLoader.js +7 -0
- package/build/config/projectConfigLoader.js.map +1 -1
- package/build/constants/mcp.d.ts +1 -1
- package/build/constants/mcp.js +1 -1
- package/build/core/capabilities/asyncLoadingOrchestrator.d.ts.map +1 -1
- package/build/core/capabilities/asyncLoadingOrchestrator.js +31 -2
- package/build/core/capabilities/asyncLoadingOrchestrator.js.map +1 -1
- package/build/core/capabilities/capabilityAggregator.d.ts +3 -1
- package/build/core/capabilities/capabilityAggregator.d.ts.map +1 -1
- package/build/core/capabilities/capabilityAggregator.js +9 -2
- package/build/core/capabilities/capabilityAggregator.js.map +1 -1
- package/build/core/capabilities/capabilityCatalog.d.ts +24 -1
- package/build/core/capabilities/capabilityCatalog.d.ts.map +1 -1
- package/build/core/capabilities/capabilityCatalog.js +410 -39
- package/build/core/capabilities/capabilityCatalog.js.map +1 -1
- package/build/core/capabilities/capabilityPagination.d.ts +18 -1
- package/build/core/capabilities/capabilityPagination.d.ts.map +1 -1
- package/build/core/capabilities/capabilityPagination.js +101 -15
- package/build/core/capabilities/capabilityPagination.js.map +1 -1
- package/build/core/capabilities/capabilityVisibility.d.ts +13 -1
- package/build/core/capabilities/capabilityVisibility.d.ts.map +1 -1
- package/build/core/capabilities/capabilityVisibility.js +24 -1
- package/build/core/capabilities/capabilityVisibility.js.map +1 -1
- package/build/core/capabilities/catalogGeneration.d.ts.map +1 -1
- package/build/core/capabilities/catalogGeneration.js +20 -1
- package/build/core/capabilities/catalogGeneration.js.map +1 -1
- package/build/core/capabilities/configuredToolSnapshot.d.ts +1 -0
- package/build/core/capabilities/configuredToolSnapshot.d.ts.map +1 -1
- package/build/core/capabilities/configuredToolSnapshot.js +30 -4
- package/build/core/capabilities/configuredToolSnapshot.js.map +1 -1
- package/build/core/capabilities/lazyLoadingOrchestrator.d.ts +2 -0
- package/build/core/capabilities/lazyLoadingOrchestrator.d.ts.map +1 -1
- package/build/core/capabilities/lazyLoadingOrchestrator.js +20 -4
- package/build/core/capabilities/lazyLoadingOrchestrator.js.map +1 -1
- package/build/core/capabilities/metaToolProvider.d.ts +3 -1
- package/build/core/capabilities/metaToolProvider.d.ts.map +1 -1
- package/build/core/capabilities/metaToolProvider.js +42 -4
- package/build/core/capabilities/metaToolProvider.js.map +1 -1
- package/build/core/capabilities/runtimeCapabilityCatalog.d.ts +15 -2
- package/build/core/capabilities/runtimeCapabilityCatalog.d.ts.map +1 -1
- package/build/core/capabilities/runtimeCapabilityCatalog.js +153 -16
- package/build/core/capabilities/runtimeCapabilityCatalog.js.map +1 -1
- package/build/core/capabilities/schemaCache.d.ts.map +1 -1
- package/build/core/capabilities/schemaCache.js +41 -0
- package/build/core/capabilities/schemaCache.js.map +1 -1
- package/build/core/capabilities/schemas/metaToolSchemas.d.ts +1 -0
- package/build/core/capabilities/schemas/metaToolSchemas.d.ts.map +1 -1
- package/build/core/capabilities/schemas/metaToolSchemas.js +1 -0
- package/build/core/capabilities/schemas/metaToolSchemas.js.map +1 -1
- package/build/core/capabilities/toolRegistry.d.ts +7 -3
- package/build/core/capabilities/toolRegistry.d.ts.map +1 -1
- package/build/core/capabilities/toolRegistry.js +28 -9
- package/build/core/capabilities/toolRegistry.js.map +1 -1
- package/build/core/instructions/instructionAggregator.d.ts.map +1 -1
- package/build/core/instructions/instructionAggregator.js +3 -1
- package/build/core/instructions/instructionAggregator.js.map +1 -1
- package/build/core/instructions/templateTypes.d.ts +1 -1
- package/build/core/instructions/templateTypes.d.ts.map +1 -1
- package/build/core/instructions/templateTypes.js +3 -3
- package/build/core/loading/loadingStateTracker.d.ts.map +1 -1
- package/build/core/loading/loadingStateTracker.js +11 -2
- package/build/core/loading/loadingStateTracker.js.map +1 -1
- package/build/core/loading/mcpLoadingManager.d.ts.map +1 -1
- package/build/core/loading/mcpLoadingManager.js +6 -2
- package/build/core/loading/mcpLoadingManager.js.map +1 -1
- package/build/core/protocol/requestHandlerUtils.d.ts +2 -2
- package/build/core/protocol/requestHandlerUtils.d.ts.map +1 -1
- package/build/core/protocol/requestHandlerUtils.js +7 -4
- package/build/core/protocol/requestHandlerUtils.js.map +1 -1
- package/build/core/server/agentConfig.d.ts +1 -0
- package/build/core/server/agentConfig.d.ts.map +1 -1
- package/build/core/server/agentConfig.js +1 -0
- package/build/core/server/agentConfig.js.map +1 -1
- package/build/core/server/disabledTools.d.ts +1 -1
- package/build/core/server/disabledTools.d.ts.map +1 -1
- package/build/core/server/disabledTools.js +18 -25
- package/build/core/server/disabledTools.js.map +1 -1
- package/build/core/server/processIdentity.d.ts.map +1 -1
- package/build/core/server/processIdentity.js +67 -18
- package/build/core/server/processIdentity.js.map +1 -1
- package/build/core/server/runtimeLaunchIpc.d.ts +14 -1
- package/build/core/server/runtimeLaunchIpc.d.ts.map +1 -1
- package/build/core/server/runtimeReplacementConfig.d.ts +14 -1
- package/build/core/server/runtimeReplacementConfig.d.ts.map +1 -1
- package/build/core/server/toolDescriptionOverrides.d.ts +1 -0
- package/build/core/server/toolDescriptionOverrides.d.ts.map +1 -1
- package/build/core/server/toolDescriptionOverrides.js +30 -5
- package/build/core/server/toolDescriptionOverrides.js.map +1 -1
- package/build/core/tools/handlers/serverManagementHandler.d.ts +21 -0
- package/build/core/tools/handlers/serverManagementHandler.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts +3 -0
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts.map +1 -1
- package/build/core/tools/internal/schemas/discovery.d.ts +1 -1
- package/build/core/tools/internal/schemas/index.d.ts +1 -1
- package/build/core/types/transport.d.ts +25 -2
- package/build/core/types/transport.d.ts.map +1 -1
- package/build/core/types/transport.js +12 -0
- package/build/core/types/transport.js.map +1 -1
- package/build/domains/admin/configuredToolInventory.d.ts.map +1 -1
- package/build/domains/admin/configuredToolInventory.js +47 -9
- package/build/domains/admin/configuredToolInventory.js.map +1 -1
- package/build/domains/admin/runtimeConfiguredToolInspectionService.d.ts.map +1 -1
- package/build/domains/admin/runtimeConfiguredToolInspectionService.js +13 -3
- package/build/domains/admin/runtimeConfiguredToolInspectionService.js.map +1 -1
- package/build/gateway/adapters/modern/modernInboundEraAdapter.d.ts.map +1 -1
- package/build/gateway/adapters/modern/modernInboundEraAdapter.js +3 -3
- package/build/gateway/adapters/modern/modernInboundEraAdapter.js.map +1 -1
- package/build/gateway/adapters/modern/modernOutboundEraAdapter.d.ts.map +1 -1
- package/build/gateway/adapters/modern/modernOutboundEraAdapter.js +4 -0
- package/build/gateway/adapters/modern/modernOutboundEraAdapter.js.map +1 -1
- package/build/gateway/contracts/gatewayFailure.d.ts +39 -1
- package/build/gateway/contracts/gatewayFailure.d.ts.map +1 -1
- package/build/gateway/contracts/gatewayFailure.js +139 -0
- package/build/gateway/contracts/gatewayFailure.js.map +1 -1
- package/build/gateway/interactions/nativeInputResponses.d.ts +16 -0
- package/build/gateway/interactions/nativeInputResponses.d.ts.map +1 -0
- package/build/gateway/interactions/nativeInputResponses.js +76 -0
- package/build/gateway/interactions/nativeInputResponses.js.map +1 -0
- package/build/gateway/interactions/validateInteractionResponse.d.ts.map +1 -1
- package/build/gateway/interactions/validateInteractionResponse.js +20 -1
- package/build/gateway/interactions/validateInteractionResponse.js.map +1 -1
- package/build/gateway/ports/outboundEraAdapter.d.ts +2 -0
- package/build/gateway/ports/outboundEraAdapter.d.ts.map +1 -1
- package/build/logger/diagnosticRedaction.d.ts +3 -0
- package/build/logger/diagnosticRedaction.d.ts.map +1 -0
- package/build/logger/diagnosticRedaction.js +12 -0
- package/build/logger/diagnosticRedaction.js.map +1 -0
- package/build/logger/httpDiagnostics.d.ts +25 -0
- package/build/logger/httpDiagnostics.d.ts.map +1 -0
- package/build/logger/httpDiagnostics.js +125 -0
- package/build/logger/httpDiagnostics.js.map +1 -0
- package/build/logger/localDiagnosticRecord.d.ts +11 -0
- package/build/logger/localDiagnosticRecord.d.ts.map +1 -0
- package/build/logger/localDiagnosticRecord.js +9 -0
- package/build/logger/localDiagnosticRecord.js.map +1 -0
- package/build/logger/localDiagnostics.d.ts +5 -0
- package/build/logger/localDiagnostics.d.ts.map +1 -0
- package/build/logger/localDiagnostics.js +116 -0
- package/build/logger/localDiagnostics.js.map +1 -0
- package/build/logger/logger.d.ts +7 -0
- package/build/logger/logger.d.ts.map +1 -1
- package/build/logger/logger.js +14 -0
- package/build/logger/logger.js.map +1 -1
- package/build/observability/events/registry.d.ts +163 -49
- package/build/observability/events/registry.d.ts.map +1 -1
- package/build/observability/events/registry.js +136 -49
- package/build/observability/events/registry.js.map +1 -1
- package/build/observability/privacy/fields.d.ts +3 -1
- package/build/observability/privacy/fields.d.ts.map +1 -1
- package/build/observability/privacy/fields.js +23 -0
- package/build/observability/privacy/fields.js.map +1 -1
- package/build/sdk/contracts/catalogCoverageInvalidation.d.ts +4 -0
- package/build/sdk/contracts/catalogCoverageInvalidation.d.ts.map +1 -0
- package/build/sdk/contracts/catalogCoverageInvalidation.js +13 -0
- package/build/sdk/contracts/catalogCoverageInvalidation.js.map +1 -0
- package/build/sdk/contracts/mcpParamHeaders.d.ts +17 -0
- package/build/sdk/contracts/mcpParamHeaders.d.ts.map +1 -0
- package/build/sdk/contracts/mcpParamHeaders.js +134 -0
- package/build/sdk/contracts/mcpParamHeaders.js.map +1 -0
- package/build/sdk/contracts/requestProgress.d.ts +29 -0
- package/build/sdk/contracts/requestProgress.d.ts.map +1 -0
- package/build/sdk/contracts/requestProgress.js +126 -0
- package/build/sdk/contracts/requestProgress.js.map +1 -0
- package/build/sdk/legacy/auth/sdkOAuthClientProvider.d.ts +77 -84
- package/build/sdk/legacy/auth/sdkOAuthClientProvider.d.ts.map +1 -1
- package/build/sdk/legacy/auth/sdkOAuthClientProvider.js +632 -209
- package/build/sdk/legacy/auth/sdkOAuthClientProvider.js.map +1 -1
- package/build/sdk/legacy/auth/sdkOAuthServerProvider.d.ts.map +1 -1
- package/build/sdk/legacy/auth/sdkOAuthServerProvider.js +25 -7
- package/build/sdk/legacy/auth/sdkOAuthServerProvider.js.map +1 -1
- package/build/sdk/legacy/client/runtime/clientManager.d.ts +5 -1
- package/build/sdk/legacy/client/runtime/clientManager.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/clientManager.js +213 -6
- package/build/sdk/legacy/client/runtime/clientManager.js.map +1 -1
- package/build/sdk/legacy/client/runtime/connectionHandler.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/connectionHandler.js +70 -4
- package/build/sdk/legacy/client/runtime/connectionHandler.js.map +1 -1
- package/build/sdk/legacy/client/runtime/legacyInteractionLease.d.ts +2 -1
- package/build/sdk/legacy/client/runtime/legacyInteractionLease.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/legacyInteractionLease.js +11 -2
- package/build/sdk/legacy/client/runtime/legacyInteractionLease.js.map +1 -1
- package/build/sdk/legacy/client/runtime/legacySdkClientAdapter.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/legacySdkClientAdapter.js +28 -2
- package/build/sdk/legacy/client/runtime/legacySdkClientAdapter.js.map +1 -1
- package/build/sdk/legacy/client/runtime/mcpParamHeaders.d.ts +2 -0
- package/build/sdk/legacy/client/runtime/mcpParamHeaders.d.ts.map +1 -0
- package/build/sdk/legacy/client/runtime/mcpParamHeaders.js +2 -0
- package/build/sdk/legacy/client/runtime/mcpParamHeaders.js.map +1 -0
- package/build/sdk/legacy/client/runtime/modernSdkClientAdapter.d.ts +6 -0
- package/build/sdk/legacy/client/runtime/modernSdkClientAdapter.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/modernSdkClientAdapter.js +117 -6
- package/build/sdk/legacy/client/runtime/modernSdkClientAdapter.js.map +1 -1
- package/build/sdk/legacy/client/runtime/oauthFlowHandler.d.ts +1 -1
- package/build/sdk/legacy/client/runtime/oauthFlowHandler.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/oauthFlowHandler.js +68 -16
- package/build/sdk/legacy/client/runtime/oauthFlowHandler.js.map +1 -1
- package/build/sdk/legacy/commands/serve.d.ts +1 -0
- package/build/sdk/legacy/commands/serve.d.ts.map +1 -1
- package/build/sdk/legacy/commands/serve.js +28 -2
- package/build/sdk/legacy/commands/serve.js.map +1 -1
- package/build/sdk/legacy/server/protocol/notificationHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/notificationHandlers.js +2 -6
- package/build/sdk/legacy/server/protocol/notificationHandlers.js.map +1 -1
- package/build/sdk/legacy/server/protocol/privateInteractionConnection.d.ts +1 -1
- package/build/sdk/legacy/server/protocol/privateInteractionConnection.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/privateInteractionConnection.js +31 -11
- package/build/sdk/legacy/server/protocol/privateInteractionConnection.js.map +1 -1
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.js +4 -4
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/protocol/requestInteractionScope.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/requestInteractionScope.js +62 -10
- package/build/sdk/legacy/server/protocol/requestInteractionScope.js.map +1 -1
- package/build/sdk/legacy/server/protocol/requestProviderProgress.d.ts +8 -0
- package/build/sdk/legacy/server/protocol/requestProviderProgress.d.ts.map +1 -0
- package/build/sdk/legacy/server/protocol/requestProviderProgress.js +29 -0
- package/build/sdk/legacy/server/protocol/requestProviderProgress.js.map +1 -0
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.js +20 -2
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.js +151 -60
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/retained-sdk/LICENSE +21 -0
- package/build/sdk/legacy/server/retained-sdk/provenance.json +17 -0
- package/build/sdk/legacy/server/retained-sdk/streamableHttp.js +160 -0
- package/build/sdk/legacy/server/retained-sdk/webStandardStreamableHttp.js +950 -0
- package/build/sdk/legacy/server/runtime/clientInstancePool.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/clientInstancePool.js +34 -6
- package/build/sdk/legacy/server/runtime/clientInstancePool.js.map +1 -1
- package/build/sdk/legacy/server/runtime/mcpLoggingEnhancer.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/mcpLoggingEnhancer.js +4 -2
- package/build/sdk/legacy/server/runtime/mcpLoggingEnhancer.js.map +1 -1
- package/build/sdk/legacy/server/runtime/serverManager.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/serverManager.js +3 -1
- package/build/sdk/legacy/server/runtime/serverManager.js.map +1 -1
- package/build/sdk/legacy/server/runtime/templateServerManager.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/templateServerManager.js +32 -7
- package/build/sdk/legacy/server/runtime/templateServerManager.js.map +1 -1
- package/build/sdk/legacy/server/streamableHttp.js +1 -1
- package/build/sdk/legacy/shared/resourceTemplateRouting.d.ts.map +1 -1
- package/build/sdk/legacy/shared/resourceTemplateRouting.js +29 -11
- package/build/sdk/legacy/shared/resourceTemplateRouting.js.map +1 -1
- package/build/sdk/legacy/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -1
- package/build/sdk/legacy/transport/http/middlewares/scopeAuthMiddleware.js +12 -1
- package/build/sdk/legacy/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -1
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.d.ts +4 -0
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.d.ts.map +1 -1
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.js +11 -0
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.js.map +1 -1
- package/build/sdk/legacy/transport/http/server.d.ts.map +1 -1
- package/build/sdk/legacy/transport/http/server.js +16 -2
- package/build/sdk/legacy/transport/http/server.js.map +1 -1
- package/build/sdk/legacy/transport/transportFactory.d.ts.map +1 -1
- package/build/sdk/legacy/transport/transportFactory.js +34 -12
- package/build/sdk/legacy/transport/transportFactory.js.map +1 -1
- package/build/transport/http/middlewares/httpRequestLogger.d.ts +4 -2
- package/build/transport/http/middlewares/httpRequestLogger.d.ts.map +1 -1
- package/build/transport/http/middlewares/httpRequestLogger.js +135 -16
- package/build/transport/http/middlewares/httpRequestLogger.js.map +1 -1
- package/build/transport/http/routes/cliTokenRoute.d.ts.map +1 -1
- package/build/transport/http/routes/cliTokenRoute.js +1 -0
- package/build/transport/http/routes/cliTokenRoute.js.map +1 -1
- package/build/transport/http/routes/healthRoutes.d.ts +11 -1
- package/build/transport/http/routes/healthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/healthRoutes.js +6 -2
- package/build/transport/http/routes/healthRoutes.js.map +1 -1
- package/build/transport/http/routes/inspectHelpers.d.ts.map +1 -1
- package/build/transport/http/routes/inspectHelpers.js +4 -3
- package/build/transport/http/routes/inspectHelpers.js.map +1 -1
- package/build/transport/http/routes/modernHttpRoutes.d.ts +4 -0
- package/build/transport/http/routes/modernHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/modernHttpRoutes.js +168 -24
- package/build/transport/http/routes/modernHttpRoutes.js.map +1 -1
- package/build/transport/http/routes/modernInteractionBinding.d.ts +2 -1
- package/build/transport/http/routes/modernInteractionBinding.d.ts.map +1 -1
- package/build/transport/http/routes/modernInteractionBinding.js +7 -4
- package/build/transport/http/routes/modernInteractionBinding.js.map +1 -1
- package/build/transport/http/routes/modernToolHeaderRegistry.d.ts +16 -0
- package/build/transport/http/routes/modernToolHeaderRegistry.d.ts.map +1 -0
- package/build/transport/http/routes/modernToolHeaderRegistry.js +161 -0
- package/build/transport/http/routes/modernToolHeaderRegistry.js.map +1 -0
- package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/oauthRoutes.js +6 -3
- package/build/transport/http/routes/oauthRoutes.js.map +1 -1
- package/build/transport/http/routes/toolRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/toolRoutes.js +18 -2
- package/build/transport/http/routes/toolRoutes.js.map +1 -1
- package/build/utils/core/parsing.d.ts +2 -0
- package/build/utils/core/parsing.d.ts.map +1 -1
- package/build/utils/core/parsing.js +19 -0
- package/build/utils/core/parsing.js.map +1 -1
- package/build/utils/core/resourceUris.d.ts +6 -0
- package/build/utils/core/resourceUris.d.ts.map +1 -0
- package/build/utils/core/resourceUris.js +104 -0
- package/build/utils/core/resourceUris.js.map +1 -0
- package/build/utils/core/toolNames.d.ts +8 -0
- package/build/utils/core/toolNames.d.ts.map +1 -0
- package/build/utils/core/toolNames.js +56 -0
- package/build/utils/core/toolNames.js.map +1 -0
- package/package.json +68 -64
|
@@ -1,243 +1,666 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { createHash, createHmac, randomBytes, randomUUID } from 'node:crypto';
|
|
3
|
+
import { authoritySlot, matchesAuthorityContext, OAUTH_ATTEMPT_TTL_MS, oauthAuthorityError, OAuthAuthorizationDeniedError, oauthDigest, sameAuthority, } from '../../../auth/oauthAuthority.js';
|
|
4
|
+
import { createOAuthEndpointFetch, validateOAuthEndpoint } from '../../../auth/oauthEndpointFetch.js';
|
|
2
5
|
import { ClientSessionRepository } from '../../../auth/storage/clientSessionRepository.js';
|
|
3
|
-
import {
|
|
6
|
+
import { createUpstreamOAuthStorage } from '../../../auth/storage/upstreamOAuthStorage.js';
|
|
4
7
|
import { AUTH_CONFIG } from '../../../constants.js';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* This provider implements the OAuth 2.1 Authorization Code Grant flow using
|
|
10
|
-
* the SDK's OAuthClientProvider interface while maintaining compatibility with
|
|
11
|
-
* the existing session storage system.
|
|
12
|
-
*/
|
|
8
|
+
import { AgentConfigManager } from '../../../core/server/agentConfig.js';
|
|
9
|
+
import { OAuthClientInformationFullSchema, OAuthTokensSchema, } from '../shared/auth.js';
|
|
10
|
+
/** Shared by the released modern and legacy SDK adapters. SDK cache objects are never authority. */
|
|
13
11
|
export class SDKOAuthClientProvider {
|
|
14
|
-
_clientMetadata;
|
|
15
|
-
_clientInfo;
|
|
16
|
-
_tokens;
|
|
17
|
-
_codeVerifier;
|
|
18
|
-
_state;
|
|
19
|
-
sessionRepository;
|
|
20
|
-
fileStorage;
|
|
21
12
|
serverName;
|
|
22
13
|
config;
|
|
23
|
-
|
|
14
|
+
sessionRepository;
|
|
15
|
+
fileStorage;
|
|
16
|
+
context;
|
|
17
|
+
slot;
|
|
18
|
+
record;
|
|
19
|
+
verifiers = new Map();
|
|
20
|
+
callbacks = new AsyncLocalStorage();
|
|
21
|
+
authorizationAttempt;
|
|
22
|
+
callbackTail = Promise.resolve();
|
|
23
|
+
operations = new AsyncLocalStorage();
|
|
24
|
+
sseEndpoint;
|
|
25
|
+
tokenRequests = new WeakMap();
|
|
26
|
+
tokenResponses = new Map();
|
|
27
|
+
registrationResponses = new Map();
|
|
28
|
+
discoveryResponses = new Map();
|
|
29
|
+
// These tickets are process-local; a random key protects secret-bearing response correlation.
|
|
30
|
+
responseKey = randomBytes(32);
|
|
31
|
+
migration;
|
|
32
|
+
shutdownSignal = new AbortController();
|
|
33
|
+
claim;
|
|
34
|
+
fetch;
|
|
24
35
|
constructor(serverName, config, sessionStoragePath) {
|
|
25
36
|
this.serverName = serverName;
|
|
26
37
|
this.config = config;
|
|
27
|
-
|
|
28
|
-
this.fileStorage =
|
|
38
|
+
const runtimeScope = AgentConfigManager.getInstance().get('runtimeScopeStoragePath');
|
|
39
|
+
this.fileStorage = createUpstreamOAuthStorage({
|
|
40
|
+
baseDir: sessionStoragePath,
|
|
41
|
+
runtimeScope: typeof runtimeScope === 'string' ? runtimeScope : undefined,
|
|
42
|
+
mode: AgentConfigManager.getInstance().get('auth').credentialStore ?? 'file',
|
|
43
|
+
});
|
|
29
44
|
this.sessionRepository = new ClientSessionRepository(this.fileStorage);
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
this.context = config.authority;
|
|
46
|
+
this.slot = this.context ? authoritySlot(this.context) : undefined;
|
|
47
|
+
const restore = () => {
|
|
48
|
+
if (this.slot && this.context) {
|
|
49
|
+
const stored = this.sessionRepository.getBound(this.slot);
|
|
50
|
+
if (stored && matchesAuthorityContext(stored.authority, this.context)) {
|
|
51
|
+
if (!config.issuer || config.issuer === stored.authority.issuer)
|
|
52
|
+
this.record = stored;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return this.slot ? (this.sessionRepository.getClaim(this.slot)?.generation ?? null) : null;
|
|
56
|
+
};
|
|
57
|
+
const alreadyReady = this.fileStorage.isReady();
|
|
58
|
+
const observed = alreadyReady ? restore() : null;
|
|
59
|
+
this.migration = this.fileStorage.ready().then(async () => {
|
|
60
|
+
const observedGeneration = alreadyReady ? observed : restore();
|
|
61
|
+
// Quarantine preserves unbound ownership: moving secrets never grants an authority.
|
|
62
|
+
await this.sessionRepository.quarantine(serverName);
|
|
63
|
+
if (this.slot && this.context)
|
|
64
|
+
this.claim = await this.sessionRepository.claimContext(this.slot, this.context, observedGeneration, this.shutdownSignal.signal);
|
|
65
|
+
});
|
|
66
|
+
void this.migration.catch(() => undefined);
|
|
67
|
+
this.fetch = createOAuthEndpointFetch({
|
|
68
|
+
resource: this.context?.route.url ?? 'https://invalid.invalid/',
|
|
69
|
+
issuer: this.config.issuer,
|
|
70
|
+
isResource: (url) => url.href === this.context?.route.url || url.href === this.sseEndpoint,
|
|
71
|
+
acceptSseEndpoint: this.context?.route.kind === 'sse'
|
|
72
|
+
? (endpoint) => {
|
|
73
|
+
const configured = new URL(this.context.route.url);
|
|
74
|
+
const target = new URL(endpoint, configured);
|
|
75
|
+
if (target.origin !== configured.origin || target.username || target.password || target.hash)
|
|
76
|
+
throw oauthAuthorityError();
|
|
77
|
+
this.sseEndpoint = target.href;
|
|
78
|
+
}
|
|
79
|
+
: undefined,
|
|
80
|
+
beforeRequest: (url, init) => this.prepareFetch(url, init),
|
|
81
|
+
pinDestination: async (host, addresses, init) => {
|
|
82
|
+
await this.migration;
|
|
83
|
+
if (!this.slot || !this.claim)
|
|
84
|
+
throw oauthAuthorityError();
|
|
85
|
+
await this.sessionRepository.pinDestination(this.slot, this.tokenRequests.get(init)?.generation ?? this.claim, host, addresses);
|
|
86
|
+
},
|
|
87
|
+
onFailure: (resourceRequest) => {
|
|
88
|
+
const operation = this.operations.getStore();
|
|
89
|
+
if (!resourceRequest && operation)
|
|
90
|
+
operation.failed = true;
|
|
91
|
+
},
|
|
92
|
+
response: (value, _url, init) => {
|
|
93
|
+
const ticket = this.tokenRequests.get(init);
|
|
94
|
+
if (!ticket)
|
|
95
|
+
return;
|
|
96
|
+
if (ticket.kind === 'token') {
|
|
97
|
+
const tokens = { ...value };
|
|
98
|
+
if (tokens.refresh_token === undefined)
|
|
99
|
+
tokens.refresh_token = new URLSearchParams(String(init.body ?? '')).get('refresh_token') ?? undefined;
|
|
100
|
+
const key = this.responseDigest(OAuthTokensSchema.parse(tokens));
|
|
101
|
+
this.recordResponse(this.responseMap('token'), key, ticket);
|
|
102
|
+
}
|
|
103
|
+
else if (ticket.kind === 'registration') {
|
|
104
|
+
const key = this.responseDigest(OAuthClientInformationFullSchema.parse({ ...this.clientMetadata, ...value }));
|
|
105
|
+
this.recordResponse(this.responseMap('registration'), key, ticket);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
metadata: (value, url, init) => {
|
|
109
|
+
const validated = this.validateMetadata(value, url);
|
|
110
|
+
const ticket = this.tokenRequests.get(init);
|
|
111
|
+
if (typeof value.issuer === 'string' && ticket)
|
|
112
|
+
this.recordResponse(this.responseMap('discovery'), this.discoveryKey(value), ticket);
|
|
113
|
+
return validated;
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
get redirectUrl() {
|
|
118
|
+
return this.config.redirectUrl || '';
|
|
119
|
+
}
|
|
120
|
+
get clientMetadataUrl() {
|
|
121
|
+
return this.config.clientMetadataUrl;
|
|
122
|
+
}
|
|
123
|
+
get clientMetadata() {
|
|
124
|
+
return {
|
|
125
|
+
client_name: `1MCP Agent - ${this.serverName}`,
|
|
126
|
+
redirect_uris: [this.redirectUrl],
|
|
34
127
|
grant_types: ['authorization_code', 'refresh_token'],
|
|
35
128
|
response_types: ['code'],
|
|
36
|
-
token_endpoint_auth_method: config.clientSecret ? 'client_secret_post' : 'none',
|
|
37
|
-
scope: config.scopes?.join(' ')
|
|
129
|
+
token_endpoint_auth_method: this.config.clientSecret ? 'client_secret_post' : 'none',
|
|
130
|
+
scope: this.config.scopes?.join(' ') ?? AUTH_CONFIG.CLIENT.OAUTH.DEFAULT_SCOPES.join(' '),
|
|
38
131
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
132
|
+
}
|
|
133
|
+
clientInformation(ctx) {
|
|
134
|
+
this.checkIssuer(ctx);
|
|
135
|
+
if (this.record)
|
|
136
|
+
this.requireCurrent();
|
|
137
|
+
if (this.config.clientId) {
|
|
138
|
+
return {
|
|
139
|
+
...this.clientMetadata,
|
|
140
|
+
client_id: this.config.clientId,
|
|
141
|
+
client_secret: this.config.clientSecret,
|
|
142
|
+
...(this.record ? { issuer: this.record.authority.issuer } : {}),
|
|
50
143
|
};
|
|
51
144
|
}
|
|
145
|
+
const record = this.current();
|
|
146
|
+
if (!record?.clientInfo)
|
|
147
|
+
return undefined;
|
|
148
|
+
try {
|
|
149
|
+
return {
|
|
150
|
+
...OAuthClientInformationFullSchema.parse(JSON.parse(record.clientInfo)),
|
|
151
|
+
issuer: record.authority.issuer,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
throw oauthAuthorityError();
|
|
156
|
+
}
|
|
52
157
|
}
|
|
53
|
-
|
|
54
|
-
|
|
158
|
+
async saveClientInformation(clientInfo, ctx) {
|
|
159
|
+
this.assertOperation();
|
|
160
|
+
this.checkIssuer(ctx);
|
|
161
|
+
const record = this.requireCurrent();
|
|
162
|
+
const stamped = clientInfo;
|
|
163
|
+
if (stamped.issuer && stamped.issuer !== record.authority.issuer)
|
|
164
|
+
throw oauthAuthorityError();
|
|
165
|
+
if (this.config.clientId)
|
|
166
|
+
return;
|
|
167
|
+
const parsed = OAuthClientInformationFullSchema.parse({ ...this.clientMetadata, ...clientInfo });
|
|
168
|
+
const key = this.responseDigest(parsed);
|
|
169
|
+
const ticket = this.responseMap('registration').get(key);
|
|
170
|
+
this.responseMap('registration').delete(key);
|
|
171
|
+
if (!ticket && parsed.client_id !== this.config.clientMetadataUrl)
|
|
172
|
+
throw oauthAuthorityError();
|
|
173
|
+
if (ticket && (ticket.ambiguous || ticket.generation !== record.generation))
|
|
174
|
+
throw oauthAuthorityError();
|
|
175
|
+
this.record = await this.sessionRepository.updateBound(this.slot, record.generation, (current) => {
|
|
176
|
+
if (ticket && current.revision !== ticket.revision)
|
|
177
|
+
throw oauthAuthorityError();
|
|
178
|
+
current.clientInfo = JSON.stringify(parsed);
|
|
179
|
+
current.revision++;
|
|
180
|
+
}, ticket?.requestVersion ?? this.operations.getStore()?.requestVersion);
|
|
181
|
+
this.advanceOperation();
|
|
182
|
+
}
|
|
183
|
+
tokens(ctx) {
|
|
184
|
+
this.checkIssuer(ctx);
|
|
185
|
+
const record = this.current();
|
|
186
|
+
if (!record?.tokens)
|
|
187
|
+
return undefined;
|
|
188
|
+
try {
|
|
189
|
+
return { ...OAuthTokensSchema.parse(JSON.parse(record.tokens)), issuer: record.authority.issuer };
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
throw oauthAuthorityError();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async saveTokens(tokens, ctx) {
|
|
196
|
+
this.assertOperation();
|
|
197
|
+
this.checkIssuer(ctx);
|
|
198
|
+
const record = this.requireCurrent();
|
|
199
|
+
const stamped = tokens;
|
|
200
|
+
if (stamped.issuer && stamped.issuer !== record.authority.issuer)
|
|
201
|
+
throw oauthAuthorityError();
|
|
202
|
+
const parsed = OAuthTokensSchema.parse(tokens);
|
|
203
|
+
if (this.config.scopes && parsed.scope?.split(' ').some((scope) => !this.config.scopes.includes(scope)))
|
|
204
|
+
throw oauthAuthorityError();
|
|
205
|
+
const responseKey = this.responseDigest(parsed);
|
|
206
|
+
const ticket = this.responseMap('token').get(responseKey);
|
|
207
|
+
this.responseMap('token').delete(responseKey);
|
|
208
|
+
if (!ticket || ticket.ambiguous || ticket.generation !== record.generation)
|
|
209
|
+
this.rejectOperation();
|
|
210
|
+
const expectedRevision = ticket.revision;
|
|
211
|
+
this.record = await this.sessionRepository.updateBound(this.slot, record.generation, (current) => {
|
|
212
|
+
if (current.revision !== expectedRevision)
|
|
213
|
+
throw oauthAuthorityError();
|
|
214
|
+
current.tokens = JSON.stringify(parsed);
|
|
215
|
+
current.revision++;
|
|
216
|
+
}, ticket.requestVersion);
|
|
217
|
+
this.authorizationAttempt = undefined;
|
|
218
|
+
}
|
|
219
|
+
async invalidateCredentials(scope) {
|
|
220
|
+
const record = this.current();
|
|
221
|
+
this.authorizationAttempt = undefined;
|
|
222
|
+
this.verifiers.clear();
|
|
223
|
+
if (!record)
|
|
224
|
+
return;
|
|
225
|
+
this.record = await this.sessionRepository.updateBound(this.slot, record.generation, (current) => {
|
|
226
|
+
current.generation = randomUUID();
|
|
227
|
+
current.revision++;
|
|
228
|
+
current.attempts = {};
|
|
229
|
+
if (scope !== 'verifier')
|
|
230
|
+
current.tokens = undefined;
|
|
231
|
+
if (scope === 'all' || scope === 'client' || scope === 'discovery')
|
|
232
|
+
current.clientInfo = undefined;
|
|
233
|
+
if (scope === 'all' || scope === 'discovery')
|
|
234
|
+
current.discovery = '';
|
|
235
|
+
});
|
|
236
|
+
this.claim = this.record.generation;
|
|
237
|
+
// In-flight work retains its old revision and cannot publish into this generation.
|
|
238
|
+
}
|
|
239
|
+
state() {
|
|
240
|
+
return randomUUID();
|
|
241
|
+
}
|
|
242
|
+
saveCodeVerifier(verifier) {
|
|
243
|
+
if (!/^[A-Za-z0-9._~-]{43,128}$/.test(verifier) || this.verifiers.size >= 32)
|
|
244
|
+
throw oauthAuthorityError();
|
|
245
|
+
this.verifiers.set(createHash('sha256').update(verifier).digest('base64url'), verifier);
|
|
246
|
+
}
|
|
247
|
+
codeVerifier() {
|
|
248
|
+
const callback = this.callbacks.getStore();
|
|
249
|
+
if (!callback || callback.generation !== this.requireCurrent().generation)
|
|
250
|
+
throw oauthAuthorityError();
|
|
251
|
+
return callback.verifier;
|
|
252
|
+
}
|
|
253
|
+
async redirectToAuthorization(url) {
|
|
254
|
+
this.assertOperation();
|
|
255
|
+
const record = this.requireCurrent();
|
|
256
|
+
const target = new URL(url);
|
|
257
|
+
const state = target.searchParams.get('state');
|
|
258
|
+
const challenge = target.searchParams.get('code_challenge');
|
|
259
|
+
const verifier = challenge ? this.verifiers.get(challenge) : undefined;
|
|
260
|
+
target.search = '';
|
|
261
|
+
const endpoint = new URL(record.authority.authorizationEndpoint);
|
|
262
|
+
endpoint.search = '';
|
|
263
|
+
if (target.href !== endpoint.href ||
|
|
264
|
+
!state ||
|
|
265
|
+
!verifier ||
|
|
266
|
+
url.searchParams.get('redirect_uri') !== this.redirectUrl ||
|
|
267
|
+
url.searchParams.get('resource') !== record.authority.resource)
|
|
268
|
+
throw oauthAuthorityError();
|
|
269
|
+
this.assertScopes(url.searchParams.get('scope'));
|
|
270
|
+
await this.sessionRepository.addAttempt(this.slot, record.generation, state, {
|
|
271
|
+
authority: record.authority,
|
|
272
|
+
generation: record.generation,
|
|
273
|
+
redirect: this.redirectUrl,
|
|
274
|
+
verifier,
|
|
275
|
+
createdAt: Date.now(),
|
|
276
|
+
expires: Date.now() + OAUTH_ATTEMPT_TTL_MS,
|
|
277
|
+
consumed: false,
|
|
278
|
+
});
|
|
279
|
+
this.verifiers.delete(challenge);
|
|
280
|
+
this.authorizationAttempt = { url: url.toString(), key: oauthDigest(state) };
|
|
55
281
|
}
|
|
56
|
-
get clientMetadata() {
|
|
57
|
-
return this._clientMetadata;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Returns current client registration information
|
|
61
|
-
*/
|
|
62
|
-
clientInformation() {
|
|
63
|
-
return this._clientInfo;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Saves client registration information from dynamic registration
|
|
67
|
-
*/
|
|
68
|
-
saveClientInformation(clientInfo) {
|
|
69
|
-
this._clientInfo = clientInfo;
|
|
70
|
-
this.persistAllData();
|
|
71
|
-
logger.info('sdkOAuthClientProvider.oauth.client.registered.for.a7d64162');
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Returns current OAuth tokens
|
|
75
|
-
*/
|
|
76
|
-
tokens() {
|
|
77
|
-
return this._tokens;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Saves OAuth tokens after successful authorization
|
|
81
|
-
*/
|
|
82
|
-
saveTokens(tokens) {
|
|
83
|
-
this._tokens = tokens;
|
|
84
|
-
this.persistAllData();
|
|
85
|
-
logger.info('sdkOAuthClientProvider.oauth.tokens.saved.for.22916b52');
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Invalidates persisted OAuth credentials as requested by the MCP SDK.
|
|
89
|
-
*/
|
|
90
|
-
invalidateCredentials(scope) {
|
|
91
|
-
switch (scope) {
|
|
92
|
-
case 'all':
|
|
93
|
-
this._clientInfo = undefined;
|
|
94
|
-
this._tokens = undefined;
|
|
95
|
-
this._codeVerifier = undefined;
|
|
96
|
-
this._state = undefined;
|
|
97
|
-
this._authorizationUrl = undefined;
|
|
98
|
-
break;
|
|
99
|
-
case 'client':
|
|
100
|
-
this._clientInfo = undefined;
|
|
101
|
-
break;
|
|
102
|
-
case 'tokens':
|
|
103
|
-
this._tokens = undefined;
|
|
104
|
-
this._state = undefined;
|
|
105
|
-
this._authorizationUrl = undefined;
|
|
106
|
-
break;
|
|
107
|
-
case 'verifier':
|
|
108
|
-
this._codeVerifier = undefined;
|
|
109
|
-
break;
|
|
110
|
-
case 'discovery':
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
this.persistAllData();
|
|
114
|
-
logger.info('sdkOAuthClientProvider.oauth.credentials.invalidated.for.a8274c9f');
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Stores authorization URL instead of prompting user in console
|
|
118
|
-
*/
|
|
119
|
-
redirectToAuthorization(authorizationUrl) {
|
|
120
|
-
this._authorizationUrl = authorizationUrl.toString();
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Gets the current authorization URL
|
|
124
|
-
*/
|
|
125
282
|
getAuthorizationUrl() {
|
|
126
|
-
return this.
|
|
283
|
+
return this.authorizationAttempt?.url;
|
|
284
|
+
}
|
|
285
|
+
/** Only a live, unconsumed attempt owned by this provider can be resumed. */
|
|
286
|
+
getPendingAuthorizationUrl() {
|
|
287
|
+
const authorization = this.authorizationAttempt;
|
|
288
|
+
if (!authorization)
|
|
289
|
+
return undefined;
|
|
290
|
+
const record = this.current();
|
|
291
|
+
if (!record)
|
|
292
|
+
return undefined;
|
|
293
|
+
// The durable key was bound to this URL at creation, before it was exposed
|
|
294
|
+
// through transport/provider APIs. Resumption never reinterprets a URL.
|
|
295
|
+
const attempt = record.attempts[authorization.key];
|
|
296
|
+
if (!attempt || attempt.consumed || attempt.expires <= Date.now())
|
|
297
|
+
return undefined;
|
|
298
|
+
if (attempt.generation !== record.generation || !sameAuthority(attempt.authority, record.authority))
|
|
299
|
+
return undefined;
|
|
300
|
+
if (attempt.redirect !== this.redirectUrl)
|
|
301
|
+
return undefined;
|
|
302
|
+
return this.authorizationAttempt?.url;
|
|
127
303
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Clears the stored authorization URL
|
|
130
|
-
*/
|
|
131
304
|
clearAuthorizationUrl() {
|
|
132
|
-
this.
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Saves PKCE code verifier for the authorization session
|
|
136
|
-
*/
|
|
137
|
-
saveCodeVerifier(codeVerifier) {
|
|
138
|
-
this._codeVerifier = codeVerifier;
|
|
139
|
-
this.persistAllData();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Returns the PKCE code verifier for token exchange
|
|
143
|
-
*/
|
|
144
|
-
codeVerifier() {
|
|
145
|
-
return this._codeVerifier || '';
|
|
305
|
+
this.authorizationAttempt = undefined;
|
|
146
306
|
}
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
307
|
+
/** Validation and durable consumption happen before the SDK can see a code, for both eras. */
|
|
308
|
+
async withAuthorizationCallback(response, operation) {
|
|
309
|
+
const run = async () => {
|
|
310
|
+
await this.migration;
|
|
311
|
+
const record = this.requireCurrent();
|
|
312
|
+
for (const key of ['state', 'code', 'iss', 'error', 'redirect_uri']) {
|
|
313
|
+
if (response.getAll(key).length > 1)
|
|
314
|
+
throw oauthAuthorityError();
|
|
315
|
+
}
|
|
316
|
+
const state = response.get('state');
|
|
317
|
+
if (!state)
|
|
318
|
+
throw oauthAuthorityError();
|
|
319
|
+
const attempt = await this.sessionRepository.consumeAttempt(this.slot, record.generation, state, (candidate) => {
|
|
320
|
+
if (!sameAuthority(candidate.authority, record.authority) ||
|
|
321
|
+
candidate.generation !== record.generation ||
|
|
322
|
+
candidate.redirect !== this.redirectUrl)
|
|
323
|
+
throw oauthAuthorityError();
|
|
324
|
+
const redirect = response.get('redirect_uri');
|
|
325
|
+
if (redirect && redirect !== candidate.redirect)
|
|
326
|
+
throw oauthAuthorityError();
|
|
327
|
+
const issuer = response.get('iss');
|
|
328
|
+
if (candidate.authority.requireIssuer && !issuer)
|
|
329
|
+
throw oauthAuthorityError();
|
|
330
|
+
if (issuer !== null && issuer !== candidate.authority.issuer)
|
|
331
|
+
throw oauthAuthorityError();
|
|
332
|
+
if (!response.get('code') && !response.get('error'))
|
|
333
|
+
throw oauthAuthorityError();
|
|
334
|
+
});
|
|
335
|
+
if (response.has('error'))
|
|
336
|
+
throw new OAuthAuthorizationDeniedError(response.get('error') === 'access_denied' ? 'access_denied' : 'provider_error');
|
|
337
|
+
return this.callbacks.run({ verifier: attempt.verifier, generation: attempt.generation }, operation);
|
|
338
|
+
};
|
|
339
|
+
const pending = this.callbackTail.then(run, run);
|
|
340
|
+
this.callbackTail = pending.catch(() => undefined);
|
|
341
|
+
return pending;
|
|
342
|
+
}
|
|
343
|
+
async bindAdminReturn(state, origin) {
|
|
344
|
+
const record = this.requireCurrent();
|
|
345
|
+
await this.sessionRepository.updateBound(this.slot, record.generation, (current) => {
|
|
346
|
+
const attempt = current.attempts[oauthDigest(state)];
|
|
347
|
+
if (!attempt || attempt.consumed || attempt.expires <= Date.now())
|
|
348
|
+
throw oauthAuthorityError();
|
|
349
|
+
attempt.adminReturnOrigin = origin;
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
getAdminReturn(state) {
|
|
353
|
+
const attempt = this.current()?.attempts[oauthDigest(state)];
|
|
354
|
+
return attempt && attempt.consumed && attempt.expires > Date.now() ? attempt.adminReturnOrigin : undefined;
|
|
156
355
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Custom resource validation (optional)
|
|
159
|
-
*/
|
|
160
356
|
async validateResourceURL(serverUrl, resource) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
357
|
+
return this.selectResourceURL(serverUrl, resource);
|
|
358
|
+
}
|
|
359
|
+
selectResourceURL(serverUrl, resource) {
|
|
360
|
+
try {
|
|
361
|
+
const configured = new URL(this.context?.route.url ?? serverUrl);
|
|
362
|
+
configured.hash = '';
|
|
363
|
+
const requested = new URL(serverUrl);
|
|
364
|
+
requested.hash = '';
|
|
365
|
+
if (requested.href !== configured.href)
|
|
366
|
+
throw oauthAuthorityError();
|
|
367
|
+
if (resource === undefined)
|
|
368
|
+
return configured;
|
|
369
|
+
const advertised = new URL(resource);
|
|
370
|
+
if (advertised.username || advertised.password || resource.includes('#'))
|
|
371
|
+
throw oauthAuthorityError();
|
|
372
|
+
if (advertised.origin !== configured.origin || advertised.search !== configured.search)
|
|
373
|
+
throw oauthAuthorityError();
|
|
374
|
+
// Resource Indicators may describe a parent resource; the transport route remains exact.
|
|
375
|
+
const resourcePath = advertised.pathname.endsWith('/') ? advertised.pathname : advertised.pathname + '/';
|
|
376
|
+
const routePath = configured.pathname.endsWith('/') ? configured.pathname : configured.pathname + '/';
|
|
377
|
+
if (configured.pathname.length < advertised.pathname.length || !routePath.startsWith(resourcePath))
|
|
378
|
+
throw oauthAuthorityError();
|
|
379
|
+
return advertised;
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
throw oauthAuthorityError();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
discoveryState() {
|
|
386
|
+
// A new SDK auth operation may retry transient transport failures. The failed
|
|
387
|
+
// operation itself remains blocked from inferred fallback or credential writes.
|
|
388
|
+
this.operations.enterWith({
|
|
389
|
+
failed: false,
|
|
390
|
+
responses: { token: new Map(), registration: new Map(), discovery: new Map() },
|
|
391
|
+
});
|
|
392
|
+
const current = this.current();
|
|
393
|
+
// Refresh/new authorization re-discovers current destinations. Only a validated
|
|
394
|
+
// callback resumes the exact discovery snapshot captured by its durable attempt.
|
|
395
|
+
if (!this.callbacks.getStore() || !current?.discovery)
|
|
396
|
+
return undefined;
|
|
397
|
+
try {
|
|
398
|
+
return JSON.parse(current.discovery);
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
throw oauthAuthorityError();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
async saveDiscoveryState(state) {
|
|
405
|
+
await this.migration;
|
|
406
|
+
this.assertOperation();
|
|
407
|
+
if (!this.context || !this.slot)
|
|
408
|
+
throw oauthAuthorityError();
|
|
409
|
+
const metadata = state.authorizationServerMetadata;
|
|
410
|
+
let requestVersion = this.operations.getStore()?.requestVersion;
|
|
411
|
+
if (metadata) {
|
|
412
|
+
const key = this.discoveryKey(metadata);
|
|
413
|
+
const ticket = this.responseMap('discovery').get(key);
|
|
414
|
+
this.responseMap('discovery').delete(key);
|
|
415
|
+
if (ticket && (ticket.ambiguous || ticket.generation !== this.claim))
|
|
416
|
+
throw oauthAuthorityError();
|
|
417
|
+
if (ticket)
|
|
418
|
+
requestVersion = ticket.requestVersion;
|
|
419
|
+
}
|
|
420
|
+
const issuer = state.authorizationServerUrl;
|
|
421
|
+
if (this.config.issuer && this.config.issuer !== issuer)
|
|
422
|
+
throw oauthAuthorityError();
|
|
423
|
+
if (metadata?.issuer && metadata.issuer !== issuer)
|
|
424
|
+
throw oauthAuthorityError();
|
|
425
|
+
const approved = this.record?.authority.issuer;
|
|
426
|
+
const advertised = state.resourceMetadata?.authorization_servers;
|
|
427
|
+
if (advertised?.length) {
|
|
428
|
+
const selected = this.config.issuer ?? (approved && advertised.includes(approved) ? approved : undefined);
|
|
429
|
+
if (selected ? selected !== issuer : advertised.length !== 1 || advertised[0] !== issuer)
|
|
430
|
+
throw oauthAuthorityError();
|
|
431
|
+
}
|
|
432
|
+
else if (!this.config.legacy && !this.config.issuer) {
|
|
433
|
+
throw oauthAuthorityError();
|
|
434
|
+
}
|
|
435
|
+
const issuerUrl = validateOAuthEndpoint(issuer, this.context.route.url, undefined, this.config.issuer);
|
|
436
|
+
if (issuerUrl.search || issuerUrl.hash)
|
|
437
|
+
throw oauthAuthorityError();
|
|
438
|
+
const fallback = this.config.legacy && issuerUrl.origin === new URL(this.context.route.url).origin;
|
|
439
|
+
if (!metadata && !fallback)
|
|
440
|
+
throw oauthAuthorityError();
|
|
441
|
+
const resource = await this.validateResourceURL(this.context.route.url, state.resourceMetadata?.resource);
|
|
442
|
+
const endpoint = (value, pathname) => {
|
|
443
|
+
if (!value && !fallback)
|
|
444
|
+
throw oauthAuthorityError();
|
|
445
|
+
return validateOAuthEndpoint(value ?? new URL(pathname, issuerUrl).href, this.context.route.url, value ? undefined : issuerUrl.origin, this.config.issuer).href;
|
|
446
|
+
};
|
|
447
|
+
let registrationEndpoint;
|
|
448
|
+
if (metadata?.registration_endpoint)
|
|
449
|
+
registrationEndpoint = endpoint(metadata.registration_endpoint, '/register');
|
|
450
|
+
else if (!metadata && fallback)
|
|
451
|
+
registrationEndpoint = endpoint(undefined, '/register');
|
|
452
|
+
const authority = {
|
|
453
|
+
...this.context,
|
|
454
|
+
version: 1,
|
|
455
|
+
issuer,
|
|
456
|
+
resource: resource.href,
|
|
457
|
+
authorizationEndpoint: endpoint(metadata?.authorization_endpoint, '/authorize'),
|
|
458
|
+
tokenEndpoint: endpoint(metadata?.token_endpoint, '/token'),
|
|
459
|
+
registrationEndpoint,
|
|
460
|
+
requireIssuer: metadata
|
|
461
|
+
?.authorization_response_iss_parameter_supported === true,
|
|
462
|
+
};
|
|
463
|
+
this.record = await this.sessionRepository.activate(this.slot, authority, JSON.stringify(state), this.claim, requestVersion);
|
|
464
|
+
this.claim = this.record.generation;
|
|
465
|
+
this.advanceOperation();
|
|
466
|
+
}
|
|
467
|
+
current() {
|
|
468
|
+
if (!this.record || !this.slot || !this.context)
|
|
164
469
|
return undefined;
|
|
470
|
+
const current = this.sessionRepository.getBound(this.slot);
|
|
471
|
+
if (this.sessionRepository.getClaim(this.slot)?.generation !== this.record.generation)
|
|
472
|
+
throw oauthAuthorityError();
|
|
473
|
+
if (!current ||
|
|
474
|
+
current.generation !== this.record.generation ||
|
|
475
|
+
!sameAuthority(current.authority, this.record.authority) ||
|
|
476
|
+
!matchesAuthorityContext(current.authority, this.context))
|
|
477
|
+
throw oauthAuthorityError();
|
|
478
|
+
return current;
|
|
479
|
+
}
|
|
480
|
+
requireCurrent() {
|
|
481
|
+
const current = this.current();
|
|
482
|
+
if (!current)
|
|
483
|
+
throw oauthAuthorityError();
|
|
484
|
+
return current;
|
|
485
|
+
}
|
|
486
|
+
checkIssuer(ctx) {
|
|
487
|
+
if (!ctx)
|
|
488
|
+
return;
|
|
489
|
+
const issuer = this.record?.authority.issuer ?? this.config.issuer;
|
|
490
|
+
if (!issuer || ctx.issuer !== issuer)
|
|
491
|
+
throw oauthAuthorityError();
|
|
492
|
+
}
|
|
493
|
+
assertScopes(scope) {
|
|
494
|
+
if (this.config.scopes && scope?.split(' ').some((item) => !this.config.scopes.includes(item)))
|
|
495
|
+
throw oauthAuthorityError();
|
|
496
|
+
}
|
|
497
|
+
validateMetadata(value, url) {
|
|
498
|
+
if (!this.context)
|
|
499
|
+
throw oauthAuthorityError();
|
|
500
|
+
if (Array.isArray(value.authorization_servers)) {
|
|
501
|
+
const issuers = value.authorization_servers;
|
|
502
|
+
if (!issuers.length || issuers.length > 16 || issuers.some((issuer) => typeof issuer !== 'string'))
|
|
503
|
+
throw oauthAuthorityError();
|
|
504
|
+
for (const issuer of issuers)
|
|
505
|
+
validateOAuthEndpoint(String(issuer), this.context.route.url, undefined, this.config.issuer);
|
|
506
|
+
const approved = this.config.issuer ?? this.record?.authority.issuer;
|
|
507
|
+
let selected;
|
|
508
|
+
if (approved && issuers.includes(approved))
|
|
509
|
+
selected = approved;
|
|
510
|
+
else if (issuers.length === 1)
|
|
511
|
+
selected = String(issuers[0]);
|
|
512
|
+
if (!selected || (this.config.issuer && selected !== this.config.issuer))
|
|
513
|
+
throw oauthAuthorityError();
|
|
514
|
+
if (typeof value.resource !== 'string')
|
|
515
|
+
throw oauthAuthorityError();
|
|
516
|
+
this.selectResourceURL(this.context.route.url, value.resource);
|
|
517
|
+
return {
|
|
518
|
+
...value,
|
|
519
|
+
authorization_servers: [selected],
|
|
520
|
+
...(this.config.scopes ? { scopes_supported: this.config.scopes } : {}),
|
|
521
|
+
};
|
|
165
522
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (clientSession) {
|
|
174
|
-
// Load client info
|
|
175
|
-
if (clientSession.clientInfo) {
|
|
176
|
-
this._clientInfo = JSON.parse(clientSession.clientInfo);
|
|
523
|
+
if (typeof value.issuer === 'string') {
|
|
524
|
+
const issuer = validateOAuthEndpoint(value.issuer, this.context.route.url, undefined, this.config.issuer);
|
|
525
|
+
if (issuer.origin !== url.origin || (this.config.issuer && value.issuer !== this.config.issuer))
|
|
526
|
+
throw oauthAuthorityError();
|
|
527
|
+
for (const key of ['authorization_endpoint', 'token_endpoint', 'registration_endpoint', 'jwks_uri']) {
|
|
528
|
+
if (value[key] !== undefined)
|
|
529
|
+
validateOAuthEndpoint(String(value[key]), this.context.route.url, undefined, this.config.issuer);
|
|
177
530
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
531
|
+
}
|
|
532
|
+
return value;
|
|
533
|
+
}
|
|
534
|
+
async prepareFetch(url, init) {
|
|
535
|
+
await this.migration;
|
|
536
|
+
if (!this.context)
|
|
537
|
+
throw oauthAuthorityError();
|
|
538
|
+
const resource = new URL(this.context.route.url);
|
|
539
|
+
const headers = new Headers(init.headers);
|
|
540
|
+
const isDiscovery = (init.method ?? 'GET') === 'GET' && url.href !== resource.href && url.href !== this.sseEndpoint;
|
|
541
|
+
if (isDiscovery) {
|
|
542
|
+
this.assertOperation();
|
|
543
|
+
const requestVersion = await this.reserveRequest();
|
|
544
|
+
if (url.search)
|
|
545
|
+
throw oauthAuthorityError();
|
|
546
|
+
const request = { ...init, headers: { accept: 'application/json' }, redirect: 'error' };
|
|
547
|
+
this.tokenRequests.set(request, {
|
|
548
|
+
generation: this.claim,
|
|
549
|
+
revision: this.record?.revision ?? 0,
|
|
550
|
+
kind: 'discovery',
|
|
551
|
+
requestVersion,
|
|
552
|
+
});
|
|
553
|
+
return request;
|
|
554
|
+
}
|
|
555
|
+
// Resource requests need the generation check in pinDestination, not credential loading.
|
|
556
|
+
if (url.href === resource.href || url.href === this.sseEndpoint)
|
|
557
|
+
return { ...init, redirect: 'error' };
|
|
558
|
+
const record = this.current();
|
|
559
|
+
const isToken = record?.authority.tokenEndpoint === url.href;
|
|
560
|
+
const isRegistration = record?.authority.registrationEndpoint === url.href;
|
|
561
|
+
if (isToken || isRegistration) {
|
|
562
|
+
this.assertOperation();
|
|
563
|
+
const requestVersion = await this.reserveRequest();
|
|
564
|
+
if ((init.method ?? 'GET') !== 'POST')
|
|
565
|
+
throw oauthAuthorityError();
|
|
566
|
+
const safeHeaders = new Headers();
|
|
567
|
+
safeHeaders.set('content-type', isToken ? 'application/x-www-form-urlencoded' : 'application/json');
|
|
568
|
+
if (isToken) {
|
|
569
|
+
const params = new URLSearchParams(String(init.body ?? ''));
|
|
570
|
+
if (params.get('resource') !== record.authority.resource)
|
|
571
|
+
throw oauthAuthorityError();
|
|
572
|
+
this.assertScopes(params.get('scope'));
|
|
573
|
+
if (params.get('grant_type') === 'authorization_code') {
|
|
574
|
+
if (this.callbacks.getStore()?.generation !== record.generation)
|
|
575
|
+
throw oauthAuthorityError();
|
|
186
576
|
}
|
|
577
|
+
const client = this.clientInformation();
|
|
578
|
+
const authorization = headers.get('authorization');
|
|
579
|
+
if (authorization?.startsWith('Basic ') && client?.client_secret) {
|
|
580
|
+
const expected = `Basic ${Buffer.from(`${client.client_id}:${client.client_secret}`).toString('base64')}`;
|
|
581
|
+
if (authorization !== expected)
|
|
582
|
+
throw oauthAuthorityError();
|
|
583
|
+
safeHeaders.set('authorization', authorization);
|
|
584
|
+
}
|
|
585
|
+
if (params.has('client_id') && params.get('client_id') !== client?.client_id)
|
|
586
|
+
throw oauthAuthorityError();
|
|
587
|
+
if (params.has('client_secret') && params.get('client_secret') !== client?.client_secret)
|
|
588
|
+
throw oauthAuthorityError();
|
|
187
589
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
this.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (clientSession.state) {
|
|
194
|
-
this._state = clientSession.state;
|
|
590
|
+
else {
|
|
591
|
+
const registration = JSON.parse(String(init.body ?? '{}'));
|
|
592
|
+
this.assertScopes(registration.scope ?? null);
|
|
593
|
+
if (this.config.clientId || this.config.autoRegister === false)
|
|
594
|
+
throw oauthAuthorityError();
|
|
195
595
|
}
|
|
596
|
+
const request = { ...init, headers: safeHeaders, redirect: 'error' };
|
|
597
|
+
this.tokenRequests.set(request, {
|
|
598
|
+
generation: record.generation,
|
|
599
|
+
revision: record.revision,
|
|
600
|
+
kind: isToken ? 'token' : 'registration',
|
|
601
|
+
requestVersion,
|
|
602
|
+
});
|
|
603
|
+
return request;
|
|
196
604
|
}
|
|
605
|
+
throw oauthAuthorityError();
|
|
197
606
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
607
|
+
responseMap(kind) {
|
|
608
|
+
const operation = this.operations.getStore();
|
|
609
|
+
if (operation)
|
|
610
|
+
return operation.responses[kind];
|
|
611
|
+
if (kind === 'token')
|
|
612
|
+
return this.tokenResponses;
|
|
613
|
+
if (kind === 'registration')
|
|
614
|
+
return this.registrationResponses;
|
|
615
|
+
return this.discoveryResponses;
|
|
616
|
+
}
|
|
617
|
+
advanceOperation() {
|
|
618
|
+
const operation = this.operations.getStore();
|
|
619
|
+
if (operation && this.slot)
|
|
620
|
+
operation.requestVersion = this.sessionRepository.getClaim(this.slot)?.requestVersion;
|
|
621
|
+
}
|
|
622
|
+
rejectOperation() {
|
|
623
|
+
const operation = this.operations.getStore();
|
|
624
|
+
if (operation)
|
|
625
|
+
operation.failed = true;
|
|
626
|
+
throw oauthAuthorityError();
|
|
627
|
+
}
|
|
628
|
+
assertOperation() {
|
|
629
|
+
if (this.operations.getStore()?.failed)
|
|
630
|
+
throw oauthAuthorityError();
|
|
631
|
+
}
|
|
632
|
+
async reserveRequest() {
|
|
633
|
+
const requestVersion = await this.sessionRepository.reserveRequest(this.slot, this.claim);
|
|
634
|
+
const operation = this.operations.getStore();
|
|
635
|
+
if (operation)
|
|
636
|
+
operation.requestVersion = requestVersion;
|
|
637
|
+
return requestVersion;
|
|
638
|
+
}
|
|
639
|
+
responseDigest(value) {
|
|
640
|
+
return createHmac('sha256', this.responseKey).update(JSON.stringify(value)).digest('hex');
|
|
641
|
+
}
|
|
642
|
+
discoveryKey(metadata) {
|
|
643
|
+
return this.responseDigest([
|
|
644
|
+
metadata.issuer,
|
|
645
|
+
metadata.authorization_endpoint,
|
|
646
|
+
metadata.token_endpoint,
|
|
647
|
+
metadata.registration_endpoint,
|
|
648
|
+
]);
|
|
649
|
+
}
|
|
650
|
+
recordResponse(target, key, ticket) {
|
|
651
|
+
if (target.size >= 32 && !target.has(key))
|
|
652
|
+
throw oauthAuthorityError();
|
|
653
|
+
const previous = target.get(key);
|
|
654
|
+
if (previous) {
|
|
655
|
+
previous.ambiguous = true;
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
target.set(key, ticket);
|
|
659
|
+
}
|
|
660
|
+
async shutdown() {
|
|
661
|
+
this.shutdownSignal.abort();
|
|
240
662
|
this.fileStorage.shutdown();
|
|
663
|
+
await this.migration.catch(() => undefined);
|
|
241
664
|
}
|
|
242
665
|
}
|
|
243
666
|
//# sourceMappingURL=sdkOAuthClientProvider.js.map
|