Showing the changes to packages/dev (1 of 6 files). Show all
Unified · Split
| @@ -283,27 +283,38 @@ const resolveSourceCallContext = (input: { · 282 unmodified lines | |||
| 283 | secretRegistry: SecretMaterialRegistry; | 283 | secretRegistry: SecretMaterialRegistry; |
| 284 | }) => | 284 | }) => |
| 285 | async (source: Source): Promise<SourceCallContext> => { | 285 | async (source: Source): Promise<SourceCallContext> => { |
| 286 | if (source.auth.kind === "none") { | 286 | switch (source.auth.kind) { |
| 287 | return { auth: { kind: "none" } }; | 287 | case "none": |
| 288 | } | 288 | return { auth: { kind: "none" } }; |
| 289 | 289 | case "bearer": { | |
| 290 | if (source.auth.kind === "oauth2_authorized_user") { | 290 | const token = await input.secretRegistry.get({ ref: source.auth.token }); |
| 291 | throw new Error("oauth2_authorized_user auth requires persistence-backed runtime resolution"); | 291 | return { |
| 292 | auth: { | ||
| 293 | kind: "headers", | ||
| 294 | headers: { | ||
| 295 | [source.auth.headerName]: `${source.auth.prefix}${token}`, | ||
| 296 | }, | ||
| 297 | }, | ||
| 298 | }; | ||
| 299 | } | ||
| 300 | case "oauth2": { | ||
| 301 | const token = await input.secretRegistry.get({ ref: source.auth.accessToken }); | ||
| 302 | return { | ||
| 303 | auth: { | ||
| 304 | kind: "headers", | ||
| 305 | headers: { | ||
| 306 | [source.auth.headerName]: `${source.auth.prefix}${token}`, | ||
| 307 | }, | ||
| 308 | }, | ||
| 309 | }; | ||
| 310 | } | ||
| 311 | case "oauth2_authorized_user": | ||
| 312 | throw new Error("oauth2_authorized_user auth requires persistence-backed runtime resolution"); | ||
| 313 | case "provider_grant_ref": | ||
| 314 | throw new Error("provider_grant_ref auth requires persistence-backed runtime resolution"); | ||
| 315 | case "mcp_oauth": | ||
| 316 | throw new Error("mcp_oauth auth requires persistence-backed runtime resolution"); | ||
| 292 | } | 317 | } |
| 293 | |||
| 294 | const tokenRef = source.auth.kind === "bearer" | ||
| 295 | ? source.auth.token | ||
| 296 | : source.auth.accessToken; | ||
| 297 | const token = await input.secretRegistry.get({ ref: tokenRef }); | ||
| 298 | |||
| 299 | return { | ||
| 300 | auth: { | ||
| 301 | kind: "headers", | ||
| 302 | headers: { | ||
| 303 | [source.auth.headerName]: `${source.auth.prefix}${token}`, | ||
| 304 | }, | ||
| 305 | }, | ||
| 306 | }; | ||
| 307 | }; | 318 | }; |
| 308 | 319 | ||
| 309 | const createProviderInvoker = (): ProviderInvoker => ({ | 320 | const createProviderInvoker = (): ProviderInvoker => ({ |