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

Function validateClientEndpoints

packages/core/sdk/src/oauth-service.ts:462–491  ·  view source on GitHub ↗
(
  input: CreateOAuthClientInput,
  endpointUrlPolicy: OAuthEndpointUrlPolicy | undefined,
)

Source from the content-addressed store, hash-verified

460 }).pipe(Effect.asVoid);
461
462const validateClientEndpoints = (
463 input: CreateOAuthClientInput,
464 endpointUrlPolicy: OAuthEndpointUrlPolicy | undefined,
465): Effect.Effect<void, StorageFailure> =>
466 Effect.gen(function* () {
467 yield* validateSupportedEndpoint(input.tokenUrl, "token_url", endpointUrlPolicy);
468 if (input.resource != null && input.resource.trim().length > 0) {
469 yield* validateSupportedEndpoint(input.resource, "resource", endpointUrlPolicy);
470 }
471 if (input.grant !== "authorization_code") return;
472 yield* validateSupportedEndpoint(
473 input.authorizationUrl,
474 "authorization_url",
475 endpointUrlPolicy,
476 );
477 if (isWellKnownOAuthMetadataUrl(input.authorizationUrl)) {
478 return yield* new StorageError({
479 message:
480 "Invalid OAuth client endpoint configuration: authorization_url must be the OAuth authorization endpoint, not a .well-known metadata URL.",
481 cause: undefined,
482 });
483 }
484 if (canonicalUrlString(input.authorizationUrl) === canonicalUrlString(input.tokenUrl)) {
485 return yield* new StorageError({
486 message:
487 "Invalid OAuth client endpoint configuration: authorization_url must not equal token_url.",
488 cause: undefined,
489 });
490 }
491 });
492
493export const makeOAuthService = (deps: OAuthServiceDeps): OAuthService => {
494 const httpClientLayer = deps.httpClientLayer ?? FetchHttpClient.layer;

Callers 1

createClientFunction · 0.85

Calls 3

canonicalUrlStringFunction · 0.85

Tested by

no test coverage detected