lotus-sdk
Version:
Central repository for several classes of tools for integrating with, and building for, the Lotusia ecosystem
51 lines (50 loc) • 1.81 kB
JavaScript
export var DiscoveryErrorType;
(function (DiscoveryErrorType) {
DiscoveryErrorType["INVALID_ADVERTISEMENT"] = "INVALID_ADVERTISEMENT";
DiscoveryErrorType["ADVERTISEMENT_EXPIRED"] = "ADVERTISEMENT_EXPIRED";
DiscoveryErrorType["SECURITY_VALIDATION_FAILED"] = "SECURITY_VALIDATION_FAILED";
DiscoveryErrorType["DHT_OPERATION_FAILED"] = "DHT_OPERATION_FAILED";
DiscoveryErrorType["NETWORK_TIMEOUT"] = "NETWORK_TIMEOUT";
DiscoveryErrorType["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
DiscoveryErrorType["INVALID_CRITERIA"] = "INVALID_CRITERIA";
DiscoveryErrorType["SUBSCRIPTION_ERROR"] = "SUBSCRIPTION_ERROR";
DiscoveryErrorType["CACHE_ERROR"] = "CACHE_ERROR";
DiscoveryErrorType["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
DiscoveryErrorType["SIGNATURE_ERROR"] = "SIGNATURE_ERROR";
})(DiscoveryErrorType || (DiscoveryErrorType = {}));
export class DiscoveryError extends Error {
type;
cause;
constructor(type, message, cause) {
super(message);
this.name = 'DiscoveryError';
this.type = type;
this.cause = cause;
}
}
export const DEFAULT_DISCOVERY_OPTIONS = {
ttl: 30 * 60 * 1000,
replicas: 3,
autoRefresh: true,
refreshInterval: 20 * 60 * 1000,
enableCache: true,
cacheTTL: 5 * 60 * 1000,
maxRetries: 3,
retryDelay: 1000,
enableRateLimit: true,
rateLimitWindow: 60 * 1000,
maxOperationsPerWindow: 10,
};
export const DEFAULT_SECURITY_POLICY = {
minReputation: 50,
maxAdvertisementAge: 60 * 60 * 1000,
enableSignatureVerification: true,
enableReplayPrevention: true,
enableRateLimiting: true,
rateLimits: {
maxAdvertisementsPerPeer: 5,
maxDiscoveryQueriesPerPeer: 20,
windowSizeMs: 60 * 1000,
},
customValidators: [],
};