41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { loadRequiredWebConfig, type WebConfig } from "@toolctrl/config";
|
|
|
|
type AuthProviderRequestOptions = {
|
|
request?: Request;
|
|
webConfig?: WebConfig;
|
|
};
|
|
|
|
// EU-Sterilisation (AD/EU-Stack): social OAuth login (GitHub/Google) is removed.
|
|
// Authentication is Email+Password, Magic-Link and TOTP only. Keep this provider
|
|
// registry so additional EU-compatible methods can slot in later.
|
|
export type PublicAuthProviders = {
|
|
magicLink: {
|
|
enabled: boolean;
|
|
configured: boolean;
|
|
};
|
|
};
|
|
|
|
export type ServerAuthProviders = {
|
|
magicLink: {
|
|
enabled: boolean;
|
|
configured: boolean;
|
|
};
|
|
};
|
|
|
|
export function getPublicAuthProviders(options: AuthProviderRequestOptions): PublicAuthProviders {
|
|
const providers = getServerAuthProviders(options);
|
|
|
|
return {
|
|
magicLink: providers.magicLink,
|
|
};
|
|
}
|
|
|
|
export function getServerAuthProviders({ webConfig = loadRequiredWebConfig() }: AuthProviderRequestOptions): ServerAuthProviders {
|
|
return {
|
|
magicLink: {
|
|
enabled: webConfig.magicLink.enabled,
|
|
configured: webConfig.magicLink.enabled,
|
|
},
|
|
};
|
|
}
|