fix and update

This commit is contained in:
lendry
2026-06-29 12:17:25 +03:00
parent 923a028cdd
commit 75ccbe5fc4
39 changed files with 1619 additions and 63 deletions

View File

@@ -19,6 +19,23 @@ export function resolveOAuthApiBase(settings: Record<string, string>, fallback =
return normalizeBaseUrl(fallback);
}
export function resolveFrontendBase(settings: Record<string, string>, fallback = 'http://localhost:3002') {
const publicFrontend = settings.PUBLIC_FRONTEND_URL?.trim();
if (publicFrontend) {
return normalizeBaseUrl(publicFrontend);
}
const domain = settings.PROJECT_DOMAIN?.trim();
if (domain) {
if (domain.startsWith('http://') || domain.startsWith('https://')) {
return normalizeBaseUrl(domain);
}
return `https://${domain.replace(/^\/+/, '')}`;
}
return normalizeBaseUrl(fallback);
}
export interface OAuthEndpoints {
issuer: string;
authorizationEndpoint: string;
@@ -26,6 +43,10 @@ export interface OAuthEndpoints {
userInfoEndpoint: string;
openIdConfigurationUrl: string;
jwksUrl: string;
webIdentityUrl: string;
fedcmConfigUrl: string;
fedcmAccountsUrl: string;
fedcmIdAssertionUrl: string;
}
export function buildOAuthEndpoints(apiBase: string): OAuthEndpoints {
@@ -36,7 +57,11 @@ export function buildOAuthEndpoints(apiBase: string): OAuthEndpoints {
tokenEndpoint: `${base}/oauth/token`,
userInfoEndpoint: `${base}/oauth/userinfo`,
openIdConfigurationUrl: `${base}/.well-known/openid-configuration`,
jwksUrl: `${base}/.well-known/jwks.json`
jwksUrl: `${base}/.well-known/jwks.json`,
webIdentityUrl: `${base}/.well-known/web-identity`,
fedcmConfigUrl: `${base}/fedcm/config.json`,
fedcmAccountsUrl: `${base}/fedcm/accounts`,
fedcmIdAssertionUrl: `${base}/fedcm/id_assertion`
};
}