@light-auth/core
Version:
light auth core framework agnostic, using arctic
34 lines (33 loc) • 1.85 kB
TypeScript
import { type LightAuthProvider, type LightAuthConfig, type LightAuthSession, type LightAuthUser, type LightAuthServerEnv } from "../models";
/**
* Checks the configuration and throws an error if any required fields are missing.
* @param config The configuration object to check.
* @returns The checked configuration object.
* @throws Error if any required fields are missing.
*/
export declare function checkConfig<Session extends LightAuthSession = LightAuthSession, User extends LightAuthUser<Session> = LightAuthUser<Session>>(config: LightAuthConfig<Session, User>, providerName?: string): Required<LightAuthConfig<Session, User>> & {
provider: LightAuthProvider;
};
/** get the max age from the environment variable or use the default value */
export declare function getSessionExpirationMaxAge(): number;
/** Resolves the basePath, defaults to "/api/default" if not provided or falsy */
export declare function resolveBasePath(basePath: string | undefined | null, env: LightAuthServerEnv | null | undefined): string;
export declare function buildSecret(env?: {
[key: string]: string | undefined;
}): string;
export declare function buildFullUrl({ url, incomingHeaders }: {
url: string;
incomingHeaders: Headers;
}): string;
/**
* Type guard to check if a provider is an OAuth provider.
* @param provider The provider to check
* @returns True if the provider is an OAuth provider
*/
export declare function isOAuthProvider(provider: LightAuthProvider): provider is import("../models").LightAuthOAuthProvider;
/**
* Type guard to check if a provider is a credentials provider.
* @param provider The provider to check
* @returns True if the provider is a credentials provider
*/
export declare function isCredentialsProvider(provider: LightAuthProvider): provider is import("../models").LightAuthCredentialsProvider;