@blamejs/pki 0.8.25 → 0.8.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/inspect.js CHANGED
@@ -164,16 +164,17 @@ var KU_LABEL = NAMES.KEY_USAGE;
164
164
  var EKU_LABEL = NAMES.EXT_KEY_USAGE;
165
165
  var GN_KIND = NAMES.GENERAL_NAME;
166
166
 
167
+ /** @internal A 4- or 16-octet buffer is ONE address, rendered by the shared home so that one address
168
+ * reads the same wherever a report carries it: the RFC 3779 blocks reach that home through
169
+ * `_ipAddressText`, and a GeneralName reaching it through a second renderer would print the same
170
+ * octets two ways in one report. An 8- or 32-octet buffer is a name constraint's address AND mask,
171
+ * which is not an address, so each half is rendered and the two are joined. The home is not widened
172
+ * to take those widths, because a mask reaching it as an address would render as one everywhere. */
167
173
  function _ipString(buf) {
168
174
  if (!Buffer.isBuffer(buf)) return "";
169
- if (buf.length === 4) return buf[0] + "." + buf[1] + "." + buf[2] + "." + buf[3];
175
+ if (buf.length === 4 || buf.length === 16) return ipUtils.textFromOctets(buf) || _hexColon(buf, {});
170
176
  if (buf.length === 8) return _ipString(buf.subarray(0, 4)) + "/" + _ipString(buf.subarray(4));
171
- if (buf.length === 16 || buf.length === 32) {
172
- var groups = [];
173
- for (var i = 0; i < 16; i += 2) groups.push((((buf[i] << 8) | buf[i + 1]) >>> 0).toString(16).toUpperCase());
174
- var s = groups.join(":");
175
- return buf.length === 32 ? s + "/" + _ipString(buf.subarray(16)) : s;
176
- }
177
+ if (buf.length === 32) return _ipString(buf.subarray(0, 16)) + "/" + _ipString(buf.subarray(16));
177
178
  return _hexColon(buf, {});
178
179
  }
179
180