@light-auth/core
Version:
light auth core framework agnostic, using arctic
28 lines (27 loc) • 1.32 kB
TypeScript
import type { LightAuthOAuthProvider, LightAuthCredentialsProvider } from "../models";
import type { ArcticProvider } from "../models";
/**
* Helper function to create an OAuth provider with explicit type.
* This ensures backward compatibility and makes the type explicit.
*
* @param provider The OAuth provider configuration
* @returns A typed OAuth provider
*/
export declare function createOAuthProvider(provider: Omit<LightAuthOAuthProvider, "type">): LightAuthOAuthProvider;
/**
* Helper function to create a credentials provider with explicit type.
*
* @param provider The credentials provider configuration
* @returns A typed credentials provider
*/
export declare function createCredentialsProvider(provider: Omit<LightAuthCredentialsProvider, "type">): LightAuthCredentialsProvider;
/**
* Backward compatibility: Converts a legacy provider (without type field) to OAuth provider.
* This allows existing code to continue working without changes.
*
* @param provider A provider that may or may not have the type field
* @returns A properly typed provider
*/
export declare function ensureProviderType(provider: LightAuthOAuthProvider | LightAuthCredentialsProvider | (Omit<LightAuthOAuthProvider, "type"> & {
arctic: ArcticProvider;
})): LightAuthOAuthProvider | LightAuthCredentialsProvider;