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

Function validateClientEndpoints

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

Source from the content-addressed store, hash-verified

391 }).pipe(Effect.asVoid);
392
393const validateClientEndpoints = (
394 input: CreateOAuthClientInput,
395 endpointUrlPolicy: OAuthEndpointUrlPolicy | undefined,
396): Effect.Effect<void, StorageFailure> =>
397 Effect.gen(function* () {
398 yield* validateSupportedEndpoint(input.tokenUrl, "token_url", endpointUrlPolicy);
399 if (input.resource != null && input.resource.trim().length > 0) {
400 yield* validateSupportedEndpoint(input.resource, "resource", endpointUrlPolicy);
401 }
402 if (input.grant !== "authorization_code") return;
403 yield* validateSupportedEndpoint(
404 input.authorizationUrl,
405 "authorization_url",
406 endpointUrlPolicy,
407 );
408 if (isWellKnownOAuthMetadataUrl(input.authorizationUrl)) {
409 return yield* new StorageError({
410 message:
411 "Invalid OAuth client endpoint configuration: authorization_url must be the OAuth authorization endpoint, not a .well-known metadata URL.",
412 cause: undefined,
413 });
414 }
415 if (canonicalUrlString(input.authorizationUrl) === canonicalUrlString(input.tokenUrl)) {
416 return yield* new StorageError({
417 message:
418 "Invalid OAuth client endpoint configuration: authorization_url must not equal token_url.",
419 cause: undefined,
420 });
421 }
422 });
423
424export const makeOAuthService = (deps: OAuthServiceDeps): OAuthService => {
425 const httpClientLayer = deps.httpClientLayer ?? FetchHttpClient.layer;

Callers 1

createClientFunction · 0.85

Calls 3

canonicalUrlStringFunction · 0.85

Tested by

no test coverage detected