( configuredTokenUrl: string, persistedTokenUrl: string | null, )
| 374 | * Only the configured URL or an exact supported regional substitution is |
| 375 | * accepted. Invalid legacy overrides return undefined, requiring reconnect. */ |
| 376 | export 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 |
no test coverage detected