/** * @module edv-service * @description Encrypted Data Vault (EDV) service for the Wallet SDK. * This module provides secure, encrypted storage functionality using EDV protocol, * enabling privacy-preserving data storage with client-side encryption. */ import { InitializeEDVParams } from './configs'; import EDVHTTPStorageInterface from '@docknetwork/universal-wallet/storage/edv-http-storage'; export declare const HKDF_LENGTH = 32; export declare const HKDF_HASH = "SHA-256"; /** * Service class for managing Encrypted Data Vaults * @class * @description Provides methods for creating, managing, and interacting with * encrypted data vaults for secure storage of sensitive wallet data */ export declare class EDVService { storageInterface: EDVHTTPStorageInterface; private insertQueue; controller: string; rpcMethods: (((params: any) => any) | ((biometricData: Buffer, identifier: string) => Buffer) | ((biometricData: Buffer, identifier: string) => Promise<{ key: Buffer; iv: Buffer; }>) | ((masterKey: Uint8Array, encryptionKey: Buffer, iv: Buffer) => Promise))[]; /** * Creates a new EDVService instance * @constructor */ constructor(); /** * Initializes the EDV service with encryption keys and connection parameters * @param {InitializeEDVParams} params - Initialization parameters * @param {Object} params.hmacKey - HMAC key for document indexing * @param {Object} params.agreementKey - Key agreement key for encryption * @param {Object} params.verificationKey - Verification key for authentication * @param {string} params.edvUrl - URL of the EDV server * @param {string} params.authKey - Authentication key for the EDV server * @returns {Promise} * @throws {Error} If unable to create or connect to EDV * @example * await edvService.initialize({ * hmacKey: hmacKeyData, * agreementKey: agreementKeyData, * verificationKey: verificationKeyData, * edvUrl: 'https://edv.example.com', * authKey: 'auth-token-123' * }); */ initialize({ hmacKey, agreementKey, verificationKey, edvUrl, authKey, }: InitializeEDVParams): Promise; initializeFromMnemonic({ mnemonic, edvUrl, authKey, }: { mnemonic: string; edvUrl: string; authKey: string; }): Promise; initializeFromMasterKey({ masterKey, edvUrl, authKey, }: { masterKey: Uint8Array; edvUrl: string; authKey: string; }): Promise; /** * Generates new cryptographic keys for EDV operations * @returns {Promise} Generated keys * @returns {Object} returns.verificationKey - Ed25519 verification key for authentication * @returns {Object} returns.agreementKey - X25519 key agreement key for encryption * @returns {Object} returns.hmacKey - HMAC key for indexing * @example * const keys = await edvService.generateKeys(); * // Use keys for EDV initialization * await edvService.initialize({ * ...keys, * edvUrl: 'https://edv.example.com', * authKey: 'auth-token' * }); */ generateKeys(): Promise<{ verificationKey: any; agreementKey: any; hmacKey: any; }>; /** * Derives cryptographic keys from a master key * @param {Uint8Array} masterKey - Master key for derivation * @returns {Promise} Derived keys * @returns {Object} returns.verificationKey - Derived Ed25519 verification key * @returns {Object} returns.agreementKey - Derived X25519 key agreement key * @returns {Object} returns.hmacKey - Derived HMAC key * @example * const masterKey = new Uint8Array(32); // Your master key * const keys = await edvService.deriveKeys(masterKey); */ deriveKeys(masterKey: Uint8Array): Promise<{ verificationKey: any; agreementKey: any; hmacKey: any; }>; /** * Gets the controller identifier for the current EDV * @returns {Promise} The controller DID or identifier * @example * const controller = await edvService.getController(); * console.log('EDV Controller:', controller); */ getController(): Promise; /** * Finds documents in the EDV based on query parameters. * * If the vault has not been indexed yet (e.g. a freshly created cloud wallet * with no documents), the EDV server responds with a "Vault indices do not * exist" error. This method catches that specific error and returns an empty * result set instead of throwing, so callers can treat an uninitialised vault * the same as an empty one. All other errors are re-thrown. * * @param {Object} params - Query parameters forwarded to the EDV storage interface * @param {Object} [params.equals] - Equality-based query conditions (e.g. `{ 'content.type': 'VerifiableCredential' }`) * @param {boolean} [params.has] - Existence-based query conditions * @param {number} [params.limit] - Maximum number of results to return * @returns {Promise<{ documents: Array }>} Object containing an array of matching documents * @throws {Error} If the EDV query fails for reasons other than missing vault indices * @example * // Query all documents * const result = await edvService.find({}); * console.log(result.documents); * * @example * // Query with filters * const result = await edvService.find({ * equals: { 'content.type': 'VerifiableCredential' }, * limit: 10 * }); */ find(params: any): Promise; /** * Updates a document in the EDV * @param {Object} params - Update parameters * @param {string} params.id - Document ID to update * @param {Object} params.content - New document content * @returns {Promise} Updated document * @example * const updated = await edvService.update({ * id: 'doc-123', * content: { ...existingContent, updated: true } * }); */ update(params: any): any; /** * Inserts a new document into the EDV * @param {Object} params - Insert parameters * @param {string} params.id - Document ID * @param {Object} params.content - Document content to store * @returns {Promise} The inserted document * @throws {Error} If insertion fails * @example * const document = await edvService.insert({ * id: 'doc-456', * content: { * type: 'VerifiableCredential', * data: credentialData * } * }); */ insert(params: any): Promise; /** * Deletes a document from the EDV * @param {Object} params - Deletion parameters * @param {string} params.id - Document ID to delete * @returns {Promise} True if deletion successful * @example * const deleted = await edvService.delete({ * id: 'doc-123' * }); */ delete(params: any): any; /** * Derives a key from biometric data using HKDF * @param {Buffer} biometricData - Biometric data from provider * @param {string} identifier - User's identifier as salt (email, phone number, etc.) * @returns {Buffer} Derived key * @example * const key = edvService.deriveBiometricKey(biometricData, 'user@example.com'); */ deriveBiometricKey(biometricData: Buffer, identifier: string): Buffer; /** * Generates a key for encrypting/decrypting the master key * @param {Buffer} biometricData - Biometric data from provider * @param {string} identifier - User's identifier as salt (email, phone number, etc.) * @returns {Promise} Encryption key and IV for AES encryption * @returns {Buffer} returns.key - Encryption key * @returns {Buffer} returns.iv - Initialization vector * @example * const { key, iv } = await edvService.deriveBiometricEncryptionKey(biometricData, 'user@example.com'); */ deriveBiometricEncryptionKey(biometricData: Buffer, identifier: string): Promise<{ key: Buffer; iv: Buffer; }>; /** * Encrypts the master key using a key derived from biometric data * @param {Uint8Array} masterKey - The CloudWalletVault master key to encrypt * @param {Buffer} encryptionKey - Key derived from biometric data * @param {Buffer} iv - Initialization vector * @returns {Promise} Encrypted master key * @example * const encrypted = await edvService.encryptMasterKey(masterKey, encryptionKey, iv); */ encryptMasterKey(masterKey: Uint8Array, encryptionKey: Buffer, iv: Buffer): Promise; /** * Decrypts the master key using biometric-derived key * @param {Uint8Array} encryptedKey - The encrypted master key * @param {Buffer} decryptionKey - Key derived from biometric data * @param {Buffer} iv - Initialization vector * @returns {Promise} The decrypted master key * @throws {Error} If decryption fails * @example * const masterKey = await edvService.decryptMasterKey(encryptedKey, decryptionKey, iv); */ decryptMasterKey(encryptedKey: Uint8Array | Record, decryptionKey: Buffer | Uint8Array | Record, iv: Buffer | Uint8Array | Record): Promise; } /** * Singleton instance of the EDV service * @type {EDVService} * @example * import { edvService } from '@docknetwork/wallet-sdk-wasm/services/edv'; * * // Generate keys and initialize * const keys = await edvService.generateKeys(); * await edvService.initialize({ * ...keys, * edvUrl: 'https://edv.example.com', * authKey: 'auth-token' * }); * * // Store encrypted data * await edvService.insert({ * id: 'credential-1', * content: { * type: 'VerifiableCredential', * data: credentialData * } * }); * * // Query encrypted data * const credentials = await edvService.find({ * equals: { 'content.type': 'VerifiableCredential' } * }); * * // Update encrypted data * await edvService.update({ * id: 'credential-1', * content: updatedData * }); */ export declare const edvService: EDVService; //# sourceMappingURL=service.d.ts.map