@opengeni/api-router 0.30.1 → 1.0.0
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/dist/access-grant-rls.d.ts +3 -0
- package/dist/admission-trace.d.ts +8 -0
- package/dist/api-websocket.d.ts +18 -0
- package/dist/app.d.ts +50 -2
- package/dist/app.js +12 -1
- package/dist/artifact-catalog-cursor.d.ts +27 -0
- package/dist/auth/managed-auth-attempt-context.d.ts +10 -0
- package/dist/auth/managed-auth-rate-limits.d.ts +167 -0
- package/dist/auth/managed-auth-session-adapter.d.ts +6 -0
- package/dist/auth/managed-auth.d.ts +102 -3
- package/dist/auth/managed-email.d.ts +29 -0
- package/dist/auth/managed-sign-in-notifications.d.ts +4 -0
- package/dist/auth/new-signups-gate.d.ts +23 -0
- package/dist/auth/organization-user-setup.d.ts +80 -0
- package/dist/auth/signup-funnel-metrics.d.ts +44 -0
- package/dist/browser-controller-authority.d.ts +1 -61
- package/dist/browser-ephemeral.d.ts +5 -0
- package/dist/browser-state-authority.d.ts +1 -27
- package/dist/chunk-6TZ5LG3O.js +123948 -0
- package/dist/chunk-6TZ5LG3O.js.map +1 -0
- package/dist/chunk-OGQDXVXY.js +18 -0
- package/dist/chunk-OGQDXVXY.js.map +1 -0
- package/dist/claude-subscription-account-conflicts.d.ts +1 -0
- package/dist/claude-subscription-account-usage.d.ts +39 -0
- package/dist/claude-subscription-oauth.d.ts +25 -0
- package/dist/claude-subscription-profile.d.ts +9 -0
- package/dist/claude-subscription-usage.d.ts +44 -0
- package/dist/claude-workspace-connection.d.ts +15 -0
- package/dist/codemode.d.ts +32 -1
- package/dist/company-brain-okf.d.ts +24 -0
- package/dist/connected-machine-computer-access.d.ts +11 -0
- package/dist/connection-ownership.d.ts +54 -0
- package/dist/controller-data-plane.d.ts +32 -0
- package/dist/editable-artifact-office-import.d.ts +7 -4
- package/dist/editable-artifact-source-session.d.ts +3 -0
- package/dist/editable-artifact-websocket.d.ts +10 -18
- package/dist/editable-artifact-workspace-files.d.ts +1 -1
- package/dist/fatal-process-boundary.d.ts +25 -0
- package/dist/github-access.d.ts +31 -2
- package/dist/http/acting-person.d.ts +24 -0
- package/dist/http/api-contract-compat.d.ts +19 -0
- package/dist/http/api-error.d.ts +27 -1
- package/dist/http/cors.d.ts +17 -0
- package/dist/http/deprecation.d.ts +42 -0
- package/dist/http/interaction-control-error.d.ts +13 -0
- package/dist/http/keyed-admission.d.ts +12 -0
- package/dist/http/local-browser-boundary.d.ts +72 -0
- package/dist/http/metrics-listener.d.ts +22 -0
- package/dist/http/path-identifier.d.ts +17 -0
- package/dist/http/registered-route-label.d.ts +16 -0
- package/dist/http/request-body.d.ts +27 -0
- package/dist/http/request-source.d.ts +52 -0
- package/dist/http/sse.d.ts +17 -6
- package/dist/http/unmatched-route.d.ts +18 -0
- package/dist/http/user-content.d.ts +36 -0
- package/dist/http/websocket-upgrade-dispatch.d.ts +18 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +1129 -166
- package/dist/index.js.map +1 -1
- package/dist/integration-endpoint-test.d.ts +20 -0
- package/dist/integrations/api-integrations.d.ts +2 -2
- package/dist/integrations/atlassian.d.ts +29 -3
- package/dist/integrations/connect-authority.d.ts +1 -0
- package/dist/integrations/connect-callback-return.d.ts +6 -0
- package/dist/integrations/fiken.d.ts +16 -2
- package/dist/integrations/github-app-connect.d.ts +47 -0
- package/dist/integrations/github-installation-proof.d.ts +3 -0
- package/dist/integrations/github-lens-connect.d.ts +116 -0
- package/dist/integrations/github-skill-source.d.ts +1 -5
- package/dist/integrations/google-drive.d.ts +25 -0
- package/dist/integrations/integration-commit-authority.d.ts +13 -0
- package/dist/integrations/marketplace-plugin.d.ts +2691 -0
- package/dist/integrations/oauth-client.d.ts +178 -18
- package/dist/integrations/oauth-profiles.d.ts +222 -0
- package/dist/integrations/oauth-return-path.d.ts +1 -0
- package/dist/integrations/personal-github-repositories.d.ts +84 -0
- package/dist/integrations/personal-github.d.ts +42 -0
- package/dist/integrations/pr-review-provider.d.ts +22 -0
- package/dist/integrations/provider-oauth.d.ts +19 -1
- package/dist/integrations/slack-app-home.d.ts +24 -0
- package/dist/integrations/slack-bot.d.ts +367 -12
- package/dist/integrations/slack-file-upload-flow.d.ts +62 -0
- package/dist/integrations/slack-install.d.ts +20 -0
- package/dist/integrations/slack-interactions.d.ts +113 -10
- package/dist/integrations/slack-mrkdwn.d.ts +41 -0
- package/dist/integrations/slack-routing.d.ts +120 -0
- package/dist/integrations/slack-session-defaults.d.ts +58 -0
- package/dist/integrations/slack-task-file-upload.d.ts +36 -0
- package/dist/integrations/social-oauth.d.ts +7 -0
- package/dist/interaction-agent-access.d.ts +15 -0
- package/dist/interaction-frame-proxy.d.ts +68 -0
- package/dist/interaction-metrics.d.ts +2 -0
- package/dist/mcp/action-catalog-types.d.ts +9 -0
- package/dist/mcp/action-catalog.gen.d.ts +2 -0
- package/dist/mcp/capability-account-readiness.d.ts +7 -0
- package/dist/mcp/child-read-evidence.d.ts +9 -0
- package/dist/mcp/command-read.d.ts +24 -0
- package/dist/mcp/company-profile-agent-admin.d.ts +44 -0
- package/dist/mcp/contract-input.d.ts +11 -0
- package/dist/mcp/documents.d.ts +7 -5
- package/dist/mcp/files.d.ts +2 -2
- package/dist/mcp/first-party-tool-permissions.d.ts +650 -0
- package/dist/mcp/knowledge-entries.d.ts +5 -0
- package/dist/mcp/orchestration-failure-diagnostic.d.ts +43 -0
- package/dist/mcp/receipts.d.ts +9 -0
- package/dist/mcp/request-abort.d.ts +19 -0
- package/dist/mcp/scheduled-task-input.d.ts +1189 -0
- package/dist/mcp/scheduled-task-view.d.ts +22 -4
- package/dist/mcp/server.d.ts +255 -3
- package/dist/mcp/session-event-view.d.ts +94 -0
- package/dist/mcp/session-view.d.ts +66 -2
- package/dist/mcp/session-wait.d.ts +174 -0
- package/dist/mcp-oauth.d.ts +52 -0
- package/dist/model-catalog.d.ts +11 -31
- package/dist/observability.d.ts +3 -1
- package/dist/organization-mcp.d.ts +52 -0
- package/dist/organization-recovery-notifications.d.ts +41 -0
- package/dist/routes/analytics-consent.d.ts +26 -0
- package/dist/routes/api-integrations.d.ts +25 -0
- package/dist/routes/api-keys.d.ts +17 -0
- package/dist/routes/artifact-catalog.d.ts +6 -0
- package/dist/routes/automations.d.ts +19 -0
- package/dist/routes/billing.d.ts +49 -0
- package/dist/routes/browser-sessions.d.ts +71 -3
- package/dist/routes/claude-subscription-accounts.d.ts +3 -0
- package/dist/routes/claude-subscription-oauth.d.ts +3 -0
- package/dist/routes/client-errors.d.ts +146 -0
- package/dist/routes/codex.d.ts +76 -2
- package/dist/routes/company-brain.d.ts +3 -0
- package/dist/routes/company-profile.d.ts +2 -1
- package/dist/routes/computer-sessions.d.ts +14 -0
- package/dist/routes/connect.d.ts +5 -0
- package/dist/routes/editable-artifacts.d.ts +2 -0
- package/dist/routes/external-identity-links.d.ts +6 -0
- package/dist/routes/feedback.d.ts +3 -0
- package/dist/routes/files.d.ts +4 -0
- package/dist/routes/github-browser-pages.d.ts +12 -0
- package/dist/routes/github.d.ts +2 -0
- package/dist/routes/insights-response-cache.d.ts +10 -0
- package/dist/routes/insights-usage.d.ts +12 -0
- package/dist/routes/insights.d.ts +30 -1
- package/dist/routes/knowledge.d.ts +3 -0
- package/dist/routes/managed-auth-session-sets.d.ts +26 -0
- package/dist/routes/managed-onboarding.d.ts +29 -0
- package/dist/routes/managed-sign-in-methods.d.ts +6 -0
- package/dist/routes/model-connection-access.d.ts +3 -0
- package/dist/routes/organization-integration-policy.d.ts +3 -0
- package/dist/routes/organization-integrations.d.ts +6 -0
- package/dist/routes/organization-mcp-connections.d.ts +3 -0
- package/dist/routes/organization-model-providers.d.ts +3 -0
- package/dist/routes/organization-recovery.d.ts +19 -0
- package/dist/routes/organization-service-accounts.d.ts +3 -0
- package/dist/routes/organization-sessions.d.ts +26 -0
- package/dist/routes/personal-github-git-broker.d.ts +29 -0
- package/dist/routes/personal-github.d.ts +3 -0
- package/dist/routes/pr-review-github.d.ts +3 -0
- package/dist/routes/pr-review.d.ts +3 -0
- package/dist/routes/session-artifact-associations.d.ts +4 -0
- package/dist/routes/session-history-imports.d.ts +9 -0
- package/dist/routes/sessions.d.ts +44 -6
- package/dist/routes/skill-content.d.ts +4 -0
- package/dist/routes/skill-install-authority.d.ts +6 -0
- package/dist/routes/subscription-account-pools.d.ts +34 -0
- package/dist/routes/subscription-pool-access.d.ts +16 -0
- package/dist/routes/supergrok.d.ts +6 -1
- package/dist/routes/usage-allowances.d.ts +12 -0
- package/dist/routes/user-resource-authorities.d.ts +3 -0
- package/dist/routes/workspace-artifacts.d.ts +2 -1
- package/dist/routes/workspace-capture.d.ts +10 -2
- package/dist/routes/workspace-integrations.d.ts +35 -0
- package/dist/routes/workspace-learning.d.ts +3 -0
- package/dist/routes/workspace-model-providers.d.ts +4 -0
- package/dist/routes/workspaces.d.ts +29 -0
- package/dist/sandbox/auth-callout.d.ts +8 -0
- package/dist/sandbox/channel-a.d.ts +19 -1
- package/dist/sandbox/connection-authority.d.ts +3 -0
- package/dist/sandbox/enrollment.d.ts +9 -1
- package/dist/sandbox/machines.d.ts +5 -2
- package/dist/sandbox/metrics-ingestion.d.ts +28 -20
- package/dist/sandbox/rematerialize.d.ts +2 -0
- package/dist/sandbox/session-attach-variable-sets.d.ts +30 -0
- package/dist/sandbox/viewer.d.ts +26 -1
- package/dist/sandbox-file-artifacts.d.ts +50 -0
- package/dist/scheduled-task-deletion.d.ts +13 -0
- package/dist/session-create-observability.d.ts +5 -0
- package/dist/session-event-view-MPS2OZD3.js +292 -0
- package/dist/session-event-view-MPS2OZD3.js.map +1 -0
- package/dist/site-session-origin.d.ts +13 -0
- package/dist/site-uploads.d.ts +41 -0
- package/dist/slack-reaction-files.d.ts +1 -1
- package/dist/temporal-schedule-cleanup.d.ts +1 -0
- package/dist/temporal-schedule-sync.d.ts +26 -0
- package/dist/transcription/providers/xai-subscription.d.ts +1 -0
- package/dist/transcription/service.d.ts +2 -1
- package/dist/work-discovery-observability.d.ts +33 -0
- package/dist/workspace-artifact-content.d.ts +28 -0
- package/dist/workspace-artifact-provenance.d.ts +7 -0
- package/dist/workspace-delete-observability.d.ts +10 -0
- package/dist/workspace-deletion.d.ts +6 -0
- package/dist/workspace-state-projection.d.ts +3 -5
- package/dist/workspace-tool-gateway-observability.d.ts +17 -0
- package/dist/workspace-tool-gateway.d.ts +123 -0
- package/dist/workspace-webhook-dispatch.d.ts +26 -0
- package/package.json +23 -19
- package/src/access-grant-rls.ts +75 -0
- package/src/admission-trace.ts +14 -0
- package/src/api-websocket.ts +23 -0
- package/src/app.ts +1974 -256
- package/src/artifact-catalog-cursor.ts +60 -0
- package/src/auth/managed-auth-attempt-context.ts +70 -0
- package/src/auth/managed-auth-rate-limits.ts +252 -0
- package/src/auth/managed-auth-session-adapter.ts +222 -0
- package/src/auth/managed-auth.ts +536 -60
- package/src/auth/managed-email.ts +174 -0
- package/src/auth/managed-sign-in-notifications.ts +81 -0
- package/src/auth/new-signups-gate.ts +49 -0
- package/src/auth/organization-user-setup.ts +307 -0
- package/src/auth/signup-funnel-metrics.ts +164 -0
- package/src/browser-controller-authority.ts +1 -186
- package/src/browser-ephemeral.ts +39 -0
- package/src/browser-state-authority.ts +1 -236
- package/src/claude-subscription-account-conflicts.ts +12 -0
- package/src/claude-subscription-account-usage.ts +48 -0
- package/src/claude-subscription-oauth.ts +362 -0
- package/src/claude-subscription-profile.ts +73 -0
- package/src/claude-subscription-usage.ts +97 -0
- package/src/claude-workspace-connection.ts +82 -0
- package/src/codemode.ts +194 -30
- package/src/codex-realtime.ts +8 -2
- package/src/company-brain-okf.ts +340 -0
- package/src/connected-machine-computer-access.ts +33 -0
- package/src/connection-ownership.ts +199 -0
- package/src/controller-data-plane.ts +81 -0
- package/src/editable-artifact-native-kernel.ts +26 -15
- package/src/editable-artifact-office-import.ts +77 -9
- package/src/editable-artifact-production.ts +23 -7
- package/src/editable-artifact-source-session.ts +123 -0
- package/src/editable-artifact-websocket.ts +27 -21
- package/src/editable-artifact-workspace-files.ts +31 -6
- package/src/fatal-process-boundary.ts +246 -0
- package/src/gateway-realtime.ts +1 -1
- package/src/github-access.ts +147 -5
- package/src/http/acting-person.ts +71 -0
- package/src/http/api-contract-compat.ts +49 -0
- package/src/http/api-error.ts +115 -1
- package/src/http/auth.ts +48 -0
- package/src/http/cors.ts +67 -0
- package/src/http/deprecation.ts +118 -0
- package/src/http/interaction-control-error.ts +164 -0
- package/src/http/keyed-admission.ts +29 -0
- package/src/http/local-browser-boundary.ts +343 -0
- package/src/http/metrics-listener.ts +57 -0
- package/src/http/path-identifier.ts +54 -0
- package/src/http/registered-route-label.ts +34 -0
- package/src/http/request-body.ts +127 -0
- package/src/http/request-source.ts +178 -0
- package/src/http/sse.ts +486 -132
- package/src/http/unmatched-route.ts +60 -0
- package/src/http/user-content.ts +158 -0
- package/src/http/websocket-upgrade-dispatch.ts +29 -0
- package/src/index.ts +157 -52
- package/src/integration-endpoint-test.ts +291 -0
- package/src/integrations/api-integrations.ts +98 -11
- package/src/integrations/atlassian.ts +474 -136
- package/src/integrations/connect-authority.ts +2 -0
- package/src/integrations/connect-callback-return.ts +86 -0
- package/src/integrations/fiken.ts +354 -64
- package/src/integrations/github-app-connect.ts +435 -0
- package/src/integrations/github-installation-proof.ts +60 -0
- package/src/integrations/github-lens-connect.ts +76 -0
- package/src/integrations/github-skill-source.ts +2 -142
- package/src/integrations/google-drive.ts +820 -222
- package/src/integrations/integration-commit-authority.ts +69 -0
- package/src/integrations/marketplace-plugin.ts +48 -0
- package/src/integrations/oauth-client.ts +1356 -459
- package/src/integrations/oauth-profiles.ts +537 -0
- package/src/integrations/oauth-return-path.ts +18 -0
- package/src/integrations/personal-github-repositories.ts +674 -0
- package/src/integrations/personal-github.ts +825 -0
- package/src/integrations/pr-review-provider.ts +246 -0
- package/src/integrations/provider-oauth.ts +250 -22
- package/src/integrations/slack-app-home.ts +300 -0
- package/src/integrations/slack-bot.ts +963 -239
- package/src/integrations/slack-file-upload-flow.ts +147 -0
- package/src/integrations/slack-install.ts +83 -0
- package/src/integrations/slack-interactions.ts +3170 -474
- package/src/integrations/slack-mrkdwn.ts +193 -0
- package/src/integrations/slack-routing.ts +337 -0
- package/src/integrations/slack-session-defaults.ts +224 -0
- package/src/integrations/slack-task-file-upload.ts +323 -0
- package/src/integrations/social-oauth.ts +213 -15
- package/src/interaction-agent-access.ts +48 -0
- package/src/interaction-frame-proxy.ts +409 -0
- package/src/interaction-metrics.ts +30 -0
- package/src/mcp/action-catalog-types.ts +9 -0
- package/src/mcp/action-catalog.gen.ts +6696 -0
- package/src/mcp/capability-account-readiness.ts +17 -0
- package/src/mcp/child-read-evidence.ts +19 -0
- package/src/mcp/command-read.ts +109 -0
- package/src/mcp/company-profile-agent-admin.ts +198 -0
- package/src/mcp/contract-input.ts +141 -0
- package/src/mcp/documents.ts +65 -377
- package/src/mcp/editable-artifacts.ts +12 -6
- package/src/mcp/files.ts +80 -38
- package/src/mcp/first-party-tool-permissions.ts +305 -0
- package/src/mcp/knowledge-entries.ts +322 -0
- package/src/mcp/orchestration-failure-diagnostic.ts +43 -0
- package/src/mcp/receipts.ts +34 -0
- package/src/mcp/request-abort.ts +44 -0
- package/src/mcp/scheduled-task-input.ts +76 -0
- package/src/mcp/scheduled-task-view.ts +44 -3
- package/src/mcp/server.ts +3030 -1267
- package/src/mcp/session-event-view.ts +383 -0
- package/src/mcp/session-view.ts +84 -3
- package/src/mcp/session-wait.ts +665 -0
- package/src/mcp-oauth.ts +1123 -0
- package/src/model-catalog.ts +91 -333
- package/src/observability.ts +15 -1
- package/src/organization-mcp.ts +397 -0
- package/src/organization-recovery-notifications.ts +103 -0
- package/src/routes/analytics-consent.ts +123 -0
- package/src/routes/api-integrations.ts +364 -74
- package/src/routes/api-keys.ts +336 -10
- package/src/routes/artifact-catalog.ts +279 -0
- package/src/routes/automations.ts +768 -0
- package/src/routes/billing.ts +461 -46
- package/src/routes/browser-sessions.ts +839 -131
- package/src/routes/canonical-human-identities.ts +90 -14
- package/src/routes/capabilities.ts +107 -6
- package/src/routes/channels.ts +20 -3
- package/src/routes/claude-subscription-accounts.ts +334 -0
- package/src/routes/claude-subscription-oauth.ts +142 -0
- package/src/routes/client-errors.ts +362 -0
- package/src/routes/codex.ts +833 -116
- package/src/routes/company-brain.ts +322 -0
- package/src/routes/company-profile.ts +65 -1
- package/src/routes/computer-sessions.ts +557 -106
- package/src/routes/connect.ts +1938 -0
- package/src/routes/connections.ts +1040 -349
- package/src/routes/documents.ts +488 -287
- package/src/routes/editable-artifacts.ts +79 -9
- package/src/routes/enrollments.ts +135 -39
- package/src/routes/environments.ts +154 -58
- package/src/routes/external-identity-links.ts +201 -0
- package/src/routes/feedback.ts +113 -0
- package/src/routes/files.ts +337 -39
- package/src/routes/github-browser-pages.ts +162 -0
- package/src/routes/github.ts +446 -144
- package/src/routes/insights-response-cache.ts +83 -0
- package/src/routes/insights-usage.ts +345 -0
- package/src/routes/insights.ts +153 -19
- package/src/routes/install.ts +133 -38
- package/src/routes/integration-facets.ts +107 -33
- package/src/routes/interaction-resources.ts +30 -3
- package/src/routes/knowledge.ts +488 -0
- package/src/routes/machines.ts +313 -15
- package/src/routes/managed-auth-session-sets.ts +1218 -0
- package/src/routes/managed-onboarding.ts +337 -0
- package/src/routes/managed-sign-in-methods.ts +433 -0
- package/src/routes/memory-slack-publications.ts +3 -2
- package/src/routes/model-connection-access.ts +208 -0
- package/src/routes/organization-integration-policy.ts +116 -0
- package/src/routes/organization-integrations.ts +326 -0
- package/src/routes/organization-mcp-connections.ts +178 -0
- package/src/routes/organization-memberships.ts +1019 -27
- package/src/routes/organization-model-providers.ts +293 -0
- package/src/routes/organization-recovery.ts +325 -0
- package/src/routes/organization-service-accounts.ts +128 -0
- package/src/routes/organization-sessions.ts +350 -0
- package/src/routes/personal-github-git-broker.ts +785 -0
- package/src/routes/personal-github.ts +370 -0
- package/src/routes/plugins.ts +251 -22
- package/src/routes/pr-review-github.ts +881 -0
- package/src/routes/pr-review.ts +622 -0
- package/src/routes/preference-registry.ts +12 -93
- package/src/routes/rigs.ts +167 -50
- package/src/routes/scheduled-tasks.ts +346 -41
- package/src/routes/session-artifact-associations.ts +87 -0
- package/src/routes/session-history-imports.ts +280 -0
- package/src/routes/sessions.ts +2306 -264
- package/src/routes/skill-content.ts +297 -0
- package/src/routes/skill-install-authority.ts +64 -0
- package/src/routes/skills.ts +62 -9
- package/src/routes/social.ts +46 -18
- package/src/routes/subscription-account-pools.ts +436 -0
- package/src/routes/subscription-pool-access.ts +126 -0
- package/src/routes/supergrok.ts +219 -303
- package/src/routes/transcription-recordings.ts +38 -3
- package/src/routes/transcriptions.ts +4 -0
- package/src/routes/usage-allowances.ts +378 -0
- package/src/routes/user-resource-authorities.ts +138 -0
- package/src/routes/video-generation.ts +14 -10
- package/src/routes/workspace-artifacts.ts +275 -69
- package/src/routes/workspace-capture.ts +21 -0
- package/src/routes/workspace-integrations.ts +576 -0
- package/src/routes/workspace-learning.ts +159 -0
- package/src/routes/workspace-model-providers.ts +148 -0
- package/src/routes/workspace-state.ts +38 -25
- package/src/routes/workspaces.ts +1004 -127
- package/src/sandbox/auth-callout.ts +96 -19
- package/src/sandbox/channel-a.ts +323 -24
- package/src/sandbox/connection-authority.ts +3 -0
- package/src/sandbox/enrollment.ts +81 -6
- package/src/sandbox/machines.ts +218 -76
- package/src/sandbox/metrics-ingestion.ts +411 -62
- package/src/sandbox/rematerialize.ts +121 -19
- package/src/sandbox/session-attach-variable-sets.ts +131 -0
- package/src/sandbox/viewer.ts +280 -25
- package/src/sandbox-file-artifacts.ts +413 -0
- package/src/scheduled-task-deletion.ts +138 -0
- package/src/session-create-observability.ts +46 -0
- package/src/session-realtime-context.ts +6 -3
- package/src/site-session-origin.ts +48 -0
- package/src/site-uploads.ts +224 -0
- package/src/slack-reaction-files.ts +16 -5
- package/src/temporal-schedule-cleanup.ts +13 -0
- package/src/temporal-schedule-sync.ts +74 -0
- package/src/transcription/providers/codex-subscription.ts +2 -0
- package/src/transcription/providers/openai.ts +1 -0
- package/src/transcription/providers/xai-subscription.ts +49 -3
- package/src/transcription/segmenter.ts +8 -2
- package/src/transcription/service.ts +43 -6
- package/src/work-discovery-observability.ts +121 -0
- package/src/workspace-artifact-content.ts +144 -0
- package/src/workspace-artifact-provenance.ts +104 -0
- package/src/workspace-delete-observability.ts +75 -0
- package/src/workspace-deletion.ts +73 -0
- package/src/workspace-state-projection.ts +18 -148
- package/src/workspace-tool-gateway-observability.ts +100 -0
- package/src/workspace-tool-gateway.ts +870 -0
- package/src/workspace-webhook-dispatch.ts +190 -0
- package/src/xai-subscription-auth.ts +9 -2
- package/dist/chunk-2PQMSRCB.js +0 -49759
- package/dist/chunk-2PQMSRCB.js.map +0 -1
- package/dist/routes/packs.d.ts +0 -3
- package/src/routes/packs.ts +0 -729
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { HTTPException } from "hono/http-exception";
|
|
4
|
+
import type { ConnectAdvance, ConnectAttempt } from "@opengeni/contracts/connect";
|
|
5
|
+
import {
|
|
6
|
+
bindAuthorizedGitHubInstallationRepositories,
|
|
7
|
+
finishConnectOperation,
|
|
8
|
+
getConnectAttempt,
|
|
9
|
+
type ConnectActorScope,
|
|
10
|
+
type ConnectOperationAuthorization,
|
|
11
|
+
} from "@opengeni/db";
|
|
12
|
+
import {
|
|
13
|
+
authorizeGitHubInstallationBinding,
|
|
14
|
+
createSignedState,
|
|
15
|
+
discoverGitHubInstallationBindingCandidates,
|
|
16
|
+
githubAppMissingSettings,
|
|
17
|
+
githubOAuthAuthorizeUrl,
|
|
18
|
+
readSignedState,
|
|
19
|
+
prReviewGitHubAppMissingSettings,
|
|
20
|
+
settingsForPrReviewGitHubApp,
|
|
21
|
+
} from "@opengeni/github";
|
|
22
|
+
import { commitGitHubLensConnect, requireGitHubLensConnect } from "./github-lens-connect";
|
|
23
|
+
import type { ApiRouteDeps, PreparedConnectOperation } from "@opengeni/core";
|
|
24
|
+
import { requireConnectOwnerAuthority } from "./connect-authority";
|
|
25
|
+
import { claimOAuthAcquisition, finishOAuthAcquisition, integrationBaseUrl } from "./oauth-client";
|
|
26
|
+
import {
|
|
27
|
+
isConsistentGitHubBindingCandidates,
|
|
28
|
+
isConsistentGitHubBindingProof,
|
|
29
|
+
} from "./github-installation-proof";
|
|
30
|
+
import { githubConnectFailureHtml } from "../routes/github-browser-pages";
|
|
31
|
+
|
|
32
|
+
const stateSchema = z.object({
|
|
33
|
+
kind: z.literal("github_app_connect"),
|
|
34
|
+
accountId: z.string().uuid(),
|
|
35
|
+
workspaceId: z.string().uuid(),
|
|
36
|
+
subjectId: z.string().min(1),
|
|
37
|
+
personalOwnerVerified: z.boolean(),
|
|
38
|
+
connectAttemptId: z.string().uuid(),
|
|
39
|
+
phase: z.enum(["discover", "install", "bind"]),
|
|
40
|
+
installationId: z.number().int().positive().safe().optional(),
|
|
41
|
+
providerId: z.enum(["github-app", "github-lens"]).default("github-app"),
|
|
42
|
+
nonce: z.string().min(1),
|
|
43
|
+
iat: z.number().int(),
|
|
44
|
+
});
|
|
45
|
+
type State = z.infer<typeof stateSchema>;
|
|
46
|
+
const lifetimeMs = 10 * 60_000;
|
|
47
|
+
|
|
48
|
+
export function isGitHubAppConnectState(deps: ApiRouteDeps, raw: string | undefined): boolean {
|
|
49
|
+
return !!raw && readSignedState(raw, deps.githubStateSecret)?.kind === "github_app_connect";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type GitHubConnectScope = ConnectActorScope & {
|
|
53
|
+
personalOwnerVerified?: boolean;
|
|
54
|
+
providerId?: "github-app" | "github-lens";
|
|
55
|
+
};
|
|
56
|
+
function callbackAuthority(scope: GitHubConnectScope): ConnectOperationAuthorization {
|
|
57
|
+
return async (tx, _attempt, origin) => {
|
|
58
|
+
const actor = { ...scope, ...(origin ? { externalContinuation: origin } : {}) };
|
|
59
|
+
await requireConnectOwnerAuthority(
|
|
60
|
+
tx,
|
|
61
|
+
actor,
|
|
62
|
+
scope.providerId === "github-lens" ? "workspace:admin" : "github:manage",
|
|
63
|
+
origin,
|
|
64
|
+
);
|
|
65
|
+
if (scope.providerId === "github-lens")
|
|
66
|
+
await requireConnectOwnerAuthority(tx, actor, "secrets:write", origin);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function githubAppConnectNavigation(
|
|
71
|
+
deps: ApiRouteDeps,
|
|
72
|
+
scope: GitHubConnectScope,
|
|
73
|
+
attemptId: string,
|
|
74
|
+
requestUrl: string,
|
|
75
|
+
phase: State["phase"] = "discover",
|
|
76
|
+
installationId?: number,
|
|
77
|
+
providerId: State["providerId"] = "github-app",
|
|
78
|
+
) {
|
|
79
|
+
const settings =
|
|
80
|
+
providerId === "github-lens" ? settingsForPrReviewGitHubApp(deps.settings) : deps.settings;
|
|
81
|
+
const missing =
|
|
82
|
+
providerId === "github-lens"
|
|
83
|
+
? prReviewGitHubAppMissingSettings(deps.settings)
|
|
84
|
+
: githubAppMissingSettings(settings);
|
|
85
|
+
if (missing.length || !settings.githubAppSlug?.trim())
|
|
86
|
+
throw new HTTPException(503, { message: "GitHub App is not configured" });
|
|
87
|
+
const state = createSignedState(deps.githubStateSecret, {
|
|
88
|
+
kind: "github_app_connect",
|
|
89
|
+
accountId: scope.accountId,
|
|
90
|
+
workspaceId: scope.workspaceId,
|
|
91
|
+
subjectId: scope.subjectId,
|
|
92
|
+
personalOwnerVerified: scope.personalOwnerVerified === true,
|
|
93
|
+
connectAttemptId: attemptId,
|
|
94
|
+
phase,
|
|
95
|
+
providerId,
|
|
96
|
+
...(installationId ? { installationId } : {}),
|
|
97
|
+
});
|
|
98
|
+
const url =
|
|
99
|
+
phase === "install"
|
|
100
|
+
? `https://github.com/apps/${encodeURIComponent(settings.githubAppSlug.trim())}/installations/new?state=${encodeURIComponent(state)}`
|
|
101
|
+
: githubOAuthAuthorizeUrl({
|
|
102
|
+
clientId: settings.githubClientId!.trim(),
|
|
103
|
+
state,
|
|
104
|
+
redirectUri: `${integrationBaseUrl(deps.settings.publicBaseUrl, requestUrl)}${providerId === "github-lens" ? "/v1/pr-review/github" : "/v1/github"}/oauth/callback`,
|
|
105
|
+
});
|
|
106
|
+
return { authorizationUrl: url, expiresAt: new Date(Date.now() + lifetimeMs).toISOString() };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function prepareGitHubAppConnectAction(
|
|
110
|
+
deps: ApiRouteDeps,
|
|
111
|
+
scope: GitHubConnectScope,
|
|
112
|
+
requestUrl: string,
|
|
113
|
+
attempt: ConnectAttempt,
|
|
114
|
+
action: ConnectAdvance,
|
|
115
|
+
): PreparedConnectOperation {
|
|
116
|
+
let phase: State["phase"] = "discover";
|
|
117
|
+
let installationId: number | undefined;
|
|
118
|
+
if (action.type === "account") {
|
|
119
|
+
if (
|
|
120
|
+
attempt.nextAction.type !== "select_account" ||
|
|
121
|
+
!attempt.nextAction.accounts.some((account) => account.id === action.accountId)
|
|
122
|
+
)
|
|
123
|
+
throw new HTTPException(409, {
|
|
124
|
+
message: "Choose an installation from the current discovery",
|
|
125
|
+
});
|
|
126
|
+
if (action.accountId === "new") phase = "install";
|
|
127
|
+
else {
|
|
128
|
+
phase = "bind";
|
|
129
|
+
installationId = z.coerce.number().int().positive().safe().parse(action.accountId);
|
|
130
|
+
}
|
|
131
|
+
} else if (action.type !== "retry" || attempt.state !== "connected_but_incomplete") {
|
|
132
|
+
throw new HTTPException(422, {
|
|
133
|
+
message: "Choose an installation or retry after owner approval",
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const navigation = githubAppConnectNavigation(
|
|
137
|
+
deps,
|
|
138
|
+
scope,
|
|
139
|
+
attempt.id,
|
|
140
|
+
requestUrl,
|
|
141
|
+
phase,
|
|
142
|
+
installationId,
|
|
143
|
+
attempt.providerId === "github-lens" ? "github-lens" : "github-app",
|
|
144
|
+
);
|
|
145
|
+
return {
|
|
146
|
+
commit: async (_tx, current) => ({
|
|
147
|
+
...current,
|
|
148
|
+
error: undefined,
|
|
149
|
+
revision: current.revision + 1,
|
|
150
|
+
state: "requires_user_action",
|
|
151
|
+
nextAction: { type: "authorize", url: navigation.authorizationUrl },
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** No browser login/cookie required: signed attempt + current stored origin,
|
|
157
|
+
* then fresh GitHub owner proof, are the two separate authority boundaries. */
|
|
158
|
+
export async function completeGitHubAppConnect(
|
|
159
|
+
deps: ApiRouteDeps,
|
|
160
|
+
input: {
|
|
161
|
+
state?: string | undefined;
|
|
162
|
+
code?: string | undefined;
|
|
163
|
+
installationId?: string | undefined;
|
|
164
|
+
setupAction?: string | undefined;
|
|
165
|
+
error?: string | undefined;
|
|
166
|
+
requestUrl: string;
|
|
167
|
+
expectedProvider?: "github-app" | "github-lens";
|
|
168
|
+
},
|
|
169
|
+
): Promise<Response> {
|
|
170
|
+
let destination: string | undefined;
|
|
171
|
+
try {
|
|
172
|
+
const state = stateSchema.parse(readSignedState(input.state ?? "", deps.githubStateSecret));
|
|
173
|
+
if (state.providerId !== (input.expectedProvider ?? "github-app"))
|
|
174
|
+
throw new Error("GitHub callback provider mismatch");
|
|
175
|
+
const age = Date.now() - state.iat * 1000;
|
|
176
|
+
if (age < 0 || age >= lifetimeMs) throw new Error("Expired GitHub connection state");
|
|
177
|
+
const stored = await getConnectAttempt(deps.db, state, state.connectAttemptId);
|
|
178
|
+
if (stored.attempt.providerId !== state.providerId || stored.attempt.ownership !== "workspace")
|
|
179
|
+
throw new Error("GitHub attempt mismatch");
|
|
180
|
+
// Reject obsolete browser stages before committing an operation claim.
|
|
181
|
+
// Otherwise a valid older callback could strand the current stage in-flight.
|
|
182
|
+
// Completed callbacks still navigate home without repeating provider work.
|
|
183
|
+
const authorize: ConnectOperationAuthorization = async (tx, attempt, origin) => {
|
|
184
|
+
await callbackAuthority(state)(tx, attempt, origin);
|
|
185
|
+
destination = stored.returnUrl;
|
|
186
|
+
};
|
|
187
|
+
const acquiring =
|
|
188
|
+
!input.error && (state.phase === "install" ? input.setupAction !== "request" : !!input.code);
|
|
189
|
+
const operation = {
|
|
190
|
+
attemptId: state.connectAttemptId,
|
|
191
|
+
operationId: `github:${state.nonce}`,
|
|
192
|
+
inputDigest: createHash("sha256").update(input.state!).digest("hex"),
|
|
193
|
+
authorize,
|
|
194
|
+
};
|
|
195
|
+
const claim = await claimOAuthAcquisition(
|
|
196
|
+
deps.db,
|
|
197
|
+
state,
|
|
198
|
+
{
|
|
199
|
+
...operation,
|
|
200
|
+
expectedRevision: stored.attempt.revision,
|
|
201
|
+
authorizeAcquisition: async (tx, current) => {
|
|
202
|
+
if (
|
|
203
|
+
current.nextAction.type !== "authorize" ||
|
|
204
|
+
new URL(current.nextAction.url).searchParams.get("state") !== input.state
|
|
205
|
+
)
|
|
206
|
+
throw new Error("Stale GitHub setup stage");
|
|
207
|
+
if (acquiring && state.providerId === "github-lens")
|
|
208
|
+
await requireGitHubLensConnect({ ...deps, db: tx });
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
state.providerId,
|
|
212
|
+
acquiring,
|
|
213
|
+
);
|
|
214
|
+
// Recover a repeated install callback only while its next stage is still
|
|
215
|
+
// current. A completed/superseded attempt returns home without reopening OAuth.
|
|
216
|
+
if (
|
|
217
|
+
claim.status === "replayed" &&
|
|
218
|
+
state.phase === "install" &&
|
|
219
|
+
claim.attempt.revision === stored.attempt.revision &&
|
|
220
|
+
claim.attempt.nextAction.type === "authorize"
|
|
221
|
+
)
|
|
222
|
+
return new Response(null, {
|
|
223
|
+
status: 302,
|
|
224
|
+
headers: { Location: claim.attempt.nextAction.url },
|
|
225
|
+
});
|
|
226
|
+
if (claim.status !== "replayed") {
|
|
227
|
+
const provider =
|
|
228
|
+
state.providerId === "github-lens" ? deps.prReviewGithubAppApi : deps.githubAppApi;
|
|
229
|
+
const settings =
|
|
230
|
+
state.providerId === "github-lens"
|
|
231
|
+
? settingsForPrReviewGitHubApp(deps.settings)
|
|
232
|
+
: deps.settings;
|
|
233
|
+
let prepared: PreparedConnectOperation;
|
|
234
|
+
if (input.error || (state.phase !== "install" && !input.code)) {
|
|
235
|
+
prepared = {
|
|
236
|
+
commit: async (_tx, current) => ({
|
|
237
|
+
...current,
|
|
238
|
+
revision: current.revision + 1,
|
|
239
|
+
state: input.error === "access_denied" ? "cancelled" : "failed",
|
|
240
|
+
nextAction: { type: "none" },
|
|
241
|
+
error: {
|
|
242
|
+
code: "authorization_not_completed",
|
|
243
|
+
message: "Authorization was not completed. Start a new attempt.",
|
|
244
|
+
retryable: false,
|
|
245
|
+
},
|
|
246
|
+
}),
|
|
247
|
+
};
|
|
248
|
+
} else if (state.phase === "install") {
|
|
249
|
+
if (input.setupAction === "request")
|
|
250
|
+
prepared = {
|
|
251
|
+
commit: async (_tx, current) => ({
|
|
252
|
+
...current,
|
|
253
|
+
revision: current.revision + 1,
|
|
254
|
+
state: "connected_but_incomplete",
|
|
255
|
+
nextAction: { type: "none" },
|
|
256
|
+
error: {
|
|
257
|
+
code: "owner_approval_pending",
|
|
258
|
+
message:
|
|
259
|
+
"A GitHub organization owner must approve installation. Retry discovery after approval.",
|
|
260
|
+
retryable: true,
|
|
261
|
+
},
|
|
262
|
+
}),
|
|
263
|
+
};
|
|
264
|
+
else {
|
|
265
|
+
const installationId = z.coerce
|
|
266
|
+
.number()
|
|
267
|
+
.int()
|
|
268
|
+
.positive()
|
|
269
|
+
.safe()
|
|
270
|
+
.parse(input.installationId);
|
|
271
|
+
const navigation = githubAppConnectNavigation(
|
|
272
|
+
deps,
|
|
273
|
+
state,
|
|
274
|
+
state.connectAttemptId,
|
|
275
|
+
input.requestUrl,
|
|
276
|
+
"bind",
|
|
277
|
+
installationId,
|
|
278
|
+
state.providerId,
|
|
279
|
+
);
|
|
280
|
+
prepared = {
|
|
281
|
+
commit: async (_tx, current) => ({
|
|
282
|
+
...current,
|
|
283
|
+
revision: current.revision + 1,
|
|
284
|
+
state: "requires_user_action",
|
|
285
|
+
nextAction: { type: "authorize", url: navigation.authorizationUrl },
|
|
286
|
+
}),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
} else if (state.phase === "discover") {
|
|
290
|
+
const candidates = provider
|
|
291
|
+
? await provider.discoverInstallationBindingCandidates?.({ code: input.code! })
|
|
292
|
+
: await discoverGitHubInstallationBindingCandidates(settings, { code: input.code! });
|
|
293
|
+
if (!candidates || !isConsistentGitHubBindingCandidates(candidates))
|
|
294
|
+
throw new Error("Provider cannot prove installation candidates");
|
|
295
|
+
prepared =
|
|
296
|
+
candidates.length > 99
|
|
297
|
+
? {
|
|
298
|
+
commit: async (_tx, current) => ({
|
|
299
|
+
...current,
|
|
300
|
+
revision: current.revision + 1,
|
|
301
|
+
state: "failed",
|
|
302
|
+
nextAction: { type: "none" },
|
|
303
|
+
error: {
|
|
304
|
+
code: "installation_selection_limit",
|
|
305
|
+
message:
|
|
306
|
+
"This account exceeds the 99-installation Connect chooser limit; no installations were omitted or bound.",
|
|
307
|
+
retryable: false,
|
|
308
|
+
},
|
|
309
|
+
}),
|
|
310
|
+
}
|
|
311
|
+
: {
|
|
312
|
+
commit: async (_tx, current) => ({
|
|
313
|
+
...current,
|
|
314
|
+
revision: current.revision + 1,
|
|
315
|
+
state: "account_selection",
|
|
316
|
+
nextAction: {
|
|
317
|
+
type: "select_account",
|
|
318
|
+
accounts: [
|
|
319
|
+
...candidates.map(({ installation }) => ({
|
|
320
|
+
id: String(installation.installationId),
|
|
321
|
+
providerId: state.providerId,
|
|
322
|
+
label: installation.accountLogin!,
|
|
323
|
+
ownership: "workspace" as const,
|
|
324
|
+
status: "connected" as const,
|
|
325
|
+
})),
|
|
326
|
+
{
|
|
327
|
+
id: "new",
|
|
328
|
+
providerId: state.providerId,
|
|
329
|
+
label: "Install on another GitHub account",
|
|
330
|
+
ownership: "workspace",
|
|
331
|
+
status: "connected",
|
|
332
|
+
},
|
|
333
|
+
],
|
|
334
|
+
},
|
|
335
|
+
}),
|
|
336
|
+
};
|
|
337
|
+
} else {
|
|
338
|
+
const installationId = z.number().int().positive().safe().parse(state.installationId);
|
|
339
|
+
const proof = provider
|
|
340
|
+
? await provider.authorizeInstallationBinding?.({ code: input.code!, installationId })
|
|
341
|
+
: await authorizeGitHubInstallationBinding(settings, {
|
|
342
|
+
code: input.code!,
|
|
343
|
+
installationId,
|
|
344
|
+
});
|
|
345
|
+
if (!proof || !isConsistentGitHubBindingProof(proof, installationId))
|
|
346
|
+
throw new Error("GitHub owner proof unavailable");
|
|
347
|
+
const checkedAt = new Date();
|
|
348
|
+
prepared = {
|
|
349
|
+
commit: async (tx, current) => {
|
|
350
|
+
if (state.providerId === "github-lens") {
|
|
351
|
+
const registration = await commitGitHubLensConnect(deps, tx, {
|
|
352
|
+
...state,
|
|
353
|
+
installationId,
|
|
354
|
+
proof,
|
|
355
|
+
checkedAt,
|
|
356
|
+
expiresAt: new Date(state.iat * 1000 + lifetimeMs),
|
|
357
|
+
nonce: state.nonce,
|
|
358
|
+
});
|
|
359
|
+
return {
|
|
360
|
+
...current,
|
|
361
|
+
revision: current.revision + 1,
|
|
362
|
+
state: "complete",
|
|
363
|
+
nextAction: { type: "none" },
|
|
364
|
+
account: {
|
|
365
|
+
id: `lens-registration:${registration.id}`,
|
|
366
|
+
providerId: "github-lens",
|
|
367
|
+
label: proof.installation.accountLogin!,
|
|
368
|
+
ownership: "workspace",
|
|
369
|
+
status: "connected",
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
const bound = await bindAuthorizedGitHubInstallationRepositories(tx, {
|
|
374
|
+
accountId: state.accountId,
|
|
375
|
+
workspaceId: state.workspaceId,
|
|
376
|
+
installationId,
|
|
377
|
+
githubAccountId: proof.installation.accountId,
|
|
378
|
+
accountLogin: proof.installation.accountLogin,
|
|
379
|
+
accountType: proof.installation.accountType,
|
|
380
|
+
linkedBySubjectId: state.subjectId,
|
|
381
|
+
githubActorId: proof.actorId,
|
|
382
|
+
githubActorLogin: proof.actorLogin,
|
|
383
|
+
authorityKind: proof.authorityKind,
|
|
384
|
+
authorityCheckedAt: checkedAt,
|
|
385
|
+
authorityExpiresAt: new Date(state.iat * 1000 + lifetimeMs),
|
|
386
|
+
authorityNonce: state.nonce,
|
|
387
|
+
repositoryIds: proof.repositories.map((repo) => repo.id),
|
|
388
|
+
});
|
|
389
|
+
if (!bound) throw new Error("GitHub binding proof already consumed");
|
|
390
|
+
return {
|
|
391
|
+
...current,
|
|
392
|
+
revision: current.revision + 1,
|
|
393
|
+
state: "complete",
|
|
394
|
+
nextAction: { type: "none" },
|
|
395
|
+
account: {
|
|
396
|
+
id: `github-installation:${installationId}`,
|
|
397
|
+
providerId: "github-app",
|
|
398
|
+
label: proof.installation.accountLogin!,
|
|
399
|
+
ownership: "workspace",
|
|
400
|
+
status: "connected",
|
|
401
|
+
},
|
|
402
|
+
};
|
|
403
|
+
},
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
const completed = acquiring
|
|
407
|
+
? await finishOAuthAcquisition(
|
|
408
|
+
deps.db,
|
|
409
|
+
state,
|
|
410
|
+
{ ...operation, commit: prepared.commit },
|
|
411
|
+
state.providerId,
|
|
412
|
+
)
|
|
413
|
+
: await finishConnectOperation(deps.db, state, { ...operation, commit: prepared.commit });
|
|
414
|
+
// Installation is only the first half of consent. Keep this browser on
|
|
415
|
+
// the exact authorization stage committed above; polling still waits for
|
|
416
|
+
// the final owner proof before reporting connection completion.
|
|
417
|
+
if (state.phase === "install" && completed.nextAction.type === "authorize")
|
|
418
|
+
return new Response(null, { status: 302, headers: { Location: completed.nextAction.url } });
|
|
419
|
+
}
|
|
420
|
+
} catch {
|
|
421
|
+
// Preserve unknown outcomes; never replay provider authorization to recover.
|
|
422
|
+
// This is browser navigation (usually the Connect popup), so explain the
|
|
423
|
+
// stale or reused link on a page instead of returning a JSON body.
|
|
424
|
+
if (!destination) {
|
|
425
|
+
const home =
|
|
426
|
+
deps.settings.webBaseUrl ??
|
|
427
|
+
integrationBaseUrl(deps.settings.publicBaseUrl, input.requestUrl);
|
|
428
|
+
return new Response(githubConnectFailureHtml("expired", `${home.replace(/\/+$/u, "")}/`), {
|
|
429
|
+
status: 400,
|
|
430
|
+
headers: { "content-type": "text/html; charset=UTF-8" },
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return new Response(null, { status: 302, headers: { Location: destination! } });
|
|
435
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GitHubInstallationBindingCandidate,
|
|
3
|
+
GitHubInstallationBindingProof,
|
|
4
|
+
} from "@opengeni/contracts";
|
|
5
|
+
|
|
6
|
+
export function isConsistentGitHubBindingCandidates(
|
|
7
|
+
candidates: GitHubInstallationBindingCandidate[],
|
|
8
|
+
): boolean {
|
|
9
|
+
const ids = new Set<number>();
|
|
10
|
+
return candidates.every(({ installation, authorityKind }) => {
|
|
11
|
+
if (
|
|
12
|
+
!Number.isSafeInteger(installation.installationId) ||
|
|
13
|
+
installation.installationId <= 0 ||
|
|
14
|
+
!Number.isSafeInteger(installation.accountId) ||
|
|
15
|
+
installation.accountId <= 0 ||
|
|
16
|
+
!installation.accountLogin?.trim() ||
|
|
17
|
+
installation.suspended ||
|
|
18
|
+
ids.has(installation.installationId)
|
|
19
|
+
)
|
|
20
|
+
return false;
|
|
21
|
+
ids.add(installation.installationId);
|
|
22
|
+
return authorityKind === "personal_owner"
|
|
23
|
+
? installation.accountType === "User"
|
|
24
|
+
: authorityKind === "organization_owner" && installation.accountType === "Organization";
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isConsistentGitHubBindingProof(
|
|
29
|
+
proof: GitHubInstallationBindingProof,
|
|
30
|
+
installationId: number,
|
|
31
|
+
): boolean {
|
|
32
|
+
const installation = proof.installation;
|
|
33
|
+
if (
|
|
34
|
+
installation.installationId !== installationId ||
|
|
35
|
+
!Number.isSafeInteger(installation.accountId) ||
|
|
36
|
+
installation.accountId <= 0 ||
|
|
37
|
+
!installation.accountLogin?.trim() ||
|
|
38
|
+
installation.suspended ||
|
|
39
|
+
!Number.isSafeInteger(proof.actorId) ||
|
|
40
|
+
proof.actorId <= 0 ||
|
|
41
|
+
!proof.actorLogin.trim() ||
|
|
42
|
+
proof.repositories.length === 0 ||
|
|
43
|
+
new Set(proof.repositories.map((repo) => repo.id)).size !== proof.repositories.length
|
|
44
|
+
)
|
|
45
|
+
return false;
|
|
46
|
+
if (
|
|
47
|
+
proof.authorityKind === "personal_owner"
|
|
48
|
+
? installation.accountType !== "User" || proof.actorId !== installation.accountId
|
|
49
|
+
: proof.authorityKind !== "organization_owner" || installation.accountType !== "Organization"
|
|
50
|
+
)
|
|
51
|
+
return false;
|
|
52
|
+
return proof.repositories.every(
|
|
53
|
+
(repo) =>
|
|
54
|
+
Number.isSafeInteger(repo.id) &&
|
|
55
|
+
repo.id > 0 &&
|
|
56
|
+
repo.installationId === installationId &&
|
|
57
|
+
repo.accountLogin === installation.accountLogin &&
|
|
58
|
+
repo.accountType === installation.accountType,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { environmentsEncryptionKeyBytes } from "@opengeni/config";
|
|
2
|
+
import { type GitHubInstallationBindingProof } from "@opengeni/contracts";
|
|
3
|
+
import { PR_REVIEW_AUTOMATION_SETUP, type ApiRouteDeps } from "@opengeni/core";
|
|
4
|
+
import {
|
|
5
|
+
encryptVariableSetValue,
|
|
6
|
+
recordAuditEvent,
|
|
7
|
+
syncManagedGitHubPrReviewInstallation,
|
|
8
|
+
type Database,
|
|
9
|
+
} from "@opengeni/db";
|
|
10
|
+
import { HTTPException } from "hono/http-exception";
|
|
11
|
+
|
|
12
|
+
export async function requireGitHubLensConnect(deps: ApiRouteDeps) {
|
|
13
|
+
if (deps.settings.sandboxBackend === "selfhosted")
|
|
14
|
+
throw new HTTPException(409, { message: "Opengeni Lens requires managed compute" });
|
|
15
|
+
if (!environmentsEncryptionKeyBytes(deps.settings))
|
|
16
|
+
throw new HTTPException(503, { message: "Lens secret encryption is unavailable" });
|
|
17
|
+
return { template: PR_REVIEW_AUTOMATION_SETUP };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Separate Lens registration/source/automation domain, not a repository-access
|
|
21
|
+
* binding. Invoked inside the Connect receipt's authorized transaction. */
|
|
22
|
+
export async function commitGitHubLensConnect(
|
|
23
|
+
deps: ApiRouteDeps,
|
|
24
|
+
tx: Database,
|
|
25
|
+
input: {
|
|
26
|
+
accountId: string;
|
|
27
|
+
workspaceId: string;
|
|
28
|
+
subjectId: string;
|
|
29
|
+
installationId: number;
|
|
30
|
+
proof: GitHubInstallationBindingProof;
|
|
31
|
+
checkedAt: Date;
|
|
32
|
+
expiresAt: Date;
|
|
33
|
+
nonce: string;
|
|
34
|
+
},
|
|
35
|
+
) {
|
|
36
|
+
const { template } = await requireGitHubLensConnect({ ...deps, db: tx });
|
|
37
|
+
const synchronized = await syncManagedGitHubPrReviewInstallation(tx, {
|
|
38
|
+
accountId: input.accountId,
|
|
39
|
+
workspaceId: input.workspaceId,
|
|
40
|
+
installationId: input.installationId,
|
|
41
|
+
providerAccountLogin: input.proof.installation.accountLogin,
|
|
42
|
+
providerAccountType: input.proof.installation.accountType as "User" | "Organization",
|
|
43
|
+
githubActorId: input.proof.actorId,
|
|
44
|
+
authorityKind: input.proof.authorityKind,
|
|
45
|
+
authorityCheckedAt: input.checkedAt,
|
|
46
|
+
authorityExpiresAt: input.expiresAt,
|
|
47
|
+
authorityNonce: input.nonce,
|
|
48
|
+
appId: deps.settings.prReviewGithubAppId!,
|
|
49
|
+
webhookSecretEncrypted: encryptVariableSetValue(
|
|
50
|
+
environmentsEncryptionKeyBytes(deps.settings)!,
|
|
51
|
+
deps.settings.prReviewGithubWebhookSecret!,
|
|
52
|
+
),
|
|
53
|
+
repositories: input.proof.repositories,
|
|
54
|
+
createdBySubjectId: input.subjectId,
|
|
55
|
+
adapterId: template.adapterId,
|
|
56
|
+
eventTypes: template.eventTypes,
|
|
57
|
+
configuration: template.configuration,
|
|
58
|
+
sessionTemplate: template.sessionTemplate,
|
|
59
|
+
});
|
|
60
|
+
await recordAuditEvent(tx, {
|
|
61
|
+
accountId: input.accountId,
|
|
62
|
+
workspaceId: input.workspaceId,
|
|
63
|
+
subjectId: input.subjectId,
|
|
64
|
+
action: "prReview.managed_github.connected",
|
|
65
|
+
targetType: "pr_review_app_registration",
|
|
66
|
+
targetId: synchronized.registration.id,
|
|
67
|
+
metadata: {
|
|
68
|
+
installationId: input.installationId,
|
|
69
|
+
providerAccountLogin: input.proof.installation.accountLogin,
|
|
70
|
+
repositoryCount: synchronized.repositories.length,
|
|
71
|
+
authorityKind: input.proof.authorityKind,
|
|
72
|
+
githubActorId: input.proof.actorId,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
return synchronized.registration;
|
|
76
|
+
}
|