forked from baron/baron-sso
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import {
|
|
buildCommonOidcRuntimeConfig,
|
|
type CommonOidcConfigOptions,
|
|
} from "../../../common/core/auth";
|
|
|
|
export interface OrgFrontAuthRedirectUris {
|
|
redirectUri: string;
|
|
postLogoutRedirectUri: string;
|
|
popupRedirectUri: string;
|
|
}
|
|
|
|
export const ORGFRONT_AUTH_CALLBACK_PATH = "/auth/callback";
|
|
|
|
export function resolveOrgFrontPublicOrigin(
|
|
configuredOrigin: string | undefined,
|
|
browserOrigin: string,
|
|
) {
|
|
const trimmed = configuredOrigin?.trim();
|
|
if (!trimmed) {
|
|
return browserOrigin;
|
|
}
|
|
|
|
try {
|
|
return new URL(trimmed).origin;
|
|
} catch {
|
|
return browserOrigin;
|
|
}
|
|
}
|
|
|
|
export function buildOrgFrontAuthRedirectUris(
|
|
publicOrigin: string,
|
|
): OrgFrontAuthRedirectUris {
|
|
return {
|
|
redirectUri: `${publicOrigin}${ORGFRONT_AUTH_CALLBACK_PATH}`,
|
|
postLogoutRedirectUri: publicOrigin,
|
|
popupRedirectUri: `${publicOrigin}${ORGFRONT_AUTH_CALLBACK_PATH}`,
|
|
};
|
|
}
|
|
|
|
export function buildOrgFrontOidcRuntimeConfig<TUserStore>(
|
|
options: Omit<CommonOidcConfigOptions<TUserStore>, "automaticSilentRenew">,
|
|
) {
|
|
return buildCommonOidcRuntimeConfig({
|
|
...options,
|
|
automaticSilentRenew: true,
|
|
});
|
|
}
|