@agent-native/core 0.7.14 → 0.7.16
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 +56 -6
- package/dist/a2a/handlers.d.ts.map +1 -1
- package/dist/a2a/handlers.js +149 -24
- package/dist/a2a/handlers.js.map +1 -1
- package/dist/a2a/server.d.ts.map +1 -1
- package/dist/a2a/server.js +180 -51
- package/dist/a2a/server.js.map +1 -1
- package/dist/a2a/task-store.d.ts +10 -1
- package/dist/a2a/task-store.d.ts.map +1 -1
- package/dist/a2a/task-store.js +36 -2
- package/dist/a2a/task-store.js.map +1 -1
- package/dist/action.d.ts +16 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +11 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/default-model.d.ts +21 -0
- package/dist/agent/default-model.d.ts.map +1 -0
- package/dist/agent/default-model.js +21 -0
- package/dist/agent/default-model.js.map +1 -0
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +7 -4
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
- package/dist/agent/engine/anthropic-engine.js +10 -4
- package/dist/agent/engine/anthropic-engine.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +4 -1
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/builtin.js +1 -1
- package/dist/agent/engine/builtin.js.map +1 -1
- package/dist/agent/engine/registry.d.ts +27 -7
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +101 -20
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +1 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/production-agent.d.ts +32 -7
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +230 -70
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +0 -3
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/types.d.ts +0 -4
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/application-state/handlers.d.ts.map +1 -1
- package/dist/application-state/handlers.js +10 -6
- package/dist/application-state/handlers.js.map +1 -1
- package/dist/application-state/script-helpers.d.ts +1 -1
- package/dist/application-state/script-helpers.d.ts.map +1 -1
- package/dist/application-state/script-helpers.js +12 -8
- package/dist/application-state/script-helpers.js.map +1 -1
- package/dist/application-state/store.d.ts.map +1 -1
- package/dist/application-state/store.js +19 -10
- package/dist/application-state/store.js.map +1 -1
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +4 -1
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/create.d.ts +3 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +106 -16
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +97 -39
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/templates-meta.d.ts +4 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +56 -12
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/cli/workspacify.d.ts +2 -0
- package/dist/cli/workspacify.d.ts.map +1 -1
- package/dist/cli/workspacify.js +5 -4
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +5 -2
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +64 -25
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AgentTaskCard.d.ts.map +1 -1
- package/dist/client/AgentTaskCard.js +3 -2
- package/dist/client/AgentTaskCard.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +0 -6
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +98 -100
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/ConnectBuilderCard.d.ts.map +1 -1
- package/dist/client/ConnectBuilderCard.js +2 -1
- package/dist/client/ConnectBuilderCard.js.map +1 -1
- package/dist/client/DefaultSpinner.d.ts +1 -1
- package/dist/client/DefaultSpinner.d.ts.map +1 -1
- package/dist/client/DefaultSpinner.js +2 -9
- package/dist/client/DefaultSpinner.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +24 -22
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +4 -3
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +6 -4
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +70 -1
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/api-path.d.ts +5 -0
- package/dist/client/api-path.d.ts.map +1 -0
- package/dist/client/api-path.js +48 -0
- package/dist/client/api-path.js.map +1 -0
- package/dist/client/components/ApiKeySettings.d.ts.map +1 -1
- package/dist/client/components/ApiKeySettings.js +3 -2
- package/dist/client/components/ApiKeySettings.js.map +1 -1
- package/dist/client/components/CodeRequiredDialog.d.ts.map +1 -1
- package/dist/client/components/CodeRequiredDialog.js +3 -2
- package/dist/client/components/CodeRequiredDialog.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +3 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +17 -9
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/draft-key.d.ts +2 -0
- package/dist/client/composer/draft-key.d.ts.map +1 -0
- package/dist/client/composer/draft-key.js +8 -0
- package/dist/client/composer/draft-key.js.map +1 -0
- package/dist/client/composer/use-file-search.d.ts.map +1 -1
- package/dist/client/composer/use-file-search.js +2 -1
- package/dist/client/composer/use-file-search.js.map +1 -1
- package/dist/client/composer/use-mention-search.d.ts.map +1 -1
- package/dist/client/composer/use-mention-search.js +2 -1
- package/dist/client/composer/use-mention-search.js.map +1 -1
- package/dist/client/composer/use-skills.d.ts.map +1 -1
- package/dist/client/composer/use-skills.js +2 -1
- package/dist/client/composer/use-skills.js.map +1 -1
- package/dist/client/composer/useVoiceDictation.d.ts +1 -1
- package/dist/client/composer/useVoiceDictation.d.ts.map +1 -1
- package/dist/client/composer/useVoiceDictation.js +16 -8
- package/dist/client/composer/useVoiceDictation.js.map +1 -1
- package/dist/client/dev-mode.d.ts +14 -0
- package/dist/client/dev-mode.d.ts.map +1 -0
- package/dist/client/dev-mode.js +14 -0
- package/dist/client/dev-mode.js.map +1 -0
- package/dist/client/dev-overlay/DevOverlay.d.ts +26 -0
- package/dist/client/dev-overlay/DevOverlay.d.ts.map +1 -0
- package/dist/client/dev-overlay/DevOverlay.js +315 -0
- package/dist/client/dev-overlay/DevOverlay.js.map +1 -0
- package/dist/client/dev-overlay/builtins.d.ts +6 -0
- package/dist/client/dev-overlay/builtins.d.ts.map +1 -0
- package/dist/client/dev-overlay/builtins.js +35 -0
- package/dist/client/dev-overlay/builtins.js.map +1 -0
- package/dist/client/dev-overlay/index.d.ts +6 -0
- package/dist/client/dev-overlay/index.d.ts.map +1 -0
- package/dist/client/dev-overlay/index.js +5 -0
- package/dist/client/dev-overlay/index.js.map +1 -0
- package/dist/client/dev-overlay/registry.d.ts +13 -0
- package/dist/client/dev-overlay/registry.d.ts.map +1 -0
- package/dist/client/dev-overlay/registry.js +63 -0
- package/dist/client/dev-overlay/registry.js.map +1 -0
- package/dist/client/dev-overlay/types.d.ts +56 -0
- package/dist/client/dev-overlay/types.d.ts.map +1 -0
- package/dist/client/dev-overlay/types.js +9 -0
- package/dist/client/dev-overlay/types.js.map +1 -0
- package/dist/client/dev-overlay/use-dev-option.d.ts +12 -0
- package/dist/client/dev-overlay/use-dev-option.d.ts.map +1 -0
- package/dist/client/dev-overlay/use-dev-option.js +73 -0
- package/dist/client/dev-overlay/use-dev-option.js.map +1 -0
- package/dist/client/dev-overlay/use-dev-overlay-shortcut.d.ts +6 -0
- package/dist/client/dev-overlay/use-dev-overlay-shortcut.d.ts.map +1 -0
- package/dist/client/dev-overlay/use-dev-overlay-shortcut.js +29 -0
- package/dist/client/dev-overlay/use-dev-overlay-shortcut.js.map +1 -0
- package/dist/client/frame-protocol.d.ts +61 -10
- package/dist/client/frame-protocol.d.ts.map +1 -1
- package/dist/client/frame.d.ts +1 -0
- package/dist/client/frame.d.ts.map +1 -1
- package/dist/client/frame.js +37 -16
- package/dist/client/frame.js.map +1 -1
- package/dist/client/index.d.ts +5 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +5 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/integrations/IntegrationCard.d.ts.map +1 -1
- package/dist/client/integrations/IntegrationCard.js +3 -2
- package/dist/client/integrations/IntegrationCard.js.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.d.ts.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.js +3 -2
- package/dist/client/integrations/IntegrationsPanel.js.map +1 -1
- package/dist/client/integrations/useIntegrationStatus.d.ts.map +1 -1
- package/dist/client/integrations/useIntegrationStatus.js +2 -1
- package/dist/client/integrations/useIntegrationStatus.js.map +1 -1
- package/dist/client/notifications/NotificationsBell.d.ts.map +1 -1
- package/dist/client/notifications/NotificationsBell.js +26 -8
- package/dist/client/notifications/NotificationsBell.js.map +1 -1
- package/dist/client/observability/ThumbsFeedback.d.ts.map +1 -1
- package/dist/client/observability/ThumbsFeedback.js +2 -1
- package/dist/client/observability/ThumbsFeedback.js.map +1 -1
- package/dist/client/observability/useObservability.d.ts.map +1 -1
- package/dist/client/observability/useObservability.js +2 -1
- package/dist/client/observability/useObservability.js.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.d.ts +0 -7
- package/dist/client/onboarding/OnboardingPanel.d.ts.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.js +20 -10
- package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
- package/dist/client/onboarding/index.d.ts +1 -0
- package/dist/client/onboarding/index.d.ts.map +1 -1
- package/dist/client/onboarding/index.js +1 -0
- package/dist/client/onboarding/index.js.map +1 -1
- package/dist/client/onboarding/use-onboarding.d.ts +1 -7
- package/dist/client/onboarding/use-onboarding.d.ts.map +1 -1
- package/dist/client/onboarding/use-onboarding.js +27 -13
- package/dist/client/onboarding/use-onboarding.js.map +1 -1
- package/dist/client/onboarding/use-preview-mode.d.ts +10 -0
- package/dist/client/onboarding/use-preview-mode.d.ts.map +1 -0
- package/dist/client/onboarding/use-preview-mode.js +35 -0
- package/dist/client/onboarding/use-preview-mode.js.map +1 -0
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.js +2 -1
- package/dist/client/org/OrgSwitcher.js.map +1 -1
- package/dist/client/org/TeamPage.d.ts.map +1 -1
- package/dist/client/org/TeamPage.js +7 -5
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/org/hooks.d.ts.map +1 -1
- package/dist/client/org/hooks.js +2 -1
- package/dist/client/org/hooks.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +2 -1
- package/dist/client/progress/RunsTray.js.map +1 -1
- package/dist/client/resources/McpServerDetail.d.ts +0 -8
- package/dist/client/resources/McpServerDetail.d.ts.map +1 -1
- package/dist/client/resources/McpServerDetail.js +6 -1
- package/dist/client/resources/McpServerDetail.js.map +1 -1
- package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
- package/dist/client/resources/ResourceEditor.js +2 -1
- package/dist/client/resources/ResourceEditor.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +2 -1
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/resources/use-mcp-servers.d.ts.map +1 -1
- package/dist/client/resources/use-mcp-servers.js +7 -2
- package/dist/client/resources/use-mcp-servers.js.map +1 -1
- package/dist/client/resources/use-resources.d.ts.map +1 -1
- package/dist/client/resources/use-resources.js +9 -7
- package/dist/client/resources/use-resources.js.map +1 -1
- package/dist/client/settings/AgentsSection.d.ts.map +1 -1
- package/dist/client/settings/AgentsSection.js +7 -5
- package/dist/client/settings/AgentsSection.js.map +1 -1
- package/dist/client/settings/AutomationsSection.d.ts.map +1 -1
- package/dist/client/settings/AutomationsSection.js +9 -5
- package/dist/client/settings/AutomationsSection.js.map +1 -1
- package/dist/client/settings/BackgroundAgentSection.d.ts.map +1 -1
- package/dist/client/settings/BackgroundAgentSection.js +2 -1
- package/dist/client/settings/BackgroundAgentSection.js.map +1 -1
- package/dist/client/settings/SecretsSection.d.ts.map +1 -1
- package/dist/client/settings/SecretsSection.js +12 -4
- package/dist/client/settings/SecretsSection.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +15 -23
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/UsageSection.d.ts.map +1 -1
- package/dist/client/settings/UsageSection.js +2 -1
- package/dist/client/settings/UsageSection.js.map +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.d.ts +2 -4
- package/dist/client/settings/VoiceTranscriptionSection.d.ts.map +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.js +66 -23
- package/dist/client/settings/VoiceTranscriptionSection.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts +9 -0
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +31 -3
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +7 -2
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/client/sharing/ShareDialog.d.ts.map +1 -1
- package/dist/client/sharing/ShareDialog.js +4 -3
- package/dist/client/sharing/ShareDialog.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +1 -3
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +3 -24
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/terminal/AgentTerminal.d.ts +1 -0
- package/dist/client/terminal/AgentTerminal.d.ts.map +1 -1
- package/dist/client/terminal/AgentTerminal.js +14 -10
- package/dist/client/terminal/AgentTerminal.js.map +1 -1
- package/dist/client/tools/EmbeddedTool.d.ts +20 -0
- package/dist/client/tools/EmbeddedTool.d.ts.map +1 -0
- package/dist/client/tools/EmbeddedTool.js +154 -0
- package/dist/client/tools/EmbeddedTool.js.map +1 -0
- package/dist/client/tools/ExtensionSlot.d.ts +27 -0
- package/dist/client/tools/ExtensionSlot.d.ts.map +1 -0
- package/dist/client/tools/ExtensionSlot.js +96 -0
- package/dist/client/tools/ExtensionSlot.js.map +1 -0
- package/dist/client/tools/ToolEditor.d.ts.map +1 -1
- package/dist/client/tools/ToolEditor.js +5 -4
- package/dist/client/tools/ToolEditor.js.map +1 -1
- package/dist/client/tools/ToolViewer.d.ts.map +1 -1
- package/dist/client/tools/ToolViewer.js +75 -44
- package/dist/client/tools/ToolViewer.js.map +1 -1
- package/dist/client/tools/ToolViewerPage.d.ts.map +1 -1
- package/dist/client/tools/ToolViewerPage.js +2 -1
- package/dist/client/tools/ToolViewerPage.js.map +1 -1
- package/dist/client/tools/ToolsListPage.d.ts.map +1 -1
- package/dist/client/tools/ToolsListPage.js +3 -2
- package/dist/client/tools/ToolsListPage.js.map +1 -1
- package/dist/client/tools/ToolsSidebarSection.d.ts.map +1 -1
- package/dist/client/tools/ToolsSidebarSection.js +4 -3
- package/dist/client/tools/ToolsSidebarSection.js.map +1 -1
- package/dist/client/tools/iframe-bridge.d.ts +38 -0
- package/dist/client/tools/iframe-bridge.d.ts.map +1 -0
- package/dist/client/tools/iframe-bridge.js +207 -0
- package/dist/client/tools/iframe-bridge.js.map +1 -0
- package/dist/client/tools/index.d.ts +2 -0
- package/dist/client/tools/index.d.ts.map +1 -1
- package/dist/client/tools/index.js +2 -0
- package/dist/client/tools/index.js.map +1 -1
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +2 -1
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-agent-chat.js +2 -2
- package/dist/client/use-agent-chat.js.map +1 -1
- package/dist/client/use-avatar.d.ts.map +1 -1
- package/dist/client/use-avatar.js +3 -2
- package/dist/client/use-avatar.js.map +1 -1
- package/dist/client/use-builder-enabled.d.ts.map +1 -1
- package/dist/client/use-builder-enabled.js +2 -1
- package/dist/client/use-builder-enabled.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +2 -1
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +3 -2
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/client/use-dev-mode.d.ts.map +1 -1
- package/dist/client/use-dev-mode.js +2 -1
- package/dist/client/use-dev-mode.js.map +1 -1
- package/dist/client/use-send-to-agent-chat.d.ts.map +1 -1
- package/dist/client/use-send-to-agent-chat.js +5 -3
- package/dist/client/use-send-to-agent-chat.js.map +1 -1
- package/dist/client/use-session.d.ts.map +1 -1
- package/dist/client/use-session.js +2 -1
- package/dist/client/use-session.js.map +1 -1
- package/dist/client/useProductionAgent.d.ts.map +1 -1
- package/dist/client/useProductionAgent.js +4 -3
- package/dist/client/useProductionAgent.js.map +1 -1
- package/dist/collab/client.d.ts.map +1 -1
- package/dist/collab/client.js +3 -2
- package/dist/collab/client.js.map +1 -1
- package/dist/credentials/index.d.ts +27 -10
- package/dist/credentials/index.d.ts.map +1 -1
- package/dist/credentials/index.js +61 -19
- package/dist/credentials/index.js.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +10 -1
- package/dist/db/client.js.map +1 -1
- package/dist/db/migrations.d.ts +13 -5
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +9 -2
- package/dist/db/migrations.js.map +1 -1
- package/dist/deploy/build.d.ts +12 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +195 -23
- package/dist/deploy/build.js.map +1 -1
- package/dist/file-upload/registry.d.ts.map +1 -1
- package/dist/file-upload/registry.js +25 -1
- package/dist/file-upload/registry.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/integrations/adapters/email.d.ts.map +1 -1
- package/dist/integrations/adapters/email.js +152 -32
- package/dist/integrations/adapters/email.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts +13 -0
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +302 -32
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/adapters/telegram.d.ts.map +1 -1
- package/dist/integrations/adapters/telegram.js +37 -2
- package/dist/integrations/adapters/telegram.js.map +1 -1
- package/dist/integrations/adapters/whatsapp.d.ts.map +1 -1
- package/dist/integrations/adapters/whatsapp.js +91 -12
- package/dist/integrations/adapters/whatsapp.js.map +1 -1
- package/dist/integrations/google-docs-poller.d.ts.map +1 -1
- package/dist/integrations/google-docs-poller.js +5 -2
- package/dist/integrations/google-docs-poller.js.map +1 -1
- package/dist/integrations/internal-token.d.ts.map +1 -1
- package/dist/integrations/internal-token.js +17 -1
- package/dist/integrations/internal-token.js.map +1 -1
- package/dist/integrations/pending-tasks-retry-job.d.ts.map +1 -1
- package/dist/integrations/pending-tasks-retry-job.js +23 -9
- package/dist/integrations/pending-tasks-retry-job.js.map +1 -1
- package/dist/integrations/pending-tasks-store.d.ts +16 -0
- package/dist/integrations/pending-tasks-store.d.ts.map +1 -1
- package/dist/integrations/pending-tasks-store.js +58 -5
- package/dist/integrations/pending-tasks-store.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +198 -15
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/types.d.ts +33 -2
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.d.ts +6 -0
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +141 -61
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/jobs/cron.d.ts.map +1 -1
- package/dist/jobs/cron.js +12 -4
- package/dist/jobs/cron.js.map +1 -1
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +141 -16
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/jobs/tools.d.ts.map +1 -1
- package/dist/jobs/tools.js +94 -3
- package/dist/jobs/tools.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +128 -62
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp-client/hub-routes.d.ts +14 -0
- package/dist/mcp-client/hub-routes.d.ts.map +1 -1
- package/dist/mcp-client/hub-routes.js +42 -2
- package/dist/mcp-client/hub-routes.js.map +1 -1
- package/dist/mcp-client/index.d.ts +1 -1
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +1 -1
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/manager.d.ts.map +1 -1
- package/dist/mcp-client/manager.js +28 -3
- package/dist/mcp-client/manager.js.map +1 -1
- package/dist/mcp-client/remote-store.d.ts +49 -1
- package/dist/mcp-client/remote-store.d.ts.map +1 -1
- package/dist/mcp-client/remote-store.js +253 -6
- package/dist/mcp-client/remote-store.js.map +1 -1
- package/dist/mcp-client/routes.d.ts.map +1 -1
- package/dist/mcp-client/routes.js +11 -9
- package/dist/mcp-client/routes.js.map +1 -1
- package/dist/mcp-client/visibility.d.ts +7 -3
- package/dist/mcp-client/visibility.d.ts.map +1 -1
- package/dist/mcp-client/visibility.js +16 -7
- package/dist/mcp-client/visibility.js.map +1 -1
- package/dist/notifications/actions.d.ts.map +1 -1
- package/dist/notifications/actions.js +7 -1
- package/dist/notifications/actions.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/notifications/routes.d.ts.map +1 -1
- package/dist/notifications/routes.js +20 -3
- package/dist/notifications/routes.js.map +1 -1
- package/dist/notifications/store.d.ts.map +1 -1
- package/dist/notifications/store.js +6 -1
- package/dist/notifications/store.js.map +1 -1
- package/dist/oauth-tokens/store.d.ts +43 -2
- package/dist/oauth-tokens/store.d.ts.map +1 -1
- package/dist/oauth-tokens/store.js +83 -14
- package/dist/oauth-tokens/store.js.map +1 -1
- package/dist/observability/cleanup-job.d.ts +38 -0
- package/dist/observability/cleanup-job.d.ts.map +1 -0
- package/dist/observability/cleanup-job.js +107 -0
- package/dist/observability/cleanup-job.js.map +1 -0
- package/dist/observability/experiments.js +5 -5
- package/dist/observability/experiments.js.map +1 -1
- package/dist/observability/index.d.ts +2 -1
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +2 -1
- package/dist/observability/index.js.map +1 -1
- package/dist/observability/plugin.d.ts.map +1 -1
- package/dist/observability/plugin.js +11 -0
- package/dist/observability/plugin.js.map +1 -1
- package/dist/observability/routes.d.ts.map +1 -1
- package/dist/observability/routes.js +37 -8
- package/dist/observability/routes.js.map +1 -1
- package/dist/observability/store.d.ts +16 -0
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +54 -3
- package/dist/observability/store.js.map +1 -1
- package/dist/observability/traces.d.ts +5 -0
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +44 -1
- package/dist/observability/traces.js.map +1 -1
- package/dist/observability/types.d.ts +7 -0
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js.map +1 -1
- package/dist/onboarding/default-steps.d.ts.map +1 -1
- package/dist/onboarding/default-steps.js +1 -2
- package/dist/onboarding/default-steps.js.map +1 -1
- package/dist/onboarding/plugin.d.ts.map +1 -1
- package/dist/onboarding/plugin.js +63 -32
- package/dist/onboarding/plugin.js.map +1 -1
- package/dist/onboarding/types.d.ts +6 -1
- package/dist/onboarding/types.d.ts.map +1 -1
- package/dist/org/accept-pending.d.ts.map +1 -1
- package/dist/org/accept-pending.js +2 -1
- package/dist/org/accept-pending.js.map +1 -1
- package/dist/progress/actions.d.ts.map +1 -1
- package/dist/progress/actions.js +10 -1
- package/dist/progress/actions.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts.map +1 -1
- package/dist/progress/routes.js +20 -3
- package/dist/progress/routes.js.map +1 -1
- package/dist/progress/store.d.ts.map +1 -1
- package/dist/progress/store.js +6 -1
- package/dist/progress/store.js.map +1 -1
- package/dist/resources/handlers.d.ts.map +1 -1
- package/dist/resources/handlers.js +35 -7
- package/dist/resources/handlers.js.map +1 -1
- package/dist/resources/script-helpers.d.ts.map +1 -1
- package/dist/resources/script-helpers.js +15 -3
- package/dist/resources/script-helpers.js.map +1 -1
- package/dist/resources/store.d.ts.map +1 -1
- package/dist/resources/store.js +12 -4
- package/dist/resources/store.js.map +1 -1
- package/dist/scripts/call-agent.d.ts +1 -0
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +78 -40
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/chat/search-chats.d.ts.map +1 -1
- package/dist/scripts/chat/search-chats.js +3 -2
- package/dist/scripts/chat/search-chats.js.map +1 -1
- package/dist/scripts/db/exec.d.ts +1 -1
- package/dist/scripts/db/exec.d.ts.map +1 -1
- package/dist/scripts/db/exec.js +171 -5
- package/dist/scripts/db/exec.js.map +1 -1
- package/dist/scripts/db/migrate-user-api-keys.d.ts.map +1 -1
- package/dist/scripts/db/migrate-user-api-keys.js +10 -0
- package/dist/scripts/db/migrate-user-api-keys.js.map +1 -1
- package/dist/scripts/db/query.d.ts +1 -1
- package/dist/scripts/db/query.d.ts.map +1 -1
- package/dist/scripts/db/query.js +104 -4
- package/dist/scripts/db/query.js.map +1 -1
- package/dist/scripts/db/scoping.d.ts.map +1 -1
- package/dist/scripts/db/scoping.js +35 -10
- package/dist/scripts/db/scoping.js.map +1 -1
- package/dist/scripts/dev/shell.d.ts.map +1 -1
- package/dist/scripts/dev/shell.js +3 -1
- package/dist/scripts/dev/shell.js.map +1 -1
- package/dist/scripts/resources/delete-memory.d.ts.map +1 -1
- package/dist/scripts/resources/delete-memory.js +2 -1
- package/dist/scripts/resources/delete-memory.js.map +1 -1
- package/dist/scripts/resources/delete.d.ts.map +1 -1
- package/dist/scripts/resources/delete.js +2 -1
- package/dist/scripts/resources/delete.js.map +1 -1
- package/dist/scripts/resources/list.d.ts.map +1 -1
- package/dist/scripts/resources/list.js +2 -1
- package/dist/scripts/resources/list.js.map +1 -1
- package/dist/scripts/resources/migrate-learnings.d.ts.map +1 -1
- package/dist/scripts/resources/migrate-learnings.js +2 -1
- package/dist/scripts/resources/migrate-learnings.js.map +1 -1
- package/dist/scripts/resources/read.d.ts.map +1 -1
- package/dist/scripts/resources/read.js +2 -1
- package/dist/scripts/resources/read.js.map +1 -1
- package/dist/scripts/resources/save-memory.d.ts.map +1 -1
- package/dist/scripts/resources/save-memory.js +2 -1
- package/dist/scripts/resources/save-memory.js.map +1 -1
- package/dist/scripts/resources/write.d.ts.map +1 -1
- package/dist/scripts/resources/write.js +2 -1
- package/dist/scripts/resources/write.js.map +1 -1
- package/dist/secrets/onboarding.d.ts.map +1 -1
- package/dist/secrets/onboarding.js +24 -16
- package/dist/secrets/onboarding.js.map +1 -1
- package/dist/secrets/routes.d.ts.map +1 -1
- package/dist/secrets/routes.js +139 -37
- package/dist/secrets/routes.js.map +1 -1
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +23 -12
- package/dist/secrets/storage.js.map +1 -1
- package/dist/secrets/substitution.d.ts +24 -2
- package/dist/secrets/substitution.d.ts.map +1 -1
- package/dist/secrets/substitution.js +44 -6
- package/dist/secrets/substitution.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +19 -51
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +61 -15
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +449 -338
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-discovery.d.ts +8 -0
- package/dist/server/agent-discovery.d.ts.map +1 -1
- package/dist/server/agent-discovery.js +39 -12
- package/dist/server/agent-discovery.js.map +1 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +4 -1
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/analytics.d.ts +0 -1
- package/dist/server/analytics.d.ts.map +1 -1
- package/dist/server/analytics.js +0 -1
- package/dist/server/analytics.js.map +1 -1
- package/dist/server/app-base-path.d.ts +4 -0
- package/dist/server/app-base-path.d.ts.map +1 -0
- package/dist/server/app-base-path.js +33 -0
- package/dist/server/app-base-path.js.map +1 -0
- package/dist/server/app-url.d.ts +4 -1
- package/dist/server/app-url.d.ts.map +1 -1
- package/dist/server/app-url.js +16 -1
- package/dist/server/app-url.js.map +1 -1
- package/dist/server/auth.d.ts +15 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +400 -68
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts +1 -0
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +67 -15
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/builder-browser.d.ts +15 -0
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +90 -4
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/cli-capture.d.ts +31 -0
- package/dist/server/cli-capture.d.ts.map +1 -0
- package/dist/server/cli-capture.js +120 -0
- package/dist/server/cli-capture.js.map +1 -0
- package/dist/server/collab-plugin.d.ts +12 -0
- package/dist/server/collab-plugin.d.ts.map +1 -1
- package/dist/server/collab-plugin.js +63 -21
- package/dist/server/collab-plugin.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +467 -130
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/create-server.d.ts +2 -0
- package/dist/server/create-server.d.ts.map +1 -1
- package/dist/server/create-server.js +82 -11
- package/dist/server/create-server.js.map +1 -1
- package/dist/server/credential-provider.d.ts +11 -0
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +51 -2
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/csrf.d.ts +58 -0
- package/dist/server/csrf.d.ts.map +1 -0
- package/dist/server/csrf.js +165 -0
- package/dist/server/csrf.js.map +1 -0
- package/dist/server/framework-request-handler.d.ts +20 -0
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +115 -34
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/google-auth-plugin.d.ts.map +1 -1
- package/dist/server/google-auth-plugin.js +10 -2
- package/dist/server/google-auth-plugin.js.map +1 -1
- package/dist/server/google-oauth.d.ts +84 -2
- package/dist/server/google-oauth.d.ts.map +1 -1
- package/dist/server/google-oauth.js +248 -45
- package/dist/server/google-oauth.js.map +1 -1
- package/dist/server/index.d.ts +5 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +5 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/oauth-helpers.d.ts +8 -3
- package/dist/server/oauth-helpers.d.ts.map +1 -1
- package/dist/server/oauth-helpers.js +12 -8
- package/dist/server/oauth-helpers.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +37 -9
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/poll.d.ts +33 -0
- package/dist/server/poll.d.ts.map +1 -1
- package/dist/server/poll.js +43 -2
- package/dist/server/poll.js.map +1 -1
- package/dist/server/request-context.d.ts +102 -3
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js +100 -7
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/security-headers.d.ts +51 -0
- package/dist/server/security-headers.d.ts.map +1 -0
- package/dist/server/security-headers.js +90 -0
- package/dist/server/security-headers.js.map +1 -0
- package/dist/server/short-lived-token.d.ts +62 -0
- package/dist/server/short-lived-token.d.ts.map +1 -0
- package/dist/server/short-lived-token.js +118 -0
- package/dist/server/short-lived-token.js.map +1 -0
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +96 -2
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts.map +1 -1
- package/dist/server/transcribe-voice.js +307 -56
- package/dist/server/transcribe-voice.js.map +1 -1
- package/dist/server/voice-providers-status.d.ts +12 -0
- package/dist/server/voice-providers-status.d.ts.map +1 -0
- package/dist/server/voice-providers-status.js +71 -0
- package/dist/server/voice-providers-status.js.map +1 -0
- package/dist/shared/agent-chat.js +1 -1
- package/dist/shared/agent-chat.js.map +1 -1
- package/dist/shared/agent-env.js +1 -1
- package/dist/shared/agent-env.js.map +1 -1
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +16 -13
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.js +3 -0
- package/dist/sharing/actions/set-resource-visibility.js.map +1 -1
- package/dist/sharing/actions/share-resource.d.ts +1 -0
- package/dist/sharing/actions/share-resource.d.ts.map +1 -1
- package/dist/sharing/actions/share-resource.js +50 -0
- package/dist/sharing/actions/share-resource.js.map +1 -1
- package/dist/sharing/actions/unshare-resource.d.ts.map +1 -1
- package/dist/sharing/actions/unshare-resource.js +2 -0
- package/dist/sharing/actions/unshare-resource.js.map +1 -1
- package/dist/templates/default/.agents/skills/delegate-to-agent/SKILL.md +54 -0
- package/dist/templates/default/app/root.tsx +1 -1
- package/dist/templates/default/app/routes/_index.tsx +6 -1
- package/dist/templates/default/package.json +1 -1
- package/dist/templates/default/public/favicon.svg +13 -0
- package/dist/templates/default/public/icon-180.svg +12 -3
- package/dist/templates/default/public/icon-192.svg +12 -3
- package/dist/templates/default/public/icon-512.svg +12 -3
- package/dist/templates/workspace-core/package.json +23 -5
- package/dist/templates/workspace-core/src/credentials.ts +32 -5
- package/dist/templates/workspace-core/tsconfig.json +4 -1
- package/dist/terminal/pty-server.d.ts.map +1 -1
- package/dist/terminal/pty-server.js +8 -2
- package/dist/terminal/pty-server.js.map +1 -1
- package/dist/terminal/terminal-plugin.js +3 -3
- package/dist/terminal/terminal-plugin.js.map +1 -1
- package/dist/tools/actions.d.ts.map +1 -1
- package/dist/tools/actions.js +130 -0
- package/dist/tools/actions.js.map +1 -1
- package/dist/tools/fetch-tool.d.ts +1 -0
- package/dist/tools/fetch-tool.d.ts.map +1 -1
- package/dist/tools/fetch-tool.js +38 -16
- package/dist/tools/fetch-tool.js.map +1 -1
- package/dist/tools/html-shell.d.ts +44 -1
- package/dist/tools/html-shell.d.ts.map +1 -1
- package/dist/tools/html-shell.js +119 -4
- package/dist/tools/html-shell.js.map +1 -1
- package/dist/tools/proxy-security.d.ts +12 -0
- package/dist/tools/proxy-security.d.ts.map +1 -0
- package/dist/tools/proxy-security.js +158 -0
- package/dist/tools/proxy-security.js.map +1 -0
- package/dist/tools/routes.d.ts.map +1 -1
- package/dist/tools/routes.js +156 -105
- package/dist/tools/routes.js.map +1 -1
- package/dist/tools/schema.d.ts +89 -0
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +34 -0
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/slots/routes.d.ts +15 -0
- package/dist/tools/slots/routes.d.ts.map +1 -0
- package/dist/tools/slots/routes.js +94 -0
- package/dist/tools/slots/routes.js.map +1 -0
- package/dist/tools/slots/schema.d.ts +303 -0
- package/dist/tools/slots/schema.d.ts.map +1 -0
- package/dist/tools/slots/schema.js +76 -0
- package/dist/tools/slots/schema.js.map +1 -0
- package/dist/tools/slots/store.d.ts +66 -0
- package/dist/tools/slots/store.d.ts.map +1 -0
- package/dist/tools/slots/store.js +227 -0
- package/dist/tools/slots/store.js.map +1 -0
- package/dist/tools/store.d.ts.map +1 -1
- package/dist/tools/store.js +35 -37
- package/dist/tools/store.js.map +1 -1
- package/dist/tools/url-safety.d.ts +24 -0
- package/dist/tools/url-safety.d.ts.map +1 -0
- package/dist/tools/url-safety.js +224 -0
- package/dist/tools/url-safety.js.map +1 -0
- package/dist/tracking/providers.d.ts.map +1 -1
- package/dist/tracking/providers.js +28 -11
- package/dist/tracking/providers.js.map +1 -1
- package/dist/tracking/registry.d.ts.map +1 -1
- package/dist/tracking/registry.js +7 -3
- package/dist/tracking/registry.js.map +1 -1
- package/dist/triggers/actions.d.ts.map +1 -1
- package/dist/triggers/actions.js +11 -6
- package/dist/triggers/actions.js.map +1 -1
- package/dist/triggers/condition-evaluator.d.ts +8 -0
- package/dist/triggers/condition-evaluator.d.ts.map +1 -1
- package/dist/triggers/condition-evaluator.js +39 -4
- package/dist/triggers/condition-evaluator.js.map +1 -1
- package/dist/triggers/dispatcher.d.ts.map +1 -1
- package/dist/triggers/dispatcher.js +67 -4
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/usage/store.d.ts +0 -11
- package/dist/usage/store.d.ts.map +1 -1
- package/dist/usage/store.js +0 -11
- package/dist/usage/store.js.map +1 -1
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +8 -5
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/dist/vite/client.d.ts +2 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +216 -4
- package/dist/vite/client.js.map +1 -1
- package/docs/content/actions.md +32 -0
- package/docs/content/authentication.md +39 -12
- package/docs/content/cloneable-saas.md +13 -15
- package/docs/content/deployment.md +84 -9
- package/docs/content/drop-in-agent.md +2 -2
- package/docs/content/faq.md +4 -1
- package/docs/content/getting-started.md +2 -0
- package/docs/content/messaging.md +195 -155
- package/docs/content/onboarding.md +82 -12
- package/docs/content/security.md +59 -8
- package/docs/content/template-analytics.md +65 -59
- package/docs/content/template-clips.md +7 -9
- package/docs/content/template-design.md +55 -0
- package/docs/content/template-dispatch.md +13 -0
- package/docs/content/template-forms.md +7 -6
- package/docs/content/template-mail.md +78 -80
- package/package.json +4 -3
- package/src/templates/default/.agents/skills/delegate-to-agent/SKILL.md +54 -0
- package/src/templates/default/app/root.tsx +1 -1
- package/src/templates/default/app/routes/_index.tsx +6 -1
- package/src/templates/default/package.json +1 -1
- package/src/templates/default/public/favicon.svg +13 -0
- package/src/templates/default/public/icon-180.svg +12 -3
- package/src/templates/default/public/icon-192.svg +12 -3
- package/src/templates/default/public/icon-512.svg +12 -3
- package/src/templates/workspace-core/package.json +23 -5
- package/src/templates/workspace-core/src/credentials.ts +32 -5
- package/src/templates/workspace-core/tsconfig.json +4 -1
package/dist/server/auth.js
CHANGED
|
@@ -9,10 +9,40 @@ async function getFs() {
|
|
|
9
9
|
}
|
|
10
10
|
return _fs;
|
|
11
11
|
}
|
|
12
|
-
import { defineEventHandler, getMethod, getQuery, sendRedirect, setResponseHeader, setResponseStatus, getCookie, setCookie, deleteCookie, } from "h3";
|
|
13
|
-
// In h3 v2, `event.req` IS the web Request —
|
|
12
|
+
import { defineEventHandler, getMethod, getQuery, getRequestIP, sendRedirect, setResponseHeader, setResponseStatus, getCookie, setCookie, deleteCookie, } from "h3";
|
|
13
|
+
// In h3 v2, `event.req` IS the web Request — but in Nitro's dev server (srvx
|
|
14
|
+
// runtime), event.url and event.req share the same underlying URL object.
|
|
15
|
+
// When registerMiddleware strips the mount prefix from event.url.pathname, it
|
|
16
|
+
// also mutates event.req.url (NodeRequestURL setter updates nodeReq.url).
|
|
17
|
+
// Better Auth's router uses new URL(request.url).pathname to extract the
|
|
18
|
+
// sub-route, so it must receive the original full URL — not the stripped one.
|
|
19
|
+
// registerMiddleware saves the original pathname in event.context so we can
|
|
20
|
+
// reconstruct a fresh Request with the correct URL here.
|
|
14
21
|
function toWebRequest(event) {
|
|
15
|
-
|
|
22
|
+
const req = event.req;
|
|
23
|
+
const ctx = event.context;
|
|
24
|
+
if (ctx?._mountedPathname && ctx._mountPrefix) {
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(req.url);
|
|
27
|
+
const mountedPathname = stripAppBasePath(ctx._mountedPathname);
|
|
28
|
+
if (url.pathname !== mountedPathname) {
|
|
29
|
+
url.pathname = mountedPathname;
|
|
30
|
+
const method = req.method.toUpperCase();
|
|
31
|
+
const hasBody = method !== "GET" && method !== "HEAD";
|
|
32
|
+
return new Request(url.href, {
|
|
33
|
+
method: req.method,
|
|
34
|
+
headers: req.headers,
|
|
35
|
+
// Body may already be partially consumed; pass through as-is.
|
|
36
|
+
// GET/HEAD cannot have a body — omit to avoid spec errors.
|
|
37
|
+
...(hasBody ? { body: req.body, duplex: "half" } : {}),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// URL reconstruction failed — fall through and use original req.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return req;
|
|
16
46
|
}
|
|
17
47
|
import { getDbExec, isPostgres, intType, isLocalDatabase, retryOnDdlRace, } from "../db/client.js";
|
|
18
48
|
import { getBetterAuth, getBetterAuthSync } from "./better-auth-instance.js";
|
|
@@ -20,7 +50,7 @@ import { getOnboardingHtml, getResetPasswordHtml } from "./onboarding-html.js";
|
|
|
20
50
|
import { migrateLocalUserData } from "./local-migration.js";
|
|
21
51
|
import { readBody } from "../server/h3-helpers.js";
|
|
22
52
|
import { readDesktopSso, writeDesktopSso, clearDesktopSso, } from "./desktop-sso.js";
|
|
23
|
-
import { isElectron as isElectronRequest,
|
|
53
|
+
import { isElectron as isElectronRequest, getAppBasePath, getAppUrl, encodeOAuthState, decodeOAuthState, createOAuthSession, oauthCallbackResponse, oauthErrorPage, resolveOAuthRedirectUri, isAllowedOAuthRedirectUri, } from "./google-oauth.js";
|
|
24
54
|
/**
|
|
25
55
|
* Get the configured session max age. Desktop SSO broker writes from
|
|
26
56
|
* OAuth flows read this so expiration stays consistent with the cookie.
|
|
@@ -95,7 +125,7 @@ async function isLocalModeEnabled() {
|
|
|
95
125
|
* Check if we're in a development/test environment.
|
|
96
126
|
* Used for cookie security settings, not for auth bypass.
|
|
97
127
|
*/
|
|
98
|
-
function isDevEnvironment() {
|
|
128
|
+
export function isDevEnvironment() {
|
|
99
129
|
const env = process.env.NODE_ENV;
|
|
100
130
|
return env === "development" || env === "test";
|
|
101
131
|
}
|
|
@@ -126,6 +156,75 @@ export function safeReturnPath(raw) {
|
|
|
126
156
|
return "/";
|
|
127
157
|
}
|
|
128
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Read the desktop-SSO broker file, but only if the request is plausibly
|
|
161
|
+
* from the Electron desktop app *and* coming from the local machine.
|
|
162
|
+
*
|
|
163
|
+
* The broker file lives in the user's home directory and trusts the local
|
|
164
|
+
* trust boundary — a non-loopback request that pretends to be Electron
|
|
165
|
+
* via User-Agent must NEVER be allowed to read it. We additionally refuse
|
|
166
|
+
* any read in production builds: the desktop app launches with
|
|
167
|
+
* `NODE_ENV=development` (or unset), and any web-hosted production deploy
|
|
168
|
+
* has no business consulting a per-user file on the server's homedir
|
|
169
|
+
* even if one exists.
|
|
170
|
+
*
|
|
171
|
+
* Returns null when the safety checks fail or the file isn't present.
|
|
172
|
+
*/
|
|
173
|
+
async function readDesktopSsoSafely(event) {
|
|
174
|
+
if (process.env.NODE_ENV === "production")
|
|
175
|
+
return null;
|
|
176
|
+
if (!isElectronRequest(event))
|
|
177
|
+
return null;
|
|
178
|
+
// Loopback-only: 127.0.0.1, ::1, and the IPv4-mapped form.
|
|
179
|
+
let ip;
|
|
180
|
+
try {
|
|
181
|
+
ip = getRequestIP(event) ?? undefined;
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
ip = undefined;
|
|
185
|
+
}
|
|
186
|
+
// Strip an optional zone id (e.g. "fe80::1%en0") before comparing.
|
|
187
|
+
const normalised = (ip ?? "").split("%")[0];
|
|
188
|
+
const isLoopback = normalised === "127.0.0.1" ||
|
|
189
|
+
normalised === "::1" ||
|
|
190
|
+
normalised === "::ffff:127.0.0.1" ||
|
|
191
|
+
normalised.startsWith("127.");
|
|
192
|
+
if (!isLoopback)
|
|
193
|
+
return null;
|
|
194
|
+
return await readDesktopSso();
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Extract the framework session token from a Better Auth response's
|
|
198
|
+
* Set-Cookie headers, if any. Used by the password-reset path to skip
|
|
199
|
+
* the freshly-minted session when revoking sibling sessions for the
|
|
200
|
+
* user. Returns undefined if no session cookie was minted (the common
|
|
201
|
+
* case — Better Auth's reset doesn't auto-sign-in by default).
|
|
202
|
+
*/
|
|
203
|
+
function extractSessionTokenFromSetCookies(response) {
|
|
204
|
+
try {
|
|
205
|
+
// Headers may have multiple Set-Cookie entries; iterate via getSetCookie
|
|
206
|
+
// when available (Node 20+ / undici), else fall back to comma split.
|
|
207
|
+
const headers = response.headers;
|
|
208
|
+
const setCookies = typeof headers.getSetCookie === "function"
|
|
209
|
+
? headers.getSetCookie()
|
|
210
|
+
: (headers.get("set-cookie") ?? "")
|
|
211
|
+
.split(/,(?=[^;]+=)/)
|
|
212
|
+
.map((s) => s.trim())
|
|
213
|
+
.filter(Boolean);
|
|
214
|
+
for (const sc of setCookies) {
|
|
215
|
+
// Better Auth's session cookie name is configurable but defaults to
|
|
216
|
+
// `<prefix>.session_token`. Match either the Better Auth default or
|
|
217
|
+
// our COOKIE_NAME (`an_session`) on the same line.
|
|
218
|
+
const match = sc.match(/(?:^|\s|;)(an_session|[\w.-]*session_token)=([^;]+)/i);
|
|
219
|
+
if (match)
|
|
220
|
+
return match[2];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// Best-effort; treat as no token.
|
|
225
|
+
}
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
129
228
|
// ---------------------------------------------------------------------------
|
|
130
229
|
// ACCESS_TOKEN resolution
|
|
131
230
|
// ---------------------------------------------------------------------------
|
|
@@ -364,7 +463,17 @@ export async function runAuthGuard(event) {
|
|
|
364
463
|
return; // Auth not mounted (local mode, etc.)
|
|
365
464
|
return _authGuardFn(event);
|
|
366
465
|
}
|
|
367
|
-
|
|
466
|
+
/**
|
|
467
|
+
* The framework's dev-mode bypass identity. When `AUTH_MODE=local` (or
|
|
468
|
+
* dev-mode falls back), `getSession()` returns `{ email: DEV_MODE_USER_EMAIL }`.
|
|
469
|
+
* Production code that needs to check whether the current request is the
|
|
470
|
+
* dev-mode user (or filter it out of mailers, dashboards, etc.) should
|
|
471
|
+
* compare against this constant instead of inlining the literal —
|
|
472
|
+
* `guard-no-localhost-fallback.mjs` blocks the literal everywhere except
|
|
473
|
+
* `auth.ts` and a handful of dev-mode helpers.
|
|
474
|
+
*/
|
|
475
|
+
export const DEV_MODE_USER_EMAIL = "local@localhost";
|
|
476
|
+
const LOCAL_SESSION = { email: DEV_MODE_USER_EMAIL };
|
|
368
477
|
// ---------------------------------------------------------------------------
|
|
369
478
|
// Auth guard factory
|
|
370
479
|
// ---------------------------------------------------------------------------
|
|
@@ -387,7 +496,7 @@ function applyCorsHeaders(event) {
|
|
|
387
496
|
const originRaw = reqHeaders["origin"];
|
|
388
497
|
const origin = Array.isArray(originRaw) ? originRaw[0] : originRaw;
|
|
389
498
|
if (!origin)
|
|
390
|
-
return;
|
|
499
|
+
return { hasOrigin: false, allowed: true };
|
|
391
500
|
// Dev convenience: always allow localhost origins across ports (Tauri
|
|
392
501
|
// tray apps, the frame, docs). In prod, the CORS_ALLOWED_ORIGINS env
|
|
393
502
|
// var is the safe-list.
|
|
@@ -399,12 +508,13 @@ function applyCorsHeaders(event) {
|
|
|
399
508
|
? /^(https?|tauri):\/\/(localhost|127\.0\.0\.1|tauri\.localhost)(:\d+)?$/.test(origin)
|
|
400
509
|
: allowlist.includes(origin);
|
|
401
510
|
if (!allowed)
|
|
402
|
-
return;
|
|
511
|
+
return { hasOrigin: true, allowed: false };
|
|
403
512
|
setResponseHeader(event, "Access-Control-Allow-Origin", origin);
|
|
404
513
|
setResponseHeader(event, "Vary", "Origin");
|
|
405
514
|
setResponseHeader(event, "Access-Control-Allow-Credentials", "true");
|
|
406
|
-
setResponseHeader(event, "Access-Control-Allow-Methods", "GET,POST,PUT,PATCH,DELETE,OPTIONS");
|
|
407
|
-
setResponseHeader(event, "Access-Control-Allow-Headers", "Content-Type,Authorization,X-Requested-With");
|
|
515
|
+
setResponseHeader(event, "Access-Control-Allow-Methods", "GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS");
|
|
516
|
+
setResponseHeader(event, "Access-Control-Allow-Headers", "Content-Type,Authorization,X-Requested-With,X-Request-Source,X-Agent-Native-CSRF");
|
|
517
|
+
return { hasOrigin: true, allowed: true };
|
|
408
518
|
}
|
|
409
519
|
function createAuthGuardFn() {
|
|
410
520
|
return async (event) => {
|
|
@@ -413,13 +523,20 @@ function createAuthGuardFn() {
|
|
|
413
523
|
return;
|
|
414
524
|
const { loginHtml, publicPaths } = config;
|
|
415
525
|
const url = event.node?.req?.url ?? event.path ?? "/";
|
|
416
|
-
const
|
|
526
|
+
const queryStart = url.indexOf("?");
|
|
527
|
+
const rawPath = queryStart >= 0 ? url.slice(0, queryStart) : url;
|
|
528
|
+
const p = stripAppBasePath(rawPath);
|
|
529
|
+
const normalizedUrl = queryStart >= 0 ? `${p}${url.slice(queryStart)}` : p;
|
|
417
530
|
// Emit CORS headers on every request the guard sees so that even
|
|
418
531
|
// error responses (401) reach the browser.
|
|
419
|
-
applyCorsHeaders(event);
|
|
532
|
+
const cors = applyCorsHeaders(event);
|
|
420
533
|
// Preflight short-circuit: the browser sends OPTIONS before the real
|
|
421
534
|
// credentialed request. Must return success without invoking auth.
|
|
422
535
|
if (getMethod(event) === "OPTIONS") {
|
|
536
|
+
if (cors.hasOrigin && !cors.allowed) {
|
|
537
|
+
setResponseStatus(event, 403);
|
|
538
|
+
return "";
|
|
539
|
+
}
|
|
423
540
|
setResponseStatus(event, 204);
|
|
424
541
|
return "";
|
|
425
542
|
}
|
|
@@ -450,6 +567,15 @@ function createAuthGuardFn() {
|
|
|
450
567
|
if (p === "/_agent-native/a2a") {
|
|
451
568
|
return;
|
|
452
569
|
}
|
|
570
|
+
// Internal processor endpoint for the A2A async-mode fanout. Mirrors the
|
|
571
|
+
// integration webhook fanout: when `message/send` is called with
|
|
572
|
+
// `async: true`, the JSON-RPC handler enqueues to a2a_tasks and self-
|
|
573
|
+
// fires a POST here so the handler runs in a fresh function execution.
|
|
574
|
+
// Authenticity is verified via an HMAC token signed with A2A_SECRET
|
|
575
|
+
// (same scheme as /_agent-native/integrations/process-task).
|
|
576
|
+
if (p === "/_agent-native/a2a/_process-task") {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
453
579
|
// A2A secret receive endpoint — verifies authenticity via JWT signed
|
|
454
580
|
// with the calling app's A2A secret, not via session cookies. Used to
|
|
455
581
|
// sync the org A2A secret across connected apps.
|
|
@@ -473,7 +599,7 @@ function createAuthGuardFn() {
|
|
|
473
599
|
// injection) are rejected up front.
|
|
474
600
|
//
|
|
475
601
|
if (p === "/_agent-native/sign-in") {
|
|
476
|
-
const queryStr =
|
|
602
|
+
const queryStr = queryStart >= 0 ? url.slice(queryStart + 1) : "";
|
|
477
603
|
const safeReturn = safeReturnPath(new URLSearchParams(queryStr).get("return"));
|
|
478
604
|
const session = await getSession(event);
|
|
479
605
|
if (session) {
|
|
@@ -500,7 +626,7 @@ function createAuthGuardFn() {
|
|
|
500
626
|
p.endsWith(".woff")) {
|
|
501
627
|
return;
|
|
502
628
|
}
|
|
503
|
-
if (isPublicPath(
|
|
629
|
+
if (isPublicPath(normalizedUrl, publicPaths))
|
|
504
630
|
return;
|
|
505
631
|
const session = await getSession(event);
|
|
506
632
|
if (session)
|
|
@@ -589,12 +715,12 @@ export async function getSession(event) {
|
|
|
589
715
|
return session;
|
|
590
716
|
// Desktop SSO broker: even with BYOA auth, fall back to the broker
|
|
591
717
|
// for Electron requests so cross-template SSO works for custom-auth
|
|
592
|
-
// templates too.
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
718
|
+
// templates too. Gated on `readDesktopSsoSafely` so a non-loopback
|
|
719
|
+
// request that spoofs `User-Agent: ... Electron/...` cannot read the
|
|
720
|
+
// home-dir broker file (and so production builds never consult it).
|
|
721
|
+
const sso = await readDesktopSsoSafely(event);
|
|
722
|
+
if (sso?.email)
|
|
723
|
+
return { email: sso.email, token: sso.token };
|
|
598
724
|
// Fall through to mobile _session check
|
|
599
725
|
}
|
|
600
726
|
else {
|
|
@@ -613,8 +739,8 @@ export async function getSession(event) {
|
|
|
613
739
|
}
|
|
614
740
|
}
|
|
615
741
|
}
|
|
616
|
-
catch {
|
|
617
|
-
|
|
742
|
+
catch (e) {
|
|
743
|
+
console.error("[auth] ba.api.getSession error:", e);
|
|
618
744
|
}
|
|
619
745
|
// 5. Legacy cookie fallback (for sessions created before migration)
|
|
620
746
|
const cookie = getCookie(event, COOKIE_NAME);
|
|
@@ -630,14 +756,14 @@ export async function getSession(event) {
|
|
|
630
756
|
// a session token created by one template doesn't resolve in another.
|
|
631
757
|
// When an Electron request has no resolvable session, trust the
|
|
632
758
|
// home-dir SSO record written by whichever template the user signed
|
|
633
|
-
// into. Gated on
|
|
634
|
-
//
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
759
|
+
// into. Gated on `readDesktopSsoSafely`: requires Electron User-Agent,
|
|
760
|
+
// a loopback (127.0.0.1 / ::1) source IP, and a non-production NODE_ENV
|
|
761
|
+
// — anything else is rejected so a hostile network request cannot
|
|
762
|
+
// impersonate whichever email last signed into the desktop app.
|
|
763
|
+
const sso = await readDesktopSsoSafely(event);
|
|
764
|
+
if (sso?.email) {
|
|
765
|
+
clearUpgradePendingCookie(event);
|
|
766
|
+
return { email: sso.email, token: sso.token };
|
|
641
767
|
}
|
|
642
768
|
}
|
|
643
769
|
// 6. Mobile WebView bridge — _session query param
|
|
@@ -664,11 +790,18 @@ export async function getSession(event) {
|
|
|
664
790
|
// on a shared DB (Postgres, Turso, D1) this fallback would land every
|
|
665
791
|
// developer on the same account and expose each other's data.
|
|
666
792
|
//
|
|
793
|
+
// STRICT NODE_ENV check: this used to read `isDevEnvironment()` which
|
|
794
|
+
// also accepted `NODE_ENV=test`, meaning a misconfigured prod deploy
|
|
795
|
+
// started with `NODE_ENV=test` (or undefined NODE_ENV in some CI/build
|
|
796
|
+
// contexts) would silently bypass auth entirely. Limiting to the literal
|
|
797
|
+
// string "development" closes that footgun. Tests that need this branch
|
|
798
|
+
// to fire stub NODE_ENV explicitly to "development".
|
|
799
|
+
//
|
|
667
800
|
// EXCEPTION: if the user has explicitly exited local mode (clicked "Upgrade
|
|
668
801
|
// to real account"), they've signaled they want real auth. The upgrade
|
|
669
802
|
// cookie suppresses this fallback so the onboarding/sign-in page is served
|
|
670
803
|
// instead of silently re-authenticating them as local@localhost.
|
|
671
|
-
if (
|
|
804
|
+
if (process.env.NODE_ENV === "development" &&
|
|
672
805
|
isLocalDatabase() &&
|
|
673
806
|
!isUpgradePending(event) &&
|
|
674
807
|
!hasSignInFlag(event)) {
|
|
@@ -714,6 +847,10 @@ function hasSignInFlag(event) {
|
|
|
714
847
|
return false;
|
|
715
848
|
}
|
|
716
849
|
}
|
|
850
|
+
function isReadMethod(event) {
|
|
851
|
+
const method = getMethod(event);
|
|
852
|
+
return method === "GET" || method === "HEAD";
|
|
853
|
+
}
|
|
717
854
|
/**
|
|
718
855
|
* Cookie attributes that work in both same-site and third-party iframe
|
|
719
856
|
* contexts. Over HTTPS we emit `SameSite=None; Secure` (required by browsers
|
|
@@ -769,6 +906,17 @@ function isPublicPath(url, publicPaths) {
|
|
|
769
906
|
const p = url.split("?")[0];
|
|
770
907
|
return publicPaths.some((pp) => p === pp || p.startsWith(pp + "/"));
|
|
771
908
|
}
|
|
909
|
+
function stripAppBasePath(pathname) {
|
|
910
|
+
const basePath = getAppBasePath();
|
|
911
|
+
if (!basePath)
|
|
912
|
+
return pathname;
|
|
913
|
+
if (pathname === basePath)
|
|
914
|
+
return "/";
|
|
915
|
+
if (pathname.startsWith(`${basePath}/`)) {
|
|
916
|
+
return pathname.slice(basePath.length) || "/";
|
|
917
|
+
}
|
|
918
|
+
return pathname;
|
|
919
|
+
}
|
|
772
920
|
// ---------------------------------------------------------------------------
|
|
773
921
|
// Login page HTML (ACCESS_TOKEN mode)
|
|
774
922
|
// ---------------------------------------------------------------------------
|
|
@@ -838,10 +986,18 @@ const TOKEN_LOGIN_HTML = `<!DOCTYPE html>
|
|
|
838
986
|
</form>
|
|
839
987
|
</div>
|
|
840
988
|
<script>
|
|
989
|
+
function __anBasePath() {
|
|
990
|
+
var marker = '/_agent-native';
|
|
991
|
+
var idx = window.location.pathname.indexOf(marker);
|
|
992
|
+
return idx > 0 ? window.location.pathname.slice(0, idx) : '';
|
|
993
|
+
}
|
|
994
|
+
function __anPath(path) {
|
|
995
|
+
return __anBasePath() + path;
|
|
996
|
+
}
|
|
841
997
|
document.getElementById('form').addEventListener('submit', async (e) => {
|
|
842
998
|
e.preventDefault();
|
|
843
999
|
const token = document.getElementById('token').value;
|
|
844
|
-
const res = await fetch('/_agent-native/auth/login', {
|
|
1000
|
+
const res = await fetch(__anPath('/_agent-native/auth/login'), {
|
|
845
1001
|
method: 'POST',
|
|
846
1002
|
headers: { 'Content-Type': 'application/json' },
|
|
847
1003
|
body: JSON.stringify({ token }),
|
|
@@ -863,7 +1019,7 @@ async function setAuthModeLocal() {
|
|
|
863
1019
|
const fs = await getFs();
|
|
864
1020
|
fs.mkdirSync(path.dirname(LOCAL_MODE_MARKER_PATH), { recursive: true });
|
|
865
1021
|
fs.writeFileSync(LOCAL_MODE_MARKER_PATH, "local\n", "utf-8");
|
|
866
|
-
process.env.AUTH_MODE = "local";
|
|
1022
|
+
process.env.AUTH_MODE = "local"; // guard:allow-env-mutation — escape-hatch writes the local-mode marker file; mirrored into env so the in-flight process honors the change without restart
|
|
867
1023
|
return true;
|
|
868
1024
|
}
|
|
869
1025
|
catch {
|
|
@@ -879,7 +1035,7 @@ async function removeAuthModeLocal() {
|
|
|
879
1035
|
catch {
|
|
880
1036
|
// Marker already absent
|
|
881
1037
|
}
|
|
882
|
-
delete process.env.AUTH_MODE;
|
|
1038
|
+
delete process.env.AUTH_MODE; // guard:allow-env-mutation — escape-hatch removes the local-mode marker; mirrored into env so the in-flight process honors the change without restart
|
|
883
1039
|
return true;
|
|
884
1040
|
}
|
|
885
1041
|
catch {
|
|
@@ -914,7 +1070,11 @@ const migrateLocalDataHandler = defineEventHandler(async (event) => {
|
|
|
914
1070
|
setResponseStatus(event, 500);
|
|
915
1071
|
return {
|
|
916
1072
|
error: e?.message || "Migration failed",
|
|
917
|
-
|
|
1073
|
+
// Only surface the stack when explicitly enabled. `isDevEnvironment()`
|
|
1074
|
+
// returns true on preview deploys and Lambda contexts that forget
|
|
1075
|
+
// NODE_ENV=production, which leaked stack traces to clients. Use
|
|
1076
|
+
// AGENT_NATIVE_DEBUG_ERRORS=1 for opt-in debug visibility.
|
|
1077
|
+
stack: process.env.AGENT_NATIVE_DEBUG_ERRORS === "1" ? e?.stack : undefined,
|
|
918
1078
|
};
|
|
919
1079
|
}
|
|
920
1080
|
});
|
|
@@ -950,8 +1110,16 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
950
1110
|
setResponseStatus(event, 405);
|
|
951
1111
|
return { error: "Method not allowed" };
|
|
952
1112
|
}
|
|
953
|
-
|
|
954
|
-
|
|
1113
|
+
// Validate the user-supplied `redirect_uri` against the framework's
|
|
1114
|
+
// server-side allowlist (must be same-origin and under
|
|
1115
|
+
// `/_agent-native/...`). Reject anything else so an attacker can't
|
|
1116
|
+
// smuggle a different already-registered redirect URI past Google's
|
|
1117
|
+
// host-prefix matching. See HIGH-1 in 09-oauth-session.md.
|
|
1118
|
+
const redirectUri = resolveOAuthRedirectUri(event);
|
|
1119
|
+
if (redirectUri === null) {
|
|
1120
|
+
setResponseStatus(event, 400);
|
|
1121
|
+
return { error: "Invalid redirect_uri" };
|
|
1122
|
+
}
|
|
955
1123
|
const q = getQuery(event);
|
|
956
1124
|
const desktop = isElectronRequest(event) || q.desktop === "1" || q.desktop === "true";
|
|
957
1125
|
const flowId = desktop ? q.flow_id || undefined : undefined;
|
|
@@ -990,7 +1158,16 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
990
1158
|
setResponseStatus(event, 400);
|
|
991
1159
|
return { error: "Missing authorization code" };
|
|
992
1160
|
}
|
|
993
|
-
const { redirectUri, desktop, returnUrl, flowId } = decodeOAuthState(query.state,
|
|
1161
|
+
const { redirectUri, desktop, returnUrl, flowId } = decodeOAuthState(query.state, getAppUrl(event, "/_agent-native/google/callback"));
|
|
1162
|
+
// Defence in depth: the state is HMAC-signed, but if the signing
|
|
1163
|
+
// key ever leaked an attacker could mint state with their own
|
|
1164
|
+
// redirect_uri. Re-validate against the same allowlist used at
|
|
1165
|
+
// auth-url time so the token exchange is always sent to a URI we
|
|
1166
|
+
// own.
|
|
1167
|
+
if (!isAllowedOAuthRedirectUri(redirectUri, event)) {
|
|
1168
|
+
setResponseStatus(event, 400);
|
|
1169
|
+
return { error: "Invalid redirect_uri in state" };
|
|
1170
|
+
}
|
|
994
1171
|
const tokenRes = await fetch("https://oauth2.googleapis.com/token", {
|
|
995
1172
|
method: "POST",
|
|
996
1173
|
headers: {
|
|
@@ -1015,6 +1192,17 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
1015
1192
|
const email = user.email;
|
|
1016
1193
|
if (!email)
|
|
1017
1194
|
throw new Error("Could not get email from Google");
|
|
1195
|
+
// Reject unverified Google addresses. Google returns
|
|
1196
|
+
// `verified_email: false` for accounts where ownership of the
|
|
1197
|
+
// address hasn't been proven (rare on consumer accounts but
|
|
1198
|
+
// reachable on Workspace tenants that allow it). Without this
|
|
1199
|
+
// check, an attacker could sign up as `victim@example.com` on
|
|
1200
|
+
// Google without controlling the inbox and take over a local
|
|
1201
|
+
// password account that already exists at that address (Better
|
|
1202
|
+
// Auth's accountLinking auto-merges trusted-provider sign-ins).
|
|
1203
|
+
if (user.verified_email !== true) {
|
|
1204
|
+
throw new Error("Google account email is not verified. Please verify your email with Google and try again.");
|
|
1205
|
+
}
|
|
1018
1206
|
const { sessionToken } = await createOAuthSession(event, email, {
|
|
1019
1207
|
hasProductionSession: false,
|
|
1020
1208
|
desktop,
|
|
@@ -1084,24 +1272,55 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
1084
1272
|
app.use("/_agent-native/auth/ba", defineEventHandler(async (event) => {
|
|
1085
1273
|
const reqPath = event.url?.pathname ?? event.path ?? "";
|
|
1086
1274
|
const isResetPassword = reqPath.includes("reset-password") && getMethod(event) === "POST";
|
|
1087
|
-
// Pre-read the body for reset-password so we can
|
|
1088
|
-
//
|
|
1275
|
+
// Pre-read the body for reset-password so we can auto-verify the
|
|
1276
|
+
// user's email after they save the new password. CRUCIAL: clone
|
|
1277
|
+
// the Request first — h3 v2 `event.req` is the live web Request,
|
|
1278
|
+
// and `.text()`/`.json()` consume the stream. The same `event.req`
|
|
1279
|
+
// is handed to Better Auth below; without the clone, Better Auth
|
|
1280
|
+
// sees an empty body, fails Zod validation, and returns 400 —
|
|
1281
|
+
// which the reset page renders as "the link may have expired".
|
|
1089
1282
|
let resetToken;
|
|
1283
|
+
let resetUserId;
|
|
1090
1284
|
if (isResetPassword) {
|
|
1091
1285
|
try {
|
|
1092
|
-
const
|
|
1286
|
+
const cloned = event.req.clone();
|
|
1287
|
+
const body = (await cloned.json().catch(() => undefined));
|
|
1093
1288
|
resetToken = body?.token;
|
|
1094
1289
|
}
|
|
1095
1290
|
catch {
|
|
1096
1291
|
// ignore — Better Auth will handle validation
|
|
1097
1292
|
}
|
|
1293
|
+
// Look up userId BEFORE calling auth.handler — Better Auth deletes
|
|
1294
|
+
// the verification row as part of the reset, so by the time the
|
|
1295
|
+
// handler returns 200 the row is gone and we can't recover the user.
|
|
1296
|
+
if (resetToken) {
|
|
1297
|
+
try {
|
|
1298
|
+
const { getDbExec } = await import("../db/client.js");
|
|
1299
|
+
const db = getDbExec();
|
|
1300
|
+
const rows = await db.execute({
|
|
1301
|
+
sql: "SELECT value FROM verification WHERE identifier = ?",
|
|
1302
|
+
args: [`reset-password:${resetToken}`],
|
|
1303
|
+
});
|
|
1304
|
+
resetUserId = rows.rows[0]?.value;
|
|
1305
|
+
}
|
|
1306
|
+
catch {
|
|
1307
|
+
// Best-effort — if we can't read the verification row we just
|
|
1308
|
+
// skip auto-verify; the user can verify normally.
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1098
1311
|
}
|
|
1099
1312
|
const response = await auth.handler(toWebRequest(event));
|
|
1100
1313
|
const isResponse = response != null &&
|
|
1101
1314
|
typeof response.status === "number" &&
|
|
1102
1315
|
typeof response.headers?.get === "function";
|
|
1103
|
-
// After email verification, add ?verified to the redirect so the
|
|
1104
|
-
// login page can show
|
|
1316
|
+
// After email verification, add ?verified=1 to the redirect so the
|
|
1317
|
+
// login page can show "Email verified!". MUTATE the response in
|
|
1318
|
+
// place — `new Response(null, { headers: new Headers(response.headers) })`
|
|
1319
|
+
// collapses multiple Set-Cookie headers into one comma-joined value,
|
|
1320
|
+
// which browsers reject. With `autoSignInAfterVerification: true`
|
|
1321
|
+
// Better Auth emits 2–3 Set-Cookie headers (session token + cookie
|
|
1322
|
+
// cache + dontRememberToken); losing them strands the user on the
|
|
1323
|
+
// login page even though verification succeeded.
|
|
1105
1324
|
if (reqPath.includes("verify-email") &&
|
|
1106
1325
|
isResponse &&
|
|
1107
1326
|
response.status >= 300 &&
|
|
@@ -1109,38 +1328,83 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
1109
1328
|
const loc = response.headers.get("location");
|
|
1110
1329
|
if (loc && !/[?&]verified=/.test(loc)) {
|
|
1111
1330
|
const sep = loc.includes("?") ? "&" : "?";
|
|
1112
|
-
|
|
1113
|
-
status: response.status,
|
|
1114
|
-
headers: new Headers(response.headers),
|
|
1115
|
-
});
|
|
1116
|
-
newResponse.headers.set("location", loc + sep + "verified=1");
|
|
1117
|
-
return newResponse;
|
|
1331
|
+
response.headers.set("location", loc + sep + "verified=1");
|
|
1118
1332
|
}
|
|
1119
1333
|
}
|
|
1120
1334
|
// Auto-verify email after a successful password reset. The user
|
|
1121
|
-
// proved email ownership by receiving and using the reset link
|
|
1335
|
+
// proved email ownership by receiving and using the reset link, so
|
|
1336
|
+
// we don't want them stuck behind `requireEmailVerification` after
|
|
1337
|
+
// resetting — that's the exact escape hatch they just used.
|
|
1122
1338
|
if (isResetPassword &&
|
|
1123
|
-
|
|
1339
|
+
resetUserId &&
|
|
1124
1340
|
isResponse &&
|
|
1125
1341
|
response.status >= 200 &&
|
|
1126
1342
|
response.status < 300) {
|
|
1127
1343
|
try {
|
|
1128
1344
|
const { getDbExec } = await import("../db/client.js");
|
|
1129
1345
|
const db = getDbExec();
|
|
1130
|
-
//
|
|
1131
|
-
//
|
|
1132
|
-
//
|
|
1133
|
-
//
|
|
1134
|
-
|
|
1135
|
-
sql: "
|
|
1136
|
-
args: [
|
|
1346
|
+
// Use boolean literals for cross-dialect portability: Postgres
|
|
1347
|
+
// stores `email_verified` as BOOLEAN and rejects integer 1/0,
|
|
1348
|
+
// SQLite accepts TRUE/FALSE as aliases for 1/0 (since 3.23).
|
|
1349
|
+
// Quote `"user"` because it's a reserved keyword in Postgres.
|
|
1350
|
+
await db.execute({
|
|
1351
|
+
sql: 'UPDATE "user" SET email_verified = TRUE WHERE id = ? AND (email_verified = FALSE OR email_verified IS NULL)',
|
|
1352
|
+
args: [resetUserId],
|
|
1137
1353
|
});
|
|
1138
|
-
|
|
1139
|
-
|
|
1354
|
+
// Revoke every existing session for this user so a stolen
|
|
1355
|
+
// cookie doesn't outlive the password it was paired with. We
|
|
1356
|
+
// do this AFTER Better Auth's response has been generated so
|
|
1357
|
+
// the freshly-minted post-reset session (if any) is captured
|
|
1358
|
+
// by the response's Set-Cookie header — but `auth.handler` for
|
|
1359
|
+
// reset-password does not auto-sign-in by default, so the
|
|
1360
|
+
// common path is "wipe everything; user signs in with new
|
|
1361
|
+
// password." The legacy `sessions` table is also wiped by
|
|
1362
|
+
// joining through the `user.email` column.
|
|
1363
|
+
//
|
|
1364
|
+
// Skip the freshly-minted Better Auth session id when present
|
|
1365
|
+
// (auto-sign-in plugins / future config). Reading it from the
|
|
1366
|
+
// response avoids racing against Better Auth's own writes.
|
|
1367
|
+
const newSessionToken = extractSessionTokenFromSetCookies(response);
|
|
1368
|
+
// 1. Better Auth `session` table — keyed by user_id.
|
|
1369
|
+
if (newSessionToken) {
|
|
1140
1370
|
await db.execute({
|
|
1141
|
-
sql:
|
|
1142
|
-
args: [
|
|
1371
|
+
sql: 'DELETE FROM "session" WHERE user_id = ? AND token <> ?',
|
|
1372
|
+
args: [resetUserId, newSessionToken],
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
else {
|
|
1376
|
+
await db.execute({
|
|
1377
|
+
sql: 'DELETE FROM "session" WHERE user_id = ?',
|
|
1378
|
+
args: [resetUserId],
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
// 2. Legacy `sessions` table — keyed by `email` column. The
|
|
1382
|
+
// reset-password verification row holds the user's id, not
|
|
1383
|
+
// their email, so we look up the email first. Best-effort —
|
|
1384
|
+
// skip silently if the lookup fails so the response still ships.
|
|
1385
|
+
try {
|
|
1386
|
+
const { rows } = await db.execute({
|
|
1387
|
+
sql: 'SELECT email FROM "user" WHERE id = ?',
|
|
1388
|
+
args: [resetUserId],
|
|
1143
1389
|
});
|
|
1390
|
+
const userEmail = (rows[0]?.email ?? rows[0]?.[0]);
|
|
1391
|
+
if (userEmail) {
|
|
1392
|
+
if (newSessionToken) {
|
|
1393
|
+
await db.execute({
|
|
1394
|
+
sql: "DELETE FROM sessions WHERE email = ? AND token <> ?",
|
|
1395
|
+
args: [userEmail, newSessionToken],
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
else {
|
|
1399
|
+
await db.execute({
|
|
1400
|
+
sql: "DELETE FROM sessions WHERE email = ?",
|
|
1401
|
+
args: [userEmail],
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
catch {
|
|
1407
|
+
// Best-effort — don't block the response
|
|
1144
1408
|
}
|
|
1145
1409
|
}
|
|
1146
1410
|
catch {
|
|
@@ -1301,9 +1565,77 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
1301
1565
|
await clearDesktopSso();
|
|
1302
1566
|
return { ok: true };
|
|
1303
1567
|
}));
|
|
1568
|
+
// POST /_agent-native/auth/logout-all — revoke every session row for
|
|
1569
|
+
// the authenticated user across both auth tables. Companion to the
|
|
1570
|
+
// password-reset session-revocation logic; lets a user sign out
|
|
1571
|
+
// everywhere from one device. Requires an authenticated session.
|
|
1572
|
+
app.use("/_agent-native/auth/logout-all", defineEventHandler(async (event) => {
|
|
1573
|
+
if (getMethod(event) !== "POST") {
|
|
1574
|
+
setResponseStatus(event, 405);
|
|
1575
|
+
return { error: "Method not allowed" };
|
|
1576
|
+
}
|
|
1577
|
+
const session = await getSession(event);
|
|
1578
|
+
if (!session?.email) {
|
|
1579
|
+
setResponseStatus(event, 401);
|
|
1580
|
+
return { error: "Not authenticated" };
|
|
1581
|
+
}
|
|
1582
|
+
try {
|
|
1583
|
+
const db = getDbExec();
|
|
1584
|
+
// 1. Resolve user_id from email so we can wipe Better Auth sessions
|
|
1585
|
+
// by their FK column.
|
|
1586
|
+
let userId;
|
|
1587
|
+
try {
|
|
1588
|
+
const { rows } = await db.execute({
|
|
1589
|
+
sql: 'SELECT id FROM "user" WHERE email = ?',
|
|
1590
|
+
args: [session.email],
|
|
1591
|
+
});
|
|
1592
|
+
userId = (rows[0]?.id ?? rows[0]?.[0]);
|
|
1593
|
+
}
|
|
1594
|
+
catch {
|
|
1595
|
+
// User table may not exist on token-only deployments — skip.
|
|
1596
|
+
}
|
|
1597
|
+
if (userId) {
|
|
1598
|
+
try {
|
|
1599
|
+
await db.execute({
|
|
1600
|
+
sql: 'DELETE FROM "session" WHERE user_id = ?',
|
|
1601
|
+
args: [userId],
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
catch {
|
|
1605
|
+
// Best-effort.
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
// 2. Legacy `sessions` table — keyed by `email` column.
|
|
1609
|
+
try {
|
|
1610
|
+
await db.execute({
|
|
1611
|
+
sql: "DELETE FROM sessions WHERE email = ?",
|
|
1612
|
+
args: [session.email],
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
catch {
|
|
1616
|
+
// Best-effort.
|
|
1617
|
+
}
|
|
1618
|
+
// 3. Drop the current request's cookie and best-effort sign out
|
|
1619
|
+
// of Better Auth (so the response sets the proper expiry header).
|
|
1620
|
+
deleteCookie(event, COOKIE_NAME, { path: "/" });
|
|
1621
|
+
try {
|
|
1622
|
+
await auth.api.signOut({ headers: event.headers });
|
|
1623
|
+
}
|
|
1624
|
+
catch {
|
|
1625
|
+
// Ignore — sessions are already gone in DB.
|
|
1626
|
+
}
|
|
1627
|
+
if (isElectronRequest(event))
|
|
1628
|
+
await clearDesktopSso();
|
|
1629
|
+
return { ok: true };
|
|
1630
|
+
}
|
|
1631
|
+
catch (e) {
|
|
1632
|
+
setResponseStatus(event, 500);
|
|
1633
|
+
return { error: e?.message || "Failed to revoke sessions" };
|
|
1634
|
+
}
|
|
1635
|
+
}));
|
|
1304
1636
|
// GET /_agent-native/auth/session
|
|
1305
1637
|
app.use("/_agent-native/auth/session", defineEventHandler(async (event) => {
|
|
1306
|
-
if (
|
|
1638
|
+
if (!isReadMethod(event)) {
|
|
1307
1639
|
setResponseStatus(event, 405);
|
|
1308
1640
|
return { error: "Method not allowed" };
|
|
1309
1641
|
}
|
|
@@ -1318,7 +1650,7 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
1318
1650
|
// reset link in their email. Reads ?token=... and POSTs to Better Auth's
|
|
1319
1651
|
// /reset-password endpoint on submit.
|
|
1320
1652
|
app.use("/_agent-native/auth/reset", defineEventHandler((event) => {
|
|
1321
|
-
if (
|
|
1653
|
+
if (!isReadMethod(event)) {
|
|
1322
1654
|
setResponseStatus(event, 405);
|
|
1323
1655
|
return { error: "Method not allowed" };
|
|
1324
1656
|
}
|
|
@@ -1374,7 +1706,7 @@ function mountTokenOnlyRoutes(app, accessTokens, publicPaths = []) {
|
|
|
1374
1706
|
return { ok: true };
|
|
1375
1707
|
}));
|
|
1376
1708
|
app.use("/_agent-native/auth/session", defineEventHandler(async (event) => {
|
|
1377
|
-
if (
|
|
1709
|
+
if (!isReadMethod(event)) {
|
|
1378
1710
|
setResponseStatus(event, 405);
|
|
1379
1711
|
return { error: "Method not allowed" };
|
|
1380
1712
|
}
|
|
@@ -1392,7 +1724,7 @@ function mountTokenOnlyRoutes(app, accessTokens, publicPaths = []) {
|
|
|
1392
1724
|
// ---------------------------------------------------------------------------
|
|
1393
1725
|
function mountLocalModeRoutes(app) {
|
|
1394
1726
|
app.use("/_agent-native/auth/session", defineEventHandler(async (event) => {
|
|
1395
|
-
if (
|
|
1727
|
+
if (!isReadMethod(event)) {
|
|
1396
1728
|
setResponseStatus(event, 405);
|
|
1397
1729
|
return { error: "Method not allowed" };
|
|
1398
1730
|
}
|
|
@@ -1552,7 +1884,7 @@ function mountAuthFallbackRoutes(app) {
|
|
|
1552
1884
|
return { ok: true };
|
|
1553
1885
|
}));
|
|
1554
1886
|
app.use("/_agent-native/auth/session", defineEventHandler(async (event) => {
|
|
1555
|
-
if (
|
|
1887
|
+
if (!isReadMethod(event)) {
|
|
1556
1888
|
setResponseStatus(event, 405);
|
|
1557
1889
|
return { error: "Method not allowed" };
|
|
1558
1890
|
}
|
|
@@ -1655,7 +1987,7 @@ export async function autoMountAuth(app, options = {}) {
|
|
|
1655
1987
|
// BYOA — custom getSession provider
|
|
1656
1988
|
if (customGetSession) {
|
|
1657
1989
|
app.use("/_agent-native/auth/session", defineEventHandler(async (event) => {
|
|
1658
|
-
if (
|
|
1990
|
+
if (!isReadMethod(event)) {
|
|
1659
1991
|
setResponseStatus(event, 405);
|
|
1660
1992
|
return { error: "Method not allowed" };
|
|
1661
1993
|
}
|