@zuplo/cli 6.73.16 → 6.73.18

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 (178) hide show
  1. package/node_modules/@hono/node-server/README.md +58 -25
  2. package/node_modules/@hono/node-server/dist/conninfo.cjs +22 -0
  3. package/node_modules/@hono/node-server/dist/{conninfo.d.ts → conninfo.d.cts} +4 -3
  4. package/node_modules/@hono/node-server/dist/conninfo.d.mts +4 -3
  5. package/node_modules/@hono/node-server/dist/conninfo.mjs +19 -16
  6. package/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs +5 -0
  7. package/node_modules/@hono/node-server/dist/constants-BXAKTxRC.cjs +11 -0
  8. package/node_modules/@hono/node-server/dist/index.cjs +1173 -0
  9. package/node_modules/@hono/node-server/dist/index.d.cts +101 -0
  10. package/node_modules/@hono/node-server/dist/index.d.mts +101 -8
  11. package/node_modules/@hono/node-server/dist/index.mjs +1143 -637
  12. package/node_modules/@hono/node-server/dist/serve-static.cjs +151 -0
  13. package/node_modules/@hono/node-server/dist/serve-static.d.cts +18 -0
  14. package/node_modules/@hono/node-server/dist/serve-static.d.mts +14 -13
  15. package/node_modules/@hono/node-server/dist/serve-static.mjs +143 -145
  16. package/node_modules/@hono/node-server/dist/utils/response.cjs +8 -0
  17. package/node_modules/@hono/node-server/dist/utils/response.d.cts +4 -0
  18. package/node_modules/@hono/node-server/dist/utils/response.d.mts +3 -2
  19. package/node_modules/@hono/node-server/dist/utils/response.mjs +6 -9
  20. package/node_modules/@hono/node-server/dist/utils/stream.cjs +65 -0
  21. package/node_modules/@hono/node-server/dist/utils/stream.d.cts +6 -0
  22. package/node_modules/@hono/node-server/dist/utils/stream.d.mts +6 -0
  23. package/node_modules/@hono/node-server/dist/utils/stream.mjs +64 -0
  24. package/node_modules/@hono/node-server/package.json +65 -54
  25. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts.map +1 -1
  26. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js +1 -12
  27. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js.map +1 -1
  28. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts +7 -0
  29. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts.map +1 -1
  30. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js +9 -3
  31. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js.map +1 -1
  32. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts.map +1 -1
  33. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js +5 -3
  34. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js.map +1 -1
  35. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.d.ts.map +1 -1
  36. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js +1 -12
  37. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js.map +1 -1
  38. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts +5 -0
  39. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts.map +1 -0
  40. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js +17 -0
  41. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js.map +1 -0
  42. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts +9 -1
  43. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts.map +1 -1
  44. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js +10 -4
  45. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js.map +1 -1
  46. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts +21 -0
  47. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -1
  48. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js +239 -41
  49. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js.map +1 -1
  50. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.d.ts.map +1 -1
  51. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js +25 -6
  52. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js.map +1 -1
  53. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts +32 -0
  54. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts.map +1 -0
  55. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js +64 -0
  56. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js.map +1 -0
  57. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts +5 -0
  58. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts.map +1 -1
  59. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js +10 -1
  60. package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js.map +1 -1
  61. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.d.ts.map +1 -1
  62. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js +2 -13
  63. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js.map +1 -1
  64. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts +7 -0
  65. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts.map +1 -1
  66. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js +9 -3
  67. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js.map +1 -1
  68. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.d.ts.map +1 -1
  69. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +5 -3
  70. package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -1
  71. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.d.ts.map +1 -1
  72. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +2 -13
  73. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -1
  74. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts +5 -0
  75. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts.map +1 -0
  76. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
  77. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js.map +1 -0
  78. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts +9 -1
  79. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts.map +1 -1
  80. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js +10 -4
  81. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js.map +1 -1
  82. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts +21 -0
  83. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -1
  84. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +239 -41
  85. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js.map +1 -1
  86. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.d.ts.map +1 -1
  87. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +25 -6
  88. package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -1
  89. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts +32 -0
  90. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts.map +1 -0
  91. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
  92. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js.map +1 -0
  93. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts +5 -0
  94. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts.map +1 -1
  95. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js +9 -0
  96. package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js.map +1 -1
  97. package/node_modules/@modelcontextprotocol/sdk/package.json +4 -3
  98. package/node_modules/@zuplo/core/package.json +1 -1
  99. package/node_modules/@zuplo/graphql/package.json +1 -1
  100. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  101. package/node_modules/@zuplo/otel/out/esm/chunk-JYT2Q52R.js +26 -0
  102. package/node_modules/@zuplo/otel/out/esm/chunk-JYT2Q52R.js.map +1 -0
  103. package/node_modules/@zuplo/otel/out/esm/index.js +1 -1
  104. package/node_modules/@zuplo/otel/package.json +1 -1
  105. package/node_modules/@zuplo/runtime/out/esm/{chunk-OAVAM6CR.js → chunk-JPPAUB3E.js} +3 -3
  106. package/node_modules/@zuplo/runtime/out/esm/chunk-JPPAUB3E.js.map +1 -0
  107. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  108. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  109. package/node_modules/@zuplo/runtime/out/types/index.d.ts +10 -3
  110. package/node_modules/@zuplo/runtime/package.json +1 -1
  111. package/node_modules/express-rate-limit/dist/index.d.cts +10 -12
  112. package/node_modules/express-rate-limit/dist/index.d.mts +10 -12
  113. package/node_modules/express-rate-limit/dist/index.d.ts +10 -12
  114. package/node_modules/express-rate-limit/package.json +5 -5
  115. package/node_modules/express-rate-limit/readme.md +2 -2
  116. package/node_modules/ip-address/README.md +102 -96
  117. package/node_modules/ip-address/dist/common.d.ts +23 -0
  118. package/node_modules/ip-address/dist/common.js +27 -4
  119. package/node_modules/ip-address/dist/common.js.map +1 -1
  120. package/node_modules/ip-address/dist/ipv4.d.ts +8 -1
  121. package/node_modules/ip-address/dist/ipv4.js +21 -8
  122. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  123. package/node_modules/ip-address/dist/ipv6.d.ts +59 -1
  124. package/node_modules/ip-address/dist/ipv6.js +149 -41
  125. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  126. package/node_modules/ip-address/dist/v4/constants.js +5 -1
  127. package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
  128. package/node_modules/ip-address/dist/v6/constants.js +3 -2
  129. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  130. package/node_modules/ip-address/package.json +2 -2
  131. package/package.json +6 -6
  132. package/node_modules/@hono/node-server/dist/conninfo.js +0 -42
  133. package/node_modules/@hono/node-server/dist/globals.d.mts +0 -2
  134. package/node_modules/@hono/node-server/dist/globals.d.ts +0 -2
  135. package/node_modules/@hono/node-server/dist/globals.js +0 -29
  136. package/node_modules/@hono/node-server/dist/globals.mjs +0 -5
  137. package/node_modules/@hono/node-server/dist/index.d.ts +0 -8
  138. package/node_modules/@hono/node-server/dist/index.js +0 -702
  139. package/node_modules/@hono/node-server/dist/listener.d.mts +0 -13
  140. package/node_modules/@hono/node-server/dist/listener.d.ts +0 -13
  141. package/node_modules/@hono/node-server/dist/listener.js +0 -670
  142. package/node_modules/@hono/node-server/dist/listener.mjs +0 -635
  143. package/node_modules/@hono/node-server/dist/request.d.mts +0 -25
  144. package/node_modules/@hono/node-server/dist/request.d.ts +0 -25
  145. package/node_modules/@hono/node-server/dist/request.js +0 -238
  146. package/node_modules/@hono/node-server/dist/request.mjs +0 -206
  147. package/node_modules/@hono/node-server/dist/response.d.mts +0 -26
  148. package/node_modules/@hono/node-server/dist/response.d.ts +0 -26
  149. package/node_modules/@hono/node-server/dist/response.js +0 -112
  150. package/node_modules/@hono/node-server/dist/response.mjs +0 -85
  151. package/node_modules/@hono/node-server/dist/serve-static.d.ts +0 -17
  152. package/node_modules/@hono/node-server/dist/serve-static.js +0 -177
  153. package/node_modules/@hono/node-server/dist/server.d.mts +0 -10
  154. package/node_modules/@hono/node-server/dist/server.d.ts +0 -10
  155. package/node_modules/@hono/node-server/dist/server.js +0 -696
  156. package/node_modules/@hono/node-server/dist/server.mjs +0 -660
  157. package/node_modules/@hono/node-server/dist/types.d.mts +0 -44
  158. package/node_modules/@hono/node-server/dist/types.d.ts +0 -44
  159. package/node_modules/@hono/node-server/dist/types.js +0 -18
  160. package/node_modules/@hono/node-server/dist/types.mjs +0 -0
  161. package/node_modules/@hono/node-server/dist/utils/response/constants.d.mts +0 -3
  162. package/node_modules/@hono/node-server/dist/utils/response/constants.d.ts +0 -3
  163. package/node_modules/@hono/node-server/dist/utils/response/constants.js +0 -30
  164. package/node_modules/@hono/node-server/dist/utils/response/constants.mjs +0 -5
  165. package/node_modules/@hono/node-server/dist/utils/response.d.ts +0 -3
  166. package/node_modules/@hono/node-server/dist/utils/response.js +0 -37
  167. package/node_modules/@hono/node-server/dist/utils.d.mts +0 -9
  168. package/node_modules/@hono/node-server/dist/utils.d.ts +0 -9
  169. package/node_modules/@hono/node-server/dist/utils.js +0 -99
  170. package/node_modules/@hono/node-server/dist/utils.mjs +0 -71
  171. package/node_modules/@hono/node-server/dist/vercel.d.mts +0 -7
  172. package/node_modules/@hono/node-server/dist/vercel.d.ts +0 -7
  173. package/node_modules/@hono/node-server/dist/vercel.js +0 -677
  174. package/node_modules/@hono/node-server/dist/vercel.mjs +0 -640
  175. package/node_modules/@zuplo/otel/out/esm/chunk-JWNK52ES.js +0 -26
  176. package/node_modules/@zuplo/otel/out/esm/chunk-JWNK52ES.js.map +0 -1
  177. package/node_modules/@zuplo/runtime/out/esm/chunk-OAVAM6CR.js.map +0 -1
  178. /package/node_modules/@zuplo/runtime/out/esm/{chunk-OAVAM6CR.js.LEGAL.txt → chunk-JPPAUB3E.js.LEGAL.txt} +0 -0
@@ -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