(input: {
readonly grantType: "authorization_code" | "client_credentials" | "refresh_token";
readonly tokenUrl: string;
readonly clientAuth: ClientAuthMethod | undefined;
readonly hasResource: boolean;
})
| 439 | * response URL and a body preview), never token or code material. */ |
| 440 | const withTokenRequestSpan = |
| 441 | (input: { |
| 442 | readonly grantType: "authorization_code" | "client_credentials" | "refresh_token"; |
| 443 | readonly tokenUrl: string; |
| 444 | readonly clientAuth: ClientAuthMethod | undefined; |
| 445 | readonly hasResource: boolean; |
| 446 | }) => |
| 447 | <A>(effect: Effect.Effect<A, OAuth2Error>): Effect.Effect<A, OAuth2Error> => |
| 448 | effect.pipe( |
| 449 | Effect.tapError((error) => |
| 450 | Effect.annotateCurrentSpan({ |
| 451 | ...(error.error !== undefined ? { "executor.oauth.error_code": error.error } : {}), |
| 452 | }), |
| 453 | ), |
| 454 | Effect.withSpan("executor.oauth.token_request", { |
| 455 | attributes: { |
| 456 | "executor.oauth.grant_type": input.grantType, |
| 457 | "executor.oauth.token_host": hostnameForTelemetry(input.tokenUrl), |
| 458 | "executor.oauth.client_auth": input.clientAuth ?? DEFAULT_CLIENT_AUTH_METHOD, |
| 459 | "executor.oauth.has_resource": input.hasResource, |
| 460 | }, |
| 461 | }), |
| 462 | ); |
| 463 | |
| 464 | /** The hostname alone — a malformed URL yields "invalid" rather than leaking |
| 465 | * whatever string failed to parse. */ |
no test coverage detected