Unified · Split
| @@ -283,27 +283,38 @@ const resolveSourceCallContext = (input: { · 282 unmodified lines | ||
| 283 | 283 | secretRegistry: SecretMaterialRegistry; |
| 284 | 284 | }) => |
| 285 | 285 | async (source: Source): Promise<SourceCallContext> => { |
| 286 | − if (source.auth.kind === "none") { | |
| 287 | − return { auth: { kind: "none" } }; | |
| 288 | − } | |
| 289 | − | |
| 290 | − if (source.auth.kind === "oauth2_authorized_user") { | |
| 291 | − throw new Error("oauth2_authorized_user auth requires persistence-backed runtime resolution"); | |
| 286 | + switch (source.auth.kind) { | |
| 287 | + case "none": | |
| 288 | + return { auth: { kind: "none" } }; | |
| 289 | + case "bearer": { | |
| 290 | + const token = await input.secretRegistry.get({ ref: source.auth.token }); | |
| 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 | 320 | const createProviderInvoker = (): ProviderInvoker => ({ |
| @@ -8,7 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | }, |
| 9 | 9 | "scripts": { |
| 10 | 10 | "typecheck": "bunx tsc --noEmit -p tsconfig.json", |
| 11 | − "test": "vitest run", | |
| 11 | + "test": "vitest run --passWithNoTests", | |
| 12 | 12 | "test:watch": "vitest" |
| 13 | 13 | }, |
| 14 | 14 | "dependencies": { |
| @@ -15,7 +15,7 @@ import type { · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | const readFixture = (name: string): string => |
| 17 | 17 | readFileSync( |
| 18 | − new URL(`../../control-plane/src/runtime/fixtures/${name}`, import.meta.url), | |
| 18 | + new URL(`../../../platform/control-plane/src/runtime/fixtures/${name}`, import.meta.url), | |
| 19 | 19 | "utf8", |
| 20 | 20 | ); |
| 21 | 21 | |
| @@ -10,7 +10,7 @@ import { buildOpenApiToolPresentation } from "./openapi-tool-presentation"; · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | const readFixture = (name: string): string => |
| 12 | 12 | readFileSync( |
| 13 | − new URL(`../../control-plane/src/runtime/fixtures/${name}`, import.meta.url), | |
| 13 | + new URL(`../../../platform/control-plane/src/runtime/fixtures/${name}`, import.meta.url), | |
| 14 | 14 | "utf8", |
| 15 | 15 | ); |
| 16 | 16 | |
| @@ -396,10 +396,16 @@ const planHttpInvocation = (input: { · 395 unmodified lines | ||
| 396 | 396 | const executeHttpPlan = (requestPlan: HttpInvocationRequestPlan) => |
| 397 | 397 | Effect.tryPromise({ |
| 398 | 398 | try: async () => { |
| 399 | + const body = | |
| 400 | + requestPlan.body === undefined | |
| 401 | + ? undefined | |
| 402 | + : typeof requestPlan.body === "string" | |
| 403 | + ? requestPlan.body | |
| 404 | + : new Uint8Array(requestPlan.body).buffer; | |
| 399 | 405 | const response = await fetch(requestPlan.url, { |
| 400 | 406 | method: requestPlan.method, |
| 401 | 407 | headers: requestPlan.headers, |
| 402 | − ...(requestPlan.body !== undefined ? { body: requestPlan.body } : {}), | |
| 408 | + ...(body !== undefined ? { body } : {}), | |
| 403 | 409 | }); |
| 404 | 410 | const responseBody = await decodeFetchBody(response); |
| 405 | 411 | return executionEnvelope({ |
| @@ -57,7 +57,7 @@ import { · 56 unmodified lines | ||
| 57 | 57 | const FIXTURE_WORKSPACE_ID = WorkspaceIdSchema.make("ws_source_fixture_matrix"); |
| 58 | 58 | |
| 59 | 59 | const readFixture = (name: string): string => |
| 60 | − readFileSync(new URL(`./fixtures/${name}`, import.meta.url), "utf8"); | |
| 60 | + readFileSync(new URL(`../fixtures/${name}`, import.meta.url), "utf8"); | |
| 61 | 61 | |
| 62 | 62 | const makeSource = (input: { |
| 63 | 63 | id: string; |