@suveren/gateway 0.3.16 → 0.4.0

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 (256) hide show
  1. package/bin/suveren-gateway.js +419 -28
  2. package/content/integrations/calendar.json +20 -8
  3. package/content/integrations/crm.json +97 -23
  4. package/content/integrations/gmail.json +166 -29
  5. package/content/integrations/linkedin.json +15 -3
  6. package/content/integrations/mollie.json +2 -2
  7. package/dist/control-plane/index.mjs +333 -41
  8. package/dist/mcp-server/http.mjs +882 -212
  9. package/dist/ui/assets/index-BDQY7Z3H.js +105 -0
  10. package/dist/ui/assets/{index-DOt3SNnl.css → index-JHaCddDE.css} +1 -1
  11. package/dist/ui/index.html +2 -2
  12. package/node_modules/@hap/core/dist/index.d.mts +34 -2
  13. package/node_modules/@hap/core/dist/index.d.ts +34 -2
  14. package/node_modules/@hap/core/dist/index.js +15 -3
  15. package/node_modules/@hap/core/dist/index.mjs +15 -3
  16. package/node_modules/@hap/core/package.json +1 -1
  17. package/node_modules/@hap/core/src/gatekeeper.ts +47 -1
  18. package/node_modules/@hap/core/src/identity.ts +9 -4
  19. package/node_modules/@hap/core/src/types.ts +27 -0
  20. package/node_modules/@hono/node-server/README.md +58 -25
  21. package/node_modules/@hono/node-server/dist/conninfo.cjs +22 -0
  22. package/node_modules/@hono/node-server/dist/{conninfo.d.ts → conninfo.d.cts} +4 -3
  23. package/node_modules/@hono/node-server/dist/conninfo.d.mts +4 -3
  24. package/node_modules/@hono/node-server/dist/conninfo.mjs +19 -16
  25. package/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs +5 -0
  26. package/node_modules/@hono/node-server/dist/constants-BXAKTxRC.cjs +11 -0
  27. package/node_modules/@hono/node-server/dist/index.cjs +1173 -0
  28. package/node_modules/@hono/node-server/dist/index.d.cts +101 -0
  29. package/node_modules/@hono/node-server/dist/index.d.mts +101 -8
  30. package/node_modules/@hono/node-server/dist/index.mjs +1143 -637
  31. package/node_modules/@hono/node-server/dist/serve-static.cjs +151 -0
  32. package/node_modules/@hono/node-server/dist/serve-static.d.cts +18 -0
  33. package/node_modules/@hono/node-server/dist/serve-static.d.mts +14 -13
  34. package/node_modules/@hono/node-server/dist/serve-static.mjs +143 -145
  35. package/node_modules/@hono/node-server/dist/utils/response.cjs +8 -0
  36. package/node_modules/@hono/node-server/dist/utils/response.d.cts +4 -0
  37. package/node_modules/@hono/node-server/dist/utils/response.d.mts +3 -2
  38. package/node_modules/@hono/node-server/dist/utils/response.mjs +6 -9
  39. package/node_modules/@hono/node-server/dist/utils/stream.cjs +65 -0
  40. package/node_modules/@hono/node-server/dist/utils/stream.d.cts +6 -0
  41. package/node_modules/@hono/node-server/dist/utils/stream.d.mts +6 -0
  42. package/node_modules/@hono/node-server/dist/utils/stream.mjs +64 -0
  43. package/node_modules/@hono/node-server/package.json +65 -54
  44. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts.map +1 -1
  45. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js +1 -12
  46. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js.map +1 -1
  47. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts +7 -0
  48. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts.map +1 -1
  49. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js +9 -3
  50. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js.map +1 -1
  51. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts.map +1 -1
  52. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js +5 -3
  53. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js.map +1 -1
  54. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.d.ts.map +1 -1
  55. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js +1 -12
  56. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js.map +1 -1
  57. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts +5 -0
  58. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts.map +1 -0
  59. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js +17 -0
  60. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js.map +1 -0
  61. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts +9 -1
  62. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts.map +1 -1
  63. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js +10 -4
  64. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js.map +1 -1
  65. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts +21 -0
  66. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -1
  67. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js +239 -41
  68. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js.map +1 -1
  69. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.d.ts.map +1 -1
  70. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js +25 -6
  71. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js.map +1 -1
  72. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts +32 -0
  73. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts.map +1 -0
  74. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js +64 -0
  75. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js.map +1 -0
  76. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts +5 -0
  77. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts.map +1 -1
  78. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js +10 -1
  79. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js.map +1 -1
  80. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.d.ts.map +1 -1
  81. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js +2 -13
  82. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js.map +1 -1
  83. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts +7 -0
  84. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts.map +1 -1
  85. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js +9 -3
  86. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js.map +1 -1
  87. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.d.ts.map +1 -1
  88. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +5 -3
  89. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -1
  90. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.d.ts.map +1 -1
  91. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +2 -13
  92. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -1
  93. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts +5 -0
  94. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts.map +1 -0
  95. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
  96. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js.map +1 -0
  97. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts +9 -1
  98. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts.map +1 -1
  99. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js +10 -4
  100. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js.map +1 -1
  101. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts +21 -0
  102. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -1
  103. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +239 -41
  104. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js.map +1 -1
  105. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.d.ts.map +1 -1
  106. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +25 -6
  107. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -1
  108. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts +32 -0
  109. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts.map +1 -0
  110. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
  111. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js.map +1 -0
  112. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts +5 -0
  113. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts.map +1 -1
  114. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js +9 -0
  115. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js.map +1 -1
  116. package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/README.md +15 -14
  117. package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/index.js +0 -8
  118. package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/package.json +16 -12
  119. package/node_modules/@modelcontextprotocol/sdk/package.json +4 -3
  120. package/node_modules/@types/node/README.md +1 -1
  121. package/node_modules/@types/node/crypto.d.ts +1 -1
  122. package/node_modules/@types/node/package.json +2 -2
  123. package/node_modules/body-parser/HISTORY.md +7 -1
  124. package/node_modules/body-parser/lib/types/json.js +7 -3
  125. package/node_modules/body-parser/lib/types/raw.js +7 -3
  126. package/node_modules/body-parser/lib/types/text.js +7 -3
  127. package/node_modules/body-parser/lib/types/urlencoded.js +7 -3
  128. package/node_modules/body-parser/package.json +1 -1
  129. package/node_modules/express-rate-limit/dist/index.cjs +69 -5
  130. package/node_modules/express-rate-limit/dist/index.d.cts +16 -0
  131. package/node_modules/express-rate-limit/dist/index.d.mts +16 -0
  132. package/node_modules/express-rate-limit/dist/index.d.ts +16 -0
  133. package/node_modules/express-rate-limit/dist/index.mjs +55 -5
  134. package/node_modules/express-rate-limit/node_modules/debug/LICENSE +20 -0
  135. package/node_modules/express-rate-limit/node_modules/debug/README.md +481 -0
  136. package/node_modules/express-rate-limit/node_modules/debug/package.json +64 -0
  137. package/node_modules/express-rate-limit/node_modules/debug/src/browser.js +272 -0
  138. package/node_modules/express-rate-limit/node_modules/debug/src/common.js +292 -0
  139. package/node_modules/express-rate-limit/node_modules/debug/src/index.js +10 -0
  140. package/node_modules/express-rate-limit/node_modules/debug/src/node.js +263 -0
  141. package/node_modules/express-rate-limit/node_modules/ms/index.js +162 -0
  142. package/node_modules/express-rate-limit/node_modules/ms/license.md +21 -0
  143. package/node_modules/express-rate-limit/node_modules/ms/package.json +38 -0
  144. package/node_modules/express-rate-limit/node_modules/ms/readme.md +59 -0
  145. package/node_modules/express-rate-limit/package.json +12 -9
  146. package/node_modules/fast-uri/index.js +17 -0
  147. package/node_modules/fast-uri/package.json +1 -1
  148. package/node_modules/fast-uri/test/security.test.js +62 -0
  149. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -4
  150. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +12 -2
  151. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -4
  152. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +12 -2
  153. package/node_modules/hono/dist/cjs/client/client.js +10 -1
  154. package/node_modules/hono/dist/cjs/client/utils.js +1 -1
  155. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +5 -4
  156. package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  157. package/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -1
  158. package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -1
  159. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +5 -3
  160. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +10 -4
  161. package/node_modules/hono/dist/cjs/request.js +8 -3
  162. package/node_modules/hono/dist/cjs/router/trie-router/node.js +9 -0
  163. package/node_modules/hono/dist/cjs/utils/accept.js +1 -1
  164. package/node_modules/hono/dist/cjs/utils/body.js +6 -0
  165. package/node_modules/hono/dist/cjs/utils/url.js +1 -1
  166. package/node_modules/hono/dist/client/client.js +10 -1
  167. package/node_modules/hono/dist/client/utils.js +1 -1
  168. package/node_modules/hono/dist/helper/streaming/sse.js +5 -4
  169. package/node_modules/hono/dist/middleware/cache/index.js +1 -1
  170. package/node_modules/hono/dist/middleware/compress/index.js +2 -1
  171. package/node_modules/hono/dist/middleware/etag/index.js +2 -1
  172. package/node_modules/hono/dist/middleware/method-override/index.js +5 -3
  173. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +10 -4
  174. package/node_modules/hono/dist/request.js +8 -3
  175. package/node_modules/hono/dist/router/trie-router/node.js +9 -0
  176. package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +9 -0
  177. package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +1 -1
  178. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +1 -1
  179. package/node_modules/hono/dist/types/middleware/combine/index.d.ts +1 -1
  180. package/node_modules/hono/dist/types/middleware/language/language.d.ts +18 -0
  181. package/node_modules/hono/dist/types/utils/types.d.ts +1 -1
  182. package/node_modules/hono/dist/utils/accept.js +1 -1
  183. package/node_modules/hono/dist/utils/body.js +6 -0
  184. package/node_modules/hono/dist/utils/url.js +1 -1
  185. package/node_modules/hono/package.json +4 -4
  186. package/node_modules/ip-address/README.md +102 -96
  187. package/node_modules/ip-address/dist/common.d.ts +23 -0
  188. package/node_modules/ip-address/dist/common.js +27 -4
  189. package/node_modules/ip-address/dist/common.js.map +1 -1
  190. package/node_modules/ip-address/dist/ipv4.d.ts +8 -1
  191. package/node_modules/ip-address/dist/ipv4.js +21 -8
  192. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  193. package/node_modules/ip-address/dist/ipv6.d.ts +59 -1
  194. package/node_modules/ip-address/dist/ipv6.js +149 -41
  195. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  196. package/node_modules/ip-address/dist/v4/constants.js +5 -1
  197. package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
  198. package/node_modules/ip-address/dist/v6/constants.js +3 -2
  199. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  200. package/node_modules/ip-address/package.json +2 -2
  201. package/node_modules/jose/README.md +1 -4
  202. package/node_modules/jose/dist/types/jwks/remote.d.ts +3 -3
  203. package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  204. package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +4 -1
  205. package/node_modules/jose/package.json +1 -1
  206. package/package.json +2 -2
  207. package/profiles/customers/0.4.profile.json +7 -4
  208. package/profiles/customers/0.5.profile.json +131 -0
  209. package/profiles/customers/0.6.profile.json +153 -0
  210. package/profiles/email/0.4.profile.json +8 -4
  211. package/profiles/index.json +2 -0
  212. package/server.js +10 -0
  213. package/dist/ui/assets/index-CTmWS7W4.js +0 -105
  214. package/node_modules/@hono/node-server/dist/conninfo.js +0 -42
  215. package/node_modules/@hono/node-server/dist/globals.d.mts +0 -2
  216. package/node_modules/@hono/node-server/dist/globals.d.ts +0 -2
  217. package/node_modules/@hono/node-server/dist/globals.js +0 -29
  218. package/node_modules/@hono/node-server/dist/globals.mjs +0 -5
  219. package/node_modules/@hono/node-server/dist/index.d.ts +0 -8
  220. package/node_modules/@hono/node-server/dist/index.js +0 -702
  221. package/node_modules/@hono/node-server/dist/listener.d.mts +0 -13
  222. package/node_modules/@hono/node-server/dist/listener.d.ts +0 -13
  223. package/node_modules/@hono/node-server/dist/listener.js +0 -670
  224. package/node_modules/@hono/node-server/dist/listener.mjs +0 -635
  225. package/node_modules/@hono/node-server/dist/request.d.mts +0 -25
  226. package/node_modules/@hono/node-server/dist/request.d.ts +0 -25
  227. package/node_modules/@hono/node-server/dist/request.js +0 -238
  228. package/node_modules/@hono/node-server/dist/request.mjs +0 -206
  229. package/node_modules/@hono/node-server/dist/response.d.mts +0 -26
  230. package/node_modules/@hono/node-server/dist/response.d.ts +0 -26
  231. package/node_modules/@hono/node-server/dist/response.js +0 -112
  232. package/node_modules/@hono/node-server/dist/response.mjs +0 -85
  233. package/node_modules/@hono/node-server/dist/serve-static.d.ts +0 -17
  234. package/node_modules/@hono/node-server/dist/serve-static.js +0 -177
  235. package/node_modules/@hono/node-server/dist/server.d.mts +0 -10
  236. package/node_modules/@hono/node-server/dist/server.d.ts +0 -10
  237. package/node_modules/@hono/node-server/dist/server.js +0 -696
  238. package/node_modules/@hono/node-server/dist/server.mjs +0 -660
  239. package/node_modules/@hono/node-server/dist/types.d.mts +0 -44
  240. package/node_modules/@hono/node-server/dist/types.d.ts +0 -44
  241. package/node_modules/@hono/node-server/dist/types.js +0 -18
  242. package/node_modules/@hono/node-server/dist/types.mjs +0 -0
  243. package/node_modules/@hono/node-server/dist/utils/response/constants.d.mts +0 -3
  244. package/node_modules/@hono/node-server/dist/utils/response/constants.d.ts +0 -3
  245. package/node_modules/@hono/node-server/dist/utils/response/constants.js +0 -30
  246. package/node_modules/@hono/node-server/dist/utils/response/constants.mjs +0 -5
  247. package/node_modules/@hono/node-server/dist/utils/response.d.ts +0 -3
  248. package/node_modules/@hono/node-server/dist/utils/response.js +0 -37
  249. package/node_modules/@hono/node-server/dist/utils.d.mts +0 -9
  250. package/node_modules/@hono/node-server/dist/utils.d.ts +0 -9
  251. package/node_modules/@hono/node-server/dist/utils.js +0 -99
  252. package/node_modules/@hono/node-server/dist/utils.mjs +0 -71
  253. package/node_modules/@hono/node-server/dist/vercel.d.mts +0 -7
  254. package/node_modules/@hono/node-server/dist/vercel.d.ts +0 -7
  255. package/node_modules/@hono/node-server/dist/vercel.js +0 -677
  256. package/node_modules/@hono/node-server/dist/vercel.mjs +0 -640
