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

Function interpretDcrFailure

packages/core/sdk/src/oauth-discovery.ts:458–491  ·  view source on GitHub ↗
(status: number, text: string)

Source from the content-addressed store, hash-verified

456};
457
458const interpretDcrFailure = (status: number, text: string): DcrErrorBody | DcrTransport => {
459 // RFC 6749 error envelope: `{error, error_description?}` with 4xx.
460 if (status >= 400 && status < 500) {
461 const body = text ? decodeDcrErrorBodyJson(text) : null;
462 return Option.match(body ?? Option.none(), {
463 onNone: () =>
464 new DcrTransport({
465 detail: `Dynamic Client Registration endpoint returned status ${status}${
466 text ? ` — ${text.slice(0, 200)}` : ""
467 }`,
468 status,
469 }),
470 onSome: (parsed) =>
471 parsed.error.length > 0
472 ? new DcrErrorBody({
473 status,
474 error: parsed.error,
475 error_description: parsed.error_description,
476 })
477 : new DcrTransport({
478 detail: `Dynamic Client Registration endpoint returned status ${status}${
479 text ? ` — ${text.slice(0, 200)}` : ""
480 }`,
481 status,
482 }),
483 });
484 }
485 return new DcrTransport({
486 detail: `Dynamic Client Registration endpoint returned status ${status}${
487 text ? ` — ${text.slice(0, 200)}` : ""
488 }`,
489 status,
490 });
491};
492
493export const registerDynamicClient = (
494 input: RegisterDynamicClientInput,

Callers 1

registerDynamicClientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected