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,140 @@
|
|
|
1
|
+
export class RDAPifyError extends Error {
|
|
2
|
+
constructor(message, code, statusCode, context, suggestion) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = this.constructor.name;
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
this.context = context;
|
|
8
|
+
this.timestamp = Date.now();
|
|
9
|
+
this.suggestion = suggestion;
|
|
10
|
+
this.queryType = context?.['queryType'];
|
|
11
|
+
this.queryValue = context?.['queryValue'];
|
|
12
|
+
this.serverUrl = context?.['serverUrl'];
|
|
13
|
+
if (Error.captureStackTrace) {
|
|
14
|
+
Error.captureStackTrace(this, this.constructor);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
toJSON() {
|
|
18
|
+
return {
|
|
19
|
+
name: this.name,
|
|
20
|
+
code: this.code,
|
|
21
|
+
message: this.message,
|
|
22
|
+
statusCode: this.statusCode,
|
|
23
|
+
context: this.context,
|
|
24
|
+
timestamp: this.timestamp,
|
|
25
|
+
suggestion: this.suggestion,
|
|
26
|
+
queryType: this.queryType,
|
|
27
|
+
queryValue: this.queryValue,
|
|
28
|
+
serverUrl: this.serverUrl,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
getUserMessage() {
|
|
32
|
+
const parts = [this.message];
|
|
33
|
+
if (this.suggestion) {
|
|
34
|
+
parts.push(`Suggestion: ${this.suggestion}`);
|
|
35
|
+
}
|
|
36
|
+
return parts.join('. ');
|
|
37
|
+
}
|
|
38
|
+
getDetailedMessage() {
|
|
39
|
+
const parts = [this.message];
|
|
40
|
+
if (this.queryType && this.queryValue) {
|
|
41
|
+
parts.push(`Query: ${this.queryType} ${this.queryValue}`);
|
|
42
|
+
}
|
|
43
|
+
if (this.serverUrl) {
|
|
44
|
+
parts.push(`Server: ${this.serverUrl}`);
|
|
45
|
+
}
|
|
46
|
+
if (this.suggestion) {
|
|
47
|
+
parts.push(`Suggestion: ${this.suggestion}`);
|
|
48
|
+
}
|
|
49
|
+
return parts.join('. ');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class ValidationError extends RDAPifyError {
|
|
53
|
+
constructor(message, context, suggestion) {
|
|
54
|
+
super(message, 'VALIDATION_ERROR', 400, context, suggestion || 'Please check your input and try again');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export class ConfigurationError extends RDAPifyError {
|
|
58
|
+
constructor(message, context, suggestion) {
|
|
59
|
+
super(message, 'CONFIGURATION_ERROR', 400, context, suggestion || 'Please check your configuration and try again');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export class NetworkError extends RDAPifyError {
|
|
63
|
+
constructor(message, statusCode, context, suggestion) {
|
|
64
|
+
super(message, 'NETWORK_ERROR', statusCode || 500, context, suggestion || 'Check your network connection and try again');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class TimeoutError extends RDAPifyError {
|
|
68
|
+
constructor(message, context, suggestion) {
|
|
69
|
+
super(message, 'TIMEOUT_ERROR', 408, context, suggestion || 'The request took too long. Try increasing the timeout or check the server status');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export class RDAPServerError extends RDAPifyError {
|
|
73
|
+
constructor(message, statusCode, context, suggestion) {
|
|
74
|
+
const defaultSuggestion = statusCode === 404
|
|
75
|
+
? 'The requested resource was not found. Verify the domain/IP/ASN exists'
|
|
76
|
+
: statusCode === 429
|
|
77
|
+
? 'Rate limit exceeded. Wait a moment before retrying'
|
|
78
|
+
: statusCode >= 500
|
|
79
|
+
? 'The RDAP server is experiencing issues. Try again later'
|
|
80
|
+
: 'Check the RDAP server status and try again';
|
|
81
|
+
super(message, 'RDAP_SERVER_ERROR', statusCode, context, suggestion || defaultSuggestion);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class NoServerFoundError extends RDAPifyError {
|
|
85
|
+
constructor(message, context) {
|
|
86
|
+
super(message, 'NO_SERVER_FOUND', 404, context);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export class ParseError extends RDAPifyError {
|
|
90
|
+
constructor(message, context) {
|
|
91
|
+
super(message, 'PARSE_ERROR', 500, context);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export class CacheError extends RDAPifyError {
|
|
95
|
+
constructor(message, context) {
|
|
96
|
+
super(message, 'CACHE_ERROR', 500, context);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export class RateLimitError extends RDAPifyError {
|
|
100
|
+
constructor(message, context, retryAfter) {
|
|
101
|
+
const suggestion = retryAfter
|
|
102
|
+
? `Rate limit exceeded. Retry after ${retryAfter}ms`
|
|
103
|
+
: 'Rate limit exceeded. Slow down your requests';
|
|
104
|
+
super(message, 'RATE_LIMIT_ERROR', 429, context, suggestion);
|
|
105
|
+
this.retryAfter = retryAfter;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export class SSRFProtectionError extends RDAPifyError {
|
|
109
|
+
constructor(message, context) {
|
|
110
|
+
super(message, 'SSRF_PROTECTION_ERROR', 403, context);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export class SearchNotSupportedError extends RDAPifyError {
|
|
114
|
+
constructor(message, context) {
|
|
115
|
+
super(message, 'SEARCH_NOT_SUPPORTED', 404, context);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export class QueryAbortedError extends RDAPifyError {
|
|
119
|
+
constructor(query) {
|
|
120
|
+
super(query ? `Query aborted by middleware: ${query}` : 'Query aborted by middleware', 'QUERY_ABORTED', 0);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export function isRDAPifyError(error) {
|
|
124
|
+
return error instanceof RDAPifyError;
|
|
125
|
+
}
|
|
126
|
+
export function isSSRFProtectionError(error) {
|
|
127
|
+
return error instanceof SSRFProtectionError;
|
|
128
|
+
}
|
|
129
|
+
export function isNetworkError(error) {
|
|
130
|
+
return error instanceof NetworkError;
|
|
131
|
+
}
|
|
132
|
+
export function isTimeoutError(error) {
|
|
133
|
+
return error instanceof TimeoutError;
|
|
134
|
+
}
|
|
135
|
+
export function isRateLimitError(error) {
|
|
136
|
+
return error instanceof RateLimitError;
|
|
137
|
+
}
|
|
138
|
+
export function isConfigurationError(error) {
|
|
139
|
+
return error instanceof ConfigurationError;
|
|
140
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base.error';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export class RDAPifyError extends Error {
|
|
2
|
+
constructor(message, code, statusCode, details) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'RDAPifyError';
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
this.details = details;
|
|
8
|
+
if (Error.captureStackTrace) {
|
|
9
|
+
Error.captureStackTrace(this, this.constructor);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class SSRFProtectionError extends RDAPifyError {
|
|
14
|
+
constructor(message, details) {
|
|
15
|
+
super(message, 'SSRF_PROTECTION', 403, details);
|
|
16
|
+
this.name = 'SSRFProtectionError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class NetworkError extends RDAPifyError {
|
|
20
|
+
constructor(message, statusCode, details) {
|
|
21
|
+
super(message, 'NETWORK_ERROR', statusCode, details);
|
|
22
|
+
this.name = 'NetworkError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class TimeoutError extends RDAPifyError {
|
|
26
|
+
constructor(message, details) {
|
|
27
|
+
super(message, 'TIMEOUT', 408, details);
|
|
28
|
+
this.name = 'TimeoutError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class RDAPServerError extends RDAPifyError {
|
|
32
|
+
constructor(message, statusCode, details) {
|
|
33
|
+
super(message, 'RDAP_SERVER_ERROR', statusCode, details);
|
|
34
|
+
this.name = 'RDAPServerError';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class NoServerFoundError extends RDAPifyError {
|
|
38
|
+
constructor(message, details) {
|
|
39
|
+
super(message, 'NO_SERVER_FOUND', 404, details);
|
|
40
|
+
this.name = 'NoServerFoundError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class ValidationError extends RDAPifyError {
|
|
44
|
+
constructor(message, details) {
|
|
45
|
+
super(message, 'VALIDATION_ERROR', 400, details);
|
|
46
|
+
this.name = 'ValidationError';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class ParseError extends RDAPifyError {
|
|
50
|
+
constructor(message, details) {
|
|
51
|
+
super(message, 'PARSE_ERROR', 500, details);
|
|
52
|
+
this.name = 'ParseError';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class CacheError extends RDAPifyError {
|
|
56
|
+
constructor(message, details) {
|
|
57
|
+
super(message, 'CACHE_ERROR', 500, details);
|
|
58
|
+
this.name = 'CacheError';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export class RateLimitError extends RDAPifyError {
|
|
62
|
+
constructor(message, retryAfter, details) {
|
|
63
|
+
super(message, 'RATE_LIMIT_EXCEEDED', 429, details);
|
|
64
|
+
this.name = 'RateLimitError';
|
|
65
|
+
this.retryAfter = retryAfter;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function isRDAPifyError(error) {
|
|
69
|
+
return error instanceof RDAPifyError;
|
|
70
|
+
}
|
|
71
|
+
export function isSSRFProtectionError(error) {
|
|
72
|
+
return error instanceof SSRFProtectionError;
|
|
73
|
+
}
|
|
74
|
+
export function isNetworkError(error) {
|
|
75
|
+
return error instanceof NetworkError;
|
|
76
|
+
}
|
|
77
|
+
export function isTimeoutError(error) {
|
|
78
|
+
return error instanceof TimeoutError;
|
|
79
|
+
}
|
|
80
|
+
export function isRateLimitError(error) {
|
|
81
|
+
return error instanceof RateLimitError;
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export const DEFAULT_OPTIONS = {
|
|
2
|
+
cache: {
|
|
3
|
+
strategy: 'memory',
|
|
4
|
+
ttl: 3600,
|
|
5
|
+
maxSize: 1000,
|
|
6
|
+
},
|
|
7
|
+
retry: {
|
|
8
|
+
maxAttempts: 3,
|
|
9
|
+
initialDelay: 1000,
|
|
10
|
+
maxDelay: 10000,
|
|
11
|
+
backoff: 'exponential',
|
|
12
|
+
retryableStatusCodes: [408, 429, 500, 502, 503, 504],
|
|
13
|
+
},
|
|
14
|
+
ssrfProtection: {
|
|
15
|
+
enabled: true,
|
|
16
|
+
blockPrivateIPs: true,
|
|
17
|
+
blockLocalhost: true,
|
|
18
|
+
blockLinkLocal: true,
|
|
19
|
+
blockedDomains: [],
|
|
20
|
+
allowedDomains: [],
|
|
21
|
+
dnsRebinding: false,
|
|
22
|
+
},
|
|
23
|
+
privacy: {
|
|
24
|
+
redactPII: true,
|
|
25
|
+
redactFields: ['email', 'phone', 'fax'],
|
|
26
|
+
redactionText: '[REDACTED]',
|
|
27
|
+
},
|
|
28
|
+
timeout: {
|
|
29
|
+
connect: 5000,
|
|
30
|
+
request: 10000,
|
|
31
|
+
dns: 3000,
|
|
32
|
+
},
|
|
33
|
+
logging: {
|
|
34
|
+
level: 'warn',
|
|
35
|
+
},
|
|
36
|
+
rateLimit: {
|
|
37
|
+
enabled: false,
|
|
38
|
+
maxRequests: 100,
|
|
39
|
+
windowMs: 60000,
|
|
40
|
+
},
|
|
41
|
+
debug: {
|
|
42
|
+
enabled: false,
|
|
43
|
+
},
|
|
44
|
+
userAgent: 'RDAPify/0.1.8 (https://rdapify.com)',
|
|
45
|
+
includeRaw: false,
|
|
46
|
+
followRedirects: true,
|
|
47
|
+
maxRedirects: 5,
|
|
48
|
+
headers: {},
|
|
49
|
+
bootstrapUrl: 'https://data.iana.org/rdap',
|
|
50
|
+
middleware: {},
|
|
51
|
+
deduplication: false,
|
|
52
|
+
backend: 'auto',
|
|
53
|
+
bootstrap: {
|
|
54
|
+
customServers: [],
|
|
55
|
+
ttl: 86400,
|
|
56
|
+
fallback: true,
|
|
57
|
+
},
|
|
58
|
+
http2: false,
|
|
59
|
+
telemetry: {
|
|
60
|
+
enabled: false,
|
|
61
|
+
},
|
|
62
|
+
signal: undefined,
|
|
63
|
+
usageTelemetry: {
|
|
64
|
+
enabled: false,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const emitted = new Set();
|
|
2
|
+
export function deprecated(name, alternative, code) {
|
|
3
|
+
const depCode = code ?? `DEP_RDAPIFY_${name.toUpperCase().replace(/[^A-Z0-9]/g, '_')}`;
|
|
4
|
+
if (emitted.has(depCode))
|
|
5
|
+
return;
|
|
6
|
+
emitted.add(depCode);
|
|
7
|
+
const msg = alternative
|
|
8
|
+
? `${name} is deprecated and will be removed in a future major release. Use ${alternative} instead.`
|
|
9
|
+
: `${name} is deprecated and will be removed in a future major release.`;
|
|
10
|
+
if (typeof process !== 'undefined' &&
|
|
11
|
+
typeof process['emitWarning'] === 'function') {
|
|
12
|
+
process.emitWarning(msg, { type: 'DeprecationWarning', code: depCode });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.warn(`[rdapify DeprecationWarning] ${depCode}: ${msg}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function _resetDeprecationState() {
|
|
19
|
+
emitted.clear();
|
|
20
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { ValidationError } from '../errors';
|
|
2
|
+
export function idnToAscii(domain) {
|
|
3
|
+
try {
|
|
4
|
+
const url = new URL(`http://${domain}`);
|
|
5
|
+
return url.hostname;
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return domain;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function asciiToIdn(domain) {
|
|
12
|
+
try {
|
|
13
|
+
if (domain.includes('xn--')) {
|
|
14
|
+
const url = new URL(`http://${domain}`);
|
|
15
|
+
return url.hostname;
|
|
16
|
+
}
|
|
17
|
+
return domain;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return domain;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function validateIdnDomain(domain) {
|
|
24
|
+
if (!domain || typeof domain !== 'string') {
|
|
25
|
+
throw new ValidationError('Domain must be a non-empty string', {
|
|
26
|
+
suggestion: 'Provide a valid domain name',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
domain = domain.trim();
|
|
30
|
+
if (/[\s<>]/.test(domain)) {
|
|
31
|
+
throw new ValidationError('Domain contains invalid characters', {
|
|
32
|
+
suggestion: 'Remove spaces and special characters',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const asciiDomain = idnToAscii(domain);
|
|
36
|
+
const domainRegex = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;
|
|
37
|
+
if (!domainRegex.test(asciiDomain)) {
|
|
38
|
+
throw new ValidationError(`Invalid domain format: ${domain}`, {
|
|
39
|
+
suggestion: 'Provide a valid domain name (e.g., example.com)',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return asciiDomain.toLowerCase();
|
|
43
|
+
}
|
|
44
|
+
export function validateIpv6WithZone(ip) {
|
|
45
|
+
if (!ip || typeof ip !== 'string') {
|
|
46
|
+
throw new ValidationError('IP address must be a non-empty string', {
|
|
47
|
+
suggestion: 'Provide a valid IPv6 address',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const zoneMatch = ip.match(/^([0-9a-f:]+)%(.+)$/i);
|
|
51
|
+
if (zoneMatch) {
|
|
52
|
+
const ipPart = zoneMatch[1];
|
|
53
|
+
const zonePart = zoneMatch[2];
|
|
54
|
+
if (!ipPart || !zonePart) {
|
|
55
|
+
throw new ValidationError(`Invalid IPv6 format: ${ip}`, {
|
|
56
|
+
suggestion: 'Provide a valid IPv6 address',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const ipv6Regex = /^(([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|([0-9a-f]{1,4}:){1,7}:|([0-9a-f]{1,4}:){1,6}:[0-9a-f]{1,4}|([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2}|([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3}|([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4}|([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5}|[0-9a-f]{1,4}:((:[0-9a-f]{1,4}){1,6})|:((:[0-9a-f]{1,4}){1,7}|:))$/i;
|
|
60
|
+
if (!ipv6Regex.test(ipPart)) {
|
|
61
|
+
throw new ValidationError(`Invalid IPv6 address: ${ipPart}`, {
|
|
62
|
+
suggestion: 'Provide a valid IPv6 address',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
ip: ipPart.toLowerCase(),
|
|
67
|
+
zone: zonePart,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const ipv6Regex = /^(([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|([0-9a-f]{1,4}:){1,7}:|([0-9a-f]{1,4}:){1,6}:[0-9a-f]{1,4}|([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2}|([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3}|([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4}|([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5}|[0-9a-f]{1,4}:((:[0-9a-f]{1,4}){1,6})|:((:[0-9a-f]{1,4}){1,7}|:))$/i;
|
|
71
|
+
if (!ipv6Regex.test(ip)) {
|
|
72
|
+
throw new ValidationError(`Invalid IPv6 address: ${ip}`, {
|
|
73
|
+
suggestion: 'Provide a valid IPv6 address',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return { ip: ip.toLowerCase() };
|
|
77
|
+
}
|
|
78
|
+
export function validateAsnRange(asn) {
|
|
79
|
+
const asnStr = typeof asn === 'number' ? asn.toString() : asn;
|
|
80
|
+
const rangeMatch = asnStr.match(/^(?:AS)?(\d+)-(?:AS)?(\d+)$/i);
|
|
81
|
+
if (rangeMatch) {
|
|
82
|
+
const startStr = rangeMatch[1];
|
|
83
|
+
const endStr = rangeMatch[2];
|
|
84
|
+
if (!startStr || !endStr) {
|
|
85
|
+
throw new ValidationError(`Invalid ASN range format: ${asnStr}`, {
|
|
86
|
+
suggestion: 'Provide a valid ASN range',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const start = parseInt(startStr, 10);
|
|
90
|
+
const end = parseInt(endStr, 10);
|
|
91
|
+
if (start < 0 || start > 4294967295) {
|
|
92
|
+
throw new ValidationError(`Invalid ASN start: ${start}`, {
|
|
93
|
+
suggestion: 'ASN must be between 0 and 4294967295',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (end < 0 || end > 4294967295) {
|
|
97
|
+
throw new ValidationError(`Invalid ASN end: ${end}`, {
|
|
98
|
+
suggestion: 'ASN must be between 0 and 4294967295',
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (start >= end) {
|
|
102
|
+
throw new ValidationError(`Invalid ASN range: start (${start}) must be less than end (${end})`, {
|
|
103
|
+
suggestion: 'Provide a valid ASN range',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return { start, end };
|
|
107
|
+
}
|
|
108
|
+
const asnMatch = asnStr.match(/^(?:AS)?(\d+)$/i);
|
|
109
|
+
if (!asnMatch || !asnMatch[1]) {
|
|
110
|
+
throw new ValidationError(`Invalid ASN format: ${asnStr}`, {
|
|
111
|
+
suggestion: 'Provide a valid ASN (e.g., 15169 or AS15169)',
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const asnNumber = parseInt(asnMatch[1], 10);
|
|
115
|
+
if (asnNumber < 0 || asnNumber > 4294967295) {
|
|
116
|
+
throw new ValidationError(`Invalid ASN: ${asnNumber}`, {
|
|
117
|
+
suggestion: 'ASN must be between 0 and 4294967295',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return { start: asnNumber };
|
|
121
|
+
}
|
|
122
|
+
export function isIdnDomain(domain) {
|
|
123
|
+
return /[^\x00-\x7F]/.test(domain);
|
|
124
|
+
}
|
|
125
|
+
export function isPunycodeDomain(domain) {
|
|
126
|
+
return domain.includes('xn--');
|
|
127
|
+
}
|
|
128
|
+
export function validateEmail(email) {
|
|
129
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
130
|
+
return emailRegex.test(email);
|
|
131
|
+
}
|
|
132
|
+
export function validatePhone(phone) {
|
|
133
|
+
const cleaned = phone.replace(/[\s\-().]/g, '');
|
|
134
|
+
const phoneRegex = /^\+?\d{10,15}$/;
|
|
135
|
+
return phoneRegex.test(cleaned);
|
|
136
|
+
}
|
|
137
|
+
export function normalizeWhitespace(str) {
|
|
138
|
+
return str.trim().replace(/\s+/g, ' ');
|
|
139
|
+
}
|
|
140
|
+
export function validateUrl(url) {
|
|
141
|
+
try {
|
|
142
|
+
new URL(url);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function calculateBackoff(attempt, strategy, initialDelay, maxDelay) {
|
|
2
|
+
let delay;
|
|
3
|
+
switch (strategy) {
|
|
4
|
+
case 'linear':
|
|
5
|
+
delay = initialDelay * attempt;
|
|
6
|
+
break;
|
|
7
|
+
case 'exponential':
|
|
8
|
+
delay = initialDelay * Math.pow(2, attempt - 1);
|
|
9
|
+
break;
|
|
10
|
+
case 'fixed':
|
|
11
|
+
default:
|
|
12
|
+
delay = initialDelay;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
return Math.min(delay, maxDelay);
|
|
16
|
+
}
|
|
17
|
+
export function sleep(ms) {
|
|
18
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
19
|
+
}
|
|
20
|
+
export function createTimeout(ms, message) {
|
|
21
|
+
let timeoutId;
|
|
22
|
+
const promise = new Promise((_, reject) => {
|
|
23
|
+
timeoutId = setTimeout(() => {
|
|
24
|
+
reject(new Error(message || `Operation timed out after ${ms}ms`));
|
|
25
|
+
}, ms);
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
promise,
|
|
29
|
+
cancel: () => clearTimeout(timeoutId),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function withTimeout(promise, timeoutMs, timeoutMessage) {
|
|
33
|
+
const timeout = createTimeout(timeoutMs, timeoutMessage);
|
|
34
|
+
try {
|
|
35
|
+
return await Promise.race([promise, timeout.promise]);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
timeout.cancel();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function formatBytes(bytes) {
|
|
2
|
+
if (bytes === 0)
|
|
3
|
+
return '0 B';
|
|
4
|
+
const k = 1024;
|
|
5
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
6
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
7
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
8
|
+
}
|
|
9
|
+
export function formatDuration(ms) {
|
|
10
|
+
if (ms < 1000)
|
|
11
|
+
return `${ms}ms`;
|
|
12
|
+
if (ms < 60000)
|
|
13
|
+
return `${(ms / 1000).toFixed(2)}s`;
|
|
14
|
+
if (ms < 3600000)
|
|
15
|
+
return `${(ms / 60000).toFixed(2)}m`;
|
|
16
|
+
return `${(ms / 3600000).toFixed(2)}h`;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function parseRetryAfter(value) {
|
|
2
|
+
if (!value)
|
|
3
|
+
return undefined;
|
|
4
|
+
const seconds = parseInt(value, 10);
|
|
5
|
+
if (!isNaN(seconds)) {
|
|
6
|
+
return seconds * 1000;
|
|
7
|
+
}
|
|
8
|
+
const date = new Date(value);
|
|
9
|
+
if (!isNaN(date.getTime())) {
|
|
10
|
+
return Math.max(0, date.getTime() - Date.now());
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { calculateBackoff, sleep, createTimeout, withTimeout } from './async';
|
|
2
|
+
export { extractTLD, sanitizeUrl, truncate } from './string';
|
|
3
|
+
export { isPlainObject, deepMerge } from './object';
|
|
4
|
+
export { generateCacheKey } from './cache';
|
|
5
|
+
export { parseRetryAfter } from './http';
|
|
6
|
+
export { formatBytes, formatDuration } from './format';
|
|
7
|
+
export { isNode, isBrowser, isDeno, isBun, isCloudflareWorkers, getRuntimeName } from './runtime';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function isPlainObject(value) {
|
|
2
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
export function deepMerge(target, source) {
|
|
5
|
+
const result = { ...target };
|
|
6
|
+
for (const key in source) {
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
8
|
+
const sourceValue = source[key];
|
|
9
|
+
const targetValue = result[key];
|
|
10
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
11
|
+
result[key] = deepMerge(targetValue, sourceValue);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
result[key] = sourceValue;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function isNode() {
|
|
2
|
+
return (typeof process !== 'undefined' &&
|
|
3
|
+
process.versions?.node != null);
|
|
4
|
+
}
|
|
5
|
+
export function isBrowser() {
|
|
6
|
+
return typeof globalThis !== 'undefined' &&
|
|
7
|
+
'window' in globalThis &&
|
|
8
|
+
typeof globalThis.window !== 'undefined';
|
|
9
|
+
}
|
|
10
|
+
export function isDeno() {
|
|
11
|
+
return typeof globalThis !== 'undefined' && 'Deno' in globalThis;
|
|
12
|
+
}
|
|
13
|
+
export function isBun() {
|
|
14
|
+
return typeof globalThis !== 'undefined' && 'Bun' in globalThis;
|
|
15
|
+
}
|
|
16
|
+
export function isCloudflareWorkers() {
|
|
17
|
+
return (typeof globalThis !== 'undefined' &&
|
|
18
|
+
'caches' in globalThis &&
|
|
19
|
+
typeof globalThis.navigator !== 'undefined' &&
|
|
20
|
+
globalThis.navigator?.userAgent === 'Cloudflare-Workers');
|
|
21
|
+
}
|
|
22
|
+
export function getRuntimeName() {
|
|
23
|
+
if (isDeno())
|
|
24
|
+
return 'Deno';
|
|
25
|
+
if (isBun())
|
|
26
|
+
return 'Bun';
|
|
27
|
+
if (isCloudflareWorkers())
|
|
28
|
+
return 'Cloudflare Workers';
|
|
29
|
+
if (isNode())
|
|
30
|
+
return 'Node.js';
|
|
31
|
+
if (isBrowser())
|
|
32
|
+
return 'Browser';
|
|
33
|
+
return 'Unknown';
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function extractTLD(domain) {
|
|
2
|
+
const parts = domain.split('.');
|
|
3
|
+
const tld = parts[parts.length - 1];
|
|
4
|
+
if (!tld) {
|
|
5
|
+
throw new Error('Invalid domain: no TLD found');
|
|
6
|
+
}
|
|
7
|
+
return tld;
|
|
8
|
+
}
|
|
9
|
+
export function sanitizeUrl(url) {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = new URL(url);
|
|
12
|
+
parsed.search = '';
|
|
13
|
+
return parsed.toString();
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return '[invalid-url]';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function truncate(str, maxLength) {
|
|
20
|
+
if (str.length <= maxLength)
|
|
21
|
+
return str;
|
|
22
|
+
return str.substring(0, maxLength - 3) + '...';
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ValidationError } from '../../types/errors';
|
|
2
|
+
export function validateASN(asn) {
|
|
3
|
+
let asnNumber;
|
|
4
|
+
if (typeof asn === 'string') {
|
|
5
|
+
const cleaned = asn.trim().replace(/^AS/i, '');
|
|
6
|
+
asnNumber = parseInt(cleaned, 10);
|
|
7
|
+
}
|
|
8
|
+
else if (typeof asn === 'number') {
|
|
9
|
+
asnNumber = asn;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
throw new ValidationError('ASN must be a string or number');
|
|
13
|
+
}
|
|
14
|
+
if (isNaN(asnNumber)) {
|
|
15
|
+
throw new ValidationError(`Invalid ASN format: ${asn}`);
|
|
16
|
+
}
|
|
17
|
+
if (asnNumber < 0 || asnNumber > 4294967295) {
|
|
18
|
+
throw new ValidationError(`ASN out of valid range (0-4294967295): ${asnNumber}`);
|
|
19
|
+
}
|
|
20
|
+
return asnNumber;
|
|
21
|
+
}
|
|
22
|
+
export function normalizeASN(asn) {
|
|
23
|
+
const asnNumber = validateASN(asn);
|
|
24
|
+
return `AS${asnNumber}`;
|
|
25
|
+
}
|