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

Function tokenEndpointForRefresh

packages/core/sdk/src/oauth-helpers.ts:376–387  ·  view source on GitHub ↗
(
  configuredTokenUrl: string,
  persistedTokenUrl: string | null,
)

Source from the content-addressed store, hash-verified

374 * Only the configured URL or an exact supported regional substitution is
375 * accepted. Invalid legacy overrides return undefined, requiring reconnect. */
376export const tokenEndpointForRefresh = (
377 configuredTokenUrl: string,
378 persistedTokenUrl: string | null,
379): string | undefined => {
380 if (persistedTokenUrl === null || persistedTokenUrl === configuredTokenUrl) {
381 return configuredTokenUrl;
382 }
383 if (!URL.canParse(persistedTokenUrl) || !URL.canParse(configuredTokenUrl)) return undefined;
384 const persisted = new URL(persistedTokenUrl);
385 const trusted = rebindTokenEndpointHostToCallbackDomain(configuredTokenUrl, persisted.origin);
386 return new URL(trusted).href === persisted.href ? trusted : undefined;
387};
388
389// ---------------------------------------------------------------------------
390// Error mapping — `oauth4webapi`'s `process*Response` failure shapes are

Callers 1

performTokenRefreshFunction · 0.90

Tested by

no test coverage detected