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

Function dcrClientSlug

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

Source from the content-addressed store, hash-verified

336};
337
338const dcrClientSlug = (
339 issuer: string | null,
340 resource: string | null,
341 fallback: OAuthClientSlug,
342): OAuthClientSlug => {
343 if (issuer === null) return fallback;
344 const issuerHost = hostOfUrl(issuer);
345 if (issuerHost === null) return fallback;
346 const base = `dcr-${slugifyOAuthKey(issuerHost) || "authorization-server"}`;
347 if (resource === null) return OAuthClientSlug.make(base);
348 const resourceUrl = parseUrl(resource);
349 const resourceSource =
350 resourceUrl === null ? resource : `${resourceUrl.host}${resourceUrl.pathname}`;
351 const resourcePart = slugifyOAuthKey(resourceSource).slice(0, 60) || "resource";
352 return OAuthClientSlug.make(`${base}-${resourcePart}-${shortStableHash(resource)}`.slice(0, 240));
353};
354
355/** Dedupe a freshly-minted DCR slug against slugs already held by an owner's
356 * 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