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,188 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
export class PersistentCache {
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
this.cache = new Map();
|
|
6
|
+
this.dirty = false;
|
|
7
|
+
this.storage = options.storage || 'memory';
|
|
8
|
+
this.ttl = options.ttl || 3600000;
|
|
9
|
+
this.maxSize = options.maxSize || 1000;
|
|
10
|
+
this.autoSave = options.autoSave ?? true;
|
|
11
|
+
if (this.storage === 'file') {
|
|
12
|
+
this.filePath = options.path || path.join(process.cwd(), '.cache', 'rdap-cache.json');
|
|
13
|
+
this.ensureCacheDirectory();
|
|
14
|
+
this.load();
|
|
15
|
+
if (this.autoSave) {
|
|
16
|
+
const interval = options.saveInterval || 60000;
|
|
17
|
+
this.saveTimer = setInterval(() => {
|
|
18
|
+
if (this.dirty) {
|
|
19
|
+
this.save();
|
|
20
|
+
}
|
|
21
|
+
}, interval);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async get(key) {
|
|
26
|
+
const entry = this.cache.get(key);
|
|
27
|
+
if (!entry) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (Date.now() > entry.expires) {
|
|
31
|
+
this.cache.delete(key);
|
|
32
|
+
this.dirty = true;
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
entry.accessed = Date.now();
|
|
36
|
+
entry.hits++;
|
|
37
|
+
this.dirty = true;
|
|
38
|
+
return entry.value;
|
|
39
|
+
}
|
|
40
|
+
async set(key, value, ttl) {
|
|
41
|
+
const effectiveTtl = ttl || this.ttl;
|
|
42
|
+
const now = Date.now();
|
|
43
|
+
const entry = {
|
|
44
|
+
value,
|
|
45
|
+
expires: now + effectiveTtl,
|
|
46
|
+
created: now,
|
|
47
|
+
accessed: now,
|
|
48
|
+
hits: 0,
|
|
49
|
+
};
|
|
50
|
+
this.cache.set(key, entry);
|
|
51
|
+
this.dirty = true;
|
|
52
|
+
if (this.cache.size > this.maxSize) {
|
|
53
|
+
this.evictLRU();
|
|
54
|
+
}
|
|
55
|
+
if (this.storage === 'file' && !this.autoSave) {
|
|
56
|
+
await this.save();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async delete(key) {
|
|
60
|
+
const deleted = this.cache.delete(key);
|
|
61
|
+
if (deleted) {
|
|
62
|
+
this.dirty = true;
|
|
63
|
+
}
|
|
64
|
+
return deleted;
|
|
65
|
+
}
|
|
66
|
+
async has(key) {
|
|
67
|
+
const entry = this.cache.get(key);
|
|
68
|
+
if (!entry) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (Date.now() > entry.expires) {
|
|
72
|
+
this.cache.delete(key);
|
|
73
|
+
this.dirty = true;
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
async clear() {
|
|
79
|
+
this.cache.clear();
|
|
80
|
+
this.dirty = true;
|
|
81
|
+
if (this.storage === 'file') {
|
|
82
|
+
await this.save();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async getStats() {
|
|
86
|
+
let totalHits = 0;
|
|
87
|
+
let oldestEntry;
|
|
88
|
+
let newestEntry;
|
|
89
|
+
for (const entry of this.cache.values()) {
|
|
90
|
+
totalHits += entry.hits;
|
|
91
|
+
if (!oldestEntry || entry.created < oldestEntry) {
|
|
92
|
+
oldestEntry = entry.created;
|
|
93
|
+
}
|
|
94
|
+
if (!newestEntry || entry.created > newestEntry) {
|
|
95
|
+
newestEntry = entry.created;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
size: this.cache.size,
|
|
100
|
+
maxSize: this.maxSize,
|
|
101
|
+
storage: this.storage,
|
|
102
|
+
hits: totalHits,
|
|
103
|
+
oldestEntry,
|
|
104
|
+
newestEntry,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
evictLRU() {
|
|
108
|
+
let lruKey = null;
|
|
109
|
+
let lruTime = Infinity;
|
|
110
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
111
|
+
if (entry.accessed < lruTime) {
|
|
112
|
+
lruTime = entry.accessed;
|
|
113
|
+
lruKey = key;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (lruKey) {
|
|
117
|
+
this.cache.delete(lruKey);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
ensureCacheDirectory() {
|
|
121
|
+
if (!this.filePath)
|
|
122
|
+
return;
|
|
123
|
+
const dir = path.dirname(this.filePath);
|
|
124
|
+
if (!fs.existsSync(dir)) {
|
|
125
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
load() {
|
|
129
|
+
if (!this.filePath || !fs.existsSync(this.filePath)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const data = fs.readFileSync(this.filePath, 'utf-8');
|
|
134
|
+
const entries = JSON.parse(data);
|
|
135
|
+
const now = Date.now();
|
|
136
|
+
for (const [key, entry] of Object.entries(entries)) {
|
|
137
|
+
const cacheEntry = entry;
|
|
138
|
+
if (cacheEntry.expires > now) {
|
|
139
|
+
this.cache.set(key, cacheEntry);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
this.dirty = false;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
console.warn('Failed to load cache:', error);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async save() {
|
|
149
|
+
if (!this.filePath)
|
|
150
|
+
return;
|
|
151
|
+
try {
|
|
152
|
+
const entries = {};
|
|
153
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
154
|
+
entries[key] = entry;
|
|
155
|
+
}
|
|
156
|
+
const data = JSON.stringify(entries, null, 2);
|
|
157
|
+
fs.writeFileSync(this.filePath, data, 'utf-8');
|
|
158
|
+
this.dirty = false;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.error('Failed to save cache:', error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async cleanup() {
|
|
165
|
+
const now = Date.now();
|
|
166
|
+
let removed = 0;
|
|
167
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
168
|
+
if (entry.expires < now) {
|
|
169
|
+
this.cache.delete(key);
|
|
170
|
+
removed++;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (removed > 0) {
|
|
174
|
+
this.dirty = true;
|
|
175
|
+
}
|
|
176
|
+
return removed;
|
|
177
|
+
}
|
|
178
|
+
destroy() {
|
|
179
|
+
if (this.saveTimer) {
|
|
180
|
+
clearInterval(this.saveTimer);
|
|
181
|
+
this.saveTimer = undefined;
|
|
182
|
+
}
|
|
183
|
+
if (this.storage === 'file' && this.dirty) {
|
|
184
|
+
this.save();
|
|
185
|
+
}
|
|
186
|
+
this.cache.clear();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export class RedisCache {
|
|
2
|
+
constructor(client, options = {}) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.keyPrefix = options.keyPrefix ?? 'rdapify:';
|
|
5
|
+
this.keyMaxLength = options.keyMaxLength ?? 200;
|
|
6
|
+
}
|
|
7
|
+
prefixed(key) {
|
|
8
|
+
const compressed = this.keyMaxLength > 0 && key.length > this.keyMaxLength
|
|
9
|
+
? RedisCache.sha256Hex(key)
|
|
10
|
+
: key;
|
|
11
|
+
return `${this.keyPrefix}${compressed}`;
|
|
12
|
+
}
|
|
13
|
+
static sha256Hex(input) {
|
|
14
|
+
const crypto = require('crypto');
|
|
15
|
+
return crypto.createHash('sha256').update(input, 'utf8').digest('hex');
|
|
16
|
+
}
|
|
17
|
+
patternAll() {
|
|
18
|
+
return `${this.keyPrefix}*`;
|
|
19
|
+
}
|
|
20
|
+
async scanAll(pattern) {
|
|
21
|
+
if (typeof this.client.scan === 'function') {
|
|
22
|
+
const collected = [];
|
|
23
|
+
let cursor = '0';
|
|
24
|
+
do {
|
|
25
|
+
const [nextCursor, keys] = await this.client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
|
|
26
|
+
cursor = nextCursor;
|
|
27
|
+
collected.push(...keys);
|
|
28
|
+
} while (cursor !== '0');
|
|
29
|
+
return collected;
|
|
30
|
+
}
|
|
31
|
+
return this.client.keys(pattern);
|
|
32
|
+
}
|
|
33
|
+
async get(key) {
|
|
34
|
+
const raw = await this.client.get(this.prefixed(key));
|
|
35
|
+
if (raw === null) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
return JSON.parse(raw);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async set(key, value, ttl) {
|
|
46
|
+
const serialised = JSON.stringify(value);
|
|
47
|
+
const prefixedKey = this.prefixed(key);
|
|
48
|
+
if (ttl !== undefined && ttl > 0) {
|
|
49
|
+
await this.client.set(prefixedKey, serialised, { EX: ttl });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
await this.client.set(prefixedKey, serialised);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async delete(key) {
|
|
56
|
+
await this.client.del(this.prefixed(key));
|
|
57
|
+
}
|
|
58
|
+
async clear() {
|
|
59
|
+
const matchingKeys = await this.scanAll(this.patternAll());
|
|
60
|
+
if (matchingKeys.length > 0) {
|
|
61
|
+
await this.client.del(...matchingKeys);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async has(key) {
|
|
65
|
+
const count = await this.client.exists(this.prefixed(key));
|
|
66
|
+
return count > 0;
|
|
67
|
+
}
|
|
68
|
+
async size() {
|
|
69
|
+
const matchingKeys = await this.scanAll(this.patternAll());
|
|
70
|
+
return matchingKeys.length;
|
|
71
|
+
}
|
|
72
|
+
async getMany(keys) {
|
|
73
|
+
if (keys.length === 0)
|
|
74
|
+
return [];
|
|
75
|
+
const prefixedKeys = keys.map((k) => this.prefixed(k));
|
|
76
|
+
let raws;
|
|
77
|
+
const clientAsAny = this.client;
|
|
78
|
+
if (typeof clientAsAny['mget'] === 'function') {
|
|
79
|
+
const mget = clientAsAny['mget'];
|
|
80
|
+
raws = await mget(...prefixedKeys);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
raws = await Promise.all(prefixedKeys.map((k) => this.client.get(k)));
|
|
84
|
+
}
|
|
85
|
+
return raws.map((raw) => {
|
|
86
|
+
if (raw === null)
|
|
87
|
+
return null;
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(raw);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async setMany(entries) {
|
|
97
|
+
await Promise.all(entries.map((e) => this.set(e.key, e.value, e.ttl)));
|
|
98
|
+
}
|
|
99
|
+
async getStats() {
|
|
100
|
+
return {
|
|
101
|
+
keyPrefix: this.keyPrefix,
|
|
102
|
+
size: await this.size(),
|
|
103
|
+
keyMaxLength: this.keyMaxLength,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class StaleWhileRevalidateCache {
|
|
2
|
+
constructor(maxSize = 1000, revalidateCallback) {
|
|
3
|
+
this.entries = new Map();
|
|
4
|
+
this.maxSize = maxSize;
|
|
5
|
+
this.revalidateCallback = revalidateCallback;
|
|
6
|
+
}
|
|
7
|
+
async get(key) {
|
|
8
|
+
const entry = this.entries.get(key);
|
|
9
|
+
if (!entry)
|
|
10
|
+
return null;
|
|
11
|
+
const isExpired = Date.now() > entry.expiresAt;
|
|
12
|
+
if (isExpired && this.revalidateCallback) {
|
|
13
|
+
Promise.resolve().then(() => {
|
|
14
|
+
this.revalidateCallback(key, entry.value);
|
|
15
|
+
}).catch(() => { });
|
|
16
|
+
}
|
|
17
|
+
return entry.value;
|
|
18
|
+
}
|
|
19
|
+
async set(key, value, ttl = 3600) {
|
|
20
|
+
if (this.entries.size >= this.maxSize && !this.entries.has(key)) {
|
|
21
|
+
this.evictOldest();
|
|
22
|
+
}
|
|
23
|
+
this.entries.set(key, { value, expiresAt: Date.now() + ttl * 1000 });
|
|
24
|
+
}
|
|
25
|
+
async delete(key) {
|
|
26
|
+
this.entries.delete(key);
|
|
27
|
+
}
|
|
28
|
+
async clear() {
|
|
29
|
+
this.entries.clear();
|
|
30
|
+
}
|
|
31
|
+
async has(key) {
|
|
32
|
+
return this.entries.has(key);
|
|
33
|
+
}
|
|
34
|
+
async size() {
|
|
35
|
+
return this.entries.size;
|
|
36
|
+
}
|
|
37
|
+
evictOldest() {
|
|
38
|
+
const firstKey = this.entries.keys().next().value;
|
|
39
|
+
if (firstKey !== undefined) {
|
|
40
|
+
this.entries.delete(firstKey);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export class AuthenticationManager {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.type = options.type;
|
|
4
|
+
this.username = options.username;
|
|
5
|
+
this.password = options.password;
|
|
6
|
+
this.token = options.token;
|
|
7
|
+
this.apiKey = options.apiKey;
|
|
8
|
+
this.apiKeyHeader = options.apiKeyHeader || 'X-API-Key';
|
|
9
|
+
this.oauth2 = options.oauth2;
|
|
10
|
+
this.validate();
|
|
11
|
+
}
|
|
12
|
+
validate() {
|
|
13
|
+
switch (this.type) {
|
|
14
|
+
case 'basic':
|
|
15
|
+
if (!this.username || !this.password) {
|
|
16
|
+
throw new Error('Basic auth requires username and password');
|
|
17
|
+
}
|
|
18
|
+
break;
|
|
19
|
+
case 'bearer':
|
|
20
|
+
if (!this.token) {
|
|
21
|
+
throw new Error('Bearer auth requires token');
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
case 'apikey':
|
|
25
|
+
if (!this.apiKey) {
|
|
26
|
+
throw new Error('API key auth requires apiKey');
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
case 'oauth2':
|
|
30
|
+
if (!this.oauth2?.accessToken) {
|
|
31
|
+
throw new Error('OAuth2 requires accessToken');
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
getHeaders() {
|
|
37
|
+
const headers = {};
|
|
38
|
+
switch (this.type) {
|
|
39
|
+
case 'basic':
|
|
40
|
+
if (this.username && this.password) {
|
|
41
|
+
const credentials = Buffer.from(`${this.username}:${this.password}`).toString('base64');
|
|
42
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case 'bearer':
|
|
46
|
+
if (this.token) {
|
|
47
|
+
headers['Authorization'] = `Bearer ${this.token}`;
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
case 'apikey':
|
|
51
|
+
if (this.apiKey) {
|
|
52
|
+
headers[this.apiKeyHeader] = this.apiKey;
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case 'oauth2':
|
|
56
|
+
if (this.oauth2?.accessToken) {
|
|
57
|
+
const tokenType = this.oauth2.tokenType || 'Bearer';
|
|
58
|
+
headers['Authorization'] = `${tokenType} ${this.oauth2.accessToken}`;
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
return headers;
|
|
63
|
+
}
|
|
64
|
+
isTokenExpired() {
|
|
65
|
+
if (this.type !== 'oauth2' || !this.oauth2?.expiresAt) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return Date.now() >= this.oauth2.expiresAt;
|
|
69
|
+
}
|
|
70
|
+
updateOAuth2Token(options) {
|
|
71
|
+
if (this.type !== 'oauth2') {
|
|
72
|
+
throw new Error('Cannot update OAuth2 token for non-OAuth2 auth');
|
|
73
|
+
}
|
|
74
|
+
this.oauth2 = options;
|
|
75
|
+
}
|
|
76
|
+
getType() {
|
|
77
|
+
return this.type;
|
|
78
|
+
}
|
|
79
|
+
getInfo() {
|
|
80
|
+
const info = {
|
|
81
|
+
type: this.type,
|
|
82
|
+
};
|
|
83
|
+
if (this.type === 'basic' && this.username) {
|
|
84
|
+
info.username = this.username;
|
|
85
|
+
}
|
|
86
|
+
if (this.type === 'apikey') {
|
|
87
|
+
info.apiKeyHeader = this.apiKeyHeader;
|
|
88
|
+
}
|
|
89
|
+
if (this.type === 'oauth2') {
|
|
90
|
+
info.tokenExpired = this.isTokenExpired();
|
|
91
|
+
}
|
|
92
|
+
return info;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import * as ipaddr from 'ipaddr.js';
|
|
2
|
+
import { NoServerFoundError, NetworkError } from '../../shared/errors';
|
|
3
|
+
import { extractTLD } from '../../shared/utils/helpers';
|
|
4
|
+
import { Fetcher } from './Fetcher';
|
|
5
|
+
const REGIONAL_BOOTSTRAP_URLS = {
|
|
6
|
+
us: 'https://data.iana.org/rdap',
|
|
7
|
+
eu: 'https://data.iana.org/rdap',
|
|
8
|
+
ap: 'https://data.iana.org/rdap',
|
|
9
|
+
};
|
|
10
|
+
export class BootstrapDiscovery {
|
|
11
|
+
constructor(baseUrl = 'https://data.iana.org/rdap', fetcher, options) {
|
|
12
|
+
this.fetcher = fetcher || new Fetcher();
|
|
13
|
+
this.cache = new Map();
|
|
14
|
+
this.cacheExpiry = new Map();
|
|
15
|
+
this.cacheTTL = ((options?.ttl ?? 86400) * 1000);
|
|
16
|
+
this.fallback = options?.fallback ?? true;
|
|
17
|
+
this.customServersMap = new Map((options?.customServers ?? []).map(({ tld, url }) => [tld.toLowerCase(), url]));
|
|
18
|
+
const regionUrls = (options?.regions ?? [])
|
|
19
|
+
.map((r) => REGIONAL_BOOTSTRAP_URLS[r])
|
|
20
|
+
.filter((url) => Boolean(url));
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
this.regionalUrls = [...regionUrls, baseUrl].filter((url) => {
|
|
23
|
+
if (seen.has(url))
|
|
24
|
+
return false;
|
|
25
|
+
seen.add(url);
|
|
26
|
+
return true;
|
|
27
|
+
});
|
|
28
|
+
void baseUrl;
|
|
29
|
+
}
|
|
30
|
+
async discoverDomain(domain) {
|
|
31
|
+
const tld = extractTLD(domain);
|
|
32
|
+
const tldKey = tld.toLowerCase();
|
|
33
|
+
const custom = this.customServersMap.get(tldKey);
|
|
34
|
+
if (custom)
|
|
35
|
+
return custom;
|
|
36
|
+
if (!this.fallback) {
|
|
37
|
+
throw new NoServerFoundError(`No RDAP server found for TLD: ${tld}`, { domain, tld });
|
|
38
|
+
}
|
|
39
|
+
const entries = await this.getBootstrapData('dns');
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
if (entry.patterns.includes(tldKey)) {
|
|
42
|
+
if (entry.servers.length === 0 || !entry.servers[0]) {
|
|
43
|
+
throw new NoServerFoundError(`No RDAP server found for TLD: ${tld}`, { domain, tld });
|
|
44
|
+
}
|
|
45
|
+
return entry.servers[0];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw new NoServerFoundError(`No RDAP server found for domain: ${domain}`, { domain, tld });
|
|
49
|
+
}
|
|
50
|
+
async discoverIPv4(ip) {
|
|
51
|
+
const entries = await this.getBootstrapData('ipv4');
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
for (const pattern of entry.patterns) {
|
|
54
|
+
if (this.ipMatchesCIDR(ip, pattern)) {
|
|
55
|
+
if (entry.servers.length === 0 || !entry.servers[0]) {
|
|
56
|
+
throw new NoServerFoundError(`No RDAP server found for IPv4: ${ip}`, { ip, pattern });
|
|
57
|
+
}
|
|
58
|
+
return entry.servers[0];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw new NoServerFoundError(`No RDAP server found for IPv4: ${ip}`, { ip });
|
|
63
|
+
}
|
|
64
|
+
async discoverIPv6(ip) {
|
|
65
|
+
const entries = await this.getBootstrapData('ipv6');
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
for (const pattern of entry.patterns) {
|
|
68
|
+
if (this.ipMatchesCIDR(ip, pattern)) {
|
|
69
|
+
if (entry.servers.length === 0 || !entry.servers[0]) {
|
|
70
|
+
throw new NoServerFoundError(`No RDAP server found for IPv6: ${ip}`, { ip, pattern });
|
|
71
|
+
}
|
|
72
|
+
return entry.servers[0];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
throw new NoServerFoundError(`No RDAP server found for IPv6: ${ip}`, { ip });
|
|
77
|
+
}
|
|
78
|
+
async discoverNameserver(nameserver) {
|
|
79
|
+
const tld = extractTLD(nameserver);
|
|
80
|
+
const tldKey = tld.toLowerCase();
|
|
81
|
+
const custom = this.customServersMap.get(tldKey);
|
|
82
|
+
if (custom)
|
|
83
|
+
return custom;
|
|
84
|
+
if (!this.fallback) {
|
|
85
|
+
throw new NoServerFoundError(`No RDAP server found for nameserver TLD: ${tld}`, {
|
|
86
|
+
nameserver,
|
|
87
|
+
tld,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const entries = await this.getBootstrapData('dns');
|
|
91
|
+
for (const entry of entries) {
|
|
92
|
+
if (entry.patterns.includes(tldKey)) {
|
|
93
|
+
if (entry.servers.length === 0 || !entry.servers[0]) {
|
|
94
|
+
throw new NoServerFoundError(`No RDAP server found for nameserver TLD: ${tld}`, {
|
|
95
|
+
nameserver,
|
|
96
|
+
tld,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return entry.servers[0];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
throw new NoServerFoundError(`No RDAP server found for nameserver: ${nameserver}`, {
|
|
103
|
+
nameserver,
|
|
104
|
+
tld,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async discoverASN(asn) {
|
|
108
|
+
const entries = await this.getBootstrapData('asn');
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
for (const pattern of entry.patterns) {
|
|
111
|
+
const parts = pattern.split('-').map((n) => parseInt(n, 10));
|
|
112
|
+
const start = parts[0];
|
|
113
|
+
const end = parts[1];
|
|
114
|
+
if (start === undefined || end === undefined || isNaN(start) || isNaN(end)) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (asn >= start && asn <= end) {
|
|
118
|
+
if (entry.servers.length === 0 || !entry.servers[0]) {
|
|
119
|
+
throw new NoServerFoundError(`No RDAP server found for ASN: ${asn}`, { asn, pattern });
|
|
120
|
+
}
|
|
121
|
+
return entry.servers[0];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
throw new NoServerFoundError(`No RDAP server found for ASN: ${asn}`, { asn });
|
|
126
|
+
}
|
|
127
|
+
async getBootstrapData(type) {
|
|
128
|
+
const cached = this.cache.get(type);
|
|
129
|
+
const expiry = this.cacheExpiry.get(type);
|
|
130
|
+
if (cached && expiry && Date.now() < expiry) {
|
|
131
|
+
return cached;
|
|
132
|
+
}
|
|
133
|
+
let response;
|
|
134
|
+
let lastError;
|
|
135
|
+
let lastUrl = '';
|
|
136
|
+
for (const base of this.regionalUrls) {
|
|
137
|
+
const url = `${base}/${type}.json`;
|
|
138
|
+
lastUrl = url;
|
|
139
|
+
try {
|
|
140
|
+
response = await this.fetcher.fetch(url);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
lastError = error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (response === undefined) {
|
|
148
|
+
throw new NetworkError(`Failed to fetch bootstrap data for ${type}`, undefined, {
|
|
149
|
+
type,
|
|
150
|
+
url: lastUrl,
|
|
151
|
+
originalError: lastError,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const bootstrapData = response;
|
|
155
|
+
if (!bootstrapData.services || !Array.isArray(bootstrapData.services)) {
|
|
156
|
+
throw new NetworkError(`Invalid bootstrap data format for ${type}`, undefined, { type, url: lastUrl });
|
|
157
|
+
}
|
|
158
|
+
const entries = bootstrapData.services.map((service) => ({
|
|
159
|
+
patterns: service[0],
|
|
160
|
+
servers: service[1],
|
|
161
|
+
}));
|
|
162
|
+
this.cache.set(type, entries);
|
|
163
|
+
this.cacheExpiry.set(type, Date.now() + this.cacheTTL);
|
|
164
|
+
return entries;
|
|
165
|
+
}
|
|
166
|
+
ipMatchesCIDR(ip, cidr) {
|
|
167
|
+
try {
|
|
168
|
+
if (!cidr.includes('/')) {
|
|
169
|
+
return ip === cidr;
|
|
170
|
+
}
|
|
171
|
+
const addr = ipaddr.process(ip);
|
|
172
|
+
const range = ipaddr.parseCIDR(cidr);
|
|
173
|
+
return addr.match(range);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
clearCache() {
|
|
180
|
+
this.cache.clear();
|
|
181
|
+
this.cacheExpiry.clear();
|
|
182
|
+
}
|
|
183
|
+
getCacheStats() {
|
|
184
|
+
return {
|
|
185
|
+
size: this.cache.size,
|
|
186
|
+
types: Array.from(this.cache.keys()),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { NetworkError, RDAPServerError, TimeoutError, RDAPifyError } from '../../shared/errors';
|
|
2
|
+
export class BrowserFetcher {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
if (!options.proxyUrl) {
|
|
5
|
+
throw new Error('BrowserFetcher: proxyUrl is required');
|
|
6
|
+
}
|
|
7
|
+
this.proxyUrl = options.proxyUrl.replace(/\/$/, '');
|
|
8
|
+
this.timeout = options.timeout ?? 15000;
|
|
9
|
+
this.headers = options.headers ?? {};
|
|
10
|
+
}
|
|
11
|
+
async fetch(url) {
|
|
12
|
+
const proxiedUrl = `${this.proxyUrl}?url=${encodeURIComponent(url)}`;
|
|
13
|
+
try {
|
|
14
|
+
const response = await globalThis.fetch(proxiedUrl, {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
headers: {
|
|
17
|
+
Accept: 'application/rdap+json, application/json',
|
|
18
|
+
...this.headers,
|
|
19
|
+
},
|
|
20
|
+
signal: AbortSignal.timeout(this.timeout),
|
|
21
|
+
});
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
throw new RDAPServerError(`RDAP proxy returned ${response.status} for ${url}`, response.status, { url: proxiedUrl });
|
|
24
|
+
}
|
|
25
|
+
const data = (await response.json());
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
if (err instanceof RDAPifyError)
|
|
30
|
+
throw err;
|
|
31
|
+
if (err instanceof DOMException && err.name === 'TimeoutError') {
|
|
32
|
+
throw new TimeoutError(`Browser proxy request timed out after ${this.timeout}ms`, {
|
|
33
|
+
url: proxiedUrl,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
throw new NetworkError(`BrowserFetcher: failed to fetch ${url} via proxy: ${err instanceof Error ? err.message : String(err)}`, undefined, { url: proxiedUrl, originalError: err });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
getProxyUrl() {
|
|
40
|
+
return this.proxyUrl;
|
|
41
|
+
}
|
|
42
|
+
}
|