/**
 * authdb-client – Native Node.js client bindings for AuthDB.
 */

export interface SessionInfo {
    sessionId: string;
    userId: string;
    username: string;
    domainId: string;
}

export declare class ClientConnection {
    constructor();

    /** Set the AuthDB server URL. */
    setUrl(url: string): void;

    /** Set the client application name. */
    setClientName(name: string): void;

    /** Set the client application secret. */
    setClientSecret(secret: string): void;

    /** Set the username for authentication. */
    setUsername(username: string): void;

    /** Set the user password for authentication. */
    setUserPassword(password: string): void;

    /** Get the client ID (UUID) assigned by the server. */
    getClientId(): string;

    /** Get the current session ID (UUID). */
    getSessionID(): string;

    /** Set an existing session ID (UUID). */
    setSessionID(sessionId: string): void;

    /** Reconnect to the AuthDB server. */
    reConnect(): void;
}

export declare class Client {
    constructor(connection: ClientConnection);

    /** Authenticate using username / password. Returns true on success. */
    userAuth(): boolean;

    /** Authenticate using client credentials. Returns true on success. */
    clientAuth(): boolean;

    /** Register a new client connection. Returns the new client DB ID. */
    addConnection(clientName: string, clientSecret: string): string;

    /** Remove a client connection by client ID (UUID). */
    remConnection(clientId: string): void;

    /** Edit an existing client connection. */
    editConnection(clientId: string, name: string, secret: string): void;

    /** Retrieve information about the current session. */
    sessionInfo(): SessionInfo;

    /** Remove (invalidate) the current session. Returns true on success. */
    remSession(): boolean;

    /** Check a GPO (Group Policy Object) by ID. Returns true if the check passes. */
    gpoCheck(gpoId: string): boolean;

    /** Check whether a GPO exists by ID. Returns true if it exists. */
    gpoExists(gpoId: string): boolean;

    /** Add a new GPO. Returns the new GPO ID (UUID). Requires clientSession auth. */
    gpoAdd(gpoId: string, name: string, desc: string, gpoDefault: boolean, members: string[]): string;

    /** Change the current user's password. */
    changeUserPw(oldPassword: string, newPassword: string): void;
}
