Unified · Split
| @@ -245,20 +245,9 @@ const appRegistrationErrorToDiagnostic = (error: unknown): SyncDiagnostic => { · 244 unmodified lines | |||
| 245 | const tokenItemId = (slug: string): ProviderItemId => | 245 | const tokenItemId = (slug: string): ProviderItemId => |
| 246 | ProviderItemId.make(`apps/source-tokens/${slug}`); | 246 | ProviderItemId.make(`apps/source-tokens/${slug}`); |
| 247 | 247 | ||
| 248 | const gitHubConnectionToken = (ctx: PluginCtx<AppsStore>): Effect.Effect<string | null, unknown> => | 248 | // A source authenticates only with its own explicitly provided token. No |
| 249 | Effect.gen(function* () { | 249 | // implicit credential sharing: a stored GitHub connection must never leak |
| 250 | const connections = yield* ctx.connections.list({ | 250 | // into git fetches the user did not tie to it. |
| 251 | integration: IntegrationSlug.make("github"), | ||
| 252 | }); | ||
| 253 | const connection = connections.find((item) => item.owner === "user") ?? connections[0]; | ||
| 254 | if (!connection) return null; | ||
| 255 | return yield* ctx.connections.resolveValue({ | ||
| 256 | owner: connection.owner, | ||
| 257 | integration: connection.integration, | ||
| 258 | name: connection.name, | ||
| 259 | }); | ||
| 260 | }); | ||
| 261 | |||
| 262 | const gitTokenFor = ( | 251 | const gitTokenFor = ( |
| 263 | ctx: PluginCtx<AppsStore>, | 252 | ctx: PluginCtx<AppsStore>, |
| 264 | config: Extract<AppSourceConfig, { readonly kind: "git" }>, | 253 | config: Extract<AppSourceConfig, { readonly kind: "git" }>, |
| @@ -270,9 +259,7 @@ const gitTokenFor = ( · 5 unmodified lines | |||
| 270 | ProviderItemId.make(config.tokenItemId), | 259 | ProviderItemId.make(config.tokenItemId), |
| 271 | ); | 260 | ); |
| 272 | } | 261 | } |
| 273 | const url = yield* parseGitSourceUrl(config.url).pipe(Effect.result); | 262 | return null; |
| 274 | if (Result.isFailure(url) || url.success.hostname.toLowerCase() !== "github.com") return null; | ||
| 275 | return yield* gitHubConnectionToken(ctx); | ||
| 276 | }); | 263 | }); |
| 277 | 264 | ||
| 278 | const activeToolNamesFor = ( | 265 | const activeToolNamesFor = ( |