@@ -1 +1 @@
1
- {"version":3,"file":"ipv4.js","sourceRoot":"","sources":["../src/ipv4.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,iDAAmC;AACnC,0DAA4C;AAC5C,mDAA+C;AAE/C,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAEpD;;;GAGG;AACH,MAAa,QAAQ;IAWnB,YAAY,OAAe;QAR3B,WAAM,GAAW,SAAS,CAAC,MAAM,CAAC;QAClC,kBAAa,GAAa,EAAE,CAAC;QAC7B,iBAAY,GAAW,EAAE,CAAC;QAC1B,WAAM,GAAW,KAAK,CAAC;QACvB,eAAU,GAAW,EAAE,CAAC;QACxB,OAAE,GAAY,IAAI,CAAC;QAoEnB;;;WAGG;QACH,cAAS,GAAG,UAAU,CAAC;QAiWvB;;;WAGG;QACH,eAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAza7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,MAAM,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAExD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAA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ourcesContent":["/* eslint-disable no-param-reassign */\n\nimport * as common from './common';\nimport * as constants from './v4/constants';\nimport { AddressError } from './address-error';\n\nconst isCorrect4 = common.isCorrect(constants.BITS);\n\n/**\n * Represents an IPv4 address\n * @param {string} address - An IPv4 address string\n */\nexport class Address4 {\n address: string;\n addressMinusSuffix?: string;\n groups: number = constants.GROUPS;\n parsedAddress: string[] = [];\n parsedSubnet: string = '';\n subnet: string = '/32';\n subnetMask: number = 32;\n v4: boolean = true;\n private _binaryZeroPad?: string;\n\n constructor(address: string) {\n this.address = address;\n\n const subnet = constants.RE_SUBNET_STRING.exec(address);\n\n if (subnet) {\n this.parsedSubnet = subnet[0].replace('/', '');\n this.subnetMask = parseInt(this.parsedSubnet, 10);\n this.subnet = `/${this.subnetMask}`;\n\n if (this.subnetMask < 0 || this.subnetMask > constants.BITS) {\n throw new AddressError('Invalid subnet mask.');\n }\n\n address = address.replace(constants.RE_SUBNET_STRING, '');\n }\n\n this.addressMinusSuffix = address;\n\n this.parsedAddress = this.parse(address);\n }\n\n /**\n * Returns true if the given string is a valid IPv4 address (with optional\n * CIDR subnet), false otherwise. Host bits in the subnet portion are\n * allowed (e.g. `192.168.1.5/24` is valid); for strict network-address\n * validation compare `correctForm()` to `startAddress().correctForm()`,\n * or use `networkForm()`.\n */\n static isValid(address: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new Address4(address);\n\n return true;\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Parses an IPv4 address string into its four octet groups and stores the\n * result on `this.parsedAddress`. Called automatically by the constructor;\n * you typically don't need to call it directly. Throws `AddressError` if\n * the input is not a valid IPv4 address.\n */\n parse(address: string) {\n const groups = address.split('.');\n\n if (!address.match(constants.RE_ADDRESS)) {\n throw new AddressError('Invalid IPv4 address.');\n }\n\n return groups;\n }\n\n /**\n * Returns the address in correct form: octets joined with `.` and any\n * leading zeros stripped (e.g. `192.168.1.1`). For IPv4 this matches the\n * canonical dotted-decimal representation.\n */\n correctForm(): string {\n return this.parsedAddress.map((part) => parseInt(part, 10)).join('.');\n }\n\n /**\n * Returns true if the address is correct, false otherwise\n * @returns {Boolean}\n */\n isCorrect = isCorrect4;\n\n /**\n * Construct an `Address4` from an address and a dotted-decimal subnet\n * mask given as separate strings (e.g. as returned by Node's\n * `os.networkInterfaces()`). Throws `AddressError` if the mask is\n * non-contiguous (e.g. `255.0.255.0`).\n * @example\n * var address = Address4.fromAddressAndMask('192.168.1.1', '255.255.255.0');\n * address.subnetMask; // 24\n */\n static fromAddressAndMask(address: string, mask: string): Address4 {\n const bits = common.prefixLengthFromMask(new Address4(mask).bigInt(), constants.BITS);\n return new Address4(`${address}/${bits}`);\n }\n\n /**\n * Construct an `Address4` from an address and a Cisco-style wildcard mask\n * given as separate strings (e.g. `0.0.0.255` for a `/24`). The wildcard\n * mask is the bitwise inverse of the subnet mask. Throws `AddressError`\n * if the mask is non-contiguous (e.g. `0.255.0.255`).\n * @example\n * var address = Address4.fromAddressAndWildcardMask('10.0.0.1', '0.0.0.255');\n * address.subnetMask; // 24\n */\n static fromAddressAndWildcardMask(address: string, wildcardMask: string): Address4 {\n const wildcard = new Address4(wildcardMask).bigInt();\n const allOnes = (BigInt(1) << BigInt(constants.BITS)) - BigInt(1);\n // eslint-disable-next-line no-bitwise\n const mask = wildcard ^ allOnes;\n const bits = common.prefixLengthFromMask(mask, constants.BITS);\n return new Address4(`${address}/${bits}`);\n }\n\n /**\n * Construct an `Address4` from a wildcard pattern with trailing `*`\n * octets. The number of trailing wildcards determines the prefix\n * length: each `*` represents 8 bits.\n *\n * Only trailing whole-octet wildcards are supported. Partial-octet\n * wildcards (e.g. `192.168.0.1*`) and interior wildcards (e.g.\n * `192.*.0.1`) throw `AddressError`.\n * @example\n * Address4.fromWildcard('192.168.0.*').subnet; // '/24'\n * Address4.fromWildcard('192.168.*.*').subnet; // '/16'\n * Address4.fromWildcard('*.*.*.*').subnet; // '/0'\n */\n static fromWildcard(input: string): Address4 {\n const groups = input.split('.');\n\n if (groups.length !== constants.GROUPS) {\n throw new AddressError('Wildcard pattern must have 4 octets');\n }\n\n let firstWildcard = -1;\n\n for (let i = 0; i < groups.length; i++) {\n if (groups[i] === '*') {\n if (firstWildcard === -1) {\n firstWildcard = i;\n }\n } else if (firstWildcard !== -1) {\n throw new AddressError(\n 'Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)',\n );\n }\n }\n\n const trailing = firstWildcard === -1 ? 0 : groups.length - firstWildcard;\n const replaced = groups.map((g) => (g === '*' ? '0' : g));\n const subnetBits = constants.BITS - trailing * 8;\n\n return new Address4(`${replaced.join('.')}/${subnetBits}`);\n }\n\n /**\n * Converts a hex string to an IPv4 address object. Accepts 8 hex digits\n * with optional `:` separators (e.g. `'7f000001'` or `'7f:00:00:01'`).\n * Throws `AddressError` for any other length or for non-hex characters.\n * @param {string} hex - a hex string to convert\n * @returns {Address4}\n */\n static fromHex(hex: string): Address4 {\n const stripped = hex.replace(/:/g, '');\n\n if (!/^[0-9a-fA-F]{8}$/.test(stripped)) {\n throw new AddressError('IPv4 hex must be exactly 8 hex digits');\n }\n\n const groups = [];\n\n for (let i = 0; i < 8; i += 2) {\n groups.push(parseInt(stripped.slice(i, i + 2), 16));\n }\n\n return new Address4(groups.join('.'));\n }\n\n /**\n * Converts an integer into a IPv4 address object. The integer must be a\n * non-negative safe integer in the range `[0, 2**32 - 1]`; otherwise\n * `AddressError` is thrown.\n * @param {integer} integer - a number to convert\n * @returns {Address4}\n */\n static fromInteger(integer: number): Address4 {\n if (!Number.isInteger(integer) || integer < 0 || integer > 0xffffffff) {\n throw new AddressError('IPv4 integer must be in the range 0 to 2**32 - 1');\n }\n\n return Address4.fromHex(integer.toString(16).padStart(8, '0'));\n }\n\n /**\n * Return an address from in-addr.arpa form\n * @param {string} arpaFormAddress - an 'in-addr.arpa' form ipv4 address\n * @returns {Adress4}\n * @example\n * var address = Address4.fromArpa(42.2.0.192.in-addr.arpa.)\n * address.correctForm(); // '192.0.2.42'\n */\n static fromArpa(arpaFormAddress: string): Address4 {\n // remove ending \".in-addr.arpa.\" or just \".\"\n const leader = arpaFormAddress.replace(/(\\.in-addr\\.arpa)?\\.$/, '');\n\n const address = leader.split('.').reverse().join('.');\n\n return new Address4(address);\n }\n\n /**\n * Converts an IPv4 address object to a hex string\n * @returns {String}\n */\n toHex(): string {\n return this.parsedAddress.map((part) => common.stringToPaddedHex(part)).join(':');\n }\n\n /**\n * Converts an IPv4 address object to an array of bytes.\n *\n * To get a Node.js `Buffer`, wrap the result: `Buffer.from(address.toArray())`.\n * @returns {Array}\n */\n toArray(): number[] {\n return this.parsedAddress.map((part) => parseInt(part, 10));\n }\n\n /**\n * Converts an IPv4 address object to an IPv6 address group\n * @returns {String}\n */\n toGroup6(): string {\n const output = [];\n let i;\n\n for (i = 0; i < constants.GROUPS; i += 2) {\n output.push(\n `${common.stringToPaddedHex(this.parsedAddress[i])}${common.stringToPaddedHex(\n this.parsedAddress[i + 1],\n )}`,\n );\n }\n\n return output.join(':');\n }\n\n /**\n * Returns the address as a `bigint`\n * @returns {bigint}\n */\n bigInt(): bigint {\n return BigInt(`0x${this.parsedAddress.map((n) => common.stringToPaddedHex(n)).join('')}`);\n }\n\n /**\n * Helper function getting start address.\n * @returns {bigint}\n */\n _startAddress(): bigint {\n return BigInt(`0b${this.mask() + '0'.repeat(constants.BITS - this.subnetMask)}`);\n }\n\n /**\n * The first address in the range given by this address' subnet.\n * Often referred to as the Network Address.\n * @returns {Address4}\n */\n startAddress(): Address4 {\n return Address4.fromBigInt(this._startAddress());\n }\n\n /**\n * The first host address in the range given by this address's subnet ie\n * the first address after the Network Address\n * @returns {Address4}\n */\n startAddressExclusive(): Address4 {\n const adjust = BigInt('1');\n return Address4.fromBigInt(this._startAddress() + adjust);\n }\n\n /**\n * Helper function getting end address.\n * @returns {bigint}\n */\n _endAddress(): bigint {\n return BigInt(`0b${this.mask() + '1'.repeat(constants.BITS - this.subnetMask)}`);\n }\n\n /**\n * The last address in the range given by this address' subnet\n * Often referred to as the Broadcast\n * @returns {Address4}\n */\n endAddress(): Address4 {\n return Address4.fromBigInt(this._endAddress());\n }\n\n /**\n * The last host address in the range given by this address's subnet ie\n * the last address prior to the Broadcast Address\n * @returns {Address4}\n */\n endAddressExclusive(): Address4 {\n const adjust = BigInt('1');\n return Address4.fromBigInt(this._endAddress() - adjust);\n }\n\n /**\n * The dotted-decimal form of the subnet mask, e.g. `255.255.240.0` for\n * a `/20`. Returns an `Address4`; call `.correctForm()` for the string.\n * @returns {Address4}\n */\n subnetMaskAddress(): Address4 {\n return Address4.fromBigInt(\n BigInt(`0b${'1'.repeat(this.subnetMask)}${'0'.repeat(constants.BITS - this.subnetMask)}`),\n );\n }\n\n /**\n * The Cisco-style wildcard mask, e.g. `0.0.0.255` for a `/24`. This is\n * the bitwise inverse of `subnetMaskAddress()`. Returns an `Address4`;\n * call `.correctForm()` for the string.\n * @returns {Address4}\n */\n wildcardMask(): Address4 {\n return Address4.fromBigInt(\n BigInt(`0b${'0'.repeat(this.subnetMask)}${'1'.repeat(constants.BITS - this.subnetMask)}`),\n );\n }\n\n /**\n * The network address in CIDR string form, e.g. `192.168.1.0/24` for\n * `192.168.1.5/24`. For an address with no explicit subnet the prefix is\n * `/32`, e.g. `networkForm()` on `192.168.1.5` returns `192.168.1.5/32`.\n * @returns {string}\n */\n networkForm(): string {\n return `${this.startAddress().correctForm()}/${this.subnetMask}`;\n }\n\n /**\n * Converts a BigInt to a v4 address object. The value must be in the\n * range `[0, 2**32 - 1]`; otherwise `AddressError` is thrown.\n * @param {bigint} bigInt - a BigInt to convert\n * @returns {Address4}\n */\n static fromBigInt(bigInt: bigint): Address4 {\n if (bigInt < 0n || bigInt > 0xffffffffn) {\n throw new AddressError('IPv4 BigInt must be in the range 0 to 2**32 - 1');\n }\n\n return Address4.fromHex(bigInt.toString(16).padStart(8, '0'));\n }\n\n /**\n * Convert a byte array to an Address4 object.\n *\n * To convert from a Node.js `Buffer`, spread it: `Address4.fromByteArray([...buf])`.\n * @param {Array<number>} bytes - an array of 4 bytes (0-255)\n * @returns {Address4}\n */\n static fromByteArray(bytes: Array<number>): Address4 {\n if (bytes.length !== 4) {\n throw new AddressError('IPv4 addresses require exactly 4 bytes');\n }\n\n // Validate that all bytes are within valid range (0-255)\n for (let i = 0; i < bytes.length; i++) {\n if (!Number.isInteger(bytes[i]) || bytes[i] < 0 || bytes[i] > 255) {\n throw new AddressError('All bytes must be integers between 0 and 255');\n }\n }\n\n return this.fromUnsignedByteArray(bytes);\n }\n\n /**\n * Convert an unsigned byte array to an Address4 object\n * @param {Array<number>} bytes - an array of 4 unsigned bytes (0-255)\n * @returns {Address4}\n */\n static fromUnsignedByteArray(bytes: Array<number>): Address4 {\n if (bytes.length !== 4) {\n throw new AddressError('IPv4 addresses require exactly 4 bytes');\n }\n\n const address = bytes.join('.');\n return new Address4(address);\n }\n\n /**\n * Returns the first n bits of the address, defaulting to the\n * subnet mask\n * @returns {String}\n */\n mask(mask?: number): string {\n if (mask === undefined) {\n mask = this.subnetMask;\n }\n\n return this.getBitsBase2(0, mask);\n }\n\n /**\n * Returns the bits in the given range as a base-2 string\n * @returns {string}\n */\n getBitsBase2(start: number, end: number): string {\n return this.binaryZeroPad().slice(start, end);\n }\n\n /**\n * Return the reversed ip6.arpa form of the address\n * @param {Object} options\n * @param {boolean} options.omitSuffix - omit the \"in-addr.arpa\" suffix\n * @returns {String}\n */\n reverseForm(options?: common.ReverseFormOptions): string {\n if (!options) {\n options = {};\n }\n\n const reversed = this.correctForm().split('.').reverse().join('.');\n\n if (options.omitSuffix) {\n return reversed;\n }\n\n return `${reversed}.in-addr.arpa.`;\n }\n\n /**\n * Returns true if the given address is in the subnet of the current address\n * @returns {boolean}\n */\n isInSubnet = common.isInSubnet;\n\n /**\n * Returns true if the given address is a multicast address\n * @returns {boolean}\n */\n isMulticast(): boolean {\n return this.isInSubnet(MULTICAST_V4);\n }\n\n /**\n * Returns true if the address is in one of the [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private address ranges (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`).\n * @returns {boolean}\n */\n isPrivate(): boolean {\n return PRIVATE_V4.some((subnet) => this.isInSubnet(subnet));\n }\n\n /**\n * Returns true if the address is in the loopback range `127.0.0.0/8` ([RFC 1122](https://datatracker.ietf.org/doc/html/rfc1122)).\n * @returns {boolean}\n */\n isLoopback(): boolean {\n return this.isInSubnet(LOOPBACK_V4);\n }\n\n /**\n * Returns true if the address is in the link-local range `169.254.0.0/16` ([RFC 3927](https://datatracker.ietf.org/doc/html/rfc3927)).\n * @returns {boolean}\n */\n isLinkLocal(): boolean {\n return this.isInSubnet(LINK_LOCAL_V4);\n }\n\n /**\n * Returns true if the address is the unspecified address `0.0.0.0`.\n * @returns {boolean}\n */\n isUnspecified(): boolean {\n return this.isInSubnet(UNSPECIFIED_V4);\n }\n\n /**\n * Returns true if the address is the limited broadcast address `255.255.255.255` ([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)).\n * @returns {boolean}\n */\n isBroadcast(): boolean {\n return this.isInSubnet(BROADCAST_V4);\n }\n\n /**\n * Returns true if the address is in the carrier-grade NAT range `100.64.0.0/10` ([RFC 6598](https://datatracker.ietf.org/doc/html/rfc6598)).\n * @returns {boolean}\n */\n isCGNAT(): boolean {\n return this.isInSubnet(CGNAT_V4);\n }\n\n /**\n * Returns a zero-padded base-2 string representation of the address\n * @returns {string}\n */\n binaryZeroPad(): string {\n if (this._binaryZeroPad === undefined) {\n this._binaryZeroPad = this.bigInt().toString(2).padStart(constants.BITS, '0');\n }\n return this._binaryZeroPad;\n }\n\n /**\n * Groups an IPv4 address for inclusion at the end of an IPv6 address\n * @returns {String}\n */\n groupForV6(): string {\n const segments = this.parsedAddress;\n\n return this.address.replace(\n constants.RE_ADDRESS,\n `<span class=\"hover-group group-v4 group-6\">${segments\n .slice(0, 2)\n .join('.')}</span>.<span class=\"hover-group group-v4 group-7\">${segments\n .slice(2, 4)\n .join('.')}</span>`,\n );\n }\n}\n\nconst MULTICAST_V4 = new Address4('224.0.0.0/4');\nconst PRIVATE_V4 = [\n new Address4('10.0.0.0/8'),\n new Address4('172.16.0.0/12'),\n new Address4('192.168.0.0/16'),\n];\nconst LOOPBACK_V4 = new Address4('127.0.0.0/8');\nconst LINK_LOCAL_V4 = new Address4('169.254.0.0/16');\nconst UNSPECIFIED_V4 = new Address4('0.0.0.0/32');\nconst BROADCAST_V4 = new Address4('255.255.255.255/32');\nconst CGNAT_V4 = new Address4('100.64.0.0/10');\n"]}
1
+ {"version":3,"file":"ipv4.js","sourceRoot":"","sources":["../src/ipv4.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,iDAAmC;AACnC,0DAA4C;AAC5C,mDAA+C;AAE/C,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAEpD;;;GAGG;AACH,MAAa,QAAQ;IAWnB,YAAY,OAAe;QAT3B,uBAAkB,GAAW,EAAE,CAAC;QAChC,WAAM,GAAW,SAAS,CAAC,MAAM,CAAC;QAClC,kBAAa,GAAa,EAAE,CAAC;QAC7B,iBAAY,GAAW,EAAE,CAAC;QAC1B,WAAM,GAAW,KAAK,CAAC;QACvB,eAAU,GAAW,EAAE,CAAC;QACxB,OAAE,GAAY,IAAI,CAAC;QA0EnB;;;WAGG;QACH,cAAS,GAAG,UAAU,CAAC;QAiWvB;;;WAGG;QACH,eAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAE/B;;;;;WAKG;QACH,mBAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QAvbrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,MAAM,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAExD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAA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MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACrD,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAC;AAClD,MAAM,YAAY,GAAG,IAAI,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AACxD,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/* eslint-disable no-param-reassign */\n\nimport * as common from './common';\nimport * as constants from './v4/constants';\nimport { AddressError } from './address-error';\n\nconst isCorrect4 = common.isCorrect(constants.BITS);\n\n/**\n * Represents an IPv4 address\n * @param {string} address - An IPv4 address string\n */\nexport class Address4 {\n address: string;\n addressMinusSuffix: string = '';\n groups: number = constants.GROUPS;\n parsedAddress: string[] = [];\n parsedSubnet: string = '';\n subnet: string = '/32';\n subnetMask: number = 32;\n v4: boolean = true;\n private _binaryZeroPad?: string;\n\n constructor(address: string) {\n this.address = address;\n\n const subnet = constants.RE_SUBNET_STRING.exec(address);\n\n if (subnet) {\n this.parsedSubnet = subnet[0].replace('/', '');\n this.subnetMask = parseInt(this.parsedSubnet, 10);\n this.subnet = `/${this.subnetMask}`;\n\n if (this.subnetMask < 0 || this.subnetMask > constants.BITS) {\n throw new AddressError('Invalid subnet mask.');\n }\n\n address = address.replace(constants.RE_SUBNET_STRING, '');\n }\n\n this.addressMinusSuffix = address;\n\n this.parsedAddress = this.parse(address);\n }\n\n /**\n * Returns true if the given string is a valid IPv4 address (with optional\n * CIDR subnet), false otherwise. Host bits in the subnet portion are\n * allowed (e.g. `192.168.1.5/24` is valid); for strict network-address\n * validation compare `correctForm()` to `startAddress().correctForm()`,\n * or use `networkForm()`.\n */\n static isValid(address: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new Address4(address);\n\n return true;\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Parses an IPv4 address string into its four octet groups and stores the\n * result on `this.parsedAddress`. Called automatically by the constructor;\n * you typically don't need to call it directly. Throws `AddressError` if\n * the input is not a valid IPv4 address.\n */\n parse(address: string) {\n const groups = address.split('.');\n\n // Checked before the general match so the error names the actual problem.\n // Address6 rejects the same notation on its v4-in-v6 path.\n if (groups.some((group) => /^0\\d/.test(group))) {\n throw new AddressError(\"IPv4 addresses can't have leading zeroes.\");\n }\n\n if (!address.match(constants.RE_ADDRESS)) {\n throw new AddressError('Invalid IPv4 address.');\n }\n\n return groups;\n }\n\n /**\n * Returns the address in correct form: octets joined with `.` and any\n * leading zeros stripped (e.g. `192.168.1.1`). For IPv4 this matches the\n * canonical dotted-decimal representation.\n */\n correctForm(): string {\n return this.parsedAddress.map((part) => parseInt(part, 10)).join('.');\n }\n\n /**\n * Returns true if the address is correct, false otherwise\n * @returns {Boolean}\n */\n isCorrect = isCorrect4;\n\n /**\n * Construct an `Address4` from an address and a dotted-decimal subnet\n * mask given as separate strings (e.g. as returned by Node's\n * `os.networkInterfaces()`). Throws `AddressError` if the mask is\n * non-contiguous (e.g. `255.0.255.0`).\n * @example\n * var address = Address4.fromAddressAndMask('192.168.1.1', '255.255.255.0');\n * address.subnetMask; // 24\n */\n static fromAddressAndMask(address: string, mask: string): Address4 {\n const bits = common.prefixLengthFromMask(new Address4(mask).bigInt(), constants.BITS);\n return new Address4(`${address}/${bits}`);\n }\n\n /**\n * Construct an `Address4` from an address and a Cisco-style wildcard mask\n * given as separate strings (e.g. `0.0.0.255` for a `/24`). The wildcard\n * mask is the bitwise inverse of the subnet mask. Throws `AddressError`\n * if the mask is non-contiguous (e.g. `0.255.0.255`).\n * @example\n * var address = Address4.fromAddressAndWildcardMask('10.0.0.1', '0.0.0.255');\n * address.subnetMask; // 24\n */\n static fromAddressAndWildcardMask(address: string, wildcardMask: string): Address4 {\n const wildcard = new Address4(wildcardMask).bigInt();\n const allOnes = (BigInt(1) << BigInt(constants.BITS)) - BigInt(1);\n // eslint-disable-next-line no-bitwise\n const mask = wildcard ^ allOnes;\n const bits = common.prefixLengthFromMask(mask, constants.BITS);\n return new Address4(`${address}/${bits}`);\n }\n\n /**\n * Construct an `Address4` from a wildcard pattern with trailing `*`\n * octets. The number of trailing wildcards determines the prefix\n * length: each `*` represents 8 bits.\n *\n * Only trailing whole-octet wildcards are supported. Partial-octet\n * wildcards (e.g. `192.168.0.1*`) and interior wildcards (e.g.\n * `192.*.0.1`) throw `AddressError`.\n * @example\n * Address4.fromWildcard('192.168.0.*').subnet; // '/24'\n * Address4.fromWildcard('192.168.*.*').subnet; // '/16'\n * Address4.fromWildcard('*.*.*.*').subnet; // '/0'\n */\n static fromWildcard(input: string): Address4 {\n const groups = input.split('.');\n\n if (groups.length !== constants.GROUPS) {\n throw new AddressError('Wildcard pattern must have 4 octets');\n }\n\n let firstWildcard = -1;\n\n for (let i = 0; i < groups.length; i++) {\n if (groups[i] === '*') {\n if (firstWildcard === -1) {\n firstWildcard = i;\n }\n } else if (firstWildcard !== -1) {\n throw new AddressError(\n 'Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)',\n );\n }\n }\n\n const trailing = firstWildcard === -1 ? 0 : groups.length - firstWildcard;\n const replaced = groups.map((g) => (g === '*' ? '0' : g));\n const subnetBits = constants.BITS - trailing * 8;\n\n return new Address4(`${replaced.join('.')}/${subnetBits}`);\n }\n\n /**\n * Converts a hex string to an IPv4 address object. Accepts 8 hex digits\n * with optional `:` separators (e.g. `'7f000001'` or `'7f:00:00:01'`).\n * Throws `AddressError` for any other length or for non-hex characters.\n * @param {string} hex - a hex string to convert\n * @returns {Address4}\n */\n static fromHex(hex: string): Address4 {\n const stripped = hex.replace(/:/g, '');\n\n if (!/^[0-9a-fA-F]{8}$/.test(stripped)) {\n throw new AddressError('IPv4 hex must be exactly 8 hex digits');\n }\n\n const groups = [];\n\n for (let i = 0; i < 8; i += 2) {\n groups.push(parseInt(stripped.slice(i, i + 2), 16));\n }\n\n return new Address4(groups.join('.'));\n }\n\n /**\n * Converts an integer into a IPv4 address object. The integer must be a\n * non-negative safe integer in the range `[0, 2**32 - 1]`; otherwise\n * `AddressError` is thrown.\n * @param {integer} integer - a number to convert\n * @returns {Address4}\n */\n static fromInteger(integer: number): Address4 {\n if (!Number.isInteger(integer) || integer < 0 || integer > 0xffffffff) {\n throw new AddressError('IPv4 integer must be in the range 0 to 2**32 - 1');\n }\n\n return Address4.fromHex(integer.toString(16).padStart(8, '0'));\n }\n\n /**\n * Return an address from in-addr.arpa form\n * @param {string} arpaFormAddress - an 'in-addr.arpa' form ipv4 address\n * @returns {Adress4}\n * @example\n * var address = Address4.fromArpa(42.2.0.192.in-addr.arpa.)\n * address.correctForm(); // '192.0.2.42'\n */\n static fromArpa(arpaFormAddress: string): Address4 {\n // remove ending \".in-addr.arpa.\" or just \".\"\n const leader = arpaFormAddress.replace(/(\\.in-addr\\.arpa)?\\.$/, '');\n\n const address = leader.split('.').reverse().join('.');\n\n return new Address4(address);\n }\n\n /**\n * Converts an IPv4 address object to a hex string\n * @returns {String}\n */\n toHex(): string {\n return this.parsedAddress.map((part) => common.stringToPaddedHex(part)).join(':');\n }\n\n /**\n * Converts an IPv4 address object to an array of bytes.\n *\n * To get a Node.js `Buffer`, wrap the result: `Buffer.from(address.toArray())`.\n * @returns {Array}\n */\n toArray(): number[] {\n return this.parsedAddress.map((part) => parseInt(part, 10));\n }\n\n /**\n * Converts an IPv4 address object to an IPv6 address group\n * @returns {String}\n */\n toGroup6(): string {\n const output = [];\n let i;\n\n for (i = 0; i < constants.GROUPS; i += 2) {\n output.push(\n `${common.stringToPaddedHex(this.parsedAddress[i])}${common.stringToPaddedHex(\n this.parsedAddress[i + 1],\n )}`,\n );\n }\n\n return output.join(':');\n }\n\n /**\n * Returns the address as a `bigint`\n * @returns {bigint}\n */\n bigInt(): bigint {\n return BigInt(`0x${this.parsedAddress.map((n) => common.stringToPaddedHex(n)).join('')}`);\n }\n\n /**\n * Helper function getting start address.\n * @returns {bigint}\n */\n _startAddress(): bigint {\n return BigInt(`0b${this.mask() + '0'.repeat(constants.BITS - this.subnetMask)}`);\n }\n\n /**\n * The first address in the range given by this address' subnet.\n * Often referred to as the Network Address.\n * @returns {Address4}\n */\n startAddress(): Address4 {\n return Address4.fromBigInt(this._startAddress());\n }\n\n /**\n * The first host address in the range given by this address's subnet ie\n * the first address after the Network Address\n * @returns {Address4}\n */\n startAddressExclusive(): Address4 {\n const adjust = BigInt('1');\n return Address4.fromBigInt(this._startAddress() + adjust);\n }\n\n /**\n * Helper function getting end address.\n * @returns {bigint}\n */\n _endAddress(): bigint {\n return BigInt(`0b${this.mask() + '1'.repeat(constants.BITS - this.subnetMask)}`);\n }\n\n /**\n * The last address in the range given by this address' subnet\n * Often referred to as the Broadcast\n * @returns {Address4}\n */\n endAddress(): Address4 {\n return Address4.fromBigInt(this._endAddress());\n }\n\n /**\n * The last host address in the range given by this address's subnet ie\n * the last address prior to the Broadcast Address\n * @returns {Address4}\n */\n endAddressExclusive(): Address4 {\n const adjust = BigInt('1');\n return Address4.fromBigInt(this._endAddress() - adjust);\n }\n\n /**\n * The dotted-decimal form of the subnet mask, e.g. `255.255.240.0` for\n * a `/20`. Returns an `Address4`; call `.correctForm()` for the string.\n * @returns {Address4}\n */\n subnetMaskAddress(): Address4 {\n return Address4.fromBigInt(\n BigInt(`0b${'1'.repeat(this.subnetMask)}${'0'.repeat(constants.BITS - this.subnetMask)}`),\n );\n }\n\n /**\n * The Cisco-style wildcard mask, e.g. `0.0.0.255` for a `/24`. This is\n * the bitwise inverse of `subnetMaskAddress()`. Returns an `Address4`;\n * call `.correctForm()` for the string.\n * @returns {Address4}\n */\n wildcardMask(): Address4 {\n return Address4.fromBigInt(\n BigInt(`0b${'0'.repeat(this.subnetMask)}${'1'.repeat(constants.BITS - this.subnetMask)}`),\n );\n }\n\n /**\n * The network address in CIDR string form, e.g. `192.168.1.0/24` for\n * `192.168.1.5/24`. For an address with no explicit subnet the prefix is\n * `/32`, e.g. `networkForm()` on `192.168.1.5` returns `192.168.1.5/32`.\n * @returns {string}\n */\n networkForm(): string {\n return `${this.startAddress().correctForm()}/${this.subnetMask}`;\n }\n\n /**\n * Converts a BigInt to a v4 address object. The value must be in the\n * range `[0, 2**32 - 1]`; otherwise `AddressError` is thrown.\n * @param {bigint} bigInt - a BigInt to convert\n * @returns {Address4}\n */\n static fromBigInt(bigInt: bigint): Address4 {\n if (bigInt < 0n || bigInt > 0xffffffffn) {\n throw new AddressError('IPv4 BigInt must be in the range 0 to 2**32 - 1');\n }\n\n return Address4.fromHex(bigInt.toString(16).padStart(8, '0'));\n }\n\n /**\n * Convert a byte array to an Address4 object.\n *\n * To convert from a Node.js `Buffer`, spread it: `Address4.fromByteArray([...buf])`.\n * @param {Array<number>} bytes - an array of 4 bytes (0-255)\n * @returns {Address4}\n */\n static fromByteArray(bytes: Array<number>): Address4 {\n if (bytes.length !== 4) {\n throw new AddressError('IPv4 addresses require exactly 4 bytes');\n }\n\n // Validate that all bytes are within valid range (0-255)\n for (let i = 0; i < bytes.length; i++) {\n if (!Number.isInteger(bytes[i]) || bytes[i] < 0 || bytes[i] > 255) {\n throw new AddressError('All bytes must be integers between 0 and 255');\n }\n }\n\n return this.fromUnsignedByteArray(bytes);\n }\n\n /**\n * Convert an unsigned byte array to an Address4 object\n * @param {Array<number>} bytes - an array of 4 unsigned bytes (0-255)\n * @returns {Address4}\n */\n static fromUnsignedByteArray(bytes: Array<number>): Address4 {\n if (bytes.length !== 4) {\n throw new AddressError('IPv4 addresses require exactly 4 bytes');\n }\n\n const address = bytes.join('.');\n return new Address4(address);\n }\n\n /**\n * Returns the first n bits of the address, defaulting to the\n * subnet mask\n * @returns {String}\n */\n mask(mask?: number): string {\n if (mask === undefined) {\n mask = this.subnetMask;\n }\n\n return this.getBitsBase2(0, mask);\n }\n\n /**\n * Returns the bits in the given range as a base-2 string\n * @returns {string}\n */\n getBitsBase2(start: number, end: number): string {\n return this.binaryZeroPad().slice(start, end);\n }\n\n /**\n * Return the reversed ip6.arpa form of the address\n * @param {Object} options\n * @param {boolean} options.omitSuffix - omit the \"in-addr.arpa\" suffix\n * @returns {String}\n */\n reverseForm(options?: common.ReverseFormOptions): string {\n if (!options) {\n options = {};\n }\n\n const reversed = this.correctForm().split('.').reverse().join('.');\n\n if (options.omitSuffix) {\n return reversed;\n }\n\n return `${reversed}.in-addr.arpa.`;\n }\n\n /**\n * Returns true if the given address is in the subnet of the current address\n * @returns {boolean}\n */\n isInSubnet = common.isInSubnet;\n\n /**\n * Returns true if this address's host bits fall inside the given subnet,\n * ignoring this address's own subnet mask. See\n * {@link common.isHostInSubnet}.\n * @returns {boolean}\n */\n isHostInSubnet = common.isHostInSubnet;\n\n /**\n * Returns true if the given address is a multicast address\n * @returns {boolean}\n */\n isMulticast(): boolean {\n return this.isHostInSubnet(MULTICAST_V4);\n }\n\n /**\n * Returns true if the address is in one of the [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private address ranges (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`).\n * @returns {boolean}\n */\n isPrivate(): boolean {\n return PRIVATE_V4.some((subnet) => this.isHostInSubnet(subnet));\n }\n\n /**\n * Returns true if the address is in the loopback range `127.0.0.0/8` ([RFC 1122](https://datatracker.ietf.org/doc/html/rfc1122)).\n * @returns {boolean}\n */\n isLoopback(): boolean {\n return this.isHostInSubnet(LOOPBACK_V4);\n }\n\n /**\n * Returns true if the address is in the link-local range `169.254.0.0/16` ([RFC 3927](https://datatracker.ietf.org/doc/html/rfc3927)).\n * @returns {boolean}\n */\n isLinkLocal(): boolean {\n return this.isHostInSubnet(LINK_LOCAL_V4);\n }\n\n /**\n * Returns true if the address is the unspecified address `0.0.0.0`.\n * @returns {boolean}\n */\n isUnspecified(): boolean {\n return this.isHostInSubnet(UNSPECIFIED_V4);\n }\n\n /**\n * Returns true if the address is the limited broadcast address `255.255.255.255` ([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)).\n * @returns {boolean}\n */\n isBroadcast(): boolean {\n return this.isHostInSubnet(BROADCAST_V4);\n }\n\n /**\n * Returns true if the address is in the carrier-grade NAT range `100.64.0.0/10` ([RFC 6598](https://datatracker.ietf.org/doc/html/rfc6598)).\n * @returns {boolean}\n */\n isCGNAT(): boolean {\n return this.isHostInSubnet(CGNAT_V4);\n }\n\n /**\n * Returns a zero-padded base-2 string representation of the address\n * @returns {string}\n */\n binaryZeroPad(): string {\n if (this._binaryZeroPad === undefined) {\n this._binaryZeroPad = this.bigInt().toString(2).padStart(constants.BITS, '0');\n }\n return this._binaryZeroPad;\n }\n\n /**\n * Groups an IPv4 address for inclusion at the end of an IPv6 address\n * @returns {String}\n */\n groupForV6(): string {\n const segments = this.parsedAddress;\n\n return this.correctForm().replace(\n constants.RE_ADDRESS,\n `<span class=\"hover-group group-v4 group-6\">${segments\n .slice(0, 2)\n .join('.')}</span>.<span class=\"hover-group group-v4 group-7\">${segments\n .slice(2, 4)\n .join('.')}</span>`,\n );\n }\n}\n\nconst MULTICAST_V4 = new Address4('224.0.0.0/4');\nconst PRIVATE_V4 = [\n new Address4('10.0.0.0/8'),\n new Address4('172.16.0.0/12'),\n new Address4('192.168.0.0/16'),\n];\nconst LOOPBACK_V4 = new Address4('127.0.0.0/8');\nconst LINK_LOCAL_V4 = new Address4('169.254.0.0/16');\nconst UNSPECIFIED_V4 = new Address4('0.0.0.0/32');\nconst BROADCAST_V4 = new Address4('255.255.255.255/32');\nconst CGNAT_V4 = new Address4('100.64.0.0/10');\n"]}
@@ -297,7 +297,11 @@ export declare class Address6 {
297
297
  */
298
298
  bigInt(): bigint;
299
299
  /**
300
- * Return the last two groups of this address as an IPv4 address string
300
+ * Return the last two groups of this address as an IPv4 address string.
301
+ * If this address carries a CIDR prefix that covers the trailing 32 bits
302
+ * (i.e. `subnetMask >= 96`), the resulting `Address4` inherits the
303
+ * corresponding v4 prefix (`subnetMask - 96`); otherwise it defaults to
304
+ * `/32`.
301
305
  * @returns {Address4}
302
306
  * @example
303
307
  * var address = new Address6('2001:4860:4001::1825:bf11');
@@ -380,6 +384,13 @@ export declare class Address6 {
380
384
  * @returns {boolean}
381
385
  */
382
386
  isInSubnet: typeof common.isInSubnet;
387
+ /**
388
+ * Returns true if this address's host bits fall inside the given subnet,
389
+ * ignoring this address's own subnet mask. See
390
+ * {@link common.isHostInSubnet}.
391
+ * @returns {boolean}
392
+ */
393
+ isHostInSubnet: typeof common.isHostInSubnet;
383
394
  /**
384
395
  * Returns true if the address is correct, false otherwise
385
396
  * @returns {boolean}
@@ -417,6 +428,24 @@ export declare class Address6 {
417
428
  * @returns {boolean}
418
429
  */
419
430
  isMapped4(): boolean;
431
+ /**
432
+ * If this address embeds a routable IPv4 address — i.e. it is IPv4-mapped
433
+ * (`::ffff:0:0/96`) or sits in the NAT64 well-known prefix (`64:ff9b::/96`,
434
+ * [RFC 6052](https://datatracker.ietf.org/doc/html/rfc6052)) — return that
435
+ * embedded address as an {@link Address4}; otherwise return null.
436
+ *
437
+ * The special-property checks (`isLoopback`, `isLinkLocal`, `isMulticast`,
438
+ * `isUnspecified`, `isPrivate`, `isCGNAT`, `isBroadcast`) call this first and
439
+ * delegate to the embedded {@link Address4} when present, so a literal such as
440
+ * `::ffff:127.0.0.1` is classified by what it actually reaches (loopback)
441
+ * rather than by its IPv6 wrapper (which `getType()` reports as IPv4-mapped).
442
+ * This matters wherever the checks back a trust-boundary decision (e.g. an
443
+ * SSRF allow/deny filter): without normalization, `::ffff:10.0.0.1`,
444
+ * `::ffff:169.254.169.254`, `64:ff9b::7f00:1`, etc. would all read as
445
+ * non-internal.
446
+ * @returns {Address4 | null}
447
+ */
448
+ embeddedIPv4(): Address4 | null;
420
449
  /**
421
450
  * Returns true if the address is a Teredo address, false otherwise
422
451
  * @returns {boolean}
@@ -437,6 +466,35 @@ export declare class Address6 {
437
466
  * @returns {boolean}
438
467
  */
439
468
  isULA(): boolean;
469
+ /**
470
+ * Returns true if the address is private, i.e. a Unique Local Address in
471
+ * `fc00::/7` ([RFC 4193](https://datatracker.ietf.org/doc/html/rfc4193)) or an
472
+ * IPv4-mapped / NAT64 address whose embedded IPv4 address is in one of the
473
+ * [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private ranges
474
+ * (e.g. `::ffff:10.0.0.1`). This is the IPv6 counterpart to
475
+ * {@link Address4.isPrivate}; use it instead of {@link isULA} when you need to
476
+ * catch mapped RFC 1918 addresses as well as native ULAs.
477
+ * @returns {boolean}
478
+ */
479
+ isPrivate(): boolean;
480
+ /**
481
+ * Returns true if the address is an IPv4-mapped / NAT64 address whose embedded
482
+ * IPv4 address is in the carrier-grade NAT range `100.64.0.0/10`
483
+ * ([RFC 6598](https://datatracker.ietf.org/doc/html/rfc6598)), false
484
+ * otherwise. There is no native IPv6 CGNAT range, so this only ever returns
485
+ * true for an embedded IPv4 address (e.g. `::ffff:100.64.0.1`).
486
+ * @returns {boolean}
487
+ */
488
+ isCGNAT(): boolean;
489
+ /**
490
+ * Returns true if the address is an IPv4-mapped / NAT64 address whose embedded
491
+ * IPv4 address is the limited broadcast address `255.255.255.255`
492
+ * ([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)), false otherwise.
493
+ * There is no IPv6 broadcast, so this only ever returns true for an embedded
494
+ * IPv4 address (e.g. `::ffff:255.255.255.255`).
495
+ * @returns {boolean}
496
+ */
497
+ isBroadcast(): boolean;
440
498
  /**
441
499
  * Returns true if the address is the unspecified address `::`.
442
500
  * @returns {boolean}
@@ -97,6 +97,13 @@ class Address6 {
97
97
  * @returns {boolean}
98
98
  */
99
99
  this.isInSubnet = common.isInSubnet;
100
+ /**
101
+ * Returns true if this address's host bits fall inside the given subnet,
102
+ * ignoring this address's own subnet mask. See
103
+ * {@link common.isHostInSubnet}.
104
+ * @returns {boolean}
105
+ */
106
+ this.isHostInSubnet = common.isHostInSubnet;
100
107
  /**
101
108
  * Returns true if the address is correct, false otherwise
102
109
  * @returns {boolean}
@@ -121,7 +128,10 @@ class Address6 {
121
128
  }
122
129
  address = address.replace(constants6.RE_SUBNET_STRING, '');
123
130
  }
124
- else if (/\//.test(address)) {
131
+ // RE_SUBNET_STRING anchors on the end of the address, so it strips only
132
+ // the trailing suffix. A second one left behind (`::/0/1`) is malformed
133
+ // and must be rejected rather than parsed as an address group.
134
+ if (/\//.test(address)) {
125
135
  throw new address_error_1.AddressError('Invalid subnet mask.');
126
136
  }
127
137
  const zone = constants6.RE_ZONE_STRING.exec(address);
@@ -184,9 +194,11 @@ class Address6 {
184
194
  let host;
185
195
  let port = null;
186
196
  let result;
197
+ // Remove the protocol prefix, if any
198
+ const stripped = url.replace(/^[a-z][a-z0-9+.-]*:\/\//i, '');
187
199
  // If we have brackets parse them and find a port
188
- if (url.indexOf('[') !== -1 && url.indexOf(']:') !== -1) {
189
- result = constants6.RE_URL_WITH_PORT.exec(url);
200
+ if (stripped.indexOf('[') !== -1 && stripped.indexOf(']:') !== -1) {
201
+ result = constants6.RE_URL_WITH_PORT.exec(stripped);
190
202
  if (result === null) {
191
203
  return {
192
204
  error: 'failed to parse address with port',
@@ -196,13 +208,9 @@ class Address6 {
196
208
  }
197
209
  host = result[1];
198
210
  port = result[2];
199
- // If there's a URL extract the address
200
211
  }
201
- else if (url.indexOf('/') !== -1) {
202
- // Remove the protocol prefix
203
- url = url.replace(/^[a-z0-9]+:\/\//, '');
204
- // Parse the address
205
- result = constants6.RE_URL.exec(url);
212
+ else {
213
+ result = constants6.RE_URL.exec(stripped);
206
214
  if (result === null) {
207
215
  return {
208
216
  error: 'failed to parse address from URL',
@@ -210,17 +218,13 @@ class Address6 {
210
218
  port: null,
211
219
  };
212
220
  }
213
- host = result[1];
214
- // Otherwise just assign the URL to the host and let the library parse it
215
- }
216
- else {
217
- host = url;
221
+ host = result[1] ?? result[2];
218
222
  }
219
223
  // If there's a port convert it to an integer
220
224
  if (port) {
221
225
  port = parseInt(port, 10);
222
- // squelch out of range ports
223
- if (port < 0 || port > 65536) {
226
+ // squelch out of range ports (valid ports are 0-65535)
227
+ if (port < 0 || port > 65535) {
224
228
  port = null;
225
229
  }
226
230
  }
@@ -493,7 +497,7 @@ class Address6 {
493
497
  getType() {
494
498
  for (let i = 0; i < TYPE_SUBNETS.length; i++) {
495
499
  const entry = TYPE_SUBNETS[i];
496
- if (this.isInSubnet(entry[0])) {
500
+ if (this.isHostInSubnet(entry[0])) {
497
501
  return entry[1];
498
502
  }
499
503
  }
@@ -635,20 +639,26 @@ class Address6 {
635
639
  }
636
640
  const groups = address.split(':');
637
641
  const lastGroup = groups.slice(-1)[0];
642
+ // RE_ADDRESS rejects octets with a leading zero, so a dotted-quad tail is
643
+ // matched permissively first: that way this notation still gets its own
644
+ // message with the offending octet highlighted, rather than falling
645
+ // through as an unrecognized group.
646
+ const v4Octets = lastGroup.split('.');
647
+ if (v4Octets.length === constants4.GROUPS && v4Octets.every((octet) => /^\d{1,3}$/.test(octet))) {
648
+ if (v4Octets.some((octet) => /^0\d/.test(octet))) {
649
+ // The prefix groups haven't been through the bad-character check
650
+ // yet, so escape them before including in the error HTML.
651
+ const highlighted = v4Octets.map(spanLeadingZeroes4).join('.');
652
+ const prefix = groups.slice(0, -1).map(helpers.escapeHtml).join(':');
653
+ const separator = groups.length > 1 ? ':' : '';
654
+ throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", `${prefix}${separator}${highlighted}`);
655
+ }
656
+ }
638
657
  const address4 = lastGroup.match(constants4.RE_ADDRESS);
639
658
  if (address4) {
640
659
  this.parsedAddress4 = address4[0];
641
- this.address4 = new ipv4_1.Address4(this.parsedAddress4);
642
- for (let i = 0; i < this.address4.groups; i++) {
643
- if (/^0[0-9]+/.test(this.address4.parsedAddress[i])) {
644
- // The prefix groups haven't been through the bad-character check
645
- // yet, so escape them before including in the error HTML.
646
- const highlighted = this.address4.parsedAddress.map(spanLeadingZeroes4).join('.');
647
- const prefix = groups.slice(0, -1).map(helpers.escapeHtml).join(':');
648
- const separator = groups.length > 1 ? ':' : '';
649
- throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", `${prefix}${separator}${highlighted}`);
650
- }
651
- }
660
+ const v4Suffix = this.subnetMask >= 96 ? `/${this.subnetMask - 96}` : '';
661
+ this.address4 = new ipv4_1.Address4(`${this.parsedAddress4}${v4Suffix}`);
652
662
  this.v4 = true;
653
663
  groups[groups.length - 1] = this.address4.toGroup6();
654
664
  address = groups.join(':');
@@ -734,7 +744,11 @@ class Address6 {
734
744
  return BigInt(`0x${this.parsedAddress.map(paddedHex).join('')}`);
735
745
  }
736
746
  /**
737
- * Return the last two groups of this address as an IPv4 address string
747
+ * Return the last two groups of this address as an IPv4 address string.
748
+ * If this address carries a CIDR prefix that covers the trailing 32 bits
749
+ * (i.e. `subnetMask >= 96`), the resulting `Address4` inherits the
750
+ * corresponding v4 prefix (`subnetMask - 96`); otherwise it defaults to
751
+ * `/32`.
738
752
  * @returns {Address4}
739
753
  * @example
740
754
  * var address = new Address6('2001:4860:4001::1825:bf11');
@@ -742,7 +756,16 @@ class Address6 {
742
756
  */
743
757
  to4() {
744
758
  const binary = this.binaryZeroPad().split('');
745
- return ipv4_1.Address4.fromHex(BigInt(`0b${binary.slice(96, 128).join('')}`).toString(16).padStart(8, '0'));
759
+ const hex = BigInt(`0b${binary.slice(96, 128).join('')}`).toString(16).padStart(8, '0');
760
+ if (this.subnetMask >= 96) {
761
+ const v4Mask = this.subnetMask - 96;
762
+ const groups = [];
763
+ for (let i = 0; i < 8; i += 2) {
764
+ groups.push(parseInt(hex.slice(i, i + 2), 16));
765
+ }
766
+ return new ipv4_1.Address4(`${groups.join('.')}/${v4Mask}`);
767
+ }
768
+ return ipv4_1.Address4.fromHex(hex);
746
769
  }
747
770
  /**
748
771
  * Return the v4-in-v6 form of the address
@@ -756,7 +779,7 @@ class Address6 {
756
779
  if (!/:$/.test(correct)) {
757
780
  infix = ':';
758
781
  }
759
- return correct + infix + address4.address;
782
+ return correct + infix + address4.correctForm();
760
783
  }
761
784
  /**
762
785
  * Decodes the Teredo tunneling fields embedded in this address. Returns the
@@ -902,7 +925,7 @@ class Address6 {
902
925
  if (pl !== 32 && pl !== 40 && pl !== 48 && pl !== 56 && pl !== 64 && pl !== 96) {
903
926
  throw new address_error_1.AddressError('NAT64 prefix length must be 32, 40, 48, 56, 64, or 96');
904
927
  }
905
- if (!this.isInSubnet(prefix6)) {
928
+ if (!this.isHostInSubnet(prefix6)) {
906
929
  return null;
907
930
  }
908
931
  const bits = this.binaryZeroPad();
@@ -927,9 +950,7 @@ class Address6 {
927
950
  * @returns {Array}
928
951
  */
929
952
  toByteArray() {
930
- const valueWithoutPadding = this.bigInt().toString(16);
931
- const leadingPad = '0'.repeat(valueWithoutPadding.length % 2);
932
- const value = `${leadingPad}${valueWithoutPadding}`;
953
+ const value = this.bigInt().toString(16).padStart(constants6.BITS / 4, '0');
933
954
  const bytes = [];
934
955
  for (let i = 0, length = value.length; i < length; i += 2) {
935
956
  bytes.push(parseInt(value.substring(i, i + 2), 16));
@@ -982,7 +1003,11 @@ class Address6 {
982
1003
  * @returns {boolean}
983
1004
  */
984
1005
  isLinkLocal() {
985
- // Zeroes are required, i.e. we can't check isInSubnet with 'fe80::/10'
1006
+ const embedded = this.embeddedIPv4();
1007
+ if (embedded) {
1008
+ return embedded.isLinkLocal();
1009
+ }
1010
+ // Zeroes are required, i.e. we can't check isHostInSubnet with 'fe80::/10'
986
1011
  if (this.getBitsBase2(0, 64) ===
987
1012
  '1111111010000000000000000000000000000000000000000000000000000000') {
988
1013
  return true;
@@ -994,6 +1019,10 @@ class Address6 {
994
1019
  * @returns {boolean}
995
1020
  */
996
1021
  isMulticast() {
1022
+ const embedded = this.embeddedIPv4();
1023
+ if (embedded) {
1024
+ return embedded.isMulticast();
1025
+ }
997
1026
  const type = this.getType();
998
1027
  return type === 'Multicast' || type.startsWith('Multicast ');
999
1028
  }
@@ -1016,27 +1045,54 @@ class Address6 {
1016
1045
  * @returns {boolean}
1017
1046
  */
1018
1047
  isMapped4() {
1019
- return this.isInSubnet(IPV4_MAPPED_SUBNET);
1048
+ return this.isHostInSubnet(IPV4_MAPPED_SUBNET);
1049
+ }
1050
+ /**
1051
+ * If this address embeds a routable IPv4 address — i.e. it is IPv4-mapped
1052
+ * (`::ffff:0:0/96`) or sits in the NAT64 well-known prefix (`64:ff9b::/96`,
1053
+ * [RFC 6052](https://datatracker.ietf.org/doc/html/rfc6052)) — return that
1054
+ * embedded address as an {@link Address4}; otherwise return null.
1055
+ *
1056
+ * The special-property checks (`isLoopback`, `isLinkLocal`, `isMulticast`,
1057
+ * `isUnspecified`, `isPrivate`, `isCGNAT`, `isBroadcast`) call this first and
1058
+ * delegate to the embedded {@link Address4} when present, so a literal such as
1059
+ * `::ffff:127.0.0.1` is classified by what it actually reaches (loopback)
1060
+ * rather than by its IPv6 wrapper (which `getType()` reports as IPv4-mapped).
1061
+ * This matters wherever the checks back a trust-boundary decision (e.g. an
1062
+ * SSRF allow/deny filter): without normalization, `::ffff:10.0.0.1`,
1063
+ * `::ffff:169.254.169.254`, `64:ff9b::7f00:1`, etc. would all read as
1064
+ * non-internal.
1065
+ * @returns {Address4 | null}
1066
+ */
1067
+ embeddedIPv4() {
1068
+ if (this.isMapped4() || this.isHostInSubnet(NAT64_WELL_KNOWN_SUBNET)) {
1069
+ return this.to4();
1070
+ }
1071
+ return null;
1020
1072
  }
1021
1073
  /**
1022
1074
  * Returns true if the address is a Teredo address, false otherwise
1023
1075
  * @returns {boolean}
1024
1076
  */
1025
1077
  isTeredo() {
1026
- return this.isInSubnet(TEREDO_SUBNET);
1078
+ return this.isHostInSubnet(TEREDO_SUBNET);
1027
1079
  }
1028
1080
  /**
1029
1081
  * Returns true if the address is a 6to4 address, false otherwise
1030
1082
  * @returns {boolean}
1031
1083
  */
1032
1084
  is6to4() {
1033
- return this.isInSubnet(SIX_TO_FOUR_SUBNET);
1085
+ return this.isHostInSubnet(SIX_TO_FOUR_SUBNET);
1034
1086
  }
1035
1087
  /**
1036
1088
  * Returns true if the address is a loopback address, false otherwise
1037
1089
  * @returns {boolean}
1038
1090
  */
1039
1091
  isLoopback() {
1092
+ const embedded = this.embeddedIPv4();
1093
+ if (embedded) {
1094
+ return embedded.isLoopback();
1095
+ }
1040
1096
  return this.getType() === 'Loopback';
1041
1097
  }
1042
1098
  /**
@@ -1044,13 +1100,64 @@ class Address6 {
1044
1100
  * @returns {boolean}
1045
1101
  */
1046
1102
  isULA() {
1047
- return this.isInSubnet(ULA_SUBNET);
1103
+ return this.isHostInSubnet(ULA_SUBNET);
1104
+ }
1105
+ /**
1106
+ * Returns true if the address is private, i.e. a Unique Local Address in
1107
+ * `fc00::/7` ([RFC 4193](https://datatracker.ietf.org/doc/html/rfc4193)) or an
1108
+ * IPv4-mapped / NAT64 address whose embedded IPv4 address is in one of the
1109
+ * [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private ranges
1110
+ * (e.g. `::ffff:10.0.0.1`). This is the IPv6 counterpart to
1111
+ * {@link Address4.isPrivate}; use it instead of {@link isULA} when you need to
1112
+ * catch mapped RFC 1918 addresses as well as native ULAs.
1113
+ * @returns {boolean}
1114
+ */
1115
+ isPrivate() {
1116
+ const embedded = this.embeddedIPv4();
1117
+ if (embedded) {
1118
+ return embedded.isPrivate();
1119
+ }
1120
+ return this.isULA();
1121
+ }
1122
+ /**
1123
+ * Returns true if the address is an IPv4-mapped / NAT64 address whose embedded
1124
+ * IPv4 address is in the carrier-grade NAT range `100.64.0.0/10`
1125
+ * ([RFC 6598](https://datatracker.ietf.org/doc/html/rfc6598)), false
1126
+ * otherwise. There is no native IPv6 CGNAT range, so this only ever returns
1127
+ * true for an embedded IPv4 address (e.g. `::ffff:100.64.0.1`).
1128
+ * @returns {boolean}
1129
+ */
1130
+ isCGNAT() {
1131
+ const embedded = this.embeddedIPv4();
1132
+ if (embedded) {
1133
+ return embedded.isCGNAT();
1134
+ }
1135
+ return false;
1136
+ }
1137
+ /**
1138
+ * Returns true if the address is an IPv4-mapped / NAT64 address whose embedded
1139
+ * IPv4 address is the limited broadcast address `255.255.255.255`
1140
+ * ([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)), false otherwise.
1141
+ * There is no IPv6 broadcast, so this only ever returns true for an embedded
1142
+ * IPv4 address (e.g. `::ffff:255.255.255.255`).
1143
+ * @returns {boolean}
1144
+ */
1145
+ isBroadcast() {
1146
+ const embedded = this.embeddedIPv4();
1147
+ if (embedded) {
1148
+ return embedded.isBroadcast();
1149
+ }
1150
+ return false;
1048
1151
  }
1049
1152
  /**
1050
1153
  * Returns true if the address is the unspecified address `::`.
1051
1154
  * @returns {boolean}
1052
1155
  */
1053
1156
  isUnspecified() {
1157
+ const embedded = this.embeddedIPv4();
1158
+ if (embedded) {
1159
+ return embedded.isUnspecified();
1160
+ }
1054
1161
  return this.getType() === 'Unspecified';
1055
1162
  }
1056
1163
  /**
@@ -1058,7 +1165,7 @@ class Address6 {
1058
1165
  * @returns {boolean}
1059
1166
  */
1060
1167
  isDocumentation() {
1061
- return this.isInSubnet(DOCUMENTATION_SUBNET);
1168
+ return this.isHostInSubnet(DOCUMENTATION_SUBNET);
1062
1169
  }
1063
1170
  // #endregion
1064
1171
  // #region HTML
@@ -1214,4 +1321,5 @@ const SIX_TO_FOUR_SUBNET = new Address6('2002::/16');
1214
1321
  const ULA_SUBNET = new Address6('fc00::/7');
1215
1322
  const DOCUMENTATION_SUBNET = new Address6('2001:db8::/32');
1216
1323
  const IPV4_MAPPED_SUBNET = new Address6('::ffff:0:0/96');
1324
+ const NAT64_WELL_KNOWN_SUBNET = new Address6('64:ff9b::/96');
1217
1325
  //# sourceMappingURL=ipv6.js.map