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