rdapify 0.3.0 → 0.3.2
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/CHANGELOG.md +17 -0
- 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 +15 -2
- 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 +126 -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 +30 -26
- 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,615 @@
|
|
|
1
|
+
import { generateCacheKey } from '../../shared/utils/helpers';
|
|
2
|
+
import { validateDomain, validateIP, validateASN, validateNameserver, validateEntityHandle, normalizeDomain, normalizeIP, normalizeASN, normalizeNameserver, normalizeEntityHandle, } from '../../shared/utils/validators';
|
|
3
|
+
import { QueryAbortedError } from '../../shared/errors';
|
|
4
|
+
export class QueryOrchestrator {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
async queryDomain(domain) {
|
|
9
|
+
const startTime = Date.now();
|
|
10
|
+
this.config.logger?.logRequest('domain', domain);
|
|
11
|
+
if (this.config.rateLimiter) {
|
|
12
|
+
await this.config.rateLimiter.checkLimit();
|
|
13
|
+
}
|
|
14
|
+
validateDomain(domain);
|
|
15
|
+
const normalized = normalizeDomain(domain);
|
|
16
|
+
const cacheKey = generateCacheKey('domain', normalized);
|
|
17
|
+
const baseCtx = {
|
|
18
|
+
queryType: 'domain',
|
|
19
|
+
query: domain,
|
|
20
|
+
normalized,
|
|
21
|
+
startTime,
|
|
22
|
+
};
|
|
23
|
+
if (await this.config.middleware?.runBeforeQuery(baseCtx)) {
|
|
24
|
+
throw new QueryAbortedError(baseCtx.query);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const cached = await this.config.cache.get(cacheKey);
|
|
28
|
+
if (cached && cached.objectClass === 'domain') {
|
|
29
|
+
this.config.logger?.logCache('hit', cacheKey);
|
|
30
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
31
|
+
this.config.debugLogger.debug('Cache hit', {
|
|
32
|
+
queryType: 'domain',
|
|
33
|
+
query: normalized,
|
|
34
|
+
cacheKey,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const duration = Date.now() - startTime;
|
|
38
|
+
this.config.metricsCollector?.record({
|
|
39
|
+
type: 'domain',
|
|
40
|
+
query: normalized,
|
|
41
|
+
success: true,
|
|
42
|
+
duration,
|
|
43
|
+
cached: true,
|
|
44
|
+
timestamp: Date.now(),
|
|
45
|
+
});
|
|
46
|
+
await this.config.middleware?.runOnCacheHit({ ...baseCtx, cached: true });
|
|
47
|
+
this.config.logger?.logResponse('domain', normalized, true, duration);
|
|
48
|
+
const result = this.config.piiRedactor.redact(cached);
|
|
49
|
+
await this.config.middleware?.runAfterQuery({
|
|
50
|
+
...baseCtx,
|
|
51
|
+
duration,
|
|
52
|
+
result,
|
|
53
|
+
fromCache: true,
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
this.config.logger?.logCache('miss', cacheKey);
|
|
58
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
59
|
+
this.config.debugLogger.debug('Cache miss', {
|
|
60
|
+
queryType: 'domain',
|
|
61
|
+
query: normalized,
|
|
62
|
+
cacheKey,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
await this.config.middleware?.runOnCacheMiss({ ...baseCtx, cached: false });
|
|
66
|
+
const fetchAndNormalize = async () => {
|
|
67
|
+
const serverUrl = await this.config.bootstrap.discoverDomain(normalized);
|
|
68
|
+
this.config.logger?.debug(`Discovered server: ${serverUrl}`);
|
|
69
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
70
|
+
this.config.debugLogger.debug('RDAP server discovered', {
|
|
71
|
+
queryType: 'domain',
|
|
72
|
+
query: normalized,
|
|
73
|
+
serverUrl,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const queryUrl = `${serverUrl}/domain/${normalized}`;
|
|
77
|
+
const raw = await this.config.fetchWithRetry(queryUrl);
|
|
78
|
+
const response = this.config.normalizer.normalize(raw, normalized, serverUrl, false, this.config.includeRaw);
|
|
79
|
+
await this.config.cache.set(cacheKey, response);
|
|
80
|
+
this.config.logger?.logCache('set', cacheKey);
|
|
81
|
+
return response;
|
|
82
|
+
};
|
|
83
|
+
const response = this.config.deduplicator
|
|
84
|
+
? await this.config.deduplicator.deduplicate(cacheKey, fetchAndNormalize)
|
|
85
|
+
: await fetchAndNormalize();
|
|
86
|
+
const duration = Date.now() - startTime;
|
|
87
|
+
this.config.metricsCollector?.record({
|
|
88
|
+
type: 'domain',
|
|
89
|
+
query: normalized,
|
|
90
|
+
success: true,
|
|
91
|
+
duration,
|
|
92
|
+
cached: false,
|
|
93
|
+
timestamp: Date.now(),
|
|
94
|
+
});
|
|
95
|
+
this.config.logger?.logResponse('domain', normalized, true, duration);
|
|
96
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
97
|
+
this.config.debugLogger.debug('Request completed', {
|
|
98
|
+
queryType: 'domain',
|
|
99
|
+
query: normalized,
|
|
100
|
+
durationMs: duration,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const result = this.config.piiRedactor.redact(response);
|
|
104
|
+
await this.config.middleware?.runAfterQuery({
|
|
105
|
+
...baseCtx,
|
|
106
|
+
duration,
|
|
107
|
+
result,
|
|
108
|
+
fromCache: false,
|
|
109
|
+
});
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
const duration = Date.now() - startTime;
|
|
114
|
+
this.config.metricsCollector?.record({
|
|
115
|
+
type: 'domain',
|
|
116
|
+
query: domain,
|
|
117
|
+
success: false,
|
|
118
|
+
duration,
|
|
119
|
+
cached: false,
|
|
120
|
+
timestamp: Date.now(),
|
|
121
|
+
error: error instanceof Error ? error.name : 'Unknown',
|
|
122
|
+
});
|
|
123
|
+
this.config.logger?.logResponse('domain', domain, false, duration, {
|
|
124
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
125
|
+
});
|
|
126
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
127
|
+
this.config.debugLogger.error('Request failed', {
|
|
128
|
+
queryType: 'domain',
|
|
129
|
+
query: domain,
|
|
130
|
+
durationMs: duration,
|
|
131
|
+
errorMessage: error instanceof Error ? error.message : 'Unknown error',
|
|
132
|
+
errorName: error instanceof Error ? error.name : 'Unknown',
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
await this.config.middleware?.runOnError({
|
|
136
|
+
...baseCtx,
|
|
137
|
+
duration,
|
|
138
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
139
|
+
fromCache: false,
|
|
140
|
+
});
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async queryIP(ip) {
|
|
145
|
+
const startTime = Date.now();
|
|
146
|
+
this.config.logger?.logRequest('ip', ip);
|
|
147
|
+
if (this.config.rateLimiter) {
|
|
148
|
+
await this.config.rateLimiter.checkLimit();
|
|
149
|
+
}
|
|
150
|
+
const version = validateIP(ip);
|
|
151
|
+
const normalized = normalizeIP(ip);
|
|
152
|
+
const cacheKey = generateCacheKey('ip', normalized);
|
|
153
|
+
const baseCtx = {
|
|
154
|
+
queryType: 'ip',
|
|
155
|
+
query: ip,
|
|
156
|
+
normalized,
|
|
157
|
+
startTime,
|
|
158
|
+
};
|
|
159
|
+
if (await this.config.middleware?.runBeforeQuery(baseCtx)) {
|
|
160
|
+
throw new QueryAbortedError(baseCtx.query);
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const cached = await this.config.cache.get(cacheKey);
|
|
164
|
+
if (cached && cached.objectClass === 'ip network') {
|
|
165
|
+
this.config.logger?.logCache('hit', cacheKey);
|
|
166
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
167
|
+
this.config.debugLogger.debug('Cache hit', {
|
|
168
|
+
queryType: 'ip',
|
|
169
|
+
query: normalized,
|
|
170
|
+
cacheKey,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const duration = Date.now() - startTime;
|
|
174
|
+
this.config.metricsCollector?.record({
|
|
175
|
+
type: 'ip',
|
|
176
|
+
query: normalized,
|
|
177
|
+
success: true,
|
|
178
|
+
duration,
|
|
179
|
+
cached: true,
|
|
180
|
+
timestamp: Date.now(),
|
|
181
|
+
});
|
|
182
|
+
await this.config.middleware?.runOnCacheHit({ ...baseCtx, cached: true });
|
|
183
|
+
this.config.logger?.logResponse('ip', normalized, true, duration);
|
|
184
|
+
const result = this.config.piiRedactor.redact(cached);
|
|
185
|
+
await this.config.middleware?.runAfterQuery({
|
|
186
|
+
...baseCtx,
|
|
187
|
+
duration,
|
|
188
|
+
result,
|
|
189
|
+
fromCache: true,
|
|
190
|
+
});
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
this.config.logger?.logCache('miss', cacheKey);
|
|
194
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
195
|
+
this.config.debugLogger.debug('Cache miss', {
|
|
196
|
+
queryType: 'ip',
|
|
197
|
+
query: normalized,
|
|
198
|
+
cacheKey,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
await this.config.middleware?.runOnCacheMiss({ ...baseCtx, cached: false });
|
|
202
|
+
const fetchAndNormalize = async () => {
|
|
203
|
+
const serverUrl = version === 'v4'
|
|
204
|
+
? await this.config.bootstrap.discoverIPv4(normalized)
|
|
205
|
+
: await this.config.bootstrap.discoverIPv6(normalized);
|
|
206
|
+
this.config.logger?.debug(`Discovered server: ${serverUrl}`);
|
|
207
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
208
|
+
this.config.debugLogger.debug('RDAP server discovered', {
|
|
209
|
+
queryType: 'ip',
|
|
210
|
+
query: normalized,
|
|
211
|
+
serverUrl,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const queryUrl = `${serverUrl}/ip/${normalized}`;
|
|
215
|
+
const raw = await this.config.fetchWithRetry(queryUrl);
|
|
216
|
+
const response = this.config.normalizer.normalize(raw, normalized, serverUrl, false, this.config.includeRaw);
|
|
217
|
+
await this.config.cache.set(cacheKey, response);
|
|
218
|
+
this.config.logger?.logCache('set', cacheKey);
|
|
219
|
+
return response;
|
|
220
|
+
};
|
|
221
|
+
const response = this.config.deduplicator
|
|
222
|
+
? await this.config.deduplicator.deduplicate(cacheKey, fetchAndNormalize)
|
|
223
|
+
: await fetchAndNormalize();
|
|
224
|
+
const duration = Date.now() - startTime;
|
|
225
|
+
this.config.metricsCollector?.record({
|
|
226
|
+
type: 'ip',
|
|
227
|
+
query: normalized,
|
|
228
|
+
success: true,
|
|
229
|
+
duration,
|
|
230
|
+
cached: false,
|
|
231
|
+
timestamp: Date.now(),
|
|
232
|
+
});
|
|
233
|
+
this.config.logger?.logResponse('ip', normalized, true, duration);
|
|
234
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
235
|
+
this.config.debugLogger.debug('Request completed', {
|
|
236
|
+
queryType: 'ip',
|
|
237
|
+
query: normalized,
|
|
238
|
+
durationMs: duration,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const result = this.config.piiRedactor.redact(response);
|
|
242
|
+
await this.config.middleware?.runAfterQuery({
|
|
243
|
+
...baseCtx,
|
|
244
|
+
duration,
|
|
245
|
+
result,
|
|
246
|
+
fromCache: false,
|
|
247
|
+
});
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
const duration = Date.now() - startTime;
|
|
252
|
+
this.config.metricsCollector?.record({
|
|
253
|
+
type: 'ip',
|
|
254
|
+
query: ip,
|
|
255
|
+
success: false,
|
|
256
|
+
duration,
|
|
257
|
+
cached: false,
|
|
258
|
+
timestamp: Date.now(),
|
|
259
|
+
error: error instanceof Error ? error.name : 'Unknown',
|
|
260
|
+
});
|
|
261
|
+
this.config.logger?.logResponse('ip', ip, false, duration, {
|
|
262
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
263
|
+
});
|
|
264
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
265
|
+
this.config.debugLogger.error('Request failed', {
|
|
266
|
+
queryType: 'ip',
|
|
267
|
+
query: ip,
|
|
268
|
+
durationMs: duration,
|
|
269
|
+
errorMessage: error instanceof Error ? error.message : 'Unknown error',
|
|
270
|
+
errorName: error instanceof Error ? error.name : 'Unknown',
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
await this.config.middleware?.runOnError({
|
|
274
|
+
...baseCtx,
|
|
275
|
+
duration,
|
|
276
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
277
|
+
fromCache: false,
|
|
278
|
+
});
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async queryASN(asn) {
|
|
283
|
+
const startTime = Date.now();
|
|
284
|
+
const asnStr = typeof asn === 'number' ? `AS${asn}` : asn;
|
|
285
|
+
this.config.logger?.logRequest('asn', asnStr);
|
|
286
|
+
if (this.config.rateLimiter) {
|
|
287
|
+
await this.config.rateLimiter.checkLimit();
|
|
288
|
+
}
|
|
289
|
+
const asnNumber = validateASN(asn);
|
|
290
|
+
const normalized = normalizeASN(asnNumber);
|
|
291
|
+
const cacheKey = generateCacheKey('asn', normalized);
|
|
292
|
+
const baseCtx = {
|
|
293
|
+
queryType: 'asn',
|
|
294
|
+
query: asnStr,
|
|
295
|
+
normalized,
|
|
296
|
+
startTime,
|
|
297
|
+
};
|
|
298
|
+
if (await this.config.middleware?.runBeforeQuery(baseCtx)) {
|
|
299
|
+
throw new QueryAbortedError(baseCtx.query);
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
const cached = await this.config.cache.get(cacheKey);
|
|
303
|
+
if (cached && cached.objectClass === 'autnum') {
|
|
304
|
+
this.config.logger?.logCache('hit', cacheKey);
|
|
305
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
306
|
+
this.config.debugLogger.debug('Cache hit', {
|
|
307
|
+
queryType: 'asn',
|
|
308
|
+
query: normalized,
|
|
309
|
+
cacheKey,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
const duration = Date.now() - startTime;
|
|
313
|
+
this.config.metricsCollector?.record({
|
|
314
|
+
type: 'asn',
|
|
315
|
+
query: normalized,
|
|
316
|
+
success: true,
|
|
317
|
+
duration,
|
|
318
|
+
cached: true,
|
|
319
|
+
timestamp: Date.now(),
|
|
320
|
+
});
|
|
321
|
+
await this.config.middleware?.runOnCacheHit({ ...baseCtx, cached: true });
|
|
322
|
+
this.config.logger?.logResponse('asn', normalized, true, duration);
|
|
323
|
+
const result = this.config.piiRedactor.redact(cached);
|
|
324
|
+
await this.config.middleware?.runAfterQuery({
|
|
325
|
+
...baseCtx,
|
|
326
|
+
duration,
|
|
327
|
+
result,
|
|
328
|
+
fromCache: true,
|
|
329
|
+
});
|
|
330
|
+
return result;
|
|
331
|
+
}
|
|
332
|
+
this.config.logger?.logCache('miss', cacheKey);
|
|
333
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
334
|
+
this.config.debugLogger.debug('Cache miss', {
|
|
335
|
+
queryType: 'asn',
|
|
336
|
+
query: normalized,
|
|
337
|
+
cacheKey,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
await this.config.middleware?.runOnCacheMiss({ ...baseCtx, cached: false });
|
|
341
|
+
const fetchAndNormalize = async () => {
|
|
342
|
+
const serverUrl = await this.config.bootstrap.discoverASN(asnNumber);
|
|
343
|
+
this.config.logger?.debug(`Discovered server: ${serverUrl}`);
|
|
344
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
345
|
+
this.config.debugLogger.debug('RDAP server discovered', {
|
|
346
|
+
queryType: 'asn',
|
|
347
|
+
query: normalized,
|
|
348
|
+
serverUrl,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
const queryUrl = `${serverUrl}/autnum/${asnNumber}`;
|
|
352
|
+
const raw = await this.config.fetchWithRetry(queryUrl);
|
|
353
|
+
const response = this.config.normalizer.normalize(raw, normalized, serverUrl, false, this.config.includeRaw);
|
|
354
|
+
await this.config.cache.set(cacheKey, response);
|
|
355
|
+
this.config.logger?.logCache('set', cacheKey);
|
|
356
|
+
return response;
|
|
357
|
+
};
|
|
358
|
+
const response = this.config.deduplicator
|
|
359
|
+
? await this.config.deduplicator.deduplicate(cacheKey, fetchAndNormalize)
|
|
360
|
+
: await fetchAndNormalize();
|
|
361
|
+
const duration = Date.now() - startTime;
|
|
362
|
+
this.config.metricsCollector?.record({
|
|
363
|
+
type: 'asn',
|
|
364
|
+
query: normalized,
|
|
365
|
+
success: true,
|
|
366
|
+
duration,
|
|
367
|
+
cached: false,
|
|
368
|
+
timestamp: Date.now(),
|
|
369
|
+
});
|
|
370
|
+
this.config.logger?.logResponse('asn', normalized, true, duration);
|
|
371
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
372
|
+
this.config.debugLogger.debug('Request completed', {
|
|
373
|
+
queryType: 'asn',
|
|
374
|
+
query: normalized,
|
|
375
|
+
durationMs: duration,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
const result = this.config.piiRedactor.redact(response);
|
|
379
|
+
await this.config.middleware?.runAfterQuery({
|
|
380
|
+
...baseCtx,
|
|
381
|
+
duration,
|
|
382
|
+
result,
|
|
383
|
+
fromCache: false,
|
|
384
|
+
});
|
|
385
|
+
return result;
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
const duration = Date.now() - startTime;
|
|
389
|
+
this.config.metricsCollector?.record({
|
|
390
|
+
type: 'asn',
|
|
391
|
+
query: asnStr,
|
|
392
|
+
success: false,
|
|
393
|
+
duration,
|
|
394
|
+
cached: false,
|
|
395
|
+
timestamp: Date.now(),
|
|
396
|
+
error: error instanceof Error ? error.name : 'Unknown',
|
|
397
|
+
});
|
|
398
|
+
this.config.logger?.logResponse('asn', asnStr, false, duration, {
|
|
399
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
400
|
+
});
|
|
401
|
+
if (this.config.debugEnabled && this.config.debugLogger) {
|
|
402
|
+
this.config.debugLogger.error('Request failed', {
|
|
403
|
+
queryType: 'asn',
|
|
404
|
+
query: asnStr,
|
|
405
|
+
durationMs: duration,
|
|
406
|
+
errorMessage: error instanceof Error ? error.message : 'Unknown error',
|
|
407
|
+
errorName: error instanceof Error ? error.name : 'Unknown',
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
await this.config.middleware?.runOnError({
|
|
411
|
+
...baseCtx,
|
|
412
|
+
duration,
|
|
413
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
414
|
+
fromCache: false,
|
|
415
|
+
});
|
|
416
|
+
throw error;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
async queryNameserver(nameserver) {
|
|
420
|
+
const startTime = Date.now();
|
|
421
|
+
this.config.logger?.logRequest('nameserver', nameserver);
|
|
422
|
+
if (this.config.rateLimiter) {
|
|
423
|
+
await this.config.rateLimiter.checkLimit();
|
|
424
|
+
}
|
|
425
|
+
validateNameserver(nameserver);
|
|
426
|
+
const normalized = normalizeNameserver(nameserver);
|
|
427
|
+
const cacheKey = generateCacheKey('nameserver', normalized);
|
|
428
|
+
const baseCtx = {
|
|
429
|
+
queryType: 'nameserver',
|
|
430
|
+
query: nameserver,
|
|
431
|
+
normalized,
|
|
432
|
+
startTime,
|
|
433
|
+
};
|
|
434
|
+
if (await this.config.middleware?.runBeforeQuery(baseCtx)) {
|
|
435
|
+
throw new QueryAbortedError(baseCtx.query);
|
|
436
|
+
}
|
|
437
|
+
try {
|
|
438
|
+
const cached = await this.config.cache.get(cacheKey);
|
|
439
|
+
if (cached && cached.objectClass === 'nameserver') {
|
|
440
|
+
this.config.logger?.logCache('hit', cacheKey);
|
|
441
|
+
const duration = Date.now() - startTime;
|
|
442
|
+
this.config.metricsCollector?.record({
|
|
443
|
+
type: 'nameserver',
|
|
444
|
+
query: normalized,
|
|
445
|
+
success: true,
|
|
446
|
+
duration,
|
|
447
|
+
cached: true,
|
|
448
|
+
timestamp: Date.now(),
|
|
449
|
+
});
|
|
450
|
+
await this.config.middleware?.runOnCacheHit({ ...baseCtx, cached: true });
|
|
451
|
+
this.config.logger?.logResponse('nameserver', normalized, true, duration);
|
|
452
|
+
const result = this.config.piiRedactor.redact(cached);
|
|
453
|
+
await this.config.middleware?.runAfterQuery({
|
|
454
|
+
...baseCtx,
|
|
455
|
+
duration,
|
|
456
|
+
result,
|
|
457
|
+
fromCache: true,
|
|
458
|
+
});
|
|
459
|
+
return result;
|
|
460
|
+
}
|
|
461
|
+
this.config.logger?.logCache('miss', cacheKey);
|
|
462
|
+
await this.config.middleware?.runOnCacheMiss({ ...baseCtx, cached: false });
|
|
463
|
+
const fetchAndNormalize = async () => {
|
|
464
|
+
const serverUrl = await this.config.bootstrap.discoverNameserver(normalized);
|
|
465
|
+
this.config.logger?.debug(`Discovered server: ${serverUrl}`);
|
|
466
|
+
const queryUrl = `${serverUrl}/nameserver/${normalized}`;
|
|
467
|
+
const raw = await this.config.fetchWithRetry(queryUrl);
|
|
468
|
+
const response = this.config.normalizer.normalize(raw, normalized, serverUrl, false, this.config.includeRaw);
|
|
469
|
+
await this.config.cache.set(cacheKey, response);
|
|
470
|
+
this.config.logger?.logCache('set', cacheKey);
|
|
471
|
+
return response;
|
|
472
|
+
};
|
|
473
|
+
const response = this.config.deduplicator
|
|
474
|
+
? await this.config.deduplicator.deduplicate(cacheKey, fetchAndNormalize)
|
|
475
|
+
: await fetchAndNormalize();
|
|
476
|
+
const duration = Date.now() - startTime;
|
|
477
|
+
this.config.metricsCollector?.record({
|
|
478
|
+
type: 'nameserver',
|
|
479
|
+
query: normalized,
|
|
480
|
+
success: true,
|
|
481
|
+
duration,
|
|
482
|
+
cached: false,
|
|
483
|
+
timestamp: Date.now(),
|
|
484
|
+
});
|
|
485
|
+
this.config.logger?.logResponse('nameserver', normalized, true, duration);
|
|
486
|
+
const result = this.config.piiRedactor.redact(response);
|
|
487
|
+
await this.config.middleware?.runAfterQuery({
|
|
488
|
+
...baseCtx,
|
|
489
|
+
duration,
|
|
490
|
+
result,
|
|
491
|
+
fromCache: false,
|
|
492
|
+
});
|
|
493
|
+
return result;
|
|
494
|
+
}
|
|
495
|
+
catch (error) {
|
|
496
|
+
const duration = Date.now() - startTime;
|
|
497
|
+
this.config.metricsCollector?.record({
|
|
498
|
+
type: 'nameserver',
|
|
499
|
+
query: nameserver,
|
|
500
|
+
success: false,
|
|
501
|
+
duration,
|
|
502
|
+
cached: false,
|
|
503
|
+
timestamp: Date.now(),
|
|
504
|
+
error: error instanceof Error ? error.name : 'Unknown',
|
|
505
|
+
});
|
|
506
|
+
this.config.logger?.logResponse('nameserver', nameserver, false, duration, {
|
|
507
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
508
|
+
});
|
|
509
|
+
await this.config.middleware?.runOnError({
|
|
510
|
+
...baseCtx,
|
|
511
|
+
duration,
|
|
512
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
513
|
+
fromCache: false,
|
|
514
|
+
});
|
|
515
|
+
throw error;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
async queryEntity(handle, serverUrl) {
|
|
519
|
+
const startTime = Date.now();
|
|
520
|
+
this.config.logger?.logRequest('entity', handle);
|
|
521
|
+
if (this.config.rateLimiter) {
|
|
522
|
+
await this.config.rateLimiter.checkLimit();
|
|
523
|
+
}
|
|
524
|
+
validateEntityHandle(handle);
|
|
525
|
+
const normalized = normalizeEntityHandle(handle);
|
|
526
|
+
const cacheKey = generateCacheKey('entity', `${serverUrl}:${normalized}`);
|
|
527
|
+
const baseCtx = {
|
|
528
|
+
queryType: 'entity',
|
|
529
|
+
query: handle,
|
|
530
|
+
normalized,
|
|
531
|
+
startTime,
|
|
532
|
+
};
|
|
533
|
+
if (await this.config.middleware?.runBeforeQuery(baseCtx)) {
|
|
534
|
+
throw new QueryAbortedError(baseCtx.query);
|
|
535
|
+
}
|
|
536
|
+
try {
|
|
537
|
+
const cached = await this.config.cache.get(cacheKey);
|
|
538
|
+
if (cached && cached.objectClass === 'entity') {
|
|
539
|
+
this.config.logger?.logCache('hit', cacheKey);
|
|
540
|
+
const duration = Date.now() - startTime;
|
|
541
|
+
this.config.metricsCollector?.record({
|
|
542
|
+
type: 'entity',
|
|
543
|
+
query: normalized,
|
|
544
|
+
success: true,
|
|
545
|
+
duration,
|
|
546
|
+
cached: true,
|
|
547
|
+
timestamp: Date.now(),
|
|
548
|
+
});
|
|
549
|
+
await this.config.middleware?.runOnCacheHit({ ...baseCtx, cached: true });
|
|
550
|
+
this.config.logger?.logResponse('entity', normalized, true, duration);
|
|
551
|
+
const result = this.config.piiRedactor.redact(cached);
|
|
552
|
+
await this.config.middleware?.runAfterQuery({
|
|
553
|
+
...baseCtx,
|
|
554
|
+
duration,
|
|
555
|
+
result,
|
|
556
|
+
fromCache: true,
|
|
557
|
+
});
|
|
558
|
+
return result;
|
|
559
|
+
}
|
|
560
|
+
this.config.logger?.logCache('miss', cacheKey);
|
|
561
|
+
await this.config.middleware?.runOnCacheMiss({ ...baseCtx, cached: false });
|
|
562
|
+
const fetchAndNormalize = async () => {
|
|
563
|
+
const queryUrl = `${serverUrl}/entity/${normalized}`;
|
|
564
|
+
const raw = await this.config.fetchWithRetry(queryUrl);
|
|
565
|
+
const response = this.config.normalizer.normalize(raw, normalized, serverUrl, false, this.config.includeRaw);
|
|
566
|
+
await this.config.cache.set(cacheKey, response);
|
|
567
|
+
this.config.logger?.logCache('set', cacheKey);
|
|
568
|
+
return response;
|
|
569
|
+
};
|
|
570
|
+
const response = this.config.deduplicator
|
|
571
|
+
? await this.config.deduplicator.deduplicate(cacheKey, fetchAndNormalize)
|
|
572
|
+
: await fetchAndNormalize();
|
|
573
|
+
const duration = Date.now() - startTime;
|
|
574
|
+
this.config.metricsCollector?.record({
|
|
575
|
+
type: 'entity',
|
|
576
|
+
query: normalized,
|
|
577
|
+
success: true,
|
|
578
|
+
duration,
|
|
579
|
+
cached: false,
|
|
580
|
+
timestamp: Date.now(),
|
|
581
|
+
});
|
|
582
|
+
this.config.logger?.logResponse('entity', normalized, true, duration);
|
|
583
|
+
const result = this.config.piiRedactor.redact(response);
|
|
584
|
+
await this.config.middleware?.runAfterQuery({
|
|
585
|
+
...baseCtx,
|
|
586
|
+
duration,
|
|
587
|
+
result,
|
|
588
|
+
fromCache: false,
|
|
589
|
+
});
|
|
590
|
+
return result;
|
|
591
|
+
}
|
|
592
|
+
catch (error) {
|
|
593
|
+
const duration = Date.now() - startTime;
|
|
594
|
+
this.config.metricsCollector?.record({
|
|
595
|
+
type: 'entity',
|
|
596
|
+
query: handle,
|
|
597
|
+
success: false,
|
|
598
|
+
duration,
|
|
599
|
+
cached: false,
|
|
600
|
+
timestamp: Date.now(),
|
|
601
|
+
error: error instanceof Error ? error.name : 'Unknown',
|
|
602
|
+
});
|
|
603
|
+
this.config.logger?.logResponse('entity', handle, false, duration, {
|
|
604
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
605
|
+
});
|
|
606
|
+
await this.config.middleware?.runOnError({
|
|
607
|
+
...baseCtx,
|
|
608
|
+
duration,
|
|
609
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
610
|
+
fromCache: false,
|
|
611
|
+
});
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|