UNPKG

buildx-connect

Version:

Official JavaScript/TypeScript SDK for Buildx low-code platform

113 lines (112 loc) 3.47 kB
import { AuthUser, LoginCredentials, GoogleCredentials, EotpRequest, EotpVerify, ErrorResponse, SuccessResponse, BuildxConfig } from "../types/index"; /** * Authentication service for Buildx * Handles user authentication, login, signup, and user management * * @example * ```typescript * const auth = buildx.auth(); * * // Login with username and password * const result = await auth.login({ username: 'user', password: 'pass' }); * * // Get current user * const user = await auth.getCurrentUser(); * * // Sign up new user * const newUser = await auth.signup({ username: 'newuser', password: 'pass' }); * ``` */ export declare class Auth { private baseService; constructor(config: BuildxConfig); updateConfig(config: BuildxConfig): void; /** * Set the access token */ setAccessToken(token: string | null): void; /** * Get the access token */ getAccessToken(): string | null; /** * Set the refresh token */ setRefreshToken(token: string | null): void; /** * Get the refresh token */ getRefreshToken(): string | null; /** * Clear all stored tokens */ clearTokens(): void; /** * Check if user is authenticated */ isAuthenticated(): boolean; /** * Store tokens from authentication response */ private storeTokens; /** * Check if response is an error response */ private isErrorResponse; /** * Login with username and password */ login(credentials: LoginCredentials, projectId?: string): Promise<AuthUser | ErrorResponse>; /** * Login with Google credentials */ loginWithGoogle(credentials: GoogleCredentials, projectId?: string): Promise<AuthUser | ErrorResponse>; /** * Sign up a new user */ signup(credentials: LoginCredentials, projectId?: string): Promise<AuthUser | ErrorResponse>; /** * Request email OTP for authentication */ requestEotp(request: EotpRequest, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Verify email OTP */ verifyEotp(verify: EotpVerify, projectId?: string): Promise<AuthUser | ErrorResponse>; /** * Get current authenticated user */ getCurrentUser(projectId?: string): Promise<AuthUser | ErrorResponse>; /** * Refresh authentication token */ refreshToken(projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Update user password */ updatePassword(password: string, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Admin update user password */ adminUpdatePassword(userId: string, password: string, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Update push notification token */ updatePushToken(token: string, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * List all users (admin only) */ listUsers(organizationId?: string): Promise<AuthUser[] | ErrorResponse>; /** * Lookup users (for autocomplete/search) */ lookupUsers(organizationId?: string): Promise<AuthUser[] | ErrorResponse>; /** * Get user by ID */ getUser(userId: string, organizationId?: string): Promise<AuthUser | ErrorResponse>; /** * Delete user (admin only) */ deleteUser(userId: string, projectId?: string): Promise<SuccessResponse | ErrorResponse>; }