bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
164 lines (163 loc) • 6.91 kB
TypeScript
import type { AuthActionResponse } from "../../auth/api/AuthController";
import type { AuthResponse, SafeUser, Strategy } from "../../auth/authenticate/Authenticator";
import { type BaseModuleApiOptions, ModuleApi } from "../../modules/ModuleApi";
export type AuthApiOptions = BaseModuleApiOptions & {
onTokenUpdate?: (token?: string) => void | Promise<void>;
credentials?: "include" | "same-origin" | "omit";
};
export declare class AuthApi extends ModuleApi<AuthApiOptions> {
protected getDefaultOptions(): Partial<AuthApiOptions>;
login(strategy: string, input: any): Promise<import("../../modules/ModuleApi").ResponseObject<AuthResponse, AuthResponse>>;
register(strategy: string, input: any): Promise<import("../../modules/ModuleApi").ResponseObject<AuthResponse, AuthResponse>>;
actionSchema(strategy: string, action: string): Promise<import("../../modules/ModuleApi").ResponseObject<Strategy, Strategy>>;
action(strategy: string, action: string, input: any): Promise<import("../../modules/ModuleApi").ResponseObject<AuthActionResponse, AuthActionResponse>>;
/**
* @deprecated use login("password", ...) instead
* @param input
*/
loginWithPassword(input: any): Promise<import("../../modules/ModuleApi").ResponseObject<AuthResponse, AuthResponse>>;
/**
* @deprecated use register("password", ...) instead
* @param input
*/
registerWithPassword(input: any): Promise<import("../../modules/ModuleApi").ResponseObject<AuthResponse, AuthResponse>>;
me(): import("../../modules/ModuleApi").FetchPromise<import("../../modules/ModuleApi").ResponseObject<{
user: SafeUser | null;
}, {
user: SafeUser | null;
}>>;
strategies(): import("../../modules/ModuleApi").FetchPromise<import("../../modules/ModuleApi").ResponseObject<Pick<{
allow_register?: boolean | undefined;
strategies?: {
[x: string]: {
enabled?: boolean | undefined;
type: "password" | "oauth" | "custom_oauth";
config: {
type: "oidc" | "oauth2";
name: "google" | "github";
client: {
client_id: string;
client_secret: string;
};
} | {
type: "oidc" | "oauth2";
name: string;
client: {
client_id: string;
client_secret: string;
token_endpoint_auth_method: "client_secret_basic";
};
as: {
code_challenge_methods_supported?: "S256" | undefined;
scopes_supported?: string[] | undefined;
scope_separator?: string | undefined;
authorization_endpoint?: string | undefined;
token_endpoint?: string | undefined;
userinfo_endpoint?: string | undefined;
issuer: string;
};
} | {
rounds?: number | undefined;
hashing: "plain" | "sha256" | "bcrypt";
};
};
} | undefined;
guard?: {
enabled?: boolean | undefined;
} | undefined;
roles?: {
[x: string]: {
permissions?: string[] | undefined;
is_default?: boolean | undefined;
implicit_allow?: boolean | undefined;
};
} | undefined;
cookie: {
path?: string | undefined;
expires?: number | undefined;
sameSite?: "strict" | "lax" | "none" | undefined;
secure?: boolean | undefined;
httpOnly?: boolean | undefined;
renew?: boolean | undefined;
pathSuccess?: string | undefined;
pathLoggedOut?: string | undefined;
};
enabled: boolean;
basepath: string;
entity_name: string;
jwt: {
alg?: "HS256" | "HS384" | "HS512" | undefined;
expires?: number | undefined;
issuer?: string | undefined;
secret: string;
fields: string[];
};
}, "basepath" | "strategies">, Pick<{
allow_register?: boolean | undefined;
strategies?: {
[x: string]: {
enabled?: boolean | undefined;
type: "password" | "oauth" | "custom_oauth";
config: {
type: "oidc" | "oauth2";
name: "google" | "github";
client: {
client_id: string;
client_secret: string;
};
} | {
type: "oidc" | "oauth2";
name: string;
client: {
client_id: string;
client_secret: string;
token_endpoint_auth_method: "client_secret_basic";
};
as: {
code_challenge_methods_supported?: "S256" | undefined;
scopes_supported?: string[] | undefined;
scope_separator?: string | undefined;
authorization_endpoint?: string | undefined;
token_endpoint?: string | undefined;
userinfo_endpoint?: string | undefined;
issuer: string;
};
} | {
rounds?: number | undefined;
hashing: "plain" | "sha256" | "bcrypt";
};
};
} | undefined;
guard?: {
enabled?: boolean | undefined;
} | undefined;
roles?: {
[x: string]: {
permissions?: string[] | undefined;
is_default?: boolean | undefined;
implicit_allow?: boolean | undefined;
};
} | undefined;
cookie: {
path?: string | undefined;
expires?: number | undefined;
sameSite?: "strict" | "lax" | "none" | undefined;
secure?: boolean | undefined;
httpOnly?: boolean | undefined;
renew?: boolean | undefined;
pathSuccess?: string | undefined;
pathLoggedOut?: string | undefined;
};
enabled: boolean;
basepath: string;
entity_name: string;
jwt: {
alg?: "HS256" | "HS384" | "HS512" | undefined;
expires?: number | undefined;
issuer?: string | undefined;
secret: string;
fields: string[];
};
}, "basepath" | "strategies">>>;
logout(): Promise<void>;
}