authrix
Version:
Lightweight, flexible authentication library for Node.js and TypeScript.
64 lines (61 loc) • 1.98 kB
TypeScript
export { a as authConfig, i as initAuth } from './index-2c4aN9k6.js';
export { A as AuthDbAdapter, a as AuthUser } from './db-BIgxMgj8.js';
/**
* Sign up a user (client-side)
* Note: This requires your API to handle the authentication logic
*/
declare function signupReact(email: string, password: string, apiEndpoint?: string): Promise<{
user: {
id: string;
email: string;
};
}>;
/**
* Sign in a user (client-side)
*/
declare function signinReact(email: string, password: string, apiEndpoint?: string): Promise<{
user: {
id: string;
email: string;
};
}>;
/**
* Log out a user (client-side)
*/
declare function logoutReact(apiEndpoint?: string): Promise<{
message: string;
}>;
/**
* Get current user (client-side)
*/
declare function getCurrentUserReact(apiEndpoint?: string): Promise<{
id: string;
email: string;
createdAt?: Date;
} | null>;
/**
* Check if user is authenticated (client-side)
*/
declare function isAuthenticatedReact(apiEndpoint?: string): Promise<boolean>;
/**
* Get auth token from cookies (client-side)
* Useful for making authenticated requests to your API
*/
declare function getAuthToken(): string | null;
/**
* Check if there's an auth token in cookies (client-side)
* This is a quick check without API call, but doesn't validate the token
*/
declare function hasAuthToken(): boolean;
declare function createUseAuthToken(): () => string | null;
/**
* Higher-order component for protecting React routes
* This is a factory function that returns the actual HOC
* Usage: const ProtectedComponent = withAuthReact(MyComponent);
*/
declare function withAuthReact(options?: {
fallback?: any;
redirectTo?: string;
checkAuthEndpoint?: string;
}): <P extends object>(WrappedComponent: any) => (props: P) => null;
export { createUseAuthToken, getAuthToken, getCurrentUserReact, hasAuthToken, isAuthenticatedReact, logoutReact, signinReact, signupReact, withAuthReact };