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

Function validateClientEndpoints

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

Source from the content-addressed store, hash-verified

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

Callers 1

createClientFunction · 0.85

Calls 3

canonicalUrlStringFunction · 0.85

Tested by

no test coverage detected