@mcp-use/inspector 20.0.0-beta.17 → 20.0.0-beta.19
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 +1 -1
- package/dist/app/inspector.css.gz +0 -0
- package/dist/app/inspector.js.gz +0 -0
- package/dist/app/providers/anthropic.png +0 -0
- package/dist/app/providers/google.png +0 -0
- package/dist/app/providers/openai.png +0 -0
- package/dist/cli.js +14 -1446
- package/dist/client/index.d.ts +1399 -50
- package/dist/client/index.js +170 -24320
- package/dist/server/index.d.ts +79 -6
- package/dist/server/index.js +99 -18
- package/package.json +61 -37
- package/dist/app/inspector.css +0 -2
- package/dist/app/inspector.js +0 -92352
- package/dist/client/auth/manufact-auth.d.ts +0 -32
- package/dist/client/auth/manufact-auth.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryHeader.d.ts +0 -4
- package/dist/client/chat-history/ChatHistoryHeader.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryPanel.d.ts +0 -28
- package/dist/client/chat-history/ChatHistoryPanel.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryRail.d.ts +0 -5
- package/dist/client/chat-history/ChatHistoryRail.d.ts.map +0 -1
- package/dist/client/chat-history/ChatList.d.ts +0 -18
- package/dist/client/chat-history/ChatList.d.ts.map +0 -1
- package/dist/client/chat-history/ChatTitleReveal.d.ts +0 -10
- package/dist/client/chat-history/ChatTitleReveal.d.ts.map +0 -1
- package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts +0 -13
- package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts.map +0 -1
- package/dist/client/chat-history/chat-title.d.ts +0 -10
- package/dist/client/chat-history/chat-title.d.ts.map +0 -1
- package/dist/client/chat-history/providers/local-storage.d.ts +0 -21
- package/dist/client/chat-history/providers/local-storage.d.ts.map +0 -1
- package/dist/client/chat-history/types.d.ts +0 -39
- package/dist/client/chat-history/types.d.ts.map +0 -1
- package/dist/client/chat-history/useChatHistory.d.ts +0 -20
- package/dist/client/chat-history/useChatHistory.d.ts.map +0 -1
- package/dist/client/chat-history/useChatTitleGeneration.d.ts +0 -17
- package/dist/client/chat-history/useChatTitleGeneration.d.ts.map +0 -1
- package/dist/client/components/AddToClientDropdown.d.ts +0 -52
- package/dist/client/components/AddToClientDropdown.d.ts.map +0 -1
- package/dist/client/components/ChatTab.d.ts +0 -98
- package/dist/client/components/ChatTab.d.ts.map +0 -1
- package/dist/client/components/IframeConsole.d.ts +0 -7
- package/dist/client/components/IframeConsole.d.ts.map +0 -1
- package/dist/client/components/MCPAppsDebugControls.d.ts +0 -19
- package/dist/client/components/MCPAppsDebugControls.d.ts.map +0 -1
- package/dist/client/components/PromptsTab.d.ts +0 -34
- package/dist/client/components/PromptsTab.d.ts.map +0 -1
- package/dist/client/components/ResourcesTab.d.ts +0 -31
- package/dist/client/components/ResourcesTab.d.ts.map +0 -1
- package/dist/client/components/ToolsTab.d.ts +0 -39
- package/dist/client/components/ToolsTab.d.ts.map +0 -1
- package/dist/client/components/chat/AssistantMessage.d.ts +0 -10
- package/dist/client/components/chat/AssistantMessage.d.ts.map +0 -1
- package/dist/client/components/chat/ChatHeader.d.ts +0 -70
- package/dist/client/components/chat/ChatHeader.d.ts.map +0 -1
- package/dist/client/components/chat/ChatInput.d.ts +0 -29
- package/dist/client/components/chat/ChatInput.d.ts.map +0 -1
- package/dist/client/components/chat/ChatInputArea.d.ts +0 -65
- package/dist/client/components/chat/ChatInputArea.d.ts.map +0 -1
- package/dist/client/components/chat/ChatLandingForm.d.ts +0 -15
- package/dist/client/components/chat/ChatLandingForm.d.ts.map +0 -1
- package/dist/client/components/chat/ChatManagedNotice.d.ts +0 -10
- package/dist/client/components/chat/ChatManagedNotice.d.ts.map +0 -1
- package/dist/client/components/chat/ChatScrollToBottomButton.d.ts +0 -7
- package/dist/client/components/chat/ChatScrollToBottomButton.d.ts.map +0 -1
- package/dist/client/components/chat/ChatScrollTopFade.d.ts +0 -7
- package/dist/client/components/chat/ChatScrollTopFade.d.ts.map +0 -1
- package/dist/client/components/chat/ChatTraceView.d.ts +0 -7
- package/dist/client/components/chat/ChatTraceView.d.ts.map +0 -1
- package/dist/client/components/chat/ConfigurationDialog.d.ts +0 -42
- package/dist/client/components/chat/ConfigurationDialog.d.ts.map +0 -1
- package/dist/client/components/chat/ConfigureEmptyState.d.ts +0 -6
- package/dist/client/components/chat/ConfigureEmptyState.d.ts.map +0 -1
- package/dist/client/components/chat/CopyButton.d.ts +0 -10
- package/dist/client/components/chat/CopyButton.d.ts.map +0 -1
- package/dist/client/components/chat/FloatingChatElicitation.d.ts +0 -10
- package/dist/client/components/chat/FloatingChatElicitation.d.ts.map +0 -1
- package/dist/client/components/chat/McpReconnectBanner.d.ts +0 -10
- package/dist/client/components/chat/McpReconnectBanner.d.ts.map +0 -1
- package/dist/client/components/chat/MessageList.d.ts +0 -48
- package/dist/client/components/chat/MessageList.d.ts.map +0 -1
- package/dist/client/components/chat/MessageMetaActions.d.ts +0 -7
- package/dist/client/components/chat/MessageMetaActions.d.ts.map +0 -1
- package/dist/client/components/chat/PromptResultsList.d.ts +0 -8
- package/dist/client/components/chat/PromptResultsList.d.ts.map +0 -1
- package/dist/client/components/chat/PromptsDropdown.d.ts +0 -11
- package/dist/client/components/chat/PromptsDropdown.d.ts.map +0 -1
- package/dist/client/components/chat/StreamingAssistantContent.d.ts +0 -7
- package/dist/client/components/chat/StreamingAssistantContent.d.ts.map +0 -1
- package/dist/client/components/chat/SystemPromptButton.d.ts +0 -11
- package/dist/client/components/chat/SystemPromptButton.d.ts.map +0 -1
- package/dist/client/components/chat/ToolCallDisplay.d.ts +0 -10
- package/dist/client/components/chat/ToolCallDisplay.d.ts.map +0 -1
- package/dist/client/components/chat/ToolResultRenderer.d.ts +0 -15
- package/dist/client/components/chat/ToolResultRenderer.d.ts.map +0 -1
- package/dist/client/components/chat/ToolSelector.d.ts +0 -13
- package/dist/client/components/chat/ToolSelector.d.ts.map +0 -1
- package/dist/client/components/chat/UserMessage.d.ts +0 -10
- package/dist/client/components/chat/UserMessage.d.ts.map +0 -1
- package/dist/client/components/chat/chat-bar-styles.d.ts +0 -6
- package/dist/client/components/chat/chat-bar-styles.d.ts.map +0 -1
- package/dist/client/components/chat/chatModeStorage.d.ts +0 -11
- package/dist/client/components/chat/chatModeStorage.d.ts.map +0 -1
- package/dist/client/components/chat/conversion.d.ts +0 -19
- package/dist/client/components/chat/conversion.d.ts.map +0 -1
- package/dist/client/components/chat/freeTier.d.ts +0 -32
- package/dist/client/components/chat/freeTier.d.ts.map +0 -1
- package/dist/client/components/chat/managedChatNotice.d.ts +0 -16
- package/dist/client/components/chat/managedChatNotice.d.ts.map +0 -1
- package/dist/client/components/chat/partialToolArgs.d.ts +0 -10
- package/dist/client/components/chat/partialToolArgs.d.ts.map +0 -1
- package/dist/client/components/chat/providerMeta.d.ts +0 -27
- package/dist/client/components/chat/providerMeta.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/local-storage.d.ts +0 -5
- package/dist/client/components/chat/system-prompt/local-storage.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/types.d.ts +0 -8
- package/dist/client/components/chat/system-prompt/types.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts +0 -3
- package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt-default.d.ts +0 -2
- package/dist/client/components/chat/system-prompt-default.d.ts.map +0 -1
- package/dist/client/components/chat/trace.d.ts +0 -84
- package/dist/client/components/chat/trace.d.ts.map +0 -1
- package/dist/client/components/chat/types.d.ts +0 -76
- package/dist/client/components/chat/types.d.ts.map +0 -1
- package/dist/client/components/chat/useChatMessages.d.ts +0 -76
- package/dist/client/components/chat/useChatMessages.d.ts.map +0 -1
- package/dist/client/components/chat/useChatMessagesClientSide.d.ts +0 -43
- package/dist/client/components/chat/useChatMessagesClientSide.d.ts.map +0 -1
- package/dist/client/components/chat/useChatScrollToBottom.d.ts +0 -14
- package/dist/client/components/chat/useChatScrollToBottom.d.ts.map +0 -1
- package/dist/client/components/chat/useConfig.d.ts +0 -24
- package/dist/client/components/chat/useConfig.d.ts.map +0 -1
- package/dist/client/components/chat/useHostedChatMode.d.ts +0 -14
- package/dist/client/components/chat/useHostedChatMode.d.ts.map +0 -1
- package/dist/client/components/chat/useManagedCloudModel.d.ts +0 -14
- package/dist/client/components/chat/useManagedCloudModel.d.ts.map +0 -1
- package/dist/client/components/chat/utils.d.ts +0 -11
- package/dist/client/components/chat/utils.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts +0 -12
- package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts +0 -9
- package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/schemaHelpers.d.ts +0 -8
- package/dist/client/components/elicitation/shared/schemaHelpers.d.ts.map +0 -1
- package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts +0 -29
- package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptExecutionPanel.d.ts +0 -13
- package/dist/client/components/prompts/PromptExecutionPanel.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptInputForm.d.ts +0 -9
- package/dist/client/components/prompts/PromptInputForm.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptMessageCard.d.ts +0 -29
- package/dist/client/components/prompts/PromptMessageCard.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptResultDisplay.d.ts +0 -34
- package/dist/client/components/prompts/PromptResultDisplay.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptsList.d.ts +0 -10
- package/dist/client/components/prompts/PromptsList.d.ts.map +0 -1
- package/dist/client/components/prompts/SavedPromptsList.d.ts +0 -19
- package/dist/client/components/prompts/SavedPromptsList.d.ts.map +0 -1
- package/dist/client/components/resources/PropsConfigDialog.d.ts +0 -16
- package/dist/client/components/resources/PropsConfigDialog.d.ts.map +0 -1
- package/dist/client/components/resources/ResourceResultDisplay.d.ts +0 -30
- package/dist/client/components/resources/ResourceResultDisplay.d.ts.map +0 -1
- package/dist/client/components/resources/ResourcesList.d.ts +0 -10
- package/dist/client/components/resources/ResourcesList.d.ts.map +0 -1
- package/dist/client/components/shared/CollapsibleJSON.d.ts +0 -6
- package/dist/client/components/shared/CollapsibleJSON.d.ts.map +0 -1
- package/dist/client/components/shared/InspectorScrollArea.d.ts +0 -9
- package/dist/client/components/shared/InspectorScrollArea.d.ts.map +0 -1
- package/dist/client/components/shared/JSONDisplay.d.ts +0 -12
- package/dist/client/components/shared/JSONDisplay.d.ts.map +0 -1
- package/dist/client/components/shared/ListItem.d.ts +0 -24
- package/dist/client/components/shared/ListItem.d.ts.map +0 -1
- package/dist/client/components/shared/ListTabHeader.d.ts +0 -47
- package/dist/client/components/shared/ListTabHeader.d.ts.map +0 -1
- package/dist/client/components/shared/MarkdownRenderer.d.ts +0 -15
- package/dist/client/components/shared/MarkdownRenderer.d.ts.map +0 -1
- package/dist/client/components/shared/SchemaFormField.d.ts +0 -12
- package/dist/client/components/shared/SchemaFormField.d.ts.map +0 -1
- package/dist/client/components/shared/SearchTabHeader.d.ts +0 -28
- package/dist/client/components/shared/SearchTabHeader.d.ts.map +0 -1
- package/dist/client/components/shared/StatusIcon.d.ts +0 -12
- package/dist/client/components/shared/StatusIcon.d.ts.map +0 -1
- package/dist/client/components/shared/index.d.ts +0 -7
- package/dist/client/components/shared/index.d.ts.map +0 -1
- package/dist/client/components/tools/SaveRequestDialog.d.ts +0 -11
- package/dist/client/components/tools/SaveRequestDialog.d.ts.map +0 -1
- package/dist/client/components/tools/SavedRequestsList.d.ts +0 -19
- package/dist/client/components/tools/SavedRequestsList.d.ts.map +0 -1
- package/dist/client/components/tools/ToolExecutionPanel.d.ts +0 -20
- package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +0 -1
- package/dist/client/components/tools/ToolInputForm.d.ts +0 -14
- package/dist/client/components/tools/ToolInputForm.d.ts.map +0 -1
- package/dist/client/components/tools/ToolResultDisplay.d.ts +0 -25
- package/dist/client/components/tools/ToolResultDisplay.d.ts.map +0 -1
- package/dist/client/components/tools/ToolsList.d.ts +0 -10
- package/dist/client/components/tools/ToolsList.d.ts.map +0 -1
- package/dist/client/components/tools/schema-utils.d.ts +0 -13
- package/dist/client/components/tools/schema-utils.d.ts.map +0 -1
- package/dist/client/components/tools/useToolExecution.d.ts +0 -26
- package/dist/client/components/tools/useToolExecution.d.ts.map +0 -1
- package/dist/client/components/tools/useToolsTabNavigation.d.ts +0 -35
- package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +0 -1
- package/dist/client/components/ui/MeshGradientCanvas.d.ts +0 -13
- package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +0 -1
- package/dist/client/components/ui/WidgetWrapper.d.ts +0 -12
- package/dist/client/components/ui/WidgetWrapper.d.ts.map +0 -1
- package/dist/client/components/ui/alert-dialog.d.ts +0 -15
- package/dist/client/components/ui/alert-dialog.d.ts.map +0 -1
- package/dist/client/components/ui/ask-user-questions.d.ts +0 -80
- package/dist/client/components/ui/ask-user-questions.d.ts.map +0 -1
- package/dist/client/components/ui/badge.d.ts +0 -34
- package/dist/client/components/ui/badge.d.ts.map +0 -1
- package/dist/client/components/ui/blur-fade.d.ts +0 -25
- package/dist/client/components/ui/blur-fade.d.ts.map +0 -1
- package/dist/client/components/ui/button.d.ts +0 -34
- package/dist/client/components/ui/button.d.ts.map +0 -1
- package/dist/client/components/ui/chat-message.d.ts +0 -23
- package/dist/client/components/ui/chat-message.d.ts.map +0 -1
- package/dist/client/components/ui/checkbox.d.ts +0 -4
- package/dist/client/components/ui/checkbox.d.ts.map +0 -1
- package/dist/client/components/ui/client-icons.d.ts +0 -20
- package/dist/client/components/ui/client-icons.d.ts.map +0 -1
- package/dist/client/components/ui/command.d.ts +0 -17
- package/dist/client/components/ui/command.d.ts.map +0 -1
- package/dist/client/components/ui/dialog.d.ts +0 -37
- package/dist/client/components/ui/dialog.d.ts.map +0 -1
- package/dist/client/components/ui/dropdown-menu.d.ts +0 -25
- package/dist/client/components/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/client/components/ui/dropdown.d.ts +0 -30
- package/dist/client/components/ui/dropdown.d.ts.map +0 -1
- package/dist/client/components/ui/file-thumbnail.d.ts +0 -9
- package/dist/client/components/ui/file-thumbnail.d.ts.map +0 -1
- package/dist/client/components/ui/input.d.ts +0 -4
- package/dist/client/components/ui/input.d.ts.map +0 -1
- package/dist/client/components/ui/kbd.d.ts +0 -3
- package/dist/client/components/ui/kbd.d.ts.map +0 -1
- package/dist/client/components/ui/label.d.ts +0 -4
- package/dist/client/components/ui/label.d.ts.map +0 -1
- package/dist/client/components/ui/menu-item.d.ts +0 -52
- package/dist/client/components/ui/menu-item.d.ts.map +0 -1
- package/dist/client/components/ui/mesh-animation-pause.d.ts +0 -14
- package/dist/client/components/ui/mesh-animation-pause.d.ts.map +0 -1
- package/dist/client/components/ui/mesh-gradient-colors.d.ts +0 -6
- package/dist/client/components/ui/mesh-gradient-colors.d.ts.map +0 -1
- package/dist/client/components/ui/mesh-tab-background.d.ts +0 -12
- package/dist/client/components/ui/mesh-tab-background.d.ts.map +0 -1
- package/dist/client/components/ui/not-found.d.ts +0 -9
- package/dist/client/components/ui/not-found.d.ts.map +0 -1
- package/dist/client/components/ui/popover.d.ts +0 -6
- package/dist/client/components/ui/popover.d.ts.map +0 -1
- package/dist/client/components/ui/resizable.d.ts +0 -10
- package/dist/client/components/ui/resizable.d.ts.map +0 -1
- package/dist/client/components/ui/scroll-area.d.ts +0 -4
- package/dist/client/components/ui/scroll-area.d.ts.map +0 -1
- package/dist/client/components/ui/select.d.ts +0 -52
- package/dist/client/components/ui/select.d.ts.map +0 -1
- package/dist/client/components/ui/sheet.d.ts +0 -14
- package/dist/client/components/ui/sheet.d.ts.map +0 -1
- package/dist/client/components/ui/skeleton.d.ts +0 -4
- package/dist/client/components/ui/skeleton.d.ts.map +0 -1
- package/dist/client/components/ui/spinner.d.ts +0 -3
- package/dist/client/components/ui/spinner.d.ts.map +0 -1
- package/dist/client/components/ui/switch.d.ts +0 -22
- package/dist/client/components/ui/switch.d.ts.map +0 -1
- package/dist/client/components/ui/table.d.ts +0 -9
- package/dist/client/components/ui/table.d.ts.map +0 -1
- package/dist/client/components/ui/tabs-subtle.d.ts +0 -25
- package/dist/client/components/ui/tabs-subtle.d.ts.map +0 -1
- package/dist/client/components/ui/text-shimmer.d.ts +0 -11
- package/dist/client/components/ui/text-shimmer.d.ts.map +0 -1
- package/dist/client/components/ui/textarea.d.ts +0 -4
- package/dist/client/components/ui/textarea.d.ts.map +0 -1
- package/dist/client/components/ui/tooltip.d.ts +0 -43
- package/dist/client/components/ui/tooltip.d.ts.map +0 -1
- package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts +0 -19
- package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts.map +0 -1
- package/dist/client/console-log-bus.d.ts +0 -24
- package/dist/client/console-log-bus.d.ts.map +0 -1
- package/dist/client/constants/debug-options.d.ts +0 -16
- package/dist/client/constants/debug-options.d.ts.map +0 -1
- package/dist/client/context/InspectorContext.d.ts +0 -134
- package/dist/client/context/InspectorContext.d.ts.map +0 -1
- package/dist/client/context/ThemeContext.d.ts +0 -17
- package/dist/client/context/ThemeContext.d.ts.map +0 -1
- package/dist/client/context/WidgetDebugContext.d.ts +0 -111
- package/dist/client/context/WidgetDebugContext.d.ts.map +0 -1
- package/dist/client/hooks/use-merge-split.d.ts +0 -36
- package/dist/client/hooks/use-merge-split.d.ts.map +0 -1
- package/dist/client/hooks/use-proximity-hover-index.d.ts +0 -27
- package/dist/client/hooks/use-proximity-hover-index.d.ts.map +0 -1
- package/dist/client/hooks/use-proximity-hover.d.ts +0 -26
- package/dist/client/hooks/use-proximity-hover.d.ts.map +0 -1
- package/dist/client/hooks/use-touch-primary.d.ts +0 -2
- package/dist/client/hooks/use-touch-primary.d.ts.map +0 -1
- package/dist/client/hooks/useDeviceViewport.d.ts +0 -14
- package/dist/client/hooks/useDeviceViewport.d.ts.map +0 -1
- package/dist/client/hooks/useHostedSession.d.ts +0 -9
- package/dist/client/hooks/useHostedSession.d.ts.map +0 -1
- package/dist/client/hooks/useIframeConsole.d.ts +0 -24
- package/dist/client/hooks/useIframeConsole.d.ts.map +0 -1
- package/dist/client/hooks/useKeyboardShortcuts.d.ts +0 -28
- package/dist/client/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/dist/client/hooks/useMCPPrompts.d.ts +0 -94
- package/dist/client/hooks/useMCPPrompts.d.ts.map +0 -1
- package/dist/client/hooks/useMcpAppsHostContext.d.ts +0 -27
- package/dist/client/hooks/useMcpAppsHostContext.d.ts.map +0 -1
- package/dist/client/hooks/usePropsLLM.d.ts +0 -20
- package/dist/client/hooks/usePropsLLM.d.ts.map +0 -1
- package/dist/client/hooks/useResourceProps.d.ts +0 -14
- package/dist/client/hooks/useResourceProps.d.ts.map +0 -1
- package/dist/client/hooks/useSavedRequests.d.ts +0 -6
- package/dist/client/hooks/useSavedRequests.d.ts.map +0 -1
- package/dist/client/hooks/useViewHostProps.d.ts +0 -19
- package/dist/client/hooks/useViewHostProps.d.ts.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/lib/elevated.d.ts +0 -28
- package/dist/client/lib/elevated.d.ts.map +0 -1
- package/dist/client/lib/font-weight.d.ts +0 -10
- package/dist/client/lib/font-weight.d.ts.map +0 -1
- package/dist/client/lib/icon-context.d.ts +0 -15
- package/dist/client/lib/icon-context.d.ts.map +0 -1
- package/dist/client/lib/shape-context.d.ts +0 -21
- package/dist/client/lib/shape-context.d.ts.map +0 -1
- package/dist/client/lib/springs.d.ts +0 -32
- package/dist/client/lib/springs.d.ts.map +0 -1
- package/dist/client/lib/surface-classes.d.ts +0 -2
- package/dist/client/lib/surface-classes.d.ts.map +0 -1
- package/dist/client/lib/surface-context.d.ts +0 -7
- package/dist/client/lib/surface-context.d.ts.map +0 -1
- package/dist/client/lib/utils.d.ts +0 -3
- package/dist/client/lib/utils.d.ts.map +0 -1
- package/dist/client/mcp-apps/csp.d.ts +0 -26
- package/dist/client/mcp-apps/csp.d.ts.map +0 -1
- package/dist/client/mcp-apps/debug/csp-suggestions.d.ts +0 -17
- package/dist/client/mcp-apps/debug/csp-suggestions.d.ts.map +0 -1
- package/dist/client/mcp-apps/logging-transport.d.ts +0 -13
- package/dist/client/mcp-apps/logging-transport.d.ts.map +0 -1
- package/dist/client/rpc-traffic-coalesce.d.ts +0 -7
- package/dist/client/rpc-traffic-coalesce.d.ts.map +0 -1
- package/dist/client/rpc-traffic-store.d.ts +0 -37
- package/dist/client/rpc-traffic-store.d.ts.map +0 -1
- package/dist/client/telemetry/capture.d.ts +0 -7
- package/dist/client/telemetry/capture.d.ts.map +0 -1
- package/dist/client/telemetry/events.d.ts +0 -168
- package/dist/client/telemetry/events.d.ts.map +0 -1
- package/dist/client/telemetry/index.d.ts +0 -5
- package/dist/client/telemetry/index.d.ts.map +0 -1
- package/dist/client/telemetry/init.d.ts +0 -2
- package/dist/client/telemetry/init.d.ts.map +0 -1
- package/dist/client/telemetry/utils.d.ts +0 -7
- package/dist/client/telemetry/utils.d.ts.map +0 -1
- package/dist/client/types/message-content-block.d.ts +0 -19
- package/dist/client/types/message-content-block.d.ts.map +0 -1
- package/dist/client/types/pending-requests.d.ts +0 -17
- package/dist/client/types/pending-requests.d.ts.map +0 -1
- package/dist/client/utils/basePath.d.ts +0 -34
- package/dist/client/utils/basePath.d.ts.map +0 -1
- package/dist/client/utils/browser.d.ts +0 -5
- package/dist/client/utils/browser.d.ts.map +0 -1
- package/dist/client/utils/format.d.ts +0 -4
- package/dist/client/utils/format.d.ts.map +0 -1
- package/dist/client/utils/highlightJson.d.ts +0 -11
- package/dist/client/utils/highlightJson.d.ts.map +0 -1
- package/dist/client/utils/jsonUtils.d.ts +0 -24
- package/dist/client/utils/jsonUtils.d.ts.map +0 -1
- package/dist/client/utils/mcpClientUtils.d.ts +0 -131
- package/dist/client/utils/mcpClientUtils.d.ts.map +0 -1
- package/dist/client/utils/servers.d.ts +0 -19
- package/dist/client/utils/servers.d.ts.map +0 -1
- package/dist/server/chunk-2K7OKCVV.js +0 -199
- package/dist/server/chunk-EKD2XITW.js +0 -44
- package/dist/server/chunk-EPPZCSJQ.js +0 -199
- package/dist/server/chunk-IKTZUWSX.js +0 -0
- package/dist/server/chunk-JWDVSQED.js +0 -156
- package/dist/server/chunk-KD7K27XK.js +0 -77
- package/dist/server/chunk-PKBMQBKP.js +0 -7
- package/dist/server/chunk-PZF2PUDE.js +0 -58
- package/dist/server/chunk-RFJAZOK7.js +0 -173
- package/dist/server/chunk-RKFQG67Z.js +0 -38
- package/dist/server/chunk-V5A5XLFJ.js +0 -762
- package/dist/server/chunk-WFT4JHYI.js +0 -24
- package/dist/server/cli.d.ts +0 -3
- package/dist/server/cli.d.ts.map +0 -1
- package/dist/server/cli.js +0 -136
- package/dist/server/create-dev-api-app.d.ts +0 -4
- package/dist/server/create-dev-api-app.d.ts.map +0 -1
- package/dist/server/create-dev-api-app.js +0 -11
- package/dist/server/dev-callback-redirect.d.ts +0 -3
- package/dist/server/dev-callback-redirect.d.ts.map +0 -1
- package/dist/server/dev-callback-redirect.js +0 -18
- package/dist/server/favicon-links.d.ts +0 -12
- package/dist/server/favicon-links.d.ts.map +0 -1
- package/dist/server/favicon-links.js +0 -11
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/inspector-shell.d.ts +0 -20
- package/dist/server/inspector-shell.d.ts.map +0 -1
- package/dist/server/inspector-shell.js +0 -10
- package/dist/server/middleware.d.ts +0 -65
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/middleware.js +0 -15
- package/dist/server/proxy/index.d.ts +0 -3
- package/dist/server/proxy/index.d.ts.map +0 -1
- package/dist/server/proxy/index.js +0 -12
- package/dist/server/proxy/mcp-proxy.d.ts +0 -101
- package/dist/server/proxy/mcp-proxy.d.ts.map +0 -1
- package/dist/server/proxy/mcp-proxy.js +0 -10
- package/dist/server/proxy/oauth-proxy.d.ts +0 -28
- package/dist/server/proxy/oauth-proxy.d.ts.map +0 -1
- package/dist/server/proxy/oauth-proxy.js +0 -9
- package/dist/server/proxy-routes.d.ts +0 -16
- package/dist/server/proxy-routes.d.ts.map +0 -1
- package/dist/server/proxy-routes.js +0 -10
- package/dist/server/rpc-log-bus.d.ts +0 -17
- package/dist/server/rpc-log-bus.d.ts.map +0 -1
- package/dist/server/rpc-log-bus.js +0 -77
- package/dist/server/server.d.ts +0 -15
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/server.js +0 -66
- package/dist/server/static-assets.d.ts +0 -5
- package/dist/server/static-assets.d.ts.map +0 -1
- package/dist/server/static-assets.js +0 -9
- package/dist/server/utils.d.ts +0 -33
- package/dist/server/utils.d.ts.map +0 -1
- package/dist/server/utils.js +0 -17
- package/dist/server/version.d.ts +0 -7
- package/dist/server/version.d.ts.map +0 -1
- package/dist/server/version.js +0 -9
- package/dist/server/vite-dev-api-plugin.d.ts +0 -4
- package/dist/server/vite-dev-api-plugin.d.ts.map +0 -1
- package/dist/server/vite-dev-api-plugin.js +0 -30
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/index-Dj_E94k4.css +0 -1
- package/dist/web/assets/index-O3gsi3le.js +0 -643
- package/dist/web/favicon-96x96.png +0 -0
- package/dist/web/favicon-black.svg +0 -5
- package/dist/web/favicon-white.svg +0 -5
- package/dist/web/favicon.ico +0 -0
- package/dist/web/favicon.svg +0 -5
- package/dist/web/index.html +0 -81
- package/dist/web/providers/anthropic.png +0 -0
- package/dist/web/providers/google.png +0 -0
- package/dist/web/providers/openai.png +0 -0
- package/dist/web/site.webmanifest +0 -21
- package/dist/web/web-app-manifest-192x192.png +0 -0
- package/dist/web/web-app-manifest-512x512.png +0 -0
|
@@ -1,762 +0,0 @@
|
|
|
1
|
-
// src/server/proxy/oauth-proxy.ts
|
|
2
|
-
import { lookup } from "dns/promises";
|
|
3
|
-
import { Buffer } from "buffer";
|
|
4
|
-
import { isIP } from "net";
|
|
5
|
-
var SAFE_REQUEST_HEADERS = /* @__PURE__ */ new Set([
|
|
6
|
-
"accept",
|
|
7
|
-
"authorization",
|
|
8
|
-
"content-type",
|
|
9
|
-
"dpop"
|
|
10
|
-
]);
|
|
11
|
-
var SAFE_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
|
|
12
|
-
"cache-control",
|
|
13
|
-
"content-type",
|
|
14
|
-
"dpop-nonce",
|
|
15
|
-
"expires",
|
|
16
|
-
"pragma",
|
|
17
|
-
"retry-after",
|
|
18
|
-
"www-authenticate"
|
|
19
|
-
]);
|
|
20
|
-
var ENDPOINT_FIELDS = [
|
|
21
|
-
["registration_endpoint", "registration"],
|
|
22
|
-
["token_endpoint", "token"],
|
|
23
|
-
["revocation_endpoint", "revocation"],
|
|
24
|
-
["introspection_endpoint", "introspection"]
|
|
25
|
-
];
|
|
26
|
-
var BINDING_TTL_MS = 10 * 60 * 1e3;
|
|
27
|
-
var MAX_BINDINGS = 100;
|
|
28
|
-
var CONFIDENTIAL_CLIENT_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
29
|
-
var MAX_CONFIDENTIAL_CLIENTS = 500;
|
|
30
|
-
function mountOAuthProxy(app, options = {}) {
|
|
31
|
-
const {
|
|
32
|
-
basePath = "/oauth",
|
|
33
|
-
allowedOrigins = [],
|
|
34
|
-
allowLoopback = false,
|
|
35
|
-
timeoutMs = 1e4,
|
|
36
|
-
maxRequestBodyBytes = 64 * 1024,
|
|
37
|
-
maxResponseBodyBytes = 1024 * 1024,
|
|
38
|
-
callbackPath = "/oauth/callback",
|
|
39
|
-
enableLogging = true,
|
|
40
|
-
authenticate,
|
|
41
|
-
validateServerUrl
|
|
42
|
-
} = options;
|
|
43
|
-
const origins = new Set(allowedOrigins.map(normalizeOrigin));
|
|
44
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
45
|
-
const confidentialClients = /* @__PURE__ */ new Map();
|
|
46
|
-
app.use(`${basePath}/*`, async (c, next) => {
|
|
47
|
-
const origin = c.req.header("Origin");
|
|
48
|
-
if (origin && !isAllowedOrigin(origin, c, origins)) {
|
|
49
|
-
return c.json({ error: "Origin not allowed" }, 403);
|
|
50
|
-
}
|
|
51
|
-
if (c.req.method === "OPTIONS") {
|
|
52
|
-
return corsResponse(origin);
|
|
53
|
-
}
|
|
54
|
-
await next();
|
|
55
|
-
if (origin) setCorsHeaders(c.res.headers, origin);
|
|
56
|
-
});
|
|
57
|
-
app.get(`${basePath}/metadata`, async (c) => {
|
|
58
|
-
if (!await isAuthenticated(c, authenticate)) {
|
|
59
|
-
return c.json({ error: "Unauthorized" }, 401);
|
|
60
|
-
}
|
|
61
|
-
const serverUrlResult = await validateUrl(
|
|
62
|
-
c.req.query("serverUrl"),
|
|
63
|
-
allowLoopback
|
|
64
|
-
);
|
|
65
|
-
if ("error" in serverUrlResult) {
|
|
66
|
-
return c.json({ error: serverUrlResult.error }, 400);
|
|
67
|
-
}
|
|
68
|
-
const serverUrl = serverUrlResult.url;
|
|
69
|
-
if (validateServerUrl && !await validateServerUrl(serverUrl.toString(), c)) {
|
|
70
|
-
return c.json({ error: "MCP server URL not allowed" }, 403);
|
|
71
|
-
}
|
|
72
|
-
const targetResult = await validateUrl(c.req.query("url"), allowLoopback);
|
|
73
|
-
if ("error" in targetResult) {
|
|
74
|
-
return c.json({ error: targetResult.error }, 400);
|
|
75
|
-
}
|
|
76
|
-
const target = targetResult.url;
|
|
77
|
-
const key = canonicalUrl(serverUrl);
|
|
78
|
-
const binding = getBinding(bindings, key);
|
|
79
|
-
let metadataKind = classifyMetadataTarget(serverUrl, target, binding);
|
|
80
|
-
if (!metadataKind && binding.authorizationServers.size === 0) {
|
|
81
|
-
try {
|
|
82
|
-
await hydrateBinding(
|
|
83
|
-
serverUrl,
|
|
84
|
-
binding,
|
|
85
|
-
allowLoopback,
|
|
86
|
-
timeoutMs,
|
|
87
|
-
maxResponseBodyBytes
|
|
88
|
-
);
|
|
89
|
-
bindings.set(key, binding);
|
|
90
|
-
metadataKind = classifyMetadataTarget(serverUrl, target, binding);
|
|
91
|
-
} catch {
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (!metadataKind) {
|
|
95
|
-
return c.json(
|
|
96
|
-
{ error: "Metadata target is not bound to this MCP server" },
|
|
97
|
-
403
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
log(enableLogging, `GET ${target}`);
|
|
102
|
-
const upstream = await safeFetch(target, {
|
|
103
|
-
method: "GET",
|
|
104
|
-
headers: { Accept: "application/json" },
|
|
105
|
-
redirect: "manual",
|
|
106
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
107
|
-
});
|
|
108
|
-
if (isRedirect(upstream.status)) {
|
|
109
|
-
return c.json(
|
|
110
|
-
{ error: "OAuth metadata redirects are not allowed" },
|
|
111
|
-
502
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
const raw = await readCapped(upstream, maxResponseBodyBytes);
|
|
115
|
-
if (!upstream.ok) {
|
|
116
|
-
return c.body(raw, upstream.status, {
|
|
117
|
-
"Content-Type": upstream.headers.get("content-type") ?? "application/json"
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
const metadata = parseObject(raw);
|
|
121
|
-
if (metadataKind.type === "protected-resource") {
|
|
122
|
-
await bindProtectedResource(
|
|
123
|
-
metadata,
|
|
124
|
-
serverUrl,
|
|
125
|
-
binding,
|
|
126
|
-
allowLoopback
|
|
127
|
-
);
|
|
128
|
-
} else {
|
|
129
|
-
await bindAuthorizationServer(
|
|
130
|
-
metadata,
|
|
131
|
-
metadataKind.issuer,
|
|
132
|
-
binding,
|
|
133
|
-
allowLoopback
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
binding.updatedAt = Date.now();
|
|
137
|
-
bindings.set(key, binding);
|
|
138
|
-
pruneBindings(bindings);
|
|
139
|
-
return c.body(raw, 200, {
|
|
140
|
-
"Content-Type": upstream.headers.get("content-type") ?? "application/json"
|
|
141
|
-
});
|
|
142
|
-
} catch (error) {
|
|
143
|
-
return proxyError(c, error, enableLogging);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
app.post(`${basePath}/proxy`, async (c) => {
|
|
147
|
-
if (!await isAuthenticated(c, authenticate)) {
|
|
148
|
-
return c.json({ error: "Unauthorized" }, 401);
|
|
149
|
-
}
|
|
150
|
-
let request;
|
|
151
|
-
try {
|
|
152
|
-
request = JSON.parse(
|
|
153
|
-
await readRequestCapped(c.req.raw, maxRequestBodyBytes)
|
|
154
|
-
);
|
|
155
|
-
} catch (error) {
|
|
156
|
-
return c.json(
|
|
157
|
-
{
|
|
158
|
-
error: error instanceof BodyTooLargeError ? "Request body too large" : "Invalid JSON request body"
|
|
159
|
-
},
|
|
160
|
-
error instanceof BodyTooLargeError ? 413 : 400
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
const serverUrlResult = await validateUrl(request.serverUrl, allowLoopback);
|
|
164
|
-
if ("error" in serverUrlResult) {
|
|
165
|
-
return c.json({ error: serverUrlResult.error }, 400);
|
|
166
|
-
}
|
|
167
|
-
const serverUrl = serverUrlResult.url;
|
|
168
|
-
if (validateServerUrl && !await validateServerUrl(serverUrl.toString(), c)) {
|
|
169
|
-
return c.json({ error: "MCP server URL not allowed" }, 403);
|
|
170
|
-
}
|
|
171
|
-
const targetResult = await validateUrl(request.url, allowLoopback);
|
|
172
|
-
if ("error" in targetResult) {
|
|
173
|
-
return c.json({ error: targetResult.error }, 400);
|
|
174
|
-
}
|
|
175
|
-
const target = targetResult.url;
|
|
176
|
-
if (request.method !== void 0 && request.method !== "POST") {
|
|
177
|
-
return c.json({ error: "Only OAuth endpoint POST is allowed" }, 405);
|
|
178
|
-
}
|
|
179
|
-
const bindingKey = canonicalUrl(serverUrl);
|
|
180
|
-
const binding = getBinding(bindings, bindingKey);
|
|
181
|
-
if (binding.endpoints.size === 0) {
|
|
182
|
-
try {
|
|
183
|
-
await hydrateBinding(
|
|
184
|
-
serverUrl,
|
|
185
|
-
binding,
|
|
186
|
-
allowLoopback,
|
|
187
|
-
timeoutMs,
|
|
188
|
-
maxResponseBodyBytes
|
|
189
|
-
);
|
|
190
|
-
bindings.set(bindingKey, binding);
|
|
191
|
-
pruneBindings(bindings);
|
|
192
|
-
} catch (error) {
|
|
193
|
-
return proxyError(c, error, enableLogging);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const endpointKind = binding.endpoints.get(canonicalUrl(target));
|
|
197
|
-
if (!endpointKind) {
|
|
198
|
-
return c.json(
|
|
199
|
-
{ error: "OAuth endpoint is not bound to this MCP server" },
|
|
200
|
-
403
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
try {
|
|
204
|
-
const headers = filterRequestHeaders(request.headers);
|
|
205
|
-
let body = serializeBody(request.body, headers);
|
|
206
|
-
if (endpointKind === "registration") {
|
|
207
|
-
const publicOrigin = normalizeOrigin(
|
|
208
|
-
c.req.header("Origin") ?? new URL(c.req.url).origin
|
|
209
|
-
);
|
|
210
|
-
body = enforceRegistrationRedirectUri(
|
|
211
|
-
body,
|
|
212
|
-
headers,
|
|
213
|
-
new URL(callbackPath, publicOrigin).toString()
|
|
214
|
-
);
|
|
215
|
-
} else {
|
|
216
|
-
body = applyConfidentialClientAuthentication({
|
|
217
|
-
body,
|
|
218
|
-
headers,
|
|
219
|
-
bindingKey,
|
|
220
|
-
clients: confidentialClients
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
if (new TextEncoder().encode(body ?? "").byteLength > maxRequestBodyBytes) {
|
|
224
|
-
return c.json({ error: "OAuth request body too large" }, 413);
|
|
225
|
-
}
|
|
226
|
-
log(enableLogging, `POST ${endpointKind} ${target}`);
|
|
227
|
-
const upstream = await safeFetch(target, {
|
|
228
|
-
method: "POST",
|
|
229
|
-
headers,
|
|
230
|
-
body,
|
|
231
|
-
redirect: "manual",
|
|
232
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
233
|
-
});
|
|
234
|
-
if (isRedirect(upstream.status)) {
|
|
235
|
-
return c.json(
|
|
236
|
-
{ error: "OAuth endpoint redirects are not allowed" },
|
|
237
|
-
502
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
const raw = await readCapped(upstream, maxResponseBodyBytes);
|
|
241
|
-
const responseHeaders = filterResponseHeaders(upstream.headers);
|
|
242
|
-
const contentType = upstream.headers.get("content-type") ?? "";
|
|
243
|
-
let responseBody = raw;
|
|
244
|
-
if (contentType.includes("json")) {
|
|
245
|
-
try {
|
|
246
|
-
responseBody = JSON.parse(raw);
|
|
247
|
-
} catch {
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (endpointKind === "registration" && upstream.ok && responseBody && typeof responseBody === "object" && !Array.isArray(responseBody)) {
|
|
251
|
-
responseBody = retainConfidentialClient({
|
|
252
|
-
responseBody,
|
|
253
|
-
binding,
|
|
254
|
-
bindingKey,
|
|
255
|
-
clients: confidentialClients
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
return c.json({
|
|
259
|
-
status: upstream.status,
|
|
260
|
-
statusText: upstream.statusText,
|
|
261
|
-
headers: responseHeaders,
|
|
262
|
-
body: responseBody
|
|
263
|
-
});
|
|
264
|
-
} catch (error) {
|
|
265
|
-
return proxyError(c, error, enableLogging);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
log(enableLogging, `Mounted at ${basePath}/metadata and ${basePath}/proxy`);
|
|
269
|
-
}
|
|
270
|
-
async function validateUrl(value, allowLoopback) {
|
|
271
|
-
if (typeof value !== "string" || !value) {
|
|
272
|
-
return { error: "Missing or invalid URL" };
|
|
273
|
-
}
|
|
274
|
-
let url;
|
|
275
|
-
try {
|
|
276
|
-
url = new URL(value);
|
|
277
|
-
} catch {
|
|
278
|
-
return { error: "Invalid URL" };
|
|
279
|
-
}
|
|
280
|
-
if (url.username || url.password || url.hash) {
|
|
281
|
-
return { error: "URL credentials and fragments are not allowed" };
|
|
282
|
-
}
|
|
283
|
-
const loopback = isLoopbackHostname(url.hostname);
|
|
284
|
-
if (url.protocol !== "https:") {
|
|
285
|
-
if (!(allowLoopback && loopback && url.protocol === "http:")) {
|
|
286
|
-
return { error: "HTTPS is required" };
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
if (loopback) {
|
|
290
|
-
return allowLoopback ? { url } : { error: "Loopback URL not allowed" };
|
|
291
|
-
}
|
|
292
|
-
if (isLocalHostname(url.hostname)) {
|
|
293
|
-
return { error: "Local network URL not allowed" };
|
|
294
|
-
}
|
|
295
|
-
try {
|
|
296
|
-
const addresses = isIP(url.hostname) ? [url.hostname] : (await lookup(url.hostname, { all: true, verbatim: true })).map(
|
|
297
|
-
({ address }) => address
|
|
298
|
-
);
|
|
299
|
-
if (addresses.length === 0 || addresses.some((address) => !isPublicAddress(address))) {
|
|
300
|
-
return { error: "Private or non-routable URL not allowed" };
|
|
301
|
-
}
|
|
302
|
-
} catch {
|
|
303
|
-
return { error: "URL hostname could not be resolved" };
|
|
304
|
-
}
|
|
305
|
-
return { url };
|
|
306
|
-
}
|
|
307
|
-
async function isSafeProxyTarget(value, allowLoopback = false) {
|
|
308
|
-
return !("error" in await validateUrl(value, allowLoopback));
|
|
309
|
-
}
|
|
310
|
-
function classifyMetadataTarget(serverUrl, target, binding) {
|
|
311
|
-
const targetUrl = canonicalUrl(target);
|
|
312
|
-
if (protectedResourceMetadataUrls(serverUrl).some(
|
|
313
|
-
(candidate) => canonicalUrl(candidate) === targetUrl
|
|
314
|
-
)) {
|
|
315
|
-
return { type: "protected-resource" };
|
|
316
|
-
}
|
|
317
|
-
for (const issuer of binding.authorizationServers) {
|
|
318
|
-
if (authorizationServerMetadataUrls(new URL(issuer)).some(
|
|
319
|
-
(candidate) => canonicalUrl(candidate) === targetUrl
|
|
320
|
-
)) {
|
|
321
|
-
return { type: "authorization-server", issuer };
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return void 0;
|
|
325
|
-
}
|
|
326
|
-
function protectedResourceMetadataUrls(serverUrl) {
|
|
327
|
-
const path = serverUrl.pathname === "/" ? "" : serverUrl.pathname;
|
|
328
|
-
return [
|
|
329
|
-
new URL(`/.well-known/oauth-protected-resource${path}`, serverUrl.origin),
|
|
330
|
-
new URL("/.well-known/oauth-protected-resource", serverUrl.origin)
|
|
331
|
-
];
|
|
332
|
-
}
|
|
333
|
-
function authorizationServerMetadataUrls(issuer) {
|
|
334
|
-
const path = issuer.pathname === "/" ? "" : issuer.pathname;
|
|
335
|
-
return [
|
|
336
|
-
new URL(`/.well-known/oauth-authorization-server${path}`, issuer.origin),
|
|
337
|
-
new URL(`/.well-known/openid-configuration${path}`, issuer.origin),
|
|
338
|
-
new URL(`${path || ""}/.well-known/openid-configuration`, issuer.origin)
|
|
339
|
-
];
|
|
340
|
-
}
|
|
341
|
-
async function bindProtectedResource(metadata, serverUrl, binding, allowLoopback) {
|
|
342
|
-
if (typeof metadata.resource !== "string" || canonicalUrl(new URL(metadata.resource)) !== canonicalUrl(serverUrl)) {
|
|
343
|
-
throw new InvalidUpstreamError(
|
|
344
|
-
"Protected-resource metadata does not match serverUrl"
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
if (!Array.isArray(metadata.authorization_servers) || metadata.authorization_servers.length === 0) {
|
|
348
|
-
throw new InvalidUpstreamError(
|
|
349
|
-
"Protected-resource metadata has no authorization servers"
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
const issuers = /* @__PURE__ */ new Set();
|
|
353
|
-
for (const value of metadata.authorization_servers) {
|
|
354
|
-
const result = await validateUrl(value, allowLoopback);
|
|
355
|
-
if ("error" in result) {
|
|
356
|
-
throw new InvalidUpstreamError(
|
|
357
|
-
`Unsafe authorization server: ${result.error}`
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
issuers.add(canonicalUrl(result.url));
|
|
361
|
-
}
|
|
362
|
-
binding.authorizationServers = issuers;
|
|
363
|
-
binding.endpoints.clear();
|
|
364
|
-
binding.tokenEndpointAuthMethods.clear();
|
|
365
|
-
}
|
|
366
|
-
async function bindAuthorizationServer(metadata, expectedIssuer, binding, allowLoopback) {
|
|
367
|
-
if (typeof metadata.issuer !== "string" || canonicalUrl(new URL(metadata.issuer)) !== expectedIssuer) {
|
|
368
|
-
throw new InvalidUpstreamError(
|
|
369
|
-
"Authorization-server metadata issuer mismatch"
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
binding.endpoints.clear();
|
|
373
|
-
binding.tokenEndpointAuthMethods = new Set(
|
|
374
|
-
Array.isArray(metadata.token_endpoint_auth_methods_supported) ? metadata.token_endpoint_auth_methods_supported.filter(
|
|
375
|
-
(method) => typeof method === "string"
|
|
376
|
-
) : []
|
|
377
|
-
);
|
|
378
|
-
for (const [field, kind] of ENDPOINT_FIELDS) {
|
|
379
|
-
const value = metadata[field];
|
|
380
|
-
if (value === void 0) continue;
|
|
381
|
-
const result = await validateUrl(value, allowLoopback);
|
|
382
|
-
if ("error" in result) {
|
|
383
|
-
throw new InvalidUpstreamError(`Unsafe ${field}: ${result.error}`);
|
|
384
|
-
}
|
|
385
|
-
binding.endpoints.set(canonicalUrl(result.url), kind);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
async function hydrateBinding(serverUrl, binding, allowLoopback, timeoutMs, maxResponseBodyBytes) {
|
|
389
|
-
for (const metadataUrl of protectedResourceMetadataUrls(serverUrl)) {
|
|
390
|
-
const response = await safeFetch(metadataUrl, {
|
|
391
|
-
method: "GET",
|
|
392
|
-
headers: { Accept: "application/json" },
|
|
393
|
-
redirect: "manual",
|
|
394
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
395
|
-
});
|
|
396
|
-
if (isRedirect(response.status)) {
|
|
397
|
-
throw new InvalidUpstreamError(
|
|
398
|
-
"OAuth metadata redirects are not allowed"
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
if (!response.ok) continue;
|
|
402
|
-
await bindProtectedResource(
|
|
403
|
-
parseObject(await readCapped(response, maxResponseBodyBytes)),
|
|
404
|
-
serverUrl,
|
|
405
|
-
binding,
|
|
406
|
-
allowLoopback
|
|
407
|
-
);
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
if (binding.authorizationServers.size === 0) {
|
|
411
|
-
throw new InvalidUpstreamError(
|
|
412
|
-
"Protected-resource metadata could not be discovered"
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
for (const issuer of binding.authorizationServers) {
|
|
416
|
-
let bound = false;
|
|
417
|
-
for (const metadataUrl of authorizationServerMetadataUrls(
|
|
418
|
-
new URL(issuer)
|
|
419
|
-
)) {
|
|
420
|
-
const response = await safeFetch(metadataUrl, {
|
|
421
|
-
method: "GET",
|
|
422
|
-
headers: { Accept: "application/json" },
|
|
423
|
-
redirect: "manual",
|
|
424
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
425
|
-
});
|
|
426
|
-
if (isRedirect(response.status)) {
|
|
427
|
-
throw new InvalidUpstreamError(
|
|
428
|
-
"OAuth metadata redirects are not allowed"
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
if (!response.ok) continue;
|
|
432
|
-
await bindAuthorizationServer(
|
|
433
|
-
parseObject(await readCapped(response, maxResponseBodyBytes)),
|
|
434
|
-
issuer,
|
|
435
|
-
binding,
|
|
436
|
-
allowLoopback
|
|
437
|
-
);
|
|
438
|
-
bound = true;
|
|
439
|
-
break;
|
|
440
|
-
}
|
|
441
|
-
if (bound) break;
|
|
442
|
-
}
|
|
443
|
-
if (binding.endpoints.size === 0) {
|
|
444
|
-
throw new InvalidUpstreamError(
|
|
445
|
-
"Authorization-server metadata could not be discovered"
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
binding.updatedAt = Date.now();
|
|
449
|
-
}
|
|
450
|
-
async function safeFetch(url, init) {
|
|
451
|
-
return fetch(url, init);
|
|
452
|
-
}
|
|
453
|
-
function filterRequestHeaders(value) {
|
|
454
|
-
const result = new Headers();
|
|
455
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
456
|
-
return result;
|
|
457
|
-
for (const [name, rawValue] of Object.entries(value)) {
|
|
458
|
-
const lower = name.toLowerCase();
|
|
459
|
-
if (SAFE_REQUEST_HEADERS.has(lower) && typeof rawValue === "string") {
|
|
460
|
-
result.set(lower, rawValue);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
return result;
|
|
464
|
-
}
|
|
465
|
-
function filterResponseHeaders(headers) {
|
|
466
|
-
const result = {};
|
|
467
|
-
headers.forEach((value, name) => {
|
|
468
|
-
if (SAFE_RESPONSE_HEADERS.has(name.toLowerCase())) result[name] = value;
|
|
469
|
-
});
|
|
470
|
-
return result;
|
|
471
|
-
}
|
|
472
|
-
function serializeBody(body, headers) {
|
|
473
|
-
if (body === void 0 || body === null) return void 0;
|
|
474
|
-
if (typeof body === "string") {
|
|
475
|
-
if (!headers.has("content-type")) {
|
|
476
|
-
try {
|
|
477
|
-
JSON.parse(body);
|
|
478
|
-
headers.set("content-type", "application/json");
|
|
479
|
-
} catch {
|
|
480
|
-
headers.set("content-type", "application/x-www-form-urlencoded");
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
return body;
|
|
484
|
-
}
|
|
485
|
-
const contentType = headers.get("content-type") ?? "";
|
|
486
|
-
if (contentType.includes("application/x-www-form-urlencoded") && typeof body === "object" && !Array.isArray(body)) {
|
|
487
|
-
const params = new URLSearchParams();
|
|
488
|
-
for (const [key, value] of Object.entries(
|
|
489
|
-
body
|
|
490
|
-
)) {
|
|
491
|
-
params.append(key, String(value));
|
|
492
|
-
}
|
|
493
|
-
return params.toString();
|
|
494
|
-
}
|
|
495
|
-
if (!headers.has("content-type")) {
|
|
496
|
-
headers.set("content-type", "application/json");
|
|
497
|
-
}
|
|
498
|
-
return JSON.stringify(body);
|
|
499
|
-
}
|
|
500
|
-
function confidentialClientKey(bindingKey, clientId) {
|
|
501
|
-
return `${bindingKey}\0${clientId}`;
|
|
502
|
-
}
|
|
503
|
-
function retainConfidentialClient(options) {
|
|
504
|
-
const { responseBody, binding, bindingKey, clients } = options;
|
|
505
|
-
const clientId = responseBody.client_id;
|
|
506
|
-
const clientSecret = responseBody.client_secret;
|
|
507
|
-
if (typeof clientId !== "string" || typeof clientSecret !== "string") {
|
|
508
|
-
return responseBody;
|
|
509
|
-
}
|
|
510
|
-
const returnedMethod = responseBody.token_endpoint_auth_method;
|
|
511
|
-
const authMethod = returnedMethod === "client_secret_post" || returnedMethod === "client_secret_basic" ? returnedMethod : binding.tokenEndpointAuthMethods.has("client_secret_basic") ? "client_secret_basic" : "client_secret_post";
|
|
512
|
-
const upstreamExpiry = responseBody.client_secret_expires_at;
|
|
513
|
-
const expiresAt = upstreamExpiry === 0 ? Number.POSITIVE_INFINITY : typeof upstreamExpiry === "number" && upstreamExpiry > 0 ? upstreamExpiry * 1e3 : Date.now() + CONFIDENTIAL_CLIENT_TTL_MS;
|
|
514
|
-
pruneConfidentialClients(clients);
|
|
515
|
-
clients.set(confidentialClientKey(bindingKey, clientId), {
|
|
516
|
-
clientSecret,
|
|
517
|
-
authMethod,
|
|
518
|
-
expiresAt
|
|
519
|
-
});
|
|
520
|
-
while (clients.size > MAX_CONFIDENTIAL_CLIENTS) {
|
|
521
|
-
const oldest = clients.keys().next().value;
|
|
522
|
-
if (!oldest) break;
|
|
523
|
-
clients.delete(oldest);
|
|
524
|
-
}
|
|
525
|
-
const browserSafe = { ...responseBody };
|
|
526
|
-
delete browserSafe.client_secret;
|
|
527
|
-
delete browserSafe.client_secret_expires_at;
|
|
528
|
-
browserSafe.token_endpoint_auth_method = "none";
|
|
529
|
-
return browserSafe;
|
|
530
|
-
}
|
|
531
|
-
function applyConfidentialClientAuthentication(options) {
|
|
532
|
-
const { body, headers, bindingKey, clients } = options;
|
|
533
|
-
if (!body || !(headers.get("content-type") ?? "").includes(
|
|
534
|
-
"application/x-www-form-urlencoded"
|
|
535
|
-
)) {
|
|
536
|
-
return body;
|
|
537
|
-
}
|
|
538
|
-
const params = new URLSearchParams(body);
|
|
539
|
-
const clientId = params.get("client_id");
|
|
540
|
-
if (!clientId) return body;
|
|
541
|
-
const key = confidentialClientKey(bindingKey, clientId);
|
|
542
|
-
const client = clients.get(key);
|
|
543
|
-
if (!client) return body;
|
|
544
|
-
if (client.expiresAt <= Date.now()) {
|
|
545
|
-
clients.delete(key);
|
|
546
|
-
return body;
|
|
547
|
-
}
|
|
548
|
-
params.delete("client_secret");
|
|
549
|
-
if (client.authMethod === "client_secret_basic") {
|
|
550
|
-
const encoded = Buffer.from(
|
|
551
|
-
`${encodeOAuthClientCredential(clientId)}:${encodeOAuthClientCredential(client.clientSecret)}`,
|
|
552
|
-
"utf8"
|
|
553
|
-
).toString("base64");
|
|
554
|
-
headers.set("authorization", `Basic ${encoded}`);
|
|
555
|
-
} else {
|
|
556
|
-
headers.delete("authorization");
|
|
557
|
-
params.set("client_id", clientId);
|
|
558
|
-
params.set("client_secret", client.clientSecret);
|
|
559
|
-
}
|
|
560
|
-
return params.toString();
|
|
561
|
-
}
|
|
562
|
-
function encodeOAuthClientCredential(value) {
|
|
563
|
-
return new URLSearchParams({ value }).toString().slice("value=".length);
|
|
564
|
-
}
|
|
565
|
-
function pruneConfidentialClients(clients) {
|
|
566
|
-
const now = Date.now();
|
|
567
|
-
for (const [key, client] of clients) {
|
|
568
|
-
if (client.expiresAt <= now) clients.delete(key);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
async function readRequestCapped(request, maxBytes) {
|
|
572
|
-
const declared = Number(request.headers.get("content-length"));
|
|
573
|
-
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
574
|
-
throw new BodyTooLargeError();
|
|
575
|
-
}
|
|
576
|
-
return readStreamCapped(request.body, maxBytes);
|
|
577
|
-
}
|
|
578
|
-
async function readCapped(response, maxBytes) {
|
|
579
|
-
const declared = Number(response.headers.get("content-length"));
|
|
580
|
-
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
581
|
-
await response.body?.cancel();
|
|
582
|
-
throw new BodyTooLargeError();
|
|
583
|
-
}
|
|
584
|
-
return readStreamCapped(response.body, maxBytes);
|
|
585
|
-
}
|
|
586
|
-
async function readStreamCapped(stream, maxBytes) {
|
|
587
|
-
if (!stream) return "";
|
|
588
|
-
const reader = stream.getReader();
|
|
589
|
-
const chunks = [];
|
|
590
|
-
let size = 0;
|
|
591
|
-
while (true) {
|
|
592
|
-
const { done, value } = await reader.read();
|
|
593
|
-
if (done) break;
|
|
594
|
-
size += value.byteLength;
|
|
595
|
-
if (size > maxBytes) {
|
|
596
|
-
await reader.cancel();
|
|
597
|
-
throw new BodyTooLargeError();
|
|
598
|
-
}
|
|
599
|
-
chunks.push(value);
|
|
600
|
-
}
|
|
601
|
-
const bytes = new Uint8Array(size);
|
|
602
|
-
let offset = 0;
|
|
603
|
-
for (const chunk of chunks) {
|
|
604
|
-
bytes.set(chunk, offset);
|
|
605
|
-
offset += chunk.byteLength;
|
|
606
|
-
}
|
|
607
|
-
return new TextDecoder().decode(bytes);
|
|
608
|
-
}
|
|
609
|
-
function parseObject(value) {
|
|
610
|
-
let parsed;
|
|
611
|
-
try {
|
|
612
|
-
parsed = JSON.parse(value);
|
|
613
|
-
} catch {
|
|
614
|
-
throw new InvalidUpstreamError("OAuth metadata is not valid JSON");
|
|
615
|
-
}
|
|
616
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
617
|
-
throw new InvalidUpstreamError("OAuth metadata is not an object");
|
|
618
|
-
}
|
|
619
|
-
return parsed;
|
|
620
|
-
}
|
|
621
|
-
function getBinding(bindings, key) {
|
|
622
|
-
const existing = bindings.get(key);
|
|
623
|
-
if (existing && Date.now() - existing.updatedAt <= BINDING_TTL_MS) {
|
|
624
|
-
return existing;
|
|
625
|
-
}
|
|
626
|
-
bindings.delete(key);
|
|
627
|
-
return {
|
|
628
|
-
authorizationServers: /* @__PURE__ */ new Set(),
|
|
629
|
-
endpoints: /* @__PURE__ */ new Map(),
|
|
630
|
-
tokenEndpointAuthMethods: /* @__PURE__ */ new Set(),
|
|
631
|
-
updatedAt: Date.now()
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
function pruneBindings(bindings) {
|
|
635
|
-
const now = Date.now();
|
|
636
|
-
for (const [key, binding] of bindings) {
|
|
637
|
-
if (now - binding.updatedAt > BINDING_TTL_MS) bindings.delete(key);
|
|
638
|
-
}
|
|
639
|
-
while (bindings.size > MAX_BINDINGS) {
|
|
640
|
-
const oldest = bindings.keys().next().value;
|
|
641
|
-
if (!oldest) break;
|
|
642
|
-
bindings.delete(oldest);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
function canonicalUrl(url) {
|
|
646
|
-
const copy = new URL(url);
|
|
647
|
-
copy.hash = "";
|
|
648
|
-
if (copy.protocol === "https:" && copy.port === "443" || copy.protocol === "http:" && copy.port === "80") {
|
|
649
|
-
copy.port = "";
|
|
650
|
-
}
|
|
651
|
-
return copy.toString().replace(/\/$/, "");
|
|
652
|
-
}
|
|
653
|
-
function enforceRegistrationRedirectUri(body, headers, callbackUrl) {
|
|
654
|
-
if (!body) return body;
|
|
655
|
-
const contentType = headers.get("content-type") ?? "";
|
|
656
|
-
if (!contentType.includes("json")) return body;
|
|
657
|
-
try {
|
|
658
|
-
const parsed = JSON.parse(body);
|
|
659
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
660
|
-
return body;
|
|
661
|
-
}
|
|
662
|
-
return JSON.stringify({
|
|
663
|
-
...parsed,
|
|
664
|
-
redirect_uris: [callbackUrl]
|
|
665
|
-
});
|
|
666
|
-
} catch {
|
|
667
|
-
return body;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
function normalizeOrigin(origin) {
|
|
671
|
-
const url = new URL(origin);
|
|
672
|
-
if (url.pathname !== "/" || url.search || url.hash) {
|
|
673
|
-
throw new Error(`OAuth proxy allowed origin must be an origin: ${origin}`);
|
|
674
|
-
}
|
|
675
|
-
return url.origin;
|
|
676
|
-
}
|
|
677
|
-
function isAllowedOrigin(origin, c, allowed) {
|
|
678
|
-
try {
|
|
679
|
-
const normalized = normalizeOrigin(origin);
|
|
680
|
-
if (normalized === new URL(c.req.url).origin || allowed.has(normalized)) {
|
|
681
|
-
return true;
|
|
682
|
-
}
|
|
683
|
-
const originUrl = new URL(normalized);
|
|
684
|
-
const forwardedHost = c.req.header("x-forwarded-host")?.split(",")[0]?.trim();
|
|
685
|
-
const requestHost = forwardedHost || c.req.header("host");
|
|
686
|
-
if (!requestHost || originUrl.host !== requestHost) return false;
|
|
687
|
-
const forwardedProto = c.req.header("x-forwarded-proto")?.split(",")[0]?.trim();
|
|
688
|
-
return !forwardedProto || `${forwardedProto}:` === originUrl.protocol;
|
|
689
|
-
} catch {
|
|
690
|
-
return false;
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
function corsResponse(origin) {
|
|
694
|
-
const headers = new Headers();
|
|
695
|
-
if (origin) setCorsHeaders(headers, origin);
|
|
696
|
-
headers.set("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
697
|
-
headers.set(
|
|
698
|
-
"Access-Control-Allow-Headers",
|
|
699
|
-
"Accept, Authorization, Content-Type"
|
|
700
|
-
);
|
|
701
|
-
headers.set("Access-Control-Max-Age", "600");
|
|
702
|
-
return new Response(null, { status: 204, headers });
|
|
703
|
-
}
|
|
704
|
-
function setCorsHeaders(headers, origin) {
|
|
705
|
-
headers.set("Access-Control-Allow-Origin", origin);
|
|
706
|
-
headers.append("Vary", "Origin");
|
|
707
|
-
}
|
|
708
|
-
async function isAuthenticated(c, authenticate) {
|
|
709
|
-
return authenticate ? authenticate(c) : true;
|
|
710
|
-
}
|
|
711
|
-
function isRedirect(status) {
|
|
712
|
-
return status >= 300 && status < 400;
|
|
713
|
-
}
|
|
714
|
-
function isLoopbackHostname(hostname) {
|
|
715
|
-
const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
716
|
-
return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "::1" || normalized.startsWith("127.");
|
|
717
|
-
}
|
|
718
|
-
function isLocalHostname(hostname) {
|
|
719
|
-
const normalized = hostname.toLowerCase();
|
|
720
|
-
return normalized.endsWith(".local") || normalized.endsWith(".internal") || normalized.endsWith(".home.arpa");
|
|
721
|
-
}
|
|
722
|
-
function isPublicAddress(address) {
|
|
723
|
-
if (address.includes(":")) {
|
|
724
|
-
const lower = address.toLowerCase();
|
|
725
|
-
if (lower.startsWith("::ffff:")) {
|
|
726
|
-
return isPublicAddress(lower.slice(7));
|
|
727
|
-
}
|
|
728
|
-
return !(lower === "::" || lower === "::1" || lower.startsWith("fc") || lower.startsWith("fd") || /^fe[89ab]/.test(lower) || lower.startsWith("ff") || lower.startsWith("2001:db8:"));
|
|
729
|
-
}
|
|
730
|
-
const parts = address.split(".").map(Number);
|
|
731
|
-
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part))) {
|
|
732
|
-
return false;
|
|
733
|
-
}
|
|
734
|
-
const [a, b, c] = parts;
|
|
735
|
-
return !(a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 0 && c === 0 || a === 192 && b === 0 && c === 2 || a === 192 && b === 168 || a === 198 && (b === 18 || b === 19) || a === 198 && b === 51 && c === 100 || a === 203 && b === 0 && c === 113 || a >= 224);
|
|
736
|
-
}
|
|
737
|
-
function log(enabled, message) {
|
|
738
|
-
if (enabled) console.log(`[OAuth BFF] ${message}`);
|
|
739
|
-
}
|
|
740
|
-
function proxyError(c, error, logging) {
|
|
741
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
742
|
-
if (logging) console.error("[OAuth BFF]", message);
|
|
743
|
-
if (error instanceof BodyTooLargeError) {
|
|
744
|
-
return c.json({ error: "Upstream response too large" }, 502);
|
|
745
|
-
}
|
|
746
|
-
if (error instanceof InvalidUpstreamError) {
|
|
747
|
-
return c.json({ error: error.message }, 502);
|
|
748
|
-
}
|
|
749
|
-
if (error instanceof DOMException && error.name === "TimeoutError") {
|
|
750
|
-
return c.json({ error: "OAuth upstream timed out" }, 504);
|
|
751
|
-
}
|
|
752
|
-
return c.json({ error: "OAuth upstream request failed" }, 502);
|
|
753
|
-
}
|
|
754
|
-
var BodyTooLargeError = class extends Error {
|
|
755
|
-
};
|
|
756
|
-
var InvalidUpstreamError = class extends Error {
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
export {
|
|
760
|
-
mountOAuthProxy,
|
|
761
|
-
isSafeProxyTarget
|
|
762
|
-
};
|