rdapify 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ar.md +572 -0
- package/README.md +74 -77
- package/dist/{application → cjs/application}/client/RDAPClient.js +197 -6
- package/dist/{application → cjs/application}/client/index.js +0 -1
- package/dist/{application → cjs/application}/deduplication/QueryDeduplicator.js +0 -1
- package/dist/{application → cjs/application}/hooks/MiddlewareHooks.js +0 -1
- package/dist/{application → cjs/application}/services/BatchProcessor.js +0 -1
- package/dist/{application → cjs/application}/services/QueryOrchestrator.js +0 -1
- package/dist/{application → cjs/application}/services/QueryPriority.js +0 -1
- package/dist/{application → cjs/application}/services/index.js +0 -1
- package/dist/{cli → cjs/cli}/index.js +0 -1
- package/dist/cjs/core/ports/bootstrap.port.js +2 -0
- package/dist/cjs/core/ports/cache.port.js +2 -0
- package/dist/cjs/core/ports/fetcher.port.js +2 -0
- package/dist/{core → cjs/core}/ports/index.js +0 -1
- package/dist/cjs/core/ports/normalizer.port.js +2 -0
- package/dist/cjs/core/ports/pii-redactor.port.js +2 -0
- package/dist/{index.js → cjs/index.js} +8 -4
- package/dist/{infrastructure → cjs/infrastructure}/cache/CacheManager.js +4 -1
- package/dist/{infrastructure → cjs/infrastructure}/cache/InMemoryCache.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/cache/PersistentCache.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/cache/RedisCache.js +0 -1
- package/dist/cjs/infrastructure/cache/StaleWhileRevalidateCache.js +47 -0
- package/dist/{infrastructure → cjs/infrastructure}/cache/index.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/AuthenticationManager.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/BootstrapDiscovery.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/BrowserFetcher.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/BunFetcher.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/CircuitBreaker.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/CloudflareWorkersFetcher.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/CompressionManager.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/ConnectionPool.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/DenoFetcher.js +0 -1
- package/dist/cjs/infrastructure/http/DistributedRateLimiter.js +26 -0
- package/dist/{infrastructure → cjs/infrastructure}/http/Fetcher.js +5 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/Normalizer.js +23 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/ProxyManager.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/RateLimiter.js +6 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/RetryStrategy.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/http/index.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/logging/AuditLogger.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/logging/Logger.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/monitoring/GrafanaDashboard.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/monitoring/MetricsCollector.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/monitoring/PrometheusExporter.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/monitoring/TelemetryExporter.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/native/NativeBackend.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/security/PIIRedactor.js +0 -1
- package/dist/{infrastructure → cjs/infrastructure}/security/SSRFProtection.js +23 -1
- package/dist/{infrastructure → cjs/infrastructure}/security/index.js +0 -1
- package/dist/cjs/infrastructure/telemetry/UsageTelemetry.js +89 -0
- package/dist/{infrastructure → cjs/infrastructure}/validation/ResponseValidator.js +0 -1
- package/dist/{integrations → cjs/integrations}/express.js +0 -1
- package/dist/{integrations → cjs/integrations}/graphql.js +0 -1
- package/dist/{integrations → cjs/integrations}/nestjs.js +0 -1
- package/dist/{shared → cjs/shared}/constants/http.constants.js +0 -1
- package/dist/{shared → cjs/shared}/constants/index.js +0 -1
- package/dist/{shared → cjs/shared}/constants/rdap.constants.js +0 -1
- package/dist/{shared → cjs/shared}/errors/base.error.js +7 -2
- package/dist/{shared → cjs/shared}/errors/index.js +0 -1
- package/dist/{shared → cjs/shared}/types/entities.js +0 -1
- package/dist/{shared → cjs/shared}/types/enums.js +0 -1
- package/dist/{shared → cjs/shared}/types/errors.js +0 -1
- package/dist/{shared → cjs/shared}/types/generics.js +0 -1
- package/dist/{shared → cjs/shared}/types/index.js +0 -1
- package/dist/{shared → cjs/shared}/types/options.js +5 -1
- package/dist/cjs/shared/types/responses.js +2 -0
- package/dist/{shared → cjs/shared}/utils/deprecation.js +0 -1
- package/dist/{shared → cjs/shared}/utils/enhanced-validators.js +0 -1
- package/dist/{shared → cjs/shared}/utils/helpers/async.js +0 -1
- package/dist/{shared → cjs/shared}/utils/helpers/cache.js +0 -1
- package/dist/{shared → cjs/shared}/utils/helpers/format.js +0 -1
- package/dist/{shared → cjs/shared}/utils/helpers/http.js +0 -1
- package/dist/{shared → cjs/shared}/utils/helpers/index.js +0 -1
- package/dist/{shared → cjs/shared}/utils/helpers/object.js +0 -1
- package/dist/{shared → cjs/shared}/utils/helpers/runtime.js +0 -1
- package/dist/{shared → cjs/shared}/utils/helpers/string.js +0 -1
- package/dist/{shared → cjs/shared}/utils/validators/asn.js +0 -1
- package/dist/{shared → cjs/shared}/utils/validators/config-validation.js +0 -1
- package/dist/{shared → cjs/shared}/utils/validators/domain.js +0 -1
- package/dist/{shared → cjs/shared}/utils/validators/entity.js +0 -1
- package/dist/{shared → cjs/shared}/utils/validators/index.js +0 -1
- package/dist/{shared → cjs/shared}/utils/validators/ip.js +0 -1
- package/dist/{shared → cjs/shared}/utils/validators/nameserver.js +0 -1
- package/dist/{shared → cjs/shared}/utils/validators/network.js +0 -1
- package/dist/esm/application/client/RDAPClient.js +439 -0
- package/dist/esm/application/client/index.js +1 -0
- package/dist/esm/application/deduplication/QueryDeduplicator.js +41 -0
- package/dist/esm/application/hooks/MiddlewareHooks.js +79 -0
- package/dist/esm/application/services/BatchProcessor.js +145 -0
- package/dist/esm/application/services/QueryOrchestrator.js +615 -0
- package/dist/esm/application/services/QueryPriority.js +109 -0
- package/dist/esm/application/services/index.js +2 -0
- package/dist/esm/cli/index.js +297 -0
- package/dist/esm/core/ports/bootstrap.port.js +1 -0
- package/dist/esm/core/ports/cache.port.js +1 -0
- package/dist/esm/core/ports/fetcher.port.js +1 -0
- package/dist/esm/core/ports/index.js +5 -0
- package/dist/esm/core/ports/normalizer.port.js +1 -0
- package/dist/esm/core/ports/pii-redactor.port.js +1 -0
- package/dist/esm/index.js +40 -0
- package/dist/esm/infrastructure/cache/CacheManager.js +123 -0
- package/dist/esm/infrastructure/cache/InMemoryCache.js +91 -0
- package/dist/esm/infrastructure/cache/PersistentCache.js +188 -0
- package/dist/esm/infrastructure/cache/RedisCache.js +106 -0
- package/dist/esm/infrastructure/cache/StaleWhileRevalidateCache.js +43 -0
- package/dist/esm/infrastructure/cache/index.js +3 -0
- package/dist/esm/infrastructure/http/AuthenticationManager.js +94 -0
- package/dist/esm/infrastructure/http/BootstrapDiscovery.js +189 -0
- package/dist/esm/infrastructure/http/BrowserFetcher.js +42 -0
- package/dist/esm/infrastructure/http/BunFetcher.js +46 -0
- package/dist/esm/infrastructure/http/CircuitBreaker.js +98 -0
- package/dist/esm/infrastructure/http/CloudflareWorkersFetcher.js +39 -0
- package/dist/esm/infrastructure/http/CompressionManager.js +80 -0
- package/dist/esm/infrastructure/http/ConnectionPool.js +101 -0
- package/dist/esm/infrastructure/http/DenoFetcher.js +38 -0
- package/dist/esm/infrastructure/http/DistributedRateLimiter.js +22 -0
- package/dist/esm/infrastructure/http/Fetcher.js +127 -0
- package/dist/esm/infrastructure/http/Normalizer.js +233 -0
- package/dist/esm/infrastructure/http/ProxyManager.js +82 -0
- package/dist/esm/infrastructure/http/RateLimiter.js +102 -0
- package/dist/esm/infrastructure/http/RetryStrategy.js +131 -0
- package/dist/esm/infrastructure/http/index.js +3 -0
- package/dist/esm/infrastructure/logging/AuditLogger.js +187 -0
- package/dist/esm/infrastructure/logging/Logger.js +145 -0
- package/dist/esm/infrastructure/monitoring/GrafanaDashboard.js +115 -0
- package/dist/esm/infrastructure/monitoring/MetricsCollector.js +284 -0
- package/dist/esm/infrastructure/monitoring/PrometheusExporter.js +72 -0
- package/dist/esm/infrastructure/monitoring/TelemetryExporter.js +112 -0
- package/dist/esm/infrastructure/native/NativeBackend.js +86 -0
- package/dist/esm/infrastructure/security/PIIRedactor.js +85 -0
- package/dist/esm/infrastructure/security/SSRFProtection.js +162 -0
- package/dist/esm/infrastructure/security/index.js +2 -0
- package/dist/esm/infrastructure/telemetry/UsageTelemetry.js +84 -0
- package/dist/esm/infrastructure/validation/ResponseValidator.js +194 -0
- package/dist/esm/integrations/express.js +43 -0
- package/dist/esm/integrations/graphql.js +80 -0
- package/dist/esm/integrations/nestjs.js +23 -0
- package/dist/esm/shared/constants/http.constants.js +25 -0
- package/dist/esm/shared/constants/index.js +2 -0
- package/dist/esm/shared/constants/rdap.constants.js +17 -0
- package/dist/esm/shared/errors/base.error.js +140 -0
- package/dist/esm/shared/errors/index.js +1 -0
- package/dist/esm/shared/types/entities.js +1 -0
- package/dist/esm/shared/types/enums.js +1 -0
- package/dist/esm/shared/types/errors.js +82 -0
- package/dist/esm/shared/types/generics.js +1 -0
- package/dist/esm/shared/types/index.js +1 -0
- package/dist/esm/shared/types/options.js +66 -0
- package/dist/esm/shared/types/responses.js +1 -0
- package/dist/esm/shared/utils/deprecation.js +20 -0
- package/dist/esm/shared/utils/enhanced-validators.js +148 -0
- package/dist/esm/shared/utils/helpers/async.js +40 -0
- package/dist/esm/shared/utils/helpers/cache.js +3 -0
- package/dist/esm/shared/utils/helpers/format.js +17 -0
- package/dist/esm/shared/utils/helpers/http.js +13 -0
- package/dist/esm/shared/utils/helpers/index.js +7 -0
- package/dist/esm/shared/utils/helpers/object.js +19 -0
- package/dist/esm/shared/utils/helpers/runtime.js +34 -0
- package/dist/esm/shared/utils/helpers/string.js +23 -0
- package/dist/esm/shared/utils/validators/asn.js +25 -0
- package/dist/esm/shared/utils/validators/config-validation.js +93 -0
- package/dist/esm/shared/utils/validators/domain.js +29 -0
- package/dist/esm/shared/utils/validators/entity.js +22 -0
- package/dist/esm/shared/utils/validators/index.js +7 -0
- package/dist/esm/shared/utils/validators/ip.js +48 -0
- package/dist/esm/shared/utils/validators/nameserver.js +44 -0
- package/dist/esm/shared/utils/validators/network.js +42 -0
- package/dist/{application → types/application}/client/RDAPClient.d.ts +10 -1
- package/dist/types/application/client/RDAPClient.d.ts.map +1 -0
- package/dist/types/application/client/index.d.ts.map +1 -0
- package/dist/types/application/deduplication/QueryDeduplicator.d.ts.map +1 -0
- package/dist/types/application/hooks/MiddlewareHooks.d.ts.map +1 -0
- package/dist/types/application/services/BatchProcessor.d.ts.map +1 -0
- package/dist/types/application/services/QueryOrchestrator.d.ts.map +1 -0
- package/dist/types/application/services/QueryPriority.d.ts.map +1 -0
- package/dist/types/application/services/index.d.ts.map +1 -0
- package/dist/{cli → types/cli}/index.d.ts.map +1 -1
- package/dist/types/core/ports/bootstrap.port.d.ts.map +1 -0
- package/dist/types/core/ports/cache.port.d.ts.map +1 -0
- package/dist/types/core/ports/fetcher.port.d.ts.map +1 -0
- package/dist/types/core/ports/index.d.ts.map +1 -0
- package/dist/types/core/ports/normalizer.port.d.ts.map +1 -0
- package/dist/types/core/ports/pii-redactor.port.d.ts.map +1 -0
- package/dist/{index.d.ts → types/index.d.ts} +6 -3
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/infrastructure/cache/CacheManager.d.ts.map +1 -0
- package/dist/types/infrastructure/cache/InMemoryCache.d.ts.map +1 -0
- package/dist/types/infrastructure/cache/PersistentCache.d.ts.map +1 -0
- package/dist/types/infrastructure/cache/RedisCache.d.ts.map +1 -0
- package/dist/types/infrastructure/cache/StaleWhileRevalidateCache.d.ts +16 -0
- package/dist/types/infrastructure/cache/StaleWhileRevalidateCache.d.ts.map +1 -0
- package/dist/types/infrastructure/cache/index.d.ts.map +1 -0
- package/dist/types/infrastructure/http/AuthenticationManager.d.ts.map +1 -0
- package/dist/types/infrastructure/http/BootstrapDiscovery.d.ts.map +1 -0
- package/dist/types/infrastructure/http/BrowserFetcher.d.ts.map +1 -0
- package/dist/types/infrastructure/http/BunFetcher.d.ts.map +1 -0
- package/dist/types/infrastructure/http/CircuitBreaker.d.ts.map +1 -0
- package/dist/types/infrastructure/http/CloudflareWorkersFetcher.d.ts.map +1 -0
- package/dist/types/infrastructure/http/CompressionManager.d.ts.map +1 -0
- package/dist/types/infrastructure/http/ConnectionPool.d.ts.map +1 -0
- package/dist/types/infrastructure/http/DenoFetcher.d.ts.map +1 -0
- package/dist/types/infrastructure/http/DistributedRateLimiter.d.ts +12 -0
- package/dist/types/infrastructure/http/DistributedRateLimiter.d.ts.map +1 -0
- package/dist/{infrastructure → types/infrastructure}/http/Fetcher.d.ts +2 -0
- package/dist/types/infrastructure/http/Fetcher.d.ts.map +1 -0
- package/dist/types/infrastructure/http/Normalizer.d.ts.map +1 -0
- package/dist/types/infrastructure/http/ProxyManager.d.ts.map +1 -0
- package/dist/{infrastructure → types/infrastructure}/http/RateLimiter.d.ts +5 -0
- package/dist/types/infrastructure/http/RateLimiter.d.ts.map +1 -0
- package/dist/types/infrastructure/http/RetryStrategy.d.ts.map +1 -0
- package/dist/types/infrastructure/http/index.d.ts.map +1 -0
- package/dist/types/infrastructure/logging/AuditLogger.d.ts.map +1 -0
- package/dist/types/infrastructure/logging/Logger.d.ts.map +1 -0
- package/dist/{infrastructure → types/infrastructure}/monitoring/GrafanaDashboard.d.ts.map +1 -1
- package/dist/types/infrastructure/monitoring/MetricsCollector.d.ts.map +1 -0
- package/dist/types/infrastructure/monitoring/PrometheusExporter.d.ts.map +1 -0
- package/dist/types/infrastructure/monitoring/TelemetryExporter.d.ts.map +1 -0
- package/dist/types/infrastructure/native/NativeBackend.d.ts.map +1 -0
- package/dist/types/infrastructure/security/PIIRedactor.d.ts.map +1 -0
- package/dist/{infrastructure → types/infrastructure}/security/SSRFProtection.d.ts +1 -0
- package/dist/types/infrastructure/security/SSRFProtection.d.ts.map +1 -0
- package/dist/types/infrastructure/security/index.d.ts.map +1 -0
- package/dist/types/infrastructure/telemetry/UsageTelemetry.d.ts +13 -0
- package/dist/types/infrastructure/telemetry/UsageTelemetry.d.ts.map +1 -0
- package/dist/types/infrastructure/validation/ResponseValidator.d.ts.map +1 -0
- package/dist/types/integrations/express.d.ts.map +1 -0
- package/dist/types/integrations/graphql.d.ts.map +1 -0
- package/dist/types/integrations/nestjs.d.ts.map +1 -0
- package/dist/types/shared/constants/http.constants.d.ts.map +1 -0
- package/dist/types/shared/constants/index.d.ts.map +1 -0
- package/dist/types/shared/constants/rdap.constants.d.ts.map +1 -0
- package/dist/{shared → types/shared}/errors/base.error.d.ts +3 -0
- package/dist/types/shared/errors/base.error.d.ts.map +1 -0
- package/dist/types/shared/errors/index.d.ts.map +1 -0
- package/dist/types/shared/types/entities.d.ts.map +1 -0
- package/dist/{shared → types/shared}/types/enums.d.ts +1 -1
- package/dist/types/shared/types/enums.d.ts.map +1 -0
- package/dist/types/shared/types/errors.d.ts.map +1 -0
- package/dist/types/shared/types/generics.d.ts.map +1 -0
- package/dist/{shared → types/shared}/types/index.d.ts +1 -1
- package/dist/types/shared/types/index.d.ts.map +1 -0
- package/dist/{shared → types/shared}/types/options.d.ts +9 -0
- package/dist/types/shared/types/options.d.ts.map +1 -0
- package/dist/{shared → types/shared}/types/responses.d.ts +20 -0
- package/dist/types/shared/types/responses.d.ts.map +1 -0
- package/dist/types/shared/utils/deprecation.d.ts.map +1 -0
- package/dist/types/shared/utils/enhanced-validators.d.ts.map +1 -0
- package/dist/types/shared/utils/helpers/async.d.ts.map +1 -0
- package/dist/types/shared/utils/helpers/cache.d.ts.map +1 -0
- package/dist/types/shared/utils/helpers/format.d.ts.map +1 -0
- package/dist/types/shared/utils/helpers/http.d.ts.map +1 -0
- package/dist/types/shared/utils/helpers/index.d.ts.map +1 -0
- package/dist/types/shared/utils/helpers/object.d.ts.map +1 -0
- package/dist/types/shared/utils/helpers/runtime.d.ts.map +1 -0
- package/dist/types/shared/utils/helpers/string.d.ts.map +1 -0
- package/dist/types/shared/utils/validators/asn.d.ts.map +1 -0
- package/dist/types/shared/utils/validators/config-validation.d.ts.map +1 -0
- package/dist/types/shared/utils/validators/domain.d.ts.map +1 -0
- package/dist/types/shared/utils/validators/entity.d.ts.map +1 -0
- package/dist/types/shared/utils/validators/index.d.ts.map +1 -0
- package/dist/types/shared/utils/validators/ip.d.ts.map +1 -0
- package/dist/types/shared/utils/validators/nameserver.d.ts.map +1 -0
- package/dist/types/shared/utils/validators/network.d.ts.map +1 -0
- package/package.json +29 -25
- package/dist/application/client/RDAPClient.d.ts.map +0 -1
- package/dist/application/client/RDAPClient.js.map +0 -1
- package/dist/application/client/index.d.ts.map +0 -1
- package/dist/application/client/index.js.map +0 -1
- package/dist/application/deduplication/QueryDeduplicator.d.ts.map +0 -1
- package/dist/application/deduplication/QueryDeduplicator.js.map +0 -1
- package/dist/application/hooks/MiddlewareHooks.d.ts.map +0 -1
- package/dist/application/hooks/MiddlewareHooks.js.map +0 -1
- package/dist/application/services/BatchProcessor.d.ts.map +0 -1
- package/dist/application/services/BatchProcessor.js.map +0 -1
- package/dist/application/services/QueryOrchestrator.d.ts.map +0 -1
- package/dist/application/services/QueryOrchestrator.js.map +0 -1
- package/dist/application/services/QueryPriority.d.ts.map +0 -1
- package/dist/application/services/QueryPriority.js.map +0 -1
- package/dist/application/services/index.d.ts.map +0 -1
- package/dist/application/services/index.js.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/core/ports/bootstrap.port.d.ts.map +0 -1
- package/dist/core/ports/bootstrap.port.js +0 -3
- package/dist/core/ports/bootstrap.port.js.map +0 -1
- package/dist/core/ports/cache.port.d.ts.map +0 -1
- package/dist/core/ports/cache.port.js +0 -3
- package/dist/core/ports/cache.port.js.map +0 -1
- package/dist/core/ports/fetcher.port.d.ts.map +0 -1
- package/dist/core/ports/fetcher.port.js +0 -3
- package/dist/core/ports/fetcher.port.js.map +0 -1
- package/dist/core/ports/index.d.ts.map +0 -1
- package/dist/core/ports/index.js.map +0 -1
- package/dist/core/ports/normalizer.port.d.ts.map +0 -1
- package/dist/core/ports/normalizer.port.js +0 -3
- package/dist/core/ports/normalizer.port.js.map +0 -1
- package/dist/core/ports/pii-redactor.port.d.ts.map +0 -1
- package/dist/core/ports/pii-redactor.port.js +0 -3
- package/dist/core/ports/pii-redactor.port.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infrastructure/cache/CacheManager.d.ts.map +0 -1
- package/dist/infrastructure/cache/CacheManager.js.map +0 -1
- package/dist/infrastructure/cache/InMemoryCache.d.ts.map +0 -1
- package/dist/infrastructure/cache/InMemoryCache.js.map +0 -1
- package/dist/infrastructure/cache/PersistentCache.d.ts.map +0 -1
- package/dist/infrastructure/cache/PersistentCache.js.map +0 -1
- package/dist/infrastructure/cache/RedisCache.d.ts.map +0 -1
- package/dist/infrastructure/cache/RedisCache.js.map +0 -1
- package/dist/infrastructure/cache/index.d.ts.map +0 -1
- package/dist/infrastructure/cache/index.js.map +0 -1
- package/dist/infrastructure/http/AuthenticationManager.d.ts.map +0 -1
- package/dist/infrastructure/http/AuthenticationManager.js.map +0 -1
- package/dist/infrastructure/http/BootstrapDiscovery.d.ts.map +0 -1
- package/dist/infrastructure/http/BootstrapDiscovery.js.map +0 -1
- package/dist/infrastructure/http/BrowserFetcher.d.ts.map +0 -1
- package/dist/infrastructure/http/BrowserFetcher.js.map +0 -1
- package/dist/infrastructure/http/BunFetcher.d.ts.map +0 -1
- package/dist/infrastructure/http/BunFetcher.js.map +0 -1
- package/dist/infrastructure/http/CircuitBreaker.d.ts.map +0 -1
- package/dist/infrastructure/http/CircuitBreaker.js.map +0 -1
- package/dist/infrastructure/http/CloudflareWorkersFetcher.d.ts.map +0 -1
- package/dist/infrastructure/http/CloudflareWorkersFetcher.js.map +0 -1
- package/dist/infrastructure/http/CompressionManager.d.ts.map +0 -1
- package/dist/infrastructure/http/CompressionManager.js.map +0 -1
- package/dist/infrastructure/http/ConnectionPool.d.ts.map +0 -1
- package/dist/infrastructure/http/ConnectionPool.js.map +0 -1
- package/dist/infrastructure/http/DenoFetcher.d.ts.map +0 -1
- package/dist/infrastructure/http/DenoFetcher.js.map +0 -1
- package/dist/infrastructure/http/Fetcher.d.ts.map +0 -1
- package/dist/infrastructure/http/Fetcher.js.map +0 -1
- package/dist/infrastructure/http/Normalizer.d.ts.map +0 -1
- package/dist/infrastructure/http/Normalizer.js.map +0 -1
- package/dist/infrastructure/http/ProxyManager.d.ts.map +0 -1
- package/dist/infrastructure/http/ProxyManager.js.map +0 -1
- package/dist/infrastructure/http/RateLimiter.d.ts.map +0 -1
- package/dist/infrastructure/http/RateLimiter.js.map +0 -1
- package/dist/infrastructure/http/RetryStrategy.d.ts.map +0 -1
- package/dist/infrastructure/http/RetryStrategy.js.map +0 -1
- package/dist/infrastructure/http/index.d.ts.map +0 -1
- package/dist/infrastructure/http/index.js.map +0 -1
- package/dist/infrastructure/logging/AuditLogger.d.ts.map +0 -1
- package/dist/infrastructure/logging/AuditLogger.js.map +0 -1
- package/dist/infrastructure/logging/Logger.d.ts.map +0 -1
- package/dist/infrastructure/logging/Logger.js.map +0 -1
- package/dist/infrastructure/monitoring/GrafanaDashboard.js.map +0 -1
- package/dist/infrastructure/monitoring/MetricsCollector.d.ts.map +0 -1
- package/dist/infrastructure/monitoring/MetricsCollector.js.map +0 -1
- package/dist/infrastructure/monitoring/PrometheusExporter.d.ts.map +0 -1
- package/dist/infrastructure/monitoring/PrometheusExporter.js.map +0 -1
- package/dist/infrastructure/monitoring/TelemetryExporter.d.ts.map +0 -1
- package/dist/infrastructure/monitoring/TelemetryExporter.js.map +0 -1
- package/dist/infrastructure/native/NativeBackend.d.ts.map +0 -1
- package/dist/infrastructure/native/NativeBackend.js.map +0 -1
- package/dist/infrastructure/security/PIIRedactor.d.ts.map +0 -1
- package/dist/infrastructure/security/PIIRedactor.js.map +0 -1
- package/dist/infrastructure/security/SSRFProtection.d.ts.map +0 -1
- package/dist/infrastructure/security/SSRFProtection.js.map +0 -1
- package/dist/infrastructure/security/index.d.ts.map +0 -1
- package/dist/infrastructure/security/index.js.map +0 -1
- package/dist/infrastructure/validation/ResponseValidator.d.ts.map +0 -1
- package/dist/infrastructure/validation/ResponseValidator.js.map +0 -1
- package/dist/integrations/express.d.ts.map +0 -1
- package/dist/integrations/express.js.map +0 -1
- package/dist/integrations/graphql.d.ts.map +0 -1
- package/dist/integrations/graphql.js.map +0 -1
- package/dist/integrations/nestjs.d.ts.map +0 -1
- package/dist/integrations/nestjs.js.map +0 -1
- package/dist/shared/constants/http.constants.d.ts.map +0 -1
- package/dist/shared/constants/http.constants.js.map +0 -1
- package/dist/shared/constants/index.d.ts.map +0 -1
- package/dist/shared/constants/index.js.map +0 -1
- package/dist/shared/constants/rdap.constants.d.ts.map +0 -1
- package/dist/shared/constants/rdap.constants.js.map +0 -1
- package/dist/shared/errors/base.error.d.ts.map +0 -1
- package/dist/shared/errors/base.error.js.map +0 -1
- package/dist/shared/errors/index.d.ts.map +0 -1
- package/dist/shared/errors/index.js.map +0 -1
- package/dist/shared/types/entities.d.ts.map +0 -1
- package/dist/shared/types/entities.js.map +0 -1
- package/dist/shared/types/enums.d.ts.map +0 -1
- package/dist/shared/types/enums.js.map +0 -1
- package/dist/shared/types/errors.d.ts.map +0 -1
- package/dist/shared/types/errors.js.map +0 -1
- package/dist/shared/types/generics.d.ts.map +0 -1
- package/dist/shared/types/generics.js.map +0 -1
- package/dist/shared/types/index.d.ts.map +0 -1
- package/dist/shared/types/index.js.map +0 -1
- package/dist/shared/types/options.d.ts.map +0 -1
- package/dist/shared/types/options.js.map +0 -1
- package/dist/shared/types/responses.d.ts.map +0 -1
- package/dist/shared/types/responses.js +0 -3
- package/dist/shared/types/responses.js.map +0 -1
- package/dist/shared/utils/deprecation.d.ts.map +0 -1
- package/dist/shared/utils/deprecation.js.map +0 -1
- package/dist/shared/utils/enhanced-validators.d.ts.map +0 -1
- package/dist/shared/utils/enhanced-validators.js.map +0 -1
- package/dist/shared/utils/helpers/async.d.ts.map +0 -1
- package/dist/shared/utils/helpers/async.js.map +0 -1
- package/dist/shared/utils/helpers/cache.d.ts.map +0 -1
- package/dist/shared/utils/helpers/cache.js.map +0 -1
- package/dist/shared/utils/helpers/format.d.ts.map +0 -1
- package/dist/shared/utils/helpers/format.js.map +0 -1
- package/dist/shared/utils/helpers/http.d.ts.map +0 -1
- package/dist/shared/utils/helpers/http.js.map +0 -1
- package/dist/shared/utils/helpers/index.d.ts.map +0 -1
- package/dist/shared/utils/helpers/index.js.map +0 -1
- package/dist/shared/utils/helpers/object.d.ts.map +0 -1
- package/dist/shared/utils/helpers/object.js.map +0 -1
- package/dist/shared/utils/helpers/runtime.d.ts.map +0 -1
- package/dist/shared/utils/helpers/runtime.js.map +0 -1
- package/dist/shared/utils/helpers/string.d.ts.map +0 -1
- package/dist/shared/utils/helpers/string.js.map +0 -1
- package/dist/shared/utils/validators/asn.d.ts.map +0 -1
- package/dist/shared/utils/validators/asn.js.map +0 -1
- package/dist/shared/utils/validators/config-validation.d.ts.map +0 -1
- package/dist/shared/utils/validators/config-validation.js.map +0 -1
- package/dist/shared/utils/validators/domain.d.ts.map +0 -1
- package/dist/shared/utils/validators/domain.js.map +0 -1
- package/dist/shared/utils/validators/entity.d.ts.map +0 -1
- package/dist/shared/utils/validators/entity.js.map +0 -1
- package/dist/shared/utils/validators/index.d.ts.map +0 -1
- package/dist/shared/utils/validators/index.js.map +0 -1
- package/dist/shared/utils/validators/ip.d.ts.map +0 -1
- package/dist/shared/utils/validators/ip.js.map +0 -1
- package/dist/shared/utils/validators/nameserver.d.ts.map +0 -1
- package/dist/shared/utils/validators/nameserver.js.map +0 -1
- package/dist/shared/utils/validators/network.d.ts.map +0 -1
- package/dist/shared/utils/validators/network.js.map +0 -1
- /package/dist/{application → types/application}/client/index.d.ts +0 -0
- /package/dist/{application → types/application}/deduplication/QueryDeduplicator.d.ts +0 -0
- /package/dist/{application → types/application}/hooks/MiddlewareHooks.d.ts +0 -0
- /package/dist/{application → types/application}/services/BatchProcessor.d.ts +0 -0
- /package/dist/{application → types/application}/services/QueryOrchestrator.d.ts +0 -0
- /package/dist/{application → types/application}/services/QueryPriority.d.ts +0 -0
- /package/dist/{application → types/application}/services/index.d.ts +0 -0
- /package/dist/{cli → types/cli}/index.d.ts +0 -0
- /package/dist/{core → types/core}/ports/bootstrap.port.d.ts +0 -0
- /package/dist/{core → types/core}/ports/cache.port.d.ts +0 -0
- /package/dist/{core → types/core}/ports/fetcher.port.d.ts +0 -0
- /package/dist/{core → types/core}/ports/index.d.ts +0 -0
- /package/dist/{core → types/core}/ports/normalizer.port.d.ts +0 -0
- /package/dist/{core → types/core}/ports/pii-redactor.port.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/cache/CacheManager.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/cache/InMemoryCache.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/cache/PersistentCache.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/cache/RedisCache.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/cache/index.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/AuthenticationManager.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/BootstrapDiscovery.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/BrowserFetcher.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/BunFetcher.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/CircuitBreaker.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/CloudflareWorkersFetcher.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/CompressionManager.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/ConnectionPool.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/DenoFetcher.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/Normalizer.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/ProxyManager.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/RetryStrategy.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/http/index.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/logging/AuditLogger.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/logging/Logger.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/monitoring/GrafanaDashboard.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/monitoring/MetricsCollector.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/monitoring/PrometheusExporter.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/monitoring/TelemetryExporter.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/native/NativeBackend.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/security/PIIRedactor.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/security/index.d.ts +0 -0
- /package/dist/{infrastructure → types/infrastructure}/validation/ResponseValidator.d.ts +0 -0
- /package/dist/{integrations → types/integrations}/express.d.ts +0 -0
- /package/dist/{integrations → types/integrations}/graphql.d.ts +0 -0
- /package/dist/{integrations → types/integrations}/nestjs.d.ts +0 -0
- /package/dist/{shared → types/shared}/constants/http.constants.d.ts +0 -0
- /package/dist/{shared → types/shared}/constants/index.d.ts +0 -0
- /package/dist/{shared → types/shared}/constants/rdap.constants.d.ts +0 -0
- /package/dist/{shared → types/shared}/errors/index.d.ts +0 -0
- /package/dist/{shared → types/shared}/types/entities.d.ts +0 -0
- /package/dist/{shared → types/shared}/types/errors.d.ts +0 -0
- /package/dist/{shared → types/shared}/types/generics.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/deprecation.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/enhanced-validators.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/helpers/async.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/helpers/cache.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/helpers/format.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/helpers/http.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/helpers/index.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/helpers/object.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/helpers/runtime.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/helpers/string.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/validators/asn.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/validators/config-validation.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/validators/domain.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/validators/entity.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/validators/index.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/validators/ip.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/validators/nameserver.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/validators/network.d.ts +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { NetworkError, RDAPServerError, TimeoutError, RDAPifyError } from '../../shared/errors';
|
|
2
|
+
export class BunFetcher {
|
|
3
|
+
constructor(options = {}) {
|
|
4
|
+
this.timeout = options.timeout ?? 10000;
|
|
5
|
+
this.userAgent = options.userAgent ?? 'RDAPify/0.2.1 (Bun) (https://rdapify.com)';
|
|
6
|
+
this.headers = options.headers ?? {};
|
|
7
|
+
this.ssrfProtection = options.ssrfProtection;
|
|
8
|
+
}
|
|
9
|
+
async fetch(url) {
|
|
10
|
+
if (this.ssrfProtection) {
|
|
11
|
+
await this.ssrfProtection.validateUrl(url);
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const nativeFetch = BunFetcher.resolveFetch();
|
|
15
|
+
const response = await nativeFetch(url, {
|
|
16
|
+
method: 'GET',
|
|
17
|
+
headers: {
|
|
18
|
+
'User-Agent': this.userAgent,
|
|
19
|
+
Accept: 'application/rdap+json, application/json',
|
|
20
|
+
...this.headers,
|
|
21
|
+
},
|
|
22
|
+
signal: AbortSignal.timeout(this.timeout),
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
throw new RDAPServerError(`RDAP server returned ${response.status}`, response.status, { url });
|
|
26
|
+
}
|
|
27
|
+
const data = await response.json();
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
if (err instanceof RDAPifyError)
|
|
32
|
+
throw err;
|
|
33
|
+
if (err instanceof DOMException && err.name === 'TimeoutError') {
|
|
34
|
+
throw new TimeoutError(`Request timed out after ${this.timeout}ms`, { url });
|
|
35
|
+
}
|
|
36
|
+
throw new NetworkError(`BunFetcher: failed to fetch ${url}: ${err instanceof Error ? err.message : String(err)}`, undefined, { url, originalError: err });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
static resolveFetch() {
|
|
40
|
+
const bun = globalThis['Bun'];
|
|
41
|
+
if (bun && typeof bun['fetch'] === 'function') {
|
|
42
|
+
return bun['fetch'];
|
|
43
|
+
}
|
|
44
|
+
return globalThis.fetch;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export class CircuitOpenError extends Error {
|
|
2
|
+
constructor(state = 'open') {
|
|
3
|
+
super(`Circuit is ${state} — request rejected`);
|
|
4
|
+
this.state = state;
|
|
5
|
+
this.name = 'CircuitOpenError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class CircuitBreaker {
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
this.state = 'closed';
|
|
11
|
+
this.failureCount = 0;
|
|
12
|
+
this.successCount = 0;
|
|
13
|
+
this.failureTimes = [];
|
|
14
|
+
this.failureThreshold = options.failureThreshold ?? 5;
|
|
15
|
+
this.successThreshold = options.successThreshold ?? 1;
|
|
16
|
+
this.halfOpenTimeout = options.halfOpenTimeout ?? 30000;
|
|
17
|
+
this.window = options.window ?? 60000;
|
|
18
|
+
}
|
|
19
|
+
getState() {
|
|
20
|
+
this.maybeTransitionToHalfOpen();
|
|
21
|
+
return this.state;
|
|
22
|
+
}
|
|
23
|
+
async execute(fn) {
|
|
24
|
+
this.maybeTransitionToHalfOpen();
|
|
25
|
+
if (this.state === 'open') {
|
|
26
|
+
throw new CircuitOpenError('open');
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const result = await fn();
|
|
30
|
+
this.onSuccess();
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
this.onFailure();
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
recordSuccess() {
|
|
39
|
+
this.onSuccess();
|
|
40
|
+
}
|
|
41
|
+
recordFailure() {
|
|
42
|
+
this.onFailure();
|
|
43
|
+
}
|
|
44
|
+
reset() {
|
|
45
|
+
this.state = 'closed';
|
|
46
|
+
this.failureCount = 0;
|
|
47
|
+
this.successCount = 0;
|
|
48
|
+
this.lastOpenedAt = undefined;
|
|
49
|
+
this.failureTimes = [];
|
|
50
|
+
}
|
|
51
|
+
maybeTransitionToHalfOpen() {
|
|
52
|
+
if (this.state === 'open' &&
|
|
53
|
+
this.lastOpenedAt !== undefined &&
|
|
54
|
+
Date.now() - this.lastOpenedAt >= this.halfOpenTimeout) {
|
|
55
|
+
this.state = 'half-open';
|
|
56
|
+
this.successCount = 0;
|
|
57
|
+
this.failureCount = 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
onSuccess() {
|
|
61
|
+
if (this.state === 'half-open') {
|
|
62
|
+
this.successCount += 1;
|
|
63
|
+
if (this.successCount >= this.successThreshold) {
|
|
64
|
+
this.state = 'closed';
|
|
65
|
+
this.failureCount = 0;
|
|
66
|
+
this.successCount = 0;
|
|
67
|
+
this.failureTimes = [];
|
|
68
|
+
this.lastOpenedAt = undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (this.state === 'closed') {
|
|
72
|
+
this.failureCount = 0;
|
|
73
|
+
this.failureTimes = [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
onFailure() {
|
|
77
|
+
const now = Date.now();
|
|
78
|
+
if (this.state === 'half-open') {
|
|
79
|
+
this.state = 'open';
|
|
80
|
+
this.lastOpenedAt = now;
|
|
81
|
+
this.successCount = 0;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (this.state === 'closed') {
|
|
85
|
+
this.failureTimes.push(now);
|
|
86
|
+
this.pruneOldFailures();
|
|
87
|
+
this.failureCount = this.failureTimes.length;
|
|
88
|
+
if (this.failureCount >= this.failureThreshold) {
|
|
89
|
+
this.state = 'open';
|
|
90
|
+
this.lastOpenedAt = now;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
pruneOldFailures() {
|
|
95
|
+
const cutoff = Date.now() - this.window;
|
|
96
|
+
this.failureTimes = this.failureTimes.filter((t) => t > cutoff);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NetworkError, RDAPServerError, TimeoutError, RDAPifyError } from '../../shared/errors';
|
|
2
|
+
export class CloudflareWorkersFetcher {
|
|
3
|
+
constructor(options = {}) {
|
|
4
|
+
this.timeout = options.timeout ?? 10000;
|
|
5
|
+
this.userAgent =
|
|
6
|
+
options.userAgent ?? 'RDAPify/0.2.2 (Cloudflare-Workers) (https://rdapify.com)';
|
|
7
|
+
this.headers = options.headers ?? {};
|
|
8
|
+
this.ssrfProtection = options.ssrfProtection;
|
|
9
|
+
}
|
|
10
|
+
async fetch(url) {
|
|
11
|
+
if (this.ssrfProtection) {
|
|
12
|
+
await this.ssrfProtection.validateUrl(url);
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const response = await globalThis.fetch(url, {
|
|
16
|
+
method: 'GET',
|
|
17
|
+
headers: {
|
|
18
|
+
'User-Agent': this.userAgent,
|
|
19
|
+
Accept: 'application/rdap+json, application/json',
|
|
20
|
+
...this.headers,
|
|
21
|
+
},
|
|
22
|
+
signal: AbortSignal.timeout(this.timeout),
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
throw new RDAPServerError(`RDAP server returned ${response.status}`, response.status, { url });
|
|
26
|
+
}
|
|
27
|
+
const data = (await response.json());
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
if (err instanceof RDAPifyError)
|
|
32
|
+
throw err;
|
|
33
|
+
if (err instanceof DOMException && err.name === 'TimeoutError') {
|
|
34
|
+
throw new TimeoutError(`Request timed out after ${this.timeout}ms`, { url });
|
|
35
|
+
}
|
|
36
|
+
throw new NetworkError(`CloudflareWorkersFetcher: failed to fetch ${url}: ${err instanceof Error ? err.message : String(err)}`, undefined, { url, originalError: err });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as zlib from 'zlib';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
const gunzip = promisify(zlib.gunzip);
|
|
4
|
+
const brotliDecompress = promisify(zlib.brotliDecompress);
|
|
5
|
+
export class CompressionManager {
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.enabled = options.enabled ?? true;
|
|
8
|
+
this.types = new Set(options.types || ['gzip', 'br']);
|
|
9
|
+
this.threshold = options.threshold || 1024;
|
|
10
|
+
}
|
|
11
|
+
getAcceptEncodingHeader() {
|
|
12
|
+
if (!this.enabled || this.types.size === 0) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const encodings = [];
|
|
16
|
+
if (this.types.has('br')) {
|
|
17
|
+
encodings.push('br;q=1.0');
|
|
18
|
+
}
|
|
19
|
+
if (this.types.has('gzip')) {
|
|
20
|
+
encodings.push('gzip;q=0.9');
|
|
21
|
+
}
|
|
22
|
+
if (this.types.has('deflate')) {
|
|
23
|
+
encodings.push('deflate;q=0.8');
|
|
24
|
+
}
|
|
25
|
+
return encodings.length > 0 ? encodings.join(', ') : undefined;
|
|
26
|
+
}
|
|
27
|
+
async decompress(data, encoding) {
|
|
28
|
+
if (!encoding || !this.enabled) {
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
const normalizedEncoding = encoding.toLowerCase().trim();
|
|
32
|
+
try {
|
|
33
|
+
switch (normalizedEncoding) {
|
|
34
|
+
case 'gzip':
|
|
35
|
+
return await gunzip(data);
|
|
36
|
+
case 'br':
|
|
37
|
+
return await brotliDecompress(data);
|
|
38
|
+
case 'deflate':
|
|
39
|
+
return await promisify(zlib.inflate)(data);
|
|
40
|
+
default:
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.warn(`Failed to decompress ${encoding}:`, error);
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
shouldCompress(size) {
|
|
50
|
+
return this.enabled && size >= this.threshold;
|
|
51
|
+
}
|
|
52
|
+
getSupportedTypes() {
|
|
53
|
+
return Array.from(this.types);
|
|
54
|
+
}
|
|
55
|
+
isSupported(type) {
|
|
56
|
+
return this.types.has(type);
|
|
57
|
+
}
|
|
58
|
+
getInfo() {
|
|
59
|
+
return {
|
|
60
|
+
enabled: this.enabled,
|
|
61
|
+
types: this.getSupportedTypes(),
|
|
62
|
+
threshold: this.threshold,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
estimateRatio(originalSize, compressedSize) {
|
|
66
|
+
if (originalSize === 0)
|
|
67
|
+
return 0;
|
|
68
|
+
return ((originalSize - compressedSize) / originalSize) * 100;
|
|
69
|
+
}
|
|
70
|
+
getStats(originalSize, compressedSize) {
|
|
71
|
+
const savedBytes = originalSize - compressedSize;
|
|
72
|
+
const savedPercentage = this.estimateRatio(originalSize, compressedSize);
|
|
73
|
+
return {
|
|
74
|
+
originalSize,
|
|
75
|
+
compressedSize,
|
|
76
|
+
savedBytes,
|
|
77
|
+
savedPercentage,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export class ConnectionPool {
|
|
2
|
+
constructor(options = {}) {
|
|
3
|
+
this.maxConnections = options.maxConnections || 10;
|
|
4
|
+
this.keepAlive = options.keepAlive ?? true;
|
|
5
|
+
this.maxIdleTime = options.maxIdleTime || 300000;
|
|
6
|
+
this.connections = new Map();
|
|
7
|
+
if (this.keepAlive) {
|
|
8
|
+
this.cleanupInterval = setInterval(() => this.cleanup(), 30000);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async acquire(host, timeout) {
|
|
12
|
+
const hostConnections = this.connections.get(host) || [];
|
|
13
|
+
const available = hostConnections.find((conn) => !conn.inUse);
|
|
14
|
+
if (available) {
|
|
15
|
+
available.inUse = true;
|
|
16
|
+
available.lastUsed = Date.now();
|
|
17
|
+
return available.id;
|
|
18
|
+
}
|
|
19
|
+
if (hostConnections.length < this.maxConnections) {
|
|
20
|
+
const connection = {
|
|
21
|
+
id: `${host}-${Date.now()}-${Math.random()}`,
|
|
22
|
+
inUse: true,
|
|
23
|
+
lastUsed: Date.now(),
|
|
24
|
+
keepAlive: this.keepAlive,
|
|
25
|
+
};
|
|
26
|
+
hostConnections.push(connection);
|
|
27
|
+
this.connections.set(host, hostConnections);
|
|
28
|
+
return connection.id;
|
|
29
|
+
}
|
|
30
|
+
return this.waitForConnection(host, timeout ?? 5000);
|
|
31
|
+
}
|
|
32
|
+
release(connectionId) {
|
|
33
|
+
for (const [, connections] of this.connections.entries()) {
|
|
34
|
+
const connection = connections.find((c) => c.id === connectionId);
|
|
35
|
+
if (connection) {
|
|
36
|
+
connection.inUse = false;
|
|
37
|
+
connection.lastUsed = Date.now();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async waitForConnection(host, timeout = 5000) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
const startTime = Date.now();
|
|
45
|
+
const checkInterval = setInterval(() => {
|
|
46
|
+
const hostConnections = this.connections.get(host) || [];
|
|
47
|
+
const available = hostConnections.find((conn) => !conn.inUse);
|
|
48
|
+
if (available) {
|
|
49
|
+
clearInterval(checkInterval);
|
|
50
|
+
available.inUse = true;
|
|
51
|
+
available.lastUsed = Date.now();
|
|
52
|
+
resolve(available.id);
|
|
53
|
+
}
|
|
54
|
+
if (Date.now() - startTime >= timeout) {
|
|
55
|
+
clearInterval(checkInterval);
|
|
56
|
+
reject(new Error(`Timeout waiting for connection to ${host} after ${timeout}ms`));
|
|
57
|
+
}
|
|
58
|
+
}, 100);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
cleanup() {
|
|
62
|
+
const now = Date.now();
|
|
63
|
+
for (const [host, connections] of this.connections.entries()) {
|
|
64
|
+
const activeConnections = connections.filter((conn) => {
|
|
65
|
+
if (conn.inUse)
|
|
66
|
+
return true;
|
|
67
|
+
const idleTime = now - conn.lastUsed;
|
|
68
|
+
return idleTime < this.maxIdleTime;
|
|
69
|
+
});
|
|
70
|
+
if (activeConnections.length === 0) {
|
|
71
|
+
this.connections.delete(host);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.connections.set(host, activeConnections);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
getStats() {
|
|
79
|
+
let total = 0;
|
|
80
|
+
let active = 0;
|
|
81
|
+
let idle = 0;
|
|
82
|
+
for (const connections of this.connections.values()) {
|
|
83
|
+
total += connections.length;
|
|
84
|
+
active += connections.filter((c) => c.inUse).length;
|
|
85
|
+
idle += connections.filter((c) => !c.inUse).length;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
totalConnections: total,
|
|
89
|
+
activeConnections: active,
|
|
90
|
+
idleConnections: idle,
|
|
91
|
+
hosts: this.connections.size,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
destroy() {
|
|
95
|
+
if (this.cleanupInterval) {
|
|
96
|
+
clearInterval(this.cleanupInterval);
|
|
97
|
+
this.cleanupInterval = undefined;
|
|
98
|
+
}
|
|
99
|
+
this.connections.clear();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { NetworkError, RDAPServerError, TimeoutError, RDAPifyError } from '../../shared/errors';
|
|
2
|
+
export class DenoFetcher {
|
|
3
|
+
constructor(options = {}) {
|
|
4
|
+
this.timeout = options.timeout ?? 10000;
|
|
5
|
+
this.userAgent = options.userAgent ?? 'RDAPify/0.2.2 (Deno) (https://rdapify.com)';
|
|
6
|
+
this.headers = options.headers ?? {};
|
|
7
|
+
this.ssrfProtection = options.ssrfProtection;
|
|
8
|
+
}
|
|
9
|
+
async fetch(url) {
|
|
10
|
+
if (this.ssrfProtection) {
|
|
11
|
+
await this.ssrfProtection.validateUrl(url);
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const response = await globalThis.fetch(url, {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
headers: {
|
|
17
|
+
'User-Agent': this.userAgent,
|
|
18
|
+
Accept: 'application/rdap+json, application/json',
|
|
19
|
+
...this.headers,
|
|
20
|
+
},
|
|
21
|
+
signal: AbortSignal.timeout(this.timeout),
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new RDAPServerError(`RDAP server returned ${response.status}`, response.status, { url });
|
|
25
|
+
}
|
|
26
|
+
const data = (await response.json());
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err instanceof RDAPifyError)
|
|
31
|
+
throw err;
|
|
32
|
+
if (err instanceof DOMException && err.name === 'TimeoutError') {
|
|
33
|
+
throw new TimeoutError(`Request timed out after ${this.timeout}ms`, { url });
|
|
34
|
+
}
|
|
35
|
+
throw new NetworkError(`DenoFetcher: failed to fetch ${url}: ${err instanceof Error ? err.message : String(err)}`, undefined, { url, originalError: err });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RateLimiter } from './RateLimiter';
|
|
2
|
+
import { RateLimitError } from '../../shared/errors';
|
|
3
|
+
export class DistributedRateLimiter extends RateLimiter {
|
|
4
|
+
constructor(redis, options = {}) {
|
|
5
|
+
super(options);
|
|
6
|
+
this.redis = redis;
|
|
7
|
+
}
|
|
8
|
+
async checkLimit(key = 'default') {
|
|
9
|
+
if (!this.isEnabled())
|
|
10
|
+
return;
|
|
11
|
+
const config = this.getConfig();
|
|
12
|
+
const windowId = Math.floor(Date.now() / config.windowMs);
|
|
13
|
+
const windowKey = `rdapify:rl:${key}:${windowId}`;
|
|
14
|
+
const current = await this.redis.incr(windowKey);
|
|
15
|
+
if (current === 1) {
|
|
16
|
+
await this.redis.pexpire(windowKey, config.windowMs);
|
|
17
|
+
}
|
|
18
|
+
if (current > config.maxRequests) {
|
|
19
|
+
throw new RateLimitError(`Rate limit exceeded (${current}/${config.maxRequests}) for key: ${key}`, { key, limit: config.maxRequests, current });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { NetworkError, TimeoutError, RDAPServerError, RDAPifyError, QueryAbortedError } from '../../shared/errors';
|
|
2
|
+
import { withTimeout } from '../../shared/utils/helpers';
|
|
3
|
+
export class Fetcher {
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
this.timeout = {
|
|
6
|
+
connect: options.timeout?.connect || 5000,
|
|
7
|
+
request: options.timeout?.request || 10000,
|
|
8
|
+
dns: options.timeout?.dns || 3000,
|
|
9
|
+
};
|
|
10
|
+
this.userAgent = options.userAgent || 'RDAPify/0.1.7 (https://rdapify.com)';
|
|
11
|
+
this.headers = options.headers || {};
|
|
12
|
+
this.followRedirects = options.followRedirects ?? true;
|
|
13
|
+
this.maxRedirects = options.maxRedirects || 5;
|
|
14
|
+
this.ssrfProtection = options.ssrfProtection;
|
|
15
|
+
this.logRedirect = options.logRedirect;
|
|
16
|
+
this.http2 = options.http2 ?? false;
|
|
17
|
+
this.signal = options.signal;
|
|
18
|
+
}
|
|
19
|
+
async fetch(url) {
|
|
20
|
+
if (this.ssrfProtection) {
|
|
21
|
+
await this.ssrfProtection.validateUrl(url);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const response = await this.makeRequest(url);
|
|
25
|
+
return response;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error instanceof RDAPifyError) {
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
throw new NetworkError(`Failed to fetch RDAP data: ${error instanceof Error ? error.message : 'Unknown error'}`, undefined, { url, originalError: error });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async makeRequest(url, redirectCount = 0) {
|
|
35
|
+
if (redirectCount > this.maxRedirects) {
|
|
36
|
+
throw new NetworkError(`Too many redirects (max: ${this.maxRedirects})`, undefined, { url });
|
|
37
|
+
}
|
|
38
|
+
const requestHeaders = {
|
|
39
|
+
'User-Agent': this.userAgent,
|
|
40
|
+
Accept: 'application/rdap+json, application/json',
|
|
41
|
+
...this.headers,
|
|
42
|
+
};
|
|
43
|
+
if (this.http2) {
|
|
44
|
+
requestHeaders['Upgrade'] = 'h2c';
|
|
45
|
+
requestHeaders['HTTP2-Settings'] = '';
|
|
46
|
+
}
|
|
47
|
+
let response;
|
|
48
|
+
try {
|
|
49
|
+
response = await withTimeout(fetch(url, {
|
|
50
|
+
method: 'GET',
|
|
51
|
+
headers: requestHeaders,
|
|
52
|
+
redirect: 'manual',
|
|
53
|
+
signal: this.signal,
|
|
54
|
+
}), this.timeout.request, `Request timeout after ${this.timeout.request}ms`);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
58
|
+
throw new QueryAbortedError(url);
|
|
59
|
+
}
|
|
60
|
+
if (error instanceof Error && error.message.includes('timeout')) {
|
|
61
|
+
throw new TimeoutError(`Request timed out after ${this.timeout.request}ms`, { url });
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
if (response.status >= 300 && response.status < 400) {
|
|
66
|
+
const fromUrl = url;
|
|
67
|
+
if (!this.followRedirects) {
|
|
68
|
+
throw new NetworkError(`Redirect not allowed (status: ${response.status})`, response.status, { url });
|
|
69
|
+
}
|
|
70
|
+
const location = response.headers.get('Location');
|
|
71
|
+
if (!location) {
|
|
72
|
+
throw new NetworkError('Redirect without Location header', response.status, { url });
|
|
73
|
+
}
|
|
74
|
+
let redirectUrl;
|
|
75
|
+
try {
|
|
76
|
+
redirectUrl = new URL(location, url).toString();
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new NetworkError('Invalid redirect URL', response.status, { url, location });
|
|
80
|
+
}
|
|
81
|
+
if (this.ssrfProtection) {
|
|
82
|
+
await this.ssrfProtection.validateUrl(redirectUrl);
|
|
83
|
+
}
|
|
84
|
+
this.logRedirect?.(fromUrl, redirectUrl);
|
|
85
|
+
return this.makeRequest(redirectUrl, redirectCount + 1);
|
|
86
|
+
}
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
let errorBody;
|
|
89
|
+
try {
|
|
90
|
+
errorBody = await response.json();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
try {
|
|
94
|
+
errorBody = await response.text();
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
errorBody = null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
throw new RDAPServerError(`RDAP server error: ${response.status} ${response.statusText}`, response.status, { url, body: errorBody });
|
|
101
|
+
}
|
|
102
|
+
let data;
|
|
103
|
+
try {
|
|
104
|
+
data = await response.json();
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw new NetworkError('Failed to parse RDAP response as JSON', response.status, {
|
|
108
|
+
url,
|
|
109
|
+
originalError: error,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (!data || typeof data !== 'object') {
|
|
113
|
+
throw new NetworkError('Invalid RDAP response: not an object', response.status, {
|
|
114
|
+
url,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
|
+
getConfig() {
|
|
120
|
+
return {
|
|
121
|
+
timeout: { ...this.timeout },
|
|
122
|
+
userAgent: this.userAgent,
|
|
123
|
+
followRedirects: this.followRedirects,
|
|
124
|
+
maxRedirects: this.maxRedirects,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|