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

Function validateClientEndpoints

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

Source from the content-addressed store, hash-verified

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

Callers 1

createClientFunction · 0.85

Calls 3

canonicalUrlStringFunction · 0.85

Tested by

no test coverage detected