UNPKG

apacuana-sdk-web

Version:

Apacuana SDK for Web

62 lines (61 loc) 3.2 kB
import { EncryptedData } from "../types"; /** * Checks if a record exists in IndexedDB for the given key. * @param keyId The key to look for (e.g., customerId). * @returns A Promise that resolves to true if the record exists, false otherwise. */ export declare function checkRecordExists(keyId: string): Promise<boolean>; /** * Stores a value in IndexedDB under a specific field for a given user ID. * This function handles both plain and encrypted values. * @param field The name of the field to store the data under. * @param value The value to store. * @param keyId The user's unique identifier. */ export declare function storeValue(field: string, value: unknown, // Cambiado de 'any' a 'unknown' keyId: string): Promise<void>; /** * Retrieves a value from IndexedDB for a given user ID and field. * @param field The name of the field to retrieve. * @param keyId The user's unique identifier. * @returns A Promise that resolves with the retrieved value, or undefined if not found. */ export declare function getValue<T>(field: string, keyId: string): Promise<T | undefined>; /** * Encrypts a value and stores it in IndexedDB. * @param field The name of the field to store the data under. * @param data The data to encrypt and store. * @param keyId The user's unique identifier. * @param password The password used for encryption. */ export declare function encryptAndStoreValue(field: string, data: string | ArrayBuffer, keyId: string, password: string): Promise<void>; /** * Encrypts data using a password-derived key with AES-GCM. * @param data The data to encrypt (string or ArrayBuffer). * @param password The password to derive the encryption key from. * @returns A Promise that resolves to an object containing the encrypted data, salt, and IV. */ export declare function encryptData(data: string | ArrayBuffer, password: string): Promise<EncryptedData>; /** * Decrypts data using a password-derived key with AES-GCM. * @param encryptedPayload The object containing encrypted data, salt, and IV. * @param password The password to derive the decryption key from. * @returns A Promise that resolves to the decrypted data as an ArrayBuffer. */ export declare function decryptData(encryptedPayload: EncryptedData, password: string): Promise<ArrayBuffer>; /** * Retrieves an encrypted value from IndexedDB and decrypts it. * @param field The field name where the data is stored. * @param keyId The user's unique identifier. * @param password The password for decryption. * @param asString If true, returns the decrypted data as a string. Otherwise, as ArrayBuffer. * @returns The decrypted data, or undefined if not found. */ export declare function retrieveAndDecryptValue<T extends string | ArrayBuffer>(field: string, keyId: string, password: string): Promise<T | undefined>; export declare function signDigest(digest: string, privateKeyBase64: string): Promise<string>; /** * Retrieves a full record from IndexedDB for a given key. * @param keyId The key to look for (e.g., customerId). * @returns A Promise that resolves with the record object, or undefined if not found. */ export declare function getRecord<T>(keyId: string): Promise<T | undefined>;