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

Function dcrClientSlug

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

Source from the content-addressed store, hash-verified

323};
324
325const dcrClientSlug = (
326 issuer: string | null,
327 resource: string | null,
328 fallback: OAuthClientSlug,
329): OAuthClientSlug => {
330 if (issuer === null) return fallback;
331 const issuerHost = hostOfUrl(issuer);
332 if (issuerHost === null) return fallback;
333 const base = `dcr-${slugifyOAuthKey(issuerHost) || "authorization-server"}`;
334 if (resource === null) return OAuthClientSlug.make(base);
335 const resourceUrl = parseUrl(resource);
336 const resourceSource =
337 resourceUrl === null ? resource : `${resourceUrl.host}${resourceUrl.pathname}`;
338 const resourcePart = slugifyOAuthKey(resourceSource).slice(0, 60) || "resource";
339 return OAuthClientSlug.make(`${base}-${resourcePart}-${shortStableHash(resource)}`.slice(0, 240));
340};
341
342/** Dedupe a freshly-minted DCR slug against slugs already held by an owner's
343 * 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