149 lines
5.4 KiB
TypeScript
149 lines
5.4 KiB
TypeScript
/* 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<NKodeSession>
|
|
*/
|
|
loginCode(email: string, passcode_bytes: Uint8Array): Promise<any>;
|
|
/**
|
|
* 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<void> - Resolves on success, rejects with error string
|
|
*/
|
|
registerKey(email: string, secret_key_hex: string): Promise<void>;
|
|
/**
|
|
* 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<IconsResponse> - JSON: { icons: [{ file_name, file_type, img_data }] }
|
|
*/
|
|
getNewIcons(count: number): Promise<any>;
|
|
/**
|
|
* Register via OPAQUE code-based registration.
|
|
*
|
|
* @param email - User's email address
|
|
* @param passcodeBytes - Passcode as Uint8Array
|
|
* @returns Promise<void>
|
|
*/
|
|
registerCode(email: string, passcode_bytes: Uint8Array): Promise<void>;
|
|
/**
|
|
* Get login data for a user (requires active session).
|
|
*
|
|
* @param userId - Target user ID (must match session user)
|
|
* @returns Promise<LoginDataPayload> - JSON with keypad config
|
|
*/
|
|
getLoginData(user_id: string): Promise<any>;
|
|
/**
|
|
* Create new login data on the server (requires active key session).
|
|
*
|
|
* @param loginDataJson - JSON string of LoginDataPayload
|
|
* @returns Promise<void>
|
|
*/
|
|
postLoginData(login_data_json: string): Promise<void>;
|
|
/**
|
|
* Update login data on the server (requires active key session).
|
|
*
|
|
* @param loginDataJson - JSON string of LoginDataPayload
|
|
* @returns Promise<void>
|
|
*/
|
|
updateLoginData(login_data_json: string): Promise<void>;
|
|
/**
|
|
* 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<CodeLoginData> - { keypadIndices, propertiesPerKey, numberOfKeys, mask, icons, loginDataJson }
|
|
*/
|
|
prepareCodeLogin(user_id: string, secret_key_hex: string): Promise<any>;
|
|
/**
|
|
* 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<IconsResponse> - JSON: { icons: [{ file_name, file_type, img_data }] }
|
|
*/
|
|
prepareCodeRegistration(): Promise<any>;
|
|
/**
|
|
* 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<void>
|
|
*/
|
|
completeCodeRegistration(selected_indices: Uint32Array): Promise<void>;
|
|
/**
|
|
* 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<void>
|
|
*/
|
|
completeCodeRegistrationWithEmail(email: string, selected_indices: Uint32Array): Promise<void>;
|
|
/**
|
|
* 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<NKodeSession> - Session info object
|
|
*/
|
|
loginKey(email: string, secret_key_hex: string): Promise<any>;
|
|
/**
|
|
* Set (store) icons on the server (requires active key session).
|
|
*
|
|
* @param iconsJson - JSON string of { icons: [{ file_name, file_type, img_data }] }
|
|
* @returns Promise<void>
|
|
*/
|
|
setIcons(icons_json: string): Promise<void>;
|
|
}
|
|
|
|
/**
|
|
* Initialize panic hook for better error messages in browser console.
|
|
*/
|
|
export function init(): void;
|