alepha
Version:
Easy-to-use modern TypeScript framework for building many kind of applications.
106 lines • 3.37 kB
TypeScript
import { Alepha } from "alepha";
import { Tokens } from "alepha/server/auth";
import { LinkProvider } from "alepha/server/links";
import { UserAccount, UserAccountToken } from "alepha/security";
import { HttpClient } from "alepha/server";
//#region ../../src/react/auth/hooks/useAuth.d.ts
declare const useAuth: <T extends object = any>() => {
user: {
id: string;
name?: string | undefined;
firstName?: string | undefined;
lastName?: string | undefined;
email?: string | undefined;
username?: string | undefined;
picture?: string | undefined;
sessionId?: string | undefined;
organization?: string | undefined;
roles?: string[] | undefined;
realm?: string | undefined;
} | undefined;
logout: () => void;
login: (provider: keyof T, options?: {
username?: string;
password?: string;
redirect?: string;
realm?: string;
[extra: string]: any;
}) => Promise<void>;
/**
* UI permission check — does the current user hold this permission?
* Supports exact and wildcard names (e.g. `"admin:*"`, `"admin:user:read"`).
*
* UI affordance only (show/hide/disable). Real access control is enforced
* server-side via `$secure` on the route/action.
*/
has: (permission: string) => boolean;
};
//#endregion
//#region ../../src/react/auth/services/ReactAuth.d.ts
/**
* Browser, SSR friendly, service to handle authentication.
*/
declare class ReactAuth {
protected readonly log: import("alepha/logger").Logger;
protected readonly alepha: Alepha;
protected readonly httpClient: HttpClient;
protected readonly linkProvider: LinkProvider;
protected readonly onBeginTransition: import("alepha").HookPrimitive<"react:transition:begin">;
protected readonly onFetchRequest: import("alepha").HookPrimitive<"client:onRequest">;
/**
* Get the current authenticated user.
*
* Alias for `alepha.state.get("user")`
*/
get user(): UserAccountToken | undefined;
ping(): Promise<{
id: string;
name?: string | undefined;
firstName?: string | undefined;
lastName?: string | undefined;
email?: string | undefined;
username?: string | undefined;
picture?: string | undefined;
sessionId?: string | undefined;
organization?: string | undefined;
roles?: string[] | undefined;
realm?: string | undefined;
} | undefined>;
can(action: string): boolean;
login(provider: string, options: {
hostname?: string;
username?: string;
password?: string;
redirect?: string;
realm?: string;
[extra: string]: any;
}): Promise<Tokens>;
logout(): void;
}
//#endregion
//#region ../../src/react/auth/providers/ReactAuthProvider.d.ts
declare class ReactAuthProvider {
protected readonly alepha: Alepha;
readonly onRender: import("alepha").HookPrimitive<"react:server:render:begin">;
}
//#endregion
//#region ../../src/react/auth/index.d.ts
declare module "alepha/react/router" {
interface ReactRouterState {
user?: UserAccount;
}
}
/**
* Auth-related React components and hooks.
*
* **Features:**
* - Login/logout components
* - Protected route wrappers
* - Auth state hooks
*
* @module alepha.react.auth
*/
declare const AlephaReactAuth: import("alepha").Service<import("alepha").Module>;
//#endregion
export { AlephaReactAuth, ReactAuth, ReactAuthProvider, useAuth };
//# sourceMappingURL=index.d.ts.map