/* tslint:disable */ /* eslint-disable */ export class NKodeClient { free(): void; [Symbol.dispose](): void; /** * Login with OPAQUE code-based authentication. * Stores the session key internally for subsequent authenticated requests. * * @param email - User's email address * @param passcodeBytes - Passcode as Uint8Array * @returns Promise */ loginCode(email: string, passcode_bytes: Uint8Array): Promise; /** * Get the current session's user ID, or null if not logged in. */ getUserId(): string | undefined; /** * Check if the client has an active session (from a prior login call). */ hasSession(): boolean; /** * Register a new user via OPAQUE key-based registration. * * @param email - User's email address * @param secretKeyHex - 16-byte secret key as hex string (32 chars) * @returns Promise - Resolves on success, rejects with error string */ registerKey(email: string, secret_key_hex: string): Promise; /** * Clear the stored session (local logout). */ clearSession(): void; /** * Fetch new icons from the server (requires active key session). * * @param count - Number of icons to fetch * @returns Promise - JSON: { icons: [{ file_name, file_type, img_data }] } */ getNewIcons(count: number): Promise; /** * Register via OPAQUE code-based registration. * * @param email - User's email address * @param passcodeBytes - Passcode as Uint8Array * @returns Promise */ registerCode(email: string, passcode_bytes: Uint8Array): Promise; /** * Get login data for a user (requires active session). * * @param userId - Target user ID (must match session user) * @returns Promise - JSON with keypad config */ getLoginData(user_id: string): Promise; /** * Create new login data on the server (requires active key session). * * @param loginDataJson - JSON string of LoginDataPayload * @returns Promise */ postLoginData(login_data_json: string): Promise; /** * Update login data on the server (requires active key session). * * @param loginDataJson - JSON string of LoginDataPayload * @returns Promise */ updateLoginData(login_data_json: string): Promise; /** * Decipher key selections into OPAQUE passcode bytes for code login. * Call this after the user taps their nKode sequence on the keypad. * * @param userId - The user's ID * @param secretKeyHex - The user's secret key as hex * @param loginDataBytes - Raw JSON bytes of login data (from server) * @param keySelections - Array of key indices the user tapped * @returns Uint8Array - The passcode bytes to pass to loginCode() */ decipherSelection(secret_key_hex: string, login_data_json: string, key_selections: Uint32Array): Uint8Array; /** * Prepare for code login: fetch login data, reconstruct keypad, and fetch icons. * Returns the keypad configuration with icons for UI display. * * Also stores the raw login data JSON internally for decipherSelection(). * * @param userId - The user's ID * @param secretKeyHex - The user's secret key as hex string * @returns Promise - { keypadIndices, propertiesPerKey, numberOfKeys, mask, icons, loginDataJson } */ prepareCodeLogin(user_id: string, secret_key_hex: string): Promise; /** * Generate a new random 16-byte secret key, returned as a hex string (32 chars). */ static generateSecretKey(): string; /** * Prepare icons for code registration (requires active key session). * Fetches icons from the server and randomizes their names via ChaCha20. * Stores intermediate state internally for completeCodeRegistration(). * * @returns Promise - JSON: { icons: [{ file_name, file_type, img_data }] } */ prepareCodeRegistration(): Promise; /** * Complete code registration after icon selection. * Enciphers the selection, registers OPAQUE code auth, and stores login data. * * @param selectedIndices - Array of icon indices the user selected (global indices, not key indices) * @returns Promise */ completeCodeRegistration(selected_indices: Uint32Array): Promise; /** * Complete code registration with email (full version). * Enciphers the selection, registers OPAQUE code auth, and stores login data on server. * * @param email - User's email address * @param selectedIndices - Uint32Array of icon indices the user selected * @returns Promise */ completeCodeRegistrationWithEmail(email: string, selected_indices: Uint32Array): Promise; /** * Create a new client pointed at the given nKode server base URL. */ constructor(base_url: string); /** * Login with OPAQUE key-based authentication. * Stores the session key internally for subsequent authenticated requests. * * @param email - User's email address * @param secretKeyHex - 16-byte secret key as hex string * @returns Promise - Session info object */ loginKey(email: string, secret_key_hex: string): Promise; /** * Set (store) icons on the server (requires active key session). * * @param iconsJson - JSON string of { icons: [{ file_name, file_type, img_data }] } * @returns Promise */ setIcons(icons_json: string): Promise; } /** * Initialize panic hook for better error messages in browser console. */ export function init(): void;