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

Function dcrClientSlug

packages/core/sdk/src/oauth-service.ts:348–363  ·  view source on GitHub ↗
(
  issuer: string | null,
  resource: string | null,
  fallback: OAuthClientSlug,
)

Source from the content-addressed store, hash-verified

346};
347
348const dcrClientSlug = (
349 issuer: string | null,
350 resource: string | null,
351 fallback: OAuthClientSlug,
352): OAuthClientSlug => {
353 if (issuer === null) return fallback;
354 const issuerHost = hostOfUrl(issuer);
355 if (issuerHost === null) return fallback;
356 const base = `dcr-${slugifyOAuthKey(issuerHost) || "authorization-server"}`;
357 if (resource === null) return OAuthClientSlug.make(base);
358 const resourceUrl = parseUrl(resource);
359 const resourceSource =
360 resourceUrl === null ? resource : `${resourceUrl.host}${resourceUrl.pathname}`;
361 const resourcePart = slugifyOAuthKey(resourceSource).slice(0, 60) || "resource";
362 return OAuthClientSlug.make(`${base}-${resourcePart}-${shortStableHash(resource)}`.slice(0, 240));
363};
364
365/** Dedupe a freshly-minted DCR slug against slugs already held by an owner's
366 * DCR candidates, appending `-2`, `-3`, … so a new client never collides with

Callers 1

decideDcrClientReuseFunction · 0.85

Calls 4

hostOfUrlFunction · 0.90
parseUrlFunction · 0.90
slugifyOAuthKeyFunction · 0.85
shortStableHashFunction · 0.85

Tested by

no test coverage detected