Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
import { isSafeLinkUrl } from 'librechat-data-provider';
import type { TStartupConfig } from 'librechat-data-provider';
/**
* The policy links a deployment published, as the surfaces that render them
* agree to read it. `externalUrl` is an optional string, so an operator can
* leave it blank; a blank one is not a published policy, because rendered as a
* link it points back at the page the reader is on and names a document that
* does not exist. Nor is one that is not an http(s), `mailto:`, `tel:` or
* relative URL: rendered as a link, a `javascript:` or `data:` URL runs script
* on the page that shows it, the sign-in page included. The server refuses to
* store or serve one; this check also covers a server that predates it.
*/
export function publishedPolicyUrl(externalUrl?: string): string | undefined {
const url = externalUrl?.trim();
return url != null && url !== '' && isSafeLinkUrl(url) ? url : undefined;
}
type PolicySource = {
interface?: Pick<NonNullable<TStartupConfig['interface']>, 'privacyPolicy' | 'termsOfService'>;
};
export function policyUrls(startupConfig: PolicySource | null | undefined) {
return {
privacyPolicyUrl: publishedPolicyUrl(startupConfig?.interface?.privacyPolicy?.externalUrl),
termsOfServiceUrl: publishedPolicyUrl(startupConfig?.interface?.termsOfService?.externalUrl),
};
}
/** Whether the deployment published anything to consent to by continuing. The
* auth layout reads this to choose between the consent and its footer bar, so
* the two cannot disagree about whether the sentence is on the screen.
*
* A deployment that asks for the terms to be accepted in a modal has its own
* explicit acceptance after sign-in (`routes/Root.tsx`), so a sentence saying
* the reader already agreed by continuing would contradict the dialog it is
* about to show; those screens keep the bare links they always had. */
export function hasPublishedPolicies(startupConfig: PolicySource | null | undefined): boolean {
if (startupConfig?.interface?.termsOfService?.modalAcceptance === true) {
return false;
}
const { privacyPolicyUrl, termsOfServiceUrl } = policyUrls(startupConfig);
return privacyPolicyUrl != null || termsOfServiceUrl != null;
}