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

Function withTokenRequestSpan

packages/core/sdk/src/oauth-helpers.ts:380–401  ·  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

378 * response URL and a body preview), never token or code material. */
379const withTokenRequestSpan =
380 (input: {
381 readonly grantType: "authorization_code" | "client_credentials" | "refresh_token";
382 readonly tokenUrl: string;
383 readonly clientAuth: ClientAuthMethod | undefined;
384 readonly hasResource: boolean;
385 }) =>
386 <A>(effect: Effect.Effect<A, OAuth2Error>): Effect.Effect<A, OAuth2Error> =>
387 effect.pipe(
388 Effect.tapError((error) =>
389 Effect.annotateCurrentSpan({
390 ...(error.error !== undefined ? { "executor.oauth.error_code": error.error } : {}),
391 }),
392 ),
393 Effect.withSpan("executor.oauth.token_request", {
394 attributes: {
395 "executor.oauth.grant_type": input.grantType,
396 "executor.oauth.token_host": hostnameForTelemetry(input.tokenUrl),
397 "executor.oauth.client_auth": input.clientAuth ?? DEFAULT_CLIENT_AUTH_METHOD,
398 "executor.oauth.has_resource": input.hasResource,
399 },
400 }),
401 );
402
403/** The hostname alone — a malformed URL yields "invalid" rather than leaking
404 * whatever string failed to parse. */

Callers 3

refreshAccessTokenFunction · 0.85

Calls 1

hostnameForTelemetryFunction · 0.85

Tested by

no test coverage detected