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

Function buildDcrBody

packages/core/sdk/src/oauth-discovery.ts:439–456  ·  view source on GitHub ↗
(m: DynamicClientMetadata)

Source from the content-addressed store, hash-verified

437const decodeDcrErrorBodyJson = Schema.decodeUnknownOption(Schema.fromJsonString(DcrErrorBodyJson));
438
439const buildDcrBody = (m: DynamicClientMetadata): Record<string, unknown> => {
440 const body: Record<string, unknown> = { redirect_uris: [...m.redirect_uris] };
441 if (m.client_name !== undefined) body.client_name = m.client_name;
442 if (m.grant_types !== undefined) body.grant_types = [...m.grant_types];
443 if (m.response_types !== undefined) body.response_types = [...m.response_types];
444 if (m.token_endpoint_auth_method !== undefined) {
445 body.token_endpoint_auth_method = m.token_endpoint_auth_method;
446 }
447 if (m.scope !== undefined) body.scope = m.scope;
448 if (m.application_type !== undefined) body.application_type = m.application_type;
449 if (m.client_uri !== undefined) body.client_uri = m.client_uri;
450 if (m.logo_uri !== undefined) body.logo_uri = m.logo_uri;
451 if (m.contacts !== undefined) body.contacts = [...m.contacts];
452 if (m.software_id !== undefined) body.software_id = m.software_id;
453 if (m.software_version !== undefined) body.software_version = m.software_version;
454 if (m.extra) for (const [k, v] of Object.entries(m.extra)) body[k] = v;
455 return body;
456};
457
458const interpretDcrFailure = (status: number, text: string): DcrErrorBody | DcrTransport => {
459 // RFC 6749 error envelope: `{error, error_description?}` with 4xx.

Callers 1

registerDynamicClientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected