nucypher-experimental-taco-storage
Version:
TypeScript SDK for encrypted data storage with TACo (Threshold Access Control), supporting multiple storage providers including IPFS and SQLite
43 lines • 1.37 kB
JavaScript
/**
* Base storage adapter interface and abstract implementation
*/
/**
* Abstract base class providing common functionality for storage adapters
*/
export class BaseStorageAdapter {
constructor(config) {
this.config = { ...config };
}
/**
* Validate that required configuration is present
* @param requiredKeys - Array of required configuration keys
* @throws Error if required configuration is missing
*/
validateConfig(requiredKeys) {
const missingKeys = requiredKeys.filter(key => !(key in this.config));
if (missingKeys.length > 0) {
throw new Error(`Missing required configuration: ${missingKeys.join(', ')}`);
}
}
/**
* Validate data ID format
* @param id - The ID to validate
* @throws Error if ID format is invalid
*/
validateId(id) {
if (!id || typeof id !== 'string' || id.trim().length === 0) {
throw new Error('Invalid ID: must be a non-empty string');
}
}
/**
* Validate encrypted data
* @param data - The data to validate
* @throws Error if data is invalid
*/
validateData(data) {
if (!data || !(data instanceof Uint8Array) || data.length === 0) {
throw new Error('Invalid data: must be a non-empty Uint8Array');
}
}
}
//# sourceMappingURL=base.js.map