nucypher-experimental-taco-storage
Version:
TypeScript SDK for encrypted data storage with TACo (Threshold Access Control), supporting multiple storage providers including IPFS and SQLite
121 lines • 5.01 kB
TypeScript
/**
* Main TACo Storage SDK class
*/
import { ethers } from 'ethers';
import { conditions } from '@nucypher/taco';
import { IStorageAdapter } from '../adapters/base';
import { TacoConfig, StorageMetadata, StorageResult, RetrievalResult } from '../types';
/**
* Options for storing data
*/
export interface StoreOptions {
/** Custom ID for the data (auto-generated if not provided) */
id?: string;
/** MIME type of the data */
contentType?: string;
/** Custom metadata to associate with the data */
metadata?: Record<string, unknown>;
/** Custom access conditions (if not provided, time-based condition will be used) */
condition?: conditions.condition.Condition;
/** Access expiry date (used if conditions not provided) */
expiresAt?: Date;
}
/**
* Main TACo Storage SDK class providing encrypted storage and retrieval
*/
export declare class TacoStorage {
private readonly adapter;
private readonly encryptionService;
private readonly provider;
constructor(adapter: IStorageAdapter, tacoConfig: TacoConfig, provider: ethers.providers.Provider);
/**
* Initialize the TacoStorage instance and its components
* @returns Promise that resolves when initialization is complete
*/
initialize(): Promise<void>;
/**
* Store data with encryption and access control
* @param data - Data to store
* @param signer - Ethereum signer for encryption
* @param options - Storage options
* @returns Promise resolving to storage result
*/
store(data: Uint8Array | string, signer: ethers.Signer, options?: StoreOptions): Promise<StorageResult>;
/**
* Retrieve and decrypt data
* @param id - Unique identifier for the data
* @param signer - Ethereum signer for decryption
* @returns Promise resolving to decrypted data and metadata
*/
retrieve(id: string, signer: ethers.Signer): Promise<RetrievalResult>;
/**
* Delete stored data
* @param id - Unique identifier for the data
* @returns Promise resolving to success status
*/
delete(id: string): Promise<boolean>;
/**
* Check if data exists
* @param id - Unique identifier for the data
* @returns Promise resolving to existence status
*/
exists(id: string): Promise<boolean>;
/**
* Get metadata for stored data without decrypting
* @param id - Unique identifier for the data
* @returns Promise resolving to storage metadata
*/
getMetadata(id: string): Promise<StorageMetadata>;
/**
* List stored data IDs (if supported by adapter)
* @param limit - Maximum number of IDs to return
* @param offset - Number of IDs to skip
* @returns Promise resolving to array of IDs
*/
list(limit?: number, offset?: number): Promise<string[]>;
/**
* Get health status of the storage system
* @returns Promise resolving to health information
*/
getHealth(): Promise<{
healthy: boolean;
details?: Record<string, unknown>;
}>;
/**
* Clean up resources
*/
cleanup(): Promise<void>;
/**
* Create a new TacoStorage instance with IPFS adapter
* @param config - TACo configuration
* @param provider - Ethereum provider
* @param ipfsConfig - IPFS adapter configuration
* @returns Promise resolving to initialized TacoStorage instance
*/
static createWithIPFS(config: TacoConfig, provider: ethers.providers.Provider, ipfsConfig?: import('../adapters/ipfs/index').IPFSAdapterConfig): Promise<TacoStorage>;
/**
* Create a new TacoStorage instance with Kubo IPFS adapter
* @param config - TACo configuration
* @param provider - Ethereum provider
* @param kuboConfig - Kubo adapter configuration
* @returns Promise resolving to initialized TacoStorage instance
*/
static createWithKubo(config: TacoConfig, provider: ethers.providers.Provider, kuboConfig?: import('../adapters/ipfs/index').KuboAdapterConfig): Promise<TacoStorage>;
/**
* Create a new TacoStorage instance with Helia IPFS adapter
* @param config - TACo configuration
* @param provider - Ethereum provider
* @param heliaConfig - Helia adapter configuration
* @returns Promise resolving to initialized TacoStorage instance
*/
static createWithHelia(config: TacoConfig, provider: ethers.providers.Provider, heliaConfig?: import('../adapters/ipfs/index').HeliaAdapterConfig): Promise<TacoStorage>;
/**
* Create a new TacoStorage instance with SQLite adapter
* @param config - TACo configuration
* @param provider - Ethereum provider
* @param sqliteConfig - SQLite adapter configuration
* @returns Promise resolving to initialized TacoStorage instance
*/
static createWithSQLite(config: TacoConfig, provider: ethers.providers.Provider, sqliteConfig?: import('../adapters/sqlite').SQLiteAdapterConfig): Promise<TacoStorage>;
}
//# sourceMappingURL=storage.d.ts.map