MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / withTokenRequestSpan

Function withTokenRequestSpan

packages/core/sdk/src/oauth-helpers.ts:441–462  ·  view source on GitHub ↗
(input: {
    readonly grantType: "authorization_code" | "client_credentials" | "refresh_token";
    readonly tokenUrl: string;
    readonly clientAuth: ClientAuthMethod | undefined;
    readonly hasResource: boolean;
  })

Source from the content-addressed store, hash-verified

439 * response URL and a body preview), never token or code material. */
440const 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. */

Callers 3

refreshAccessTokenFunction · 0.85

Calls 1

hostnameForTelemetryFunction · 0.85

Tested by

no test coverage detected