rdapify 0.1.0 → 0.1.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 (235) hide show
  1. package/CHANGELOG.md +316 -0
  2. package/README.md +456 -69
  3. package/dist/application/client/RDAPClient.d.ts +53 -0
  4. package/dist/application/client/RDAPClient.d.ts.map +1 -0
  5. package/dist/application/client/RDAPClient.js +163 -0
  6. package/dist/application/client/RDAPClient.js.map +1 -0
  7. package/dist/application/client/index.d.ts +2 -0
  8. package/dist/application/client/index.d.ts.map +1 -0
  9. package/dist/application/client/index.js +6 -0
  10. package/dist/application/client/index.js.map +1 -0
  11. package/dist/application/services/BatchProcessor.d.ts +27 -0
  12. package/dist/application/services/BatchProcessor.d.ts.map +1 -0
  13. package/dist/application/services/BatchProcessor.js +89 -0
  14. package/dist/application/services/BatchProcessor.js.map +1 -0
  15. package/dist/application/services/QueryOrchestrator.d.ts +27 -0
  16. package/dist/application/services/QueryOrchestrator.d.ts.map +1 -0
  17. package/dist/application/services/QueryOrchestrator.js +201 -0
  18. package/dist/application/services/QueryOrchestrator.js.map +1 -0
  19. package/dist/application/services/QueryPriority.d.ts +35 -0
  20. package/dist/application/services/QueryPriority.d.ts.map +1 -0
  21. package/dist/application/services/QueryPriority.js +114 -0
  22. package/dist/application/services/QueryPriority.js.map +1 -0
  23. package/dist/application/services/index.d.ts +3 -0
  24. package/dist/application/services/index.d.ts.map +1 -0
  25. package/dist/application/services/index.js +8 -0
  26. package/dist/application/services/index.js.map +1 -0
  27. package/dist/core/ports/bootstrap.port.d.ts +8 -0
  28. package/dist/core/ports/bootstrap.port.d.ts.map +1 -0
  29. package/dist/core/ports/bootstrap.port.js +3 -0
  30. package/dist/core/ports/bootstrap.port.js.map +1 -0
  31. package/dist/core/ports/cache.port.d.ts +10 -0
  32. package/dist/core/ports/cache.port.d.ts.map +1 -0
  33. package/dist/core/ports/cache.port.js +3 -0
  34. package/dist/core/ports/cache.port.js.map +1 -0
  35. package/dist/core/ports/fetcher.port.d.ts +5 -0
  36. package/dist/core/ports/fetcher.port.d.ts.map +1 -0
  37. package/dist/core/ports/fetcher.port.js +3 -0
  38. package/dist/core/ports/fetcher.port.js.map +1 -0
  39. package/dist/core/ports/index.d.ts +6 -0
  40. package/dist/core/ports/index.d.ts.map +1 -0
  41. package/dist/core/ports/index.js +9 -0
  42. package/dist/core/ports/index.js.map +1 -0
  43. package/dist/core/ports/normalizer.port.d.ts +5 -0
  44. package/dist/core/ports/normalizer.port.d.ts.map +1 -0
  45. package/dist/core/ports/normalizer.port.js +3 -0
  46. package/dist/core/ports/normalizer.port.js.map +1 -0
  47. package/dist/core/ports/pii-redactor.port.d.ts +6 -0
  48. package/dist/core/ports/pii-redactor.port.d.ts.map +1 -0
  49. package/dist/core/ports/pii-redactor.port.js +3 -0
  50. package/dist/core/ports/pii-redactor.port.js.map +1 -0
  51. package/dist/index.d.ts +26 -7
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +65 -16
  54. package/dist/index.js.map +1 -0
  55. package/dist/infrastructure/cache/CacheManager.d.ts +28 -0
  56. package/dist/infrastructure/cache/CacheManager.d.ts.map +1 -0
  57. package/dist/infrastructure/cache/CacheManager.js +117 -0
  58. package/dist/infrastructure/cache/CacheManager.js.map +1 -0
  59. package/dist/infrastructure/cache/InMemoryCache.d.ts +24 -0
  60. package/dist/infrastructure/cache/InMemoryCache.d.ts.map +1 -0
  61. package/dist/infrastructure/cache/InMemoryCache.js +96 -0
  62. package/dist/infrastructure/cache/InMemoryCache.js.map +1 -0
  63. package/dist/infrastructure/cache/PersistentCache.d.ts +39 -0
  64. package/dist/infrastructure/cache/PersistentCache.d.ts.map +1 -0
  65. package/dist/infrastructure/cache/PersistentCache.js +194 -0
  66. package/dist/infrastructure/cache/PersistentCache.js.map +1 -0
  67. package/dist/infrastructure/cache/index.d.ts +3 -0
  68. package/dist/infrastructure/cache/index.d.ts.map +1 -0
  69. package/dist/infrastructure/cache/index.js +8 -0
  70. package/dist/infrastructure/cache/index.js.map +1 -0
  71. package/dist/infrastructure/http/AuthenticationManager.d.ts +38 -0
  72. package/dist/infrastructure/http/AuthenticationManager.d.ts.map +1 -0
  73. package/dist/infrastructure/http/AuthenticationManager.js +99 -0
  74. package/dist/infrastructure/http/AuthenticationManager.js.map +1 -0
  75. package/dist/infrastructure/http/BootstrapDiscovery.d.ts +21 -0
  76. package/dist/infrastructure/http/BootstrapDiscovery.d.ts.map +1 -0
  77. package/dist/infrastructure/http/BootstrapDiscovery.js +130 -0
  78. package/dist/infrastructure/http/BootstrapDiscovery.js.map +1 -0
  79. package/dist/infrastructure/http/CompressionManager.d.ts +30 -0
  80. package/dist/infrastructure/http/CompressionManager.d.ts.map +1 -0
  81. package/dist/infrastructure/http/CompressionManager.js +86 -0
  82. package/dist/infrastructure/http/CompressionManager.js.map +1 -0
  83. package/dist/infrastructure/http/ConnectionPool.d.ts +25 -0
  84. package/dist/infrastructure/http/ConnectionPool.d.ts.map +1 -0
  85. package/dist/infrastructure/http/ConnectionPool.js +101 -0
  86. package/dist/infrastructure/http/ConnectionPool.js.map +1 -0
  87. package/dist/infrastructure/http/Fetcher.d.ts +29 -0
  88. package/dist/infrastructure/http/Fetcher.d.ts.map +1 -0
  89. package/dist/infrastructure/http/Fetcher.js +114 -0
  90. package/dist/infrastructure/http/Fetcher.js.map +1 -0
  91. package/dist/infrastructure/http/Normalizer.d.ts +11 -0
  92. package/dist/infrastructure/http/Normalizer.d.ts.map +1 -0
  93. package/dist/infrastructure/http/Normalizer.js +151 -0
  94. package/dist/infrastructure/http/Normalizer.js.map +1 -0
  95. package/dist/infrastructure/http/ProxyManager.d.ts +43 -0
  96. package/dist/infrastructure/http/ProxyManager.d.ts.map +1 -0
  97. package/dist/infrastructure/http/ProxyManager.js +87 -0
  98. package/dist/infrastructure/http/ProxyManager.js.map +1 -0
  99. package/dist/infrastructure/http/RateLimiter.d.ts +28 -0
  100. package/dist/infrastructure/http/RateLimiter.d.ts.map +1 -0
  101. package/dist/infrastructure/http/RateLimiter.js +101 -0
  102. package/dist/infrastructure/http/RateLimiter.js.map +1 -0
  103. package/dist/infrastructure/http/RetryStrategy.d.ts +58 -0
  104. package/dist/infrastructure/http/RetryStrategy.d.ts.map +1 -0
  105. package/dist/infrastructure/http/RetryStrategy.js +136 -0
  106. package/dist/infrastructure/http/RetryStrategy.js.map +1 -0
  107. package/dist/infrastructure/http/index.d.ts +4 -0
  108. package/dist/infrastructure/http/index.d.ts.map +1 -0
  109. package/dist/infrastructure/http/index.js +10 -0
  110. package/dist/infrastructure/http/index.js.map +1 -0
  111. package/dist/infrastructure/logging/Logger.d.ts +49 -0
  112. package/dist/infrastructure/logging/Logger.d.ts.map +1 -0
  113. package/dist/infrastructure/logging/Logger.js +126 -0
  114. package/dist/infrastructure/logging/Logger.js.map +1 -0
  115. package/dist/infrastructure/monitoring/MetricsCollector.d.ts +53 -0
  116. package/dist/infrastructure/monitoring/MetricsCollector.d.ts.map +1 -0
  117. package/dist/infrastructure/monitoring/MetricsCollector.js +109 -0
  118. package/dist/infrastructure/monitoring/MetricsCollector.js.map +1 -0
  119. package/dist/infrastructure/security/PIIRedactor.d.ts +13 -0
  120. package/dist/infrastructure/security/PIIRedactor.d.ts.map +1 -0
  121. package/dist/infrastructure/security/PIIRedactor.js +83 -0
  122. package/dist/infrastructure/security/PIIRedactor.js.map +1 -0
  123. package/dist/infrastructure/security/SSRFProtection.d.ts +13 -0
  124. package/dist/infrastructure/security/SSRFProtection.d.ts.map +1 -0
  125. package/dist/infrastructure/security/SSRFProtection.js +142 -0
  126. package/dist/infrastructure/security/SSRFProtection.js.map +1 -0
  127. package/dist/infrastructure/security/index.d.ts +3 -0
  128. package/dist/infrastructure/security/index.d.ts.map +1 -0
  129. package/dist/infrastructure/security/index.js +8 -0
  130. package/dist/infrastructure/security/index.js.map +1 -0
  131. package/dist/shared/constants/http.constants.d.ts +26 -0
  132. package/dist/shared/constants/http.constants.d.ts.map +1 -0
  133. package/dist/shared/constants/http.constants.js +29 -0
  134. package/dist/shared/constants/http.constants.js.map +1 -0
  135. package/dist/shared/constants/index.d.ts +3 -0
  136. package/dist/shared/constants/index.d.ts.map +1 -0
  137. package/dist/shared/constants/index.js +6 -0
  138. package/dist/shared/constants/index.js.map +1 -0
  139. package/dist/shared/constants/rdap.constants.d.ts +9 -0
  140. package/dist/shared/constants/rdap.constants.d.ts.map +1 -0
  141. package/dist/shared/constants/rdap.constants.js +21 -0
  142. package/dist/shared/constants/rdap.constants.js.map +1 -0
  143. package/dist/shared/errors/base.error.d.ts +44 -0
  144. package/dist/shared/errors/base.error.d.ts.map +1 -0
  145. package/dist/shared/errors/base.error.js +122 -0
  146. package/dist/shared/errors/base.error.js.map +1 -0
  147. package/dist/shared/errors/index.d.ts +2 -0
  148. package/dist/shared/errors/index.d.ts.map +1 -0
  149. package/dist/shared/errors/index.js +5 -0
  150. package/dist/shared/errors/index.js.map +1 -0
  151. package/dist/shared/types/entities.d.ts +50 -0
  152. package/dist/shared/types/entities.d.ts.map +1 -0
  153. package/dist/shared/types/entities.js +3 -0
  154. package/dist/shared/types/entities.js.map +1 -0
  155. package/dist/shared/types/enums.d.ts +10 -0
  156. package/dist/shared/types/enums.d.ts.map +1 -0
  157. package/dist/shared/types/enums.js +3 -0
  158. package/dist/shared/types/enums.js.map +1 -0
  159. package/dist/shared/types/errors.d.ts +40 -0
  160. package/dist/shared/types/errors.d.ts.map +1 -0
  161. package/dist/shared/types/errors.js +101 -0
  162. package/dist/shared/types/errors.js.map +1 -0
  163. package/dist/shared/types/generics.d.ts +32 -0
  164. package/dist/shared/types/generics.d.ts.map +1 -0
  165. package/dist/shared/types/generics.js +3 -0
  166. package/dist/shared/types/generics.js.map +1 -0
  167. package/dist/shared/types/index.d.ts +4 -0
  168. package/dist/shared/types/index.d.ts.map +1 -0
  169. package/dist/shared/types/index.js +3 -0
  170. package/dist/shared/types/index.js.map +1 -0
  171. package/dist/shared/types/options.d.ts +60 -0
  172. package/dist/shared/types/options.d.ts.map +1 -0
  173. package/dist/shared/types/options.js +50 -0
  174. package/dist/shared/types/options.js.map +1 -0
  175. package/dist/shared/types/responses.d.ts +76 -0
  176. package/dist/shared/types/responses.d.ts.map +1 -0
  177. package/dist/shared/types/responses.js +3 -0
  178. package/dist/shared/types/responses.js.map +1 -0
  179. package/dist/shared/utils/enhanced-validators.d.ts +18 -0
  180. package/dist/shared/utils/enhanced-validators.d.ts.map +1 -0
  181. package/dist/shared/utils/enhanced-validators.js +162 -0
  182. package/dist/shared/utils/enhanced-validators.js.map +1 -0
  183. package/dist/shared/utils/helpers/async.d.ts +9 -0
  184. package/dist/shared/utils/helpers/async.d.ts.map +1 -0
  185. package/dist/shared/utils/helpers/async.js +47 -0
  186. package/dist/shared/utils/helpers/async.js.map +1 -0
  187. package/dist/shared/utils/helpers/cache.d.ts +2 -0
  188. package/dist/shared/utils/helpers/cache.d.ts.map +1 -0
  189. package/dist/shared/utils/helpers/cache.js +7 -0
  190. package/dist/shared/utils/helpers/cache.js.map +1 -0
  191. package/dist/shared/utils/helpers/format.d.ts +3 -0
  192. package/dist/shared/utils/helpers/format.d.ts.map +1 -0
  193. package/dist/shared/utils/helpers/format.js +22 -0
  194. package/dist/shared/utils/helpers/format.js.map +1 -0
  195. package/dist/shared/utils/helpers/http.d.ts +2 -0
  196. package/dist/shared/utils/helpers/http.d.ts.map +1 -0
  197. package/dist/shared/utils/helpers/http.js +17 -0
  198. package/dist/shared/utils/helpers/http.js.map +1 -0
  199. package/dist/shared/utils/helpers/index.d.ts +8 -0
  200. package/dist/shared/utils/helpers/index.d.ts.map +1 -0
  201. package/dist/shared/utils/helpers/index.js +29 -0
  202. package/dist/shared/utils/helpers/index.js.map +1 -0
  203. package/dist/shared/utils/helpers/object.d.ts +3 -0
  204. package/dist/shared/utils/helpers/object.d.ts.map +1 -0
  205. package/dist/shared/utils/helpers/object.js +24 -0
  206. package/dist/shared/utils/helpers/object.js.map +1 -0
  207. package/dist/shared/utils/helpers/runtime.d.ts +6 -0
  208. package/dist/shared/utils/helpers/runtime.d.ts.map +1 -0
  209. package/dist/shared/utils/helpers/runtime.js +33 -0
  210. package/dist/shared/utils/helpers/runtime.js.map +1 -0
  211. package/dist/shared/utils/helpers/string.d.ts +4 -0
  212. package/dist/shared/utils/helpers/string.d.ts.map +1 -0
  213. package/dist/shared/utils/helpers/string.js +29 -0
  214. package/dist/shared/utils/helpers/string.js.map +1 -0
  215. package/dist/shared/utils/validators/asn.d.ts +3 -0
  216. package/dist/shared/utils/validators/asn.d.ts.map +1 -0
  217. package/dist/shared/utils/validators/asn.js +30 -0
  218. package/dist/shared/utils/validators/asn.js.map +1 -0
  219. package/dist/shared/utils/validators/domain.d.ts +3 -0
  220. package/dist/shared/utils/validators/domain.d.ts.map +1 -0
  221. package/dist/shared/utils/validators/domain.js +34 -0
  222. package/dist/shared/utils/validators/domain.js.map +1 -0
  223. package/dist/shared/utils/validators/index.d.ts +5 -0
  224. package/dist/shared/utils/validators/index.d.ts.map +1 -0
  225. package/dist/shared/utils/validators/index.js +19 -0
  226. package/dist/shared/utils/validators/index.js.map +1 -0
  227. package/dist/shared/utils/validators/ip.d.ts +5 -0
  228. package/dist/shared/utils/validators/ip.d.ts.map +1 -0
  229. package/dist/shared/utils/validators/ip.js +55 -0
  230. package/dist/shared/utils/validators/ip.js.map +1 -0
  231. package/dist/shared/utils/validators/network.d.ts +4 -0
  232. package/dist/shared/utils/validators/network.d.ts.map +1 -0
  233. package/dist/shared/utils/validators/network.js +48 -0
  234. package/dist/shared/utils/validators/network.js.map +1 -0
  235. package/package.json +108 -20
@@ -0,0 +1,24 @@
1
+ import type { RDAPResponse } from '../../shared/types';
2
+ import type { ICache } from './CacheManager';
3
+ export declare class InMemoryCache implements ICache {
4
+ private cache;
5
+ private readonly maxSize;
6
+ private accessOrder;
7
+ constructor(maxSize?: number);
8
+ get(key: string): Promise<RDAPResponse | null>;
9
+ set(key: string, value: RDAPResponse, ttl?: number): Promise<void>;
10
+ delete(key: string): Promise<void>;
11
+ clear(): Promise<void>;
12
+ has(key: string): Promise<boolean>;
13
+ size(): Promise<number>;
14
+ private updateAccessOrder;
15
+ private removeFromAccessOrder;
16
+ private evictLRU;
17
+ private cleanupExpired;
18
+ getStats(): Promise<{
19
+ size: number;
20
+ maxSize: number;
21
+ hitRate?: number;
22
+ }>;
23
+ }
24
+ //# sourceMappingURL=InMemoryCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InMemoryCache.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/cache/InMemoryCache.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAa7C,qBAAa,aAAc,YAAW,MAAM;IAC1C,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,WAAW,CAAW;gBAElB,OAAO,GAAE,MAAa;IAS5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAsB9C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBxE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAmBlC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAS7B,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,qBAAqB;YAUf,QAAQ;YAeR,cAAc;IAkBtB,QAAQ,IAAI,OAAO,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CAQH"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InMemoryCache = void 0;
4
+ class InMemoryCache {
5
+ constructor(maxSize = 1000) {
6
+ this.cache = new Map();
7
+ this.maxSize = maxSize;
8
+ this.accessOrder = [];
9
+ }
10
+ async get(key) {
11
+ const entry = this.cache.get(key);
12
+ if (!entry) {
13
+ return null;
14
+ }
15
+ if (Date.now() > entry.expiresAt) {
16
+ await this.delete(key);
17
+ return null;
18
+ }
19
+ this.updateAccessOrder(key);
20
+ return entry.value;
21
+ }
22
+ async set(key, value, ttl = 3600) {
23
+ if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
24
+ await this.evictLRU();
25
+ }
26
+ const expiresAt = Date.now() + ttl * 1000;
27
+ this.cache.set(key, {
28
+ value,
29
+ expiresAt,
30
+ });
31
+ this.updateAccessOrder(key);
32
+ }
33
+ async delete(key) {
34
+ this.cache.delete(key);
35
+ this.removeFromAccessOrder(key);
36
+ }
37
+ async clear() {
38
+ this.cache.clear();
39
+ this.accessOrder = [];
40
+ }
41
+ async has(key) {
42
+ const entry = this.cache.get(key);
43
+ if (!entry) {
44
+ return false;
45
+ }
46
+ if (Date.now() > entry.expiresAt) {
47
+ await this.delete(key);
48
+ return false;
49
+ }
50
+ return true;
51
+ }
52
+ async size() {
53
+ await this.cleanupExpired();
54
+ return this.cache.size;
55
+ }
56
+ updateAccessOrder(key) {
57
+ this.removeFromAccessOrder(key);
58
+ this.accessOrder.push(key);
59
+ }
60
+ removeFromAccessOrder(key) {
61
+ const index = this.accessOrder.indexOf(key);
62
+ if (index > -1) {
63
+ this.accessOrder.splice(index, 1);
64
+ }
65
+ }
66
+ async evictLRU() {
67
+ if (this.accessOrder.length === 0) {
68
+ return;
69
+ }
70
+ const lruKey = this.accessOrder[0];
71
+ if (lruKey) {
72
+ await this.delete(lruKey);
73
+ }
74
+ }
75
+ async cleanupExpired() {
76
+ const now = Date.now();
77
+ const expiredKeys = [];
78
+ for (const [key, entry] of this.cache.entries()) {
79
+ if (now > entry.expiresAt) {
80
+ expiredKeys.push(key);
81
+ }
82
+ }
83
+ for (const key of expiredKeys) {
84
+ await this.delete(key);
85
+ }
86
+ }
87
+ async getStats() {
88
+ await this.cleanupExpired();
89
+ return {
90
+ size: this.cache.size,
91
+ maxSize: this.maxSize,
92
+ };
93
+ }
94
+ }
95
+ exports.InMemoryCache = InMemoryCache;
96
+ //# sourceMappingURL=InMemoryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InMemoryCache.js","sourceRoot":"","sources":["../../../src/infrastructure/cache/InMemoryCache.ts"],"names":[],"mappings":";;;AAoBA,MAAa,aAAa;IAKxB,YAAY,UAAkB,IAAI;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAKD,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QAGD,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAGD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAE5B,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAKD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAmB,EAAE,MAAc,IAAI;QAE5D,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,C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,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AApKD,sCAoKC"}
@@ -0,0 +1,39 @@
1
+ export interface PersistentCacheOptions {
2
+ storage?: 'file' | 'memory';
3
+ path?: string;
4
+ ttl?: number;
5
+ maxSize?: number;
6
+ autoSave?: boolean;
7
+ saveInterval?: number;
8
+ }
9
+ export declare class PersistentCache {
10
+ private cache;
11
+ private readonly storage;
12
+ private readonly filePath?;
13
+ private readonly ttl;
14
+ private readonly maxSize;
15
+ private readonly autoSave;
16
+ private saveTimer?;
17
+ private dirty;
18
+ constructor(options?: PersistentCacheOptions);
19
+ get(key: string): Promise<any | null>;
20
+ set(key: string, value: any, ttl?: number): Promise<void>;
21
+ delete(key: string): Promise<boolean>;
22
+ has(key: string): Promise<boolean>;
23
+ clear(): Promise<void>;
24
+ getStats(): Promise<{
25
+ size: number;
26
+ maxSize: number;
27
+ storage: string;
28
+ hits: number;
29
+ oldestEntry?: number;
30
+ newestEntry?: number;
31
+ }>;
32
+ private evictLRU;
33
+ private ensureCacheDirectory;
34
+ private load;
35
+ private save;
36
+ cleanup(): Promise<number>;
37
+ destroy(): void;
38
+ }
39
+ //# sourceMappingURL=PersistentCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersistentCache.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/cache/PersistentCache.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAaD,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAsC;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,OAAO,CAAC,KAAK,CAAkB;gBAEnB,OAAO,GAAE,sBAA2B;IA0B1C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAyBrC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BzD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAoBlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtB,QAAQ,IAAI,OAAO,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IA8BF,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,IAAI;YA8BE,IAAI;IAqBZ,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAqBhC,OAAO,IAAI,IAAI;CAYhB"}
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PersistentCache = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ class PersistentCache {
8
+ constructor(options = {}) {
9
+ this.cache = new Map();
10
+ this.dirty = false;
11
+ this.storage = options.storage || 'memory';
12
+ this.ttl = options.ttl || 3600000;
13
+ this.maxSize = options.maxSize || 1000;
14
+ this.autoSave = options.autoSave ?? true;
15
+ if (this.storage === 'file') {
16
+ this.filePath = options.path || path.join(process.cwd(), '.cache', 'rdap-cache.json');
17
+ this.ensureCacheDirectory();
18
+ this.load();
19
+ if (this.autoSave) {
20
+ const interval = options.saveInterval || 60000;
21
+ this.saveTimer = setInterval(() => {
22
+ if (this.dirty) {
23
+ this.save();
24
+ }
25
+ }, interval);
26
+ }
27
+ }
28
+ }
29
+ async get(key) {
30
+ const entry = this.cache.get(key);
31
+ if (!entry) {
32
+ return null;
33
+ }
34
+ if (Date.now() > entry.expires) {
35
+ this.cache.delete(key);
36
+ this.dirty = true;
37
+ return null;
38
+ }
39
+ entry.accessed = Date.now();
40
+ entry.hits++;
41
+ this.dirty = true;
42
+ return entry.value;
43
+ }
44
+ async set(key, value, ttl) {
45
+ const effectiveTtl = ttl || this.ttl;
46
+ const now = Date.now();
47
+ const entry = {
48
+ value,
49
+ expires: now + effectiveTtl,
50
+ created: now,
51
+ accessed: now,
52
+ hits: 0,
53
+ };
54
+ this.cache.set(key, entry);
55
+ this.dirty = true;
56
+ if (this.cache.size > this.maxSize) {
57
+ this.evictLRU();
58
+ }
59
+ if (this.storage === 'file' && !this.autoSave) {
60
+ await this.save();
61
+ }
62
+ }
63
+ async delete(key) {
64
+ const deleted = this.cache.delete(key);
65
+ if (deleted) {
66
+ this.dirty = true;
67
+ }
68
+ return deleted;
69
+ }
70
+ async has(key) {
71
+ const entry = this.cache.get(key);
72
+ if (!entry) {
73
+ return false;
74
+ }
75
+ if (Date.now() > entry.expires) {
76
+ this.cache.delete(key);
77
+ this.dirty = true;
78
+ return false;
79
+ }
80
+ return true;
81
+ }
82
+ async clear() {
83
+ this.cache.clear();
84
+ this.dirty = true;
85
+ if (this.storage === 'file') {
86
+ await this.save();
87
+ }
88
+ }
89
+ async getStats() {
90
+ let totalHits = 0;
91
+ let oldestEntry;
92
+ let newestEntry;
93
+ for (const entry of this.cache.values()) {
94
+ totalHits += entry.hits;
95
+ if (!oldestEntry || entry.created < oldestEntry) {
96
+ oldestEntry = entry.created;
97
+ }
98
+ if (!newestEntry || entry.created > newestEntry) {
99
+ newestEntry = entry.created;
100
+ }
101
+ }
102
+ return {
103
+ size: this.cache.size,
104
+ maxSize: this.maxSize,
105
+ storage: this.storage,
106
+ hits: totalHits,
107
+ oldestEntry,
108
+ newestEntry,
109
+ };
110
+ }
111
+ evictLRU() {
112
+ let lruKey = null;
113
+ let lruTime = Infinity;
114
+ for (const [key, entry] of this.cache.entries()) {
115
+ if (entry.accessed < lruTime) {
116
+ lruTime = entry.accessed;
117
+ lruKey = key;
118
+ }
119
+ }
120
+ if (lruKey) {
121
+ this.cache.delete(lruKey);
122
+ }
123
+ }
124
+ ensureCacheDirectory() {
125
+ if (!this.filePath)
126
+ return;
127
+ const dir = path.dirname(this.filePath);
128
+ if (!fs.existsSync(dir)) {
129
+ fs.mkdirSync(dir, { recursive: true });
130
+ }
131
+ }
132
+ load() {
133
+ if (!this.filePath || !fs.existsSync(this.filePath)) {
134
+ return;
135
+ }
136
+ try {
137
+ const data = fs.readFileSync(this.filePath, 'utf-8');
138
+ const entries = JSON.parse(data);
139
+ const now = Date.now();
140
+ for (const [key, entry] of Object.entries(entries)) {
141
+ const cacheEntry = entry;
142
+ if (cacheEntry.expires > now) {
143
+ this.cache.set(key, cacheEntry);
144
+ }
145
+ }
146
+ this.dirty = false;
147
+ }
148
+ catch (error) {
149
+ console.warn('Failed to load cache:', error);
150
+ }
151
+ }
152
+ async save() {
153
+ if (!this.filePath)
154
+ return;
155
+ try {
156
+ const entries = {};
157
+ for (const [key, entry] of this.cache.entries()) {
158
+ entries[key] = entry;
159
+ }
160
+ const data = JSON.stringify(entries, null, 2);
161
+ fs.writeFileSync(this.filePath, data, 'utf-8');
162
+ this.dirty = false;
163
+ }
164
+ catch (error) {
165
+ console.error('Failed to save cache:', error);
166
+ }
167
+ }
168
+ async cleanup() {
169
+ const now = Date.now();
170
+ let removed = 0;
171
+ for (const [key, entry] of this.cache.entries()) {
172
+ if (entry.expires < now) {
173
+ this.cache.delete(key);
174
+ removed++;
175
+ }
176
+ }
177
+ if (removed > 0) {
178
+ this.dirty = true;
179
+ }
180
+ return removed;
181
+ }
182
+ destroy() {
183
+ if (this.saveTimer) {
184
+ clearInterval(this.saveTimer);
185
+ this.saveTimer = undefined;
186
+ }
187
+ if (this.storage === 'file' && this.dirty) {
188
+ this.save();
189
+ }
190
+ this.cache.clear();
191
+ }
192
+ }
193
+ exports.PersistentCache = PersistentCache;
194
+ //# sourceMappingURL=PersistentCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersistentCache.js","sourceRoot":"","sources":["../../../src/infrastructure/cache/PersistentCache.ts"],"names":[],"mappings":";;;;AAKA,+CAAyB;AACzB,mDAA6B;AAsB7B,MAAa,eAAe;IAU1B,YAAY,UAAkC,EAAE;QATxC,UAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;QAO3C,UAAK,GAAY,KAAK,CAAC;QAG7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC;QAC3C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC;QAEzC,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;YACtF,IAA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AC;YAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7B,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC1C,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AA/RD,0CA+RC"}
@@ -0,0 +1,3 @@
1
+ export { InMemoryCache } from './InMemoryCache';
2
+ export { CacheManager, type ICache } from './CacheManager';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/cache/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CacheManager = exports.InMemoryCache = void 0;
4
+ var InMemoryCache_1 = require("./InMemoryCache");
5
+ Object.defineProperty(exports, "InMemoryCache", { enumerable: true, get: function () { return InMemoryCache_1.InMemoryCache; } });
6
+ var CacheManager_1 = require("./CacheManager");
7
+ Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function () { return CacheManager_1.CacheManager; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/cache/index.ts"],"names":[],"mappings":";;;AAKA,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,+CAA2D;AAAlD,4GAAA,YAAY,OAAA"}
@@ -0,0 +1,38 @@
1
+ export type AuthType = 'basic' | 'bearer' | 'apikey' | 'oauth2';
2
+ export interface AuthenticationOptions {
3
+ type: AuthType;
4
+ username?: string;
5
+ password?: string;
6
+ token?: string;
7
+ apiKey?: string;
8
+ apiKeyHeader?: string;
9
+ oauth2?: OAuth2Options;
10
+ }
11
+ export interface OAuth2Options {
12
+ accessToken: string;
13
+ tokenType?: string;
14
+ refreshToken?: string;
15
+ expiresAt?: number;
16
+ }
17
+ export declare class AuthenticationManager {
18
+ private readonly type;
19
+ private readonly username?;
20
+ private readonly password?;
21
+ private readonly token?;
22
+ private readonly apiKey?;
23
+ private readonly apiKeyHeader;
24
+ private oauth2?;
25
+ constructor(options: AuthenticationOptions);
26
+ private validate;
27
+ getHeaders(): Record<string, string>;
28
+ isTokenExpired(): boolean;
29
+ updateOAuth2Token(options: OAuth2Options): void;
30
+ getType(): AuthType;
31
+ getInfo(): {
32
+ type: AuthType;
33
+ username?: string;
34
+ apiKeyHeader?: string;
35
+ tokenExpired?: boolean;
36
+ };
37
+ }
38
+ //# sourceMappingURL=AuthenticationManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthenticationManager.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/http/AuthenticationManager.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAW;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,MAAM,CAAC,CAAgB;gBAEnB,OAAO,EAAE,qBAAqB;IAe1C,OAAO,CAAC,QAAQ;IA+BhB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAqCpC,cAAc,IAAI,OAAO;IAWzB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAW/C,OAAO,IAAI,QAAQ;IAOnB,OAAO,IAAI;QACT,IAAI,EAAE,QAAQ,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB;CAmBF"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthenticationManager = void 0;
4
+ class AuthenticationManager {
5
+ constructor(options) {
6
+ this.type = options.type;
7
+ this.username = options.username;
8
+ this.password = options.password;
9
+ this.token = options.token;
10
+ this.apiKey = options.apiKey;
11
+ this.apiKeyHeader = options.apiKeyHeader || 'X-API-Key';
12
+ this.oauth2 = options.oauth2;
13
+ this.validate();
14
+ }
15
+ validate() {
16
+ switch (this.type) {
17
+ case 'basic':
18
+ if (!this.username || !this.password) {
19
+ throw new Error('Basic auth requires username and password');
20
+ }
21
+ break;
22
+ case 'bearer':
23
+ if (!this.token) {
24
+ throw new Error('Bearer auth requires token');
25
+ }
26
+ break;
27
+ case 'apikey':
28
+ if (!this.apiKey) {
29
+ throw new Error('API key auth requires apiKey');
30
+ }
31
+ break;
32
+ case 'oauth2':
33
+ if (!this.oauth2?.accessToken) {
34
+ throw new Error('OAuth2 requires accessToken');
35
+ }
36
+ break;
37
+ }
38
+ }
39
+ getHeaders() {
40
+ const headers = {};
41
+ switch (this.type) {
42
+ case 'basic':
43
+ if (this.username && this.password) {
44
+ const credentials = Buffer.from(`${this.username}:${this.password}`).toString('base64');
45
+ headers['Authorization'] = `Basic ${credentials}`;
46
+ }
47
+ break;
48
+ case 'bearer':
49
+ if (this.token) {
50
+ headers['Authorization'] = `Bearer ${this.token}`;
51
+ }
52
+ break;
53
+ case 'apikey':
54
+ if (this.apiKey) {
55
+ headers[this.apiKeyHeader] = this.apiKey;
56
+ }
57
+ break;
58
+ case 'oauth2':
59
+ if (this.oauth2?.accessToken) {
60
+ const tokenType = this.oauth2.tokenType || 'Bearer';
61
+ headers['Authorization'] = `${tokenType} ${this.oauth2.accessToken}`;
62
+ }
63
+ break;
64
+ }
65
+ return headers;
66
+ }
67
+ isTokenExpired() {
68
+ if (this.type !== 'oauth2' || !this.oauth2?.expiresAt) {
69
+ return false;
70
+ }
71
+ return Date.now() >= this.oauth2.expiresAt;
72
+ }
73
+ updateOAuth2Token(options) {
74
+ if (this.type !== 'oauth2') {
75
+ throw new Error('Cannot update OAuth2 token for non-OAuth2 auth');
76
+ }
77
+ this.oauth2 = options;
78
+ }
79
+ getType() {
80
+ return this.type;
81
+ }
82
+ getInfo() {
83
+ const info = {
84
+ type: this.type,
85
+ };
86
+ if (this.type === 'basic' && this.username) {
87
+ info.username = this.username;
88
+ }
89
+ if (this.type === 'apikey') {
90
+ info.apiKeyHeader = this.apiKeyHeader;
91
+ }
92
+ if (this.type === 'oauth2') {
93
+ info.tokenExpired = this.isTokenExpired();
94
+ }
95
+ return info;
96
+ }
97
+ }
98
+ exports.AuthenticationManager = AuthenticationManager;
99
+ //# sourceMappingURL=AuthenticationManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthenticationManager.js","sourceRoot":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EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC7C,CAAC;IAKD,iBAAiB,CAAC,OAAsB;QACtC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;IACxB,CAAC;IAKD,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAKD,OAAO;QAML,MAAM,IAAI,GAAQ;YAChB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;QAEF,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAChC,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACxC,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAjJD,sDAiJC"}
@@ -0,0 +1,21 @@
1
+ import { Fetcher } from './Fetcher';
2
+ export declare class BootstrapDiscovery {
3
+ private readonly baseUrl;
4
+ private readonly fetcher;
5
+ private cache;
6
+ private cacheExpiry;
7
+ private readonly cacheTTL;
8
+ constructor(baseUrl?: string, fetcher?: Fetcher);
9
+ discoverDomain(domain: string): Promise<string>;
10
+ discoverIPv4(ip: string): Promise<string>;
11
+ discoverIPv6(ip: string): Promise<string>;
12
+ discoverASN(asn: number): Promise<string>;
13
+ private getBootstrapData;
14
+ private ipMatchesCIDR;
15
+ clearCache(): void;
16
+ getCacheStats(): {
17
+ size: number;
18
+ types: string[];
19
+ };
20
+ }
21
+ //# sourceMappingURL=BootstrapDiscovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BootstrapDiscovery.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/http/BootstrapDiscovery.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBpC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;gBAEjC,OAAO,GAAE,MAAqC,EAAE,OAAO,CAAC,EAAE,OAAO;IAUvE,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB/C,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqBzC,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqBzC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAwBjC,gBAAgB;IA+C9B,OAAO,CAAC,aAAa;IAwBrB,UAAU,IAAI,IAAI;IAQlB,aAAa,IAAI;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB;CAMF"}