@datadog/datadog-ci-plugin-terraform 5.23.0 → 5.24.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.
package/dist/bundle.js CHANGED
@@ -10914,7 +10914,7 @@ var require_glob = /* @__PURE__ */ __commonJSMin(((exports) => {
10914
10914
  var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10915
10915
  module.exports = {
10916
10916
  "name": "@datadog/datadog-ci-base",
10917
- "version": "5.23.0",
10917
+ "version": "5.24.0",
10918
10918
  "description": "Base package for Datadog CI",
10919
10919
  "license": "Apache-2.0",
10920
10920
  "keywords": ["datadog", "datadog-ci"],
@@ -11003,6 +11003,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11003
11003
  },
11004
11004
  "dependencies": {
11005
11005
  "@antfu/install-pkg": "^1.1.0",
11006
+ "@babel/parser": "^7.29.0",
11006
11007
  "@types/datadog-metrics": "^0.6.1",
11007
11008
  "async-retry": "^1.3.3",
11008
11009
  "chalk": "^3.0.0",
@@ -11016,7 +11017,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11016
11017
  "inquirer": "^8.2.7",
11017
11018
  "is-docker": "^4.0.0",
11018
11019
  "jest-diff": "^30.2.0",
11019
- "js-yaml": "^4.3.1",
11020
+ "js-yaml": "^4.3.2",
11020
11021
  "jszip": "^3.10.1",
11021
11022
  "proxy-agent": "^6.4.0",
11022
11023
  "semver": "^7.6.3",
@@ -11025,7 +11026,8 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11025
11026
  "tiny-async-pool": "^2.1.0",
11026
11027
  "typanion": "^3.14.0",
11027
11028
  "undici": "^7.29.0",
11028
- "upath": "^2.0.1"
11029
+ "upath": "^2.0.1",
11030
+ "webpack-sources": "^3.5.1"
11029
11031
  },
11030
11032
  "devDependencies": {
11031
11033
  "@types/async-retry": "^1.4.8",
@@ -11034,7 +11036,8 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11034
11036
  "@types/inquirer": "^8.2.6",
11035
11037
  "@types/js-yaml": "^4.0.9",
11036
11038
  "@types/semver": "^7.7.1",
11037
- "@types/tiny-async-pool": "^2.0.3"
11039
+ "@types/tiny-async-pool": "^2.0.3",
11040
+ "source-map": "^0.7.4"
11038
11041
  }
11039
11042
  };
11040
11043
  }));
@@ -16858,24 +16861,106 @@ var require_util$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
16858
16861
  exports.shuffleArray = shuffleArray;
16859
16862
  }));
16860
16863
  //#endregion
16864
+ //#region ../../node_modules/ip-address/dist/address-error.js
16865
+ var require_address_error = /* @__PURE__ */ __commonJSMin(((exports) => {
16866
+ Object.defineProperty(exports, "__esModule", { value: true });
16867
+ exports.AddressError = void 0;
16868
+ var AddressError = class extends Error {
16869
+ constructor(message, parseMessage) {
16870
+ super(message);
16871
+ this.name = "AddressError";
16872
+ this.parseMessage = parseMessage;
16873
+ }
16874
+ };
16875
+ exports.AddressError = AddressError;
16876
+ }));
16877
+ //#endregion
16861
16878
  //#region ../../node_modules/ip-address/dist/common.js
16862
16879
  var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
16863
16880
  Object.defineProperty(exports, "__esModule", { value: true });
16864
- exports.isCorrect = exports.isInSubnet = void 0;
16881
+ exports.isInSubnet = isInSubnet;
16882
+ exports.isHostInSubnet = isHostInSubnet;
16883
+ exports.isCorrect = isCorrect;
16884
+ exports.prefixLengthFromMask = prefixLengthFromMask;
16885
+ exports.assertByteArray = assertByteArray;
16886
+ exports.numberToPaddedHex = numberToPaddedHex;
16887
+ exports.stringToPaddedHex = stringToPaddedHex;
16888
+ exports.testBit = testBit;
16889
+ const address_error_1 = require_address_error();
16890
+ /**
16891
+ * Returns whether this address's *network* is contained within `address`,
16892
+ * i.e. whether every address this one can represent also falls inside
16893
+ * `address`. A network wider than `address` is not contained in it, so
16894
+ * `10.0.0.0/8` is not in `10.0.0.0/16`.
16895
+ *
16896
+ * To ask whether the address itself falls inside a range, ignoring any CIDR
16897
+ * suffix it was written with, use {@link isHostInSubnet} instead. That is the
16898
+ * question the special-use classifiers ask.
16899
+ */
16865
16900
  function isInSubnet(address) {
16866
16901
  if (this.subnetMask < address.subnetMask) return false;
16867
- if (this.mask(address.subnetMask) === address.mask()) return true;
16868
- return false;
16902
+ return isHostInSubnet.call(this, address);
16903
+ }
16904
+ /**
16905
+ * Returns whether this address's host bits fall inside `address`, ignoring
16906
+ * this address's own subnet mask.
16907
+ *
16908
+ * This is the primitive the special-use classifiers (`isLoopback`,
16909
+ * `isPrivate`, `isLinkLocal`, `getType`, …) are built on: they answer a
16910
+ * question about the address, so the answer must not change with the CIDR
16911
+ * suffix the caller happened to write. Use this rather than
16912
+ * {@link isInSubnet} when classifying a single address — notably when the
16913
+ * address came from untrusted input and the result backs a trust-boundary
16914
+ * decision such as an SSRF allow/deny filter.
16915
+ */
16916
+ function isHostInSubnet(address) {
16917
+ return this.mask(address.subnetMask) === address.mask();
16869
16918
  }
16870
- exports.isInSubnet = isInSubnet;
16871
16919
  function isCorrect(defaultBits) {
16872
- return function() {
16920
+ return function isCorrectForm() {
16873
16921
  if (this.addressMinusSuffix !== this.correctForm()) return false;
16874
16922
  if (this.subnetMask === defaultBits && !this.parsedSubnet) return true;
16875
16923
  return this.parsedSubnet === String(this.subnetMask);
16876
16924
  };
16877
16925
  }
16878
- exports.isCorrect = isCorrect;
16926
+ /**
16927
+ * Returns the prefix length (number of leading 1 bits) of a contiguous
16928
+ * subnet mask. Throws `AddressError` if the mask is non-contiguous (e.g.
16929
+ * `255.0.255.0`).
16930
+ */
16931
+ function prefixLengthFromMask(value, totalBits) {
16932
+ const binary = value.toString(2).padStart(totalBits, "0");
16933
+ if (binary.length > totalBits) throw new address_error_1.AddressError("Invalid subnet mask.");
16934
+ const firstZero = binary.indexOf("0");
16935
+ if (firstZero === -1) return totalBits;
16936
+ if (binary.slice(firstZero).includes("1")) throw new address_error_1.AddressError("Invalid subnet mask.");
16937
+ return firstZero;
16938
+ }
16939
+ /**
16940
+ * Throws `AddressError` unless `bytes` holds exactly `byteCount` integers,
16941
+ * each from `minimum` to 255. Pass a `minimum` of `-128` where signed bytes
16942
+ * are accepted and folded to unsigned, and `0` where they are not.
16943
+ */
16944
+ function assertByteArray(bytes, byteCount, family, minimum) {
16945
+ if (bytes.length !== byteCount) throw new address_error_1.AddressError(`${family} addresses require exactly ${byteCount} bytes`);
16946
+ for (let i = 0; i < bytes.length; i++) if (!Number.isInteger(bytes[i]) || bytes[i] < minimum || bytes[i] > 255) throw new address_error_1.AddressError(`All bytes must be integers between ${minimum} and 255`);
16947
+ }
16948
+ function numberToPaddedHex(number) {
16949
+ return number.toString(16).padStart(2, "0");
16950
+ }
16951
+ function stringToPaddedHex(numberString) {
16952
+ return numberToPaddedHex(parseInt(numberString, 10));
16953
+ }
16954
+ /**
16955
+ * @param binaryValue Binary representation of a value (e.g. `10`)
16956
+ * @param position Byte position, where 0 is the least significant bit
16957
+ */
16958
+ function testBit(binaryValue, position) {
16959
+ const { length } = binaryValue;
16960
+ if (position > length) return false;
16961
+ const positionInString = length - position;
16962
+ return binaryValue.substring(positionInString, positionInString + 1) === "1";
16963
+ }
16879
16964
  }));
16880
16965
  //#endregion
16881
16966
  //#region ../../node_modules/ip-address/dist/v4/constants.js
@@ -16884,1602 +16969,10 @@ var require_constants$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
16884
16969
  exports.RE_SUBNET_STRING = exports.RE_ADDRESS = exports.GROUPS = exports.BITS = void 0;
16885
16970
  exports.BITS = 32;
16886
16971
  exports.GROUPS = 4;
16887
- exports.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;
16972
+ exports.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/g;
16888
16973
  exports.RE_SUBNET_STRING = /\/\d{1,2}$/;
16889
16974
  }));
16890
16975
  //#endregion
16891
- //#region ../../node_modules/ip-address/dist/address-error.js
16892
- var require_address_error = /* @__PURE__ */ __commonJSMin(((exports) => {
16893
- Object.defineProperty(exports, "__esModule", { value: true });
16894
- exports.AddressError = void 0;
16895
- var AddressError = class extends Error {
16896
- constructor(message, parseMessage) {
16897
- super(message);
16898
- this.name = "AddressError";
16899
- if (parseMessage !== null) this.parseMessage = parseMessage;
16900
- }
16901
- };
16902
- exports.AddressError = AddressError;
16903
- }));
16904
- //#endregion
16905
- //#region ../../node_modules/ip-address/node_modules/jsbn/index.js
16906
- var require_jsbn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
16907
- (function() {
16908
- var dbits;
16909
- var j_lm = true;
16910
- function BigInteger(a, b, c) {
16911
- if (a != null) if ("number" == typeof a) this.fromNumber(a, b, c);
16912
- else if (b == null && "string" != typeof a) this.fromString(a, 256);
16913
- else this.fromString(a, b);
16914
- }
16915
- function nbi() {
16916
- return new BigInteger(null);
16917
- }
16918
- function am1(i, x, w, j, c, n) {
16919
- while (--n >= 0) {
16920
- var v = x * this[i++] + w[j] + c;
16921
- c = Math.floor(v / 67108864);
16922
- w[j++] = v & 67108863;
16923
- }
16924
- return c;
16925
- }
16926
- function am2(i, x, w, j, c, n) {
16927
- var xl = x & 32767, xh = x >> 15;
16928
- while (--n >= 0) {
16929
- var l = this[i] & 32767;
16930
- var h = this[i++] >> 15;
16931
- var m = xh * l + h * xl;
16932
- l = xl * l + ((m & 32767) << 15) + w[j] + (c & 1073741823);
16933
- c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
16934
- w[j++] = l & 1073741823;
16935
- }
16936
- return c;
16937
- }
16938
- function am3(i, x, w, j, c, n) {
16939
- var xl = x & 16383, xh = x >> 14;
16940
- while (--n >= 0) {
16941
- var l = this[i] & 16383;
16942
- var h = this[i++] >> 14;
16943
- var m = xh * l + h * xl;
16944
- l = xl * l + ((m & 16383) << 14) + w[j] + c;
16945
- c = (l >> 28) + (m >> 14) + xh * h;
16946
- w[j++] = l & 268435455;
16947
- }
16948
- return c;
16949
- }
16950
- var inBrowser = typeof navigator !== "undefined";
16951
- if (inBrowser && j_lm && navigator.appName == "Microsoft Internet Explorer") {
16952
- BigInteger.prototype.am = am2;
16953
- dbits = 30;
16954
- } else if (inBrowser && j_lm && navigator.appName != "Netscape") {
16955
- BigInteger.prototype.am = am1;
16956
- dbits = 26;
16957
- } else {
16958
- BigInteger.prototype.am = am3;
16959
- dbits = 28;
16960
- }
16961
- BigInteger.prototype.DB = dbits;
16962
- BigInteger.prototype.DM = (1 << dbits) - 1;
16963
- BigInteger.prototype.DV = 1 << dbits;
16964
- var BI_FP = 52;
16965
- BigInteger.prototype.FV = Math.pow(2, BI_FP);
16966
- BigInteger.prototype.F1 = BI_FP - dbits;
16967
- BigInteger.prototype.F2 = 2 * dbits - BI_FP;
16968
- var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
16969
- var BI_RC = new Array();
16970
- var rr = "0".charCodeAt(0), vv;
16971
- for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
16972
- rr = "a".charCodeAt(0);
16973
- for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
16974
- rr = "A".charCodeAt(0);
16975
- for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
16976
- function int2char(n) {
16977
- return BI_RM.charAt(n);
16978
- }
16979
- function intAt(s, i) {
16980
- var c = BI_RC[s.charCodeAt(i)];
16981
- return c == null ? -1 : c;
16982
- }
16983
- function bnpCopyTo(r) {
16984
- for (var i = this.t - 1; i >= 0; --i) r[i] = this[i];
16985
- r.t = this.t;
16986
- r.s = this.s;
16987
- }
16988
- function bnpFromInt(x) {
16989
- this.t = 1;
16990
- this.s = x < 0 ? -1 : 0;
16991
- if (x > 0) this[0] = x;
16992
- else if (x < -1) this[0] = x + this.DV;
16993
- else this.t = 0;
16994
- }
16995
- function nbv(i) {
16996
- var r = nbi();
16997
- r.fromInt(i);
16998
- return r;
16999
- }
17000
- function bnpFromString(s, b) {
17001
- var k;
17002
- if (b == 16) k = 4;
17003
- else if (b == 8) k = 3;
17004
- else if (b == 256) k = 8;
17005
- else if (b == 2) k = 1;
17006
- else if (b == 32) k = 5;
17007
- else if (b == 4) k = 2;
17008
- else {
17009
- this.fromRadix(s, b);
17010
- return;
17011
- }
17012
- this.t = 0;
17013
- this.s = 0;
17014
- var i = s.length, mi = false, sh = 0;
17015
- while (--i >= 0) {
17016
- var x = k == 8 ? s[i] & 255 : intAt(s, i);
17017
- if (x < 0) {
17018
- if (s.charAt(i) == "-") mi = true;
17019
- continue;
17020
- }
17021
- mi = false;
17022
- if (sh == 0) this[this.t++] = x;
17023
- else if (sh + k > this.DB) {
17024
- this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;
17025
- this[this.t++] = x >> this.DB - sh;
17026
- } else this[this.t - 1] |= x << sh;
17027
- sh += k;
17028
- if (sh >= this.DB) sh -= this.DB;
17029
- }
17030
- if (k == 8 && (s[0] & 128) != 0) {
17031
- this.s = -1;
17032
- if (sh > 0) this[this.t - 1] |= (1 << this.DB - sh) - 1 << sh;
17033
- }
17034
- this.clamp();
17035
- if (mi) BigInteger.ZERO.subTo(this, this);
17036
- }
17037
- function bnpClamp() {
17038
- var c = this.s & this.DM;
17039
- while (this.t > 0 && this[this.t - 1] == c) --this.t;
17040
- }
17041
- function bnToString(b) {
17042
- if (this.s < 0) return "-" + this.negate().toString(b);
17043
- var k;
17044
- if (b == 16) k = 4;
17045
- else if (b == 8) k = 3;
17046
- else if (b == 2) k = 1;
17047
- else if (b == 32) k = 5;
17048
- else if (b == 4) k = 2;
17049
- else return this.toRadix(b);
17050
- var km = (1 << k) - 1, d, m = false, r = "", i = this.t;
17051
- var p = this.DB - i * this.DB % k;
17052
- if (i-- > 0) {
17053
- if (p < this.DB && (d = this[i] >> p) > 0) {
17054
- m = true;
17055
- r = int2char(d);
17056
- }
17057
- while (i >= 0) {
17058
- if (p < k) {
17059
- d = (this[i] & (1 << p) - 1) << k - p;
17060
- d |= this[--i] >> (p += this.DB - k);
17061
- } else {
17062
- d = this[i] >> (p -= k) & km;
17063
- if (p <= 0) {
17064
- p += this.DB;
17065
- --i;
17066
- }
17067
- }
17068
- if (d > 0) m = true;
17069
- if (m) r += int2char(d);
17070
- }
17071
- }
17072
- return m ? r : "0";
17073
- }
17074
- function bnNegate() {
17075
- var r = nbi();
17076
- BigInteger.ZERO.subTo(this, r);
17077
- return r;
17078
- }
17079
- function bnAbs() {
17080
- return this.s < 0 ? this.negate() : this;
17081
- }
17082
- function bnCompareTo(a) {
17083
- var r = this.s - a.s;
17084
- if (r != 0) return r;
17085
- var i = this.t;
17086
- r = i - a.t;
17087
- if (r != 0) return this.s < 0 ? -r : r;
17088
- while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
17089
- return 0;
17090
- }
17091
- function nbits(x) {
17092
- var r = 1, t;
17093
- if ((t = x >>> 16) != 0) {
17094
- x = t;
17095
- r += 16;
17096
- }
17097
- if ((t = x >> 8) != 0) {
17098
- x = t;
17099
- r += 8;
17100
- }
17101
- if ((t = x >> 4) != 0) {
17102
- x = t;
17103
- r += 4;
17104
- }
17105
- if ((t = x >> 2) != 0) {
17106
- x = t;
17107
- r += 2;
17108
- }
17109
- if ((t = x >> 1) != 0) {
17110
- x = t;
17111
- r += 1;
17112
- }
17113
- return r;
17114
- }
17115
- function bnBitLength() {
17116
- if (this.t <= 0) return 0;
17117
- return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);
17118
- }
17119
- function bnpDLShiftTo(n, r) {
17120
- var i;
17121
- for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i];
17122
- for (i = n - 1; i >= 0; --i) r[i] = 0;
17123
- r.t = this.t + n;
17124
- r.s = this.s;
17125
- }
17126
- function bnpDRShiftTo(n, r) {
17127
- for (var i = n; i < this.t; ++i) r[i - n] = this[i];
17128
- r.t = Math.max(this.t - n, 0);
17129
- r.s = this.s;
17130
- }
17131
- function bnpLShiftTo(n, r) {
17132
- var bs = n % this.DB;
17133
- var cbs = this.DB - bs;
17134
- var bm = (1 << cbs) - 1;
17135
- var ds = Math.floor(n / this.DB), c = this.s << bs & this.DM, i;
17136
- for (i = this.t - 1; i >= 0; --i) {
17137
- r[i + ds + 1] = this[i] >> cbs | c;
17138
- c = (this[i] & bm) << bs;
17139
- }
17140
- for (i = ds - 1; i >= 0; --i) r[i] = 0;
17141
- r[ds] = c;
17142
- r.t = this.t + ds + 1;
17143
- r.s = this.s;
17144
- r.clamp();
17145
- }
17146
- function bnpRShiftTo(n, r) {
17147
- r.s = this.s;
17148
- var ds = Math.floor(n / this.DB);
17149
- if (ds >= this.t) {
17150
- r.t = 0;
17151
- return;
17152
- }
17153
- var bs = n % this.DB;
17154
- var cbs = this.DB - bs;
17155
- var bm = (1 << bs) - 1;
17156
- r[0] = this[ds] >> bs;
17157
- for (var i = ds + 1; i < this.t; ++i) {
17158
- r[i - ds - 1] |= (this[i] & bm) << cbs;
17159
- r[i - ds] = this[i] >> bs;
17160
- }
17161
- if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
17162
- r.t = this.t - ds;
17163
- r.clamp();
17164
- }
17165
- function bnpSubTo(a, r) {
17166
- var i = 0, c = 0, m = Math.min(a.t, this.t);
17167
- while (i < m) {
17168
- c += this[i] - a[i];
17169
- r[i++] = c & this.DM;
17170
- c >>= this.DB;
17171
- }
17172
- if (a.t < this.t) {
17173
- c -= a.s;
17174
- while (i < this.t) {
17175
- c += this[i];
17176
- r[i++] = c & this.DM;
17177
- c >>= this.DB;
17178
- }
17179
- c += this.s;
17180
- } else {
17181
- c += this.s;
17182
- while (i < a.t) {
17183
- c -= a[i];
17184
- r[i++] = c & this.DM;
17185
- c >>= this.DB;
17186
- }
17187
- c -= a.s;
17188
- }
17189
- r.s = c < 0 ? -1 : 0;
17190
- if (c < -1) r[i++] = this.DV + c;
17191
- else if (c > 0) r[i++] = c;
17192
- r.t = i;
17193
- r.clamp();
17194
- }
17195
- function bnpMultiplyTo(a, r) {
17196
- var x = this.abs(), y = a.abs();
17197
- var i = x.t;
17198
- r.t = i + y.t;
17199
- while (--i >= 0) r[i] = 0;
17200
- for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
17201
- r.s = 0;
17202
- r.clamp();
17203
- if (this.s != a.s) BigInteger.ZERO.subTo(r, r);
17204
- }
17205
- function bnpSquareTo(r) {
17206
- var x = this.abs();
17207
- var i = r.t = 2 * x.t;
17208
- while (--i >= 0) r[i] = 0;
17209
- for (i = 0; i < x.t - 1; ++i) {
17210
- var c = x.am(i, x[i], r, 2 * i, 0, 1);
17211
- if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
17212
- r[i + x.t] -= x.DV;
17213
- r[i + x.t + 1] = 1;
17214
- }
17215
- }
17216
- if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
17217
- r.s = 0;
17218
- r.clamp();
17219
- }
17220
- function bnpDivRemTo(m, q, r) {
17221
- var pm = m.abs();
17222
- if (pm.t <= 0) return;
17223
- var pt = this.abs();
17224
- if (pt.t < pm.t) {
17225
- if (q != null) q.fromInt(0);
17226
- if (r != null) this.copyTo(r);
17227
- return;
17228
- }
17229
- if (r == null) r = nbi();
17230
- var y = nbi(), ts = this.s, ms = m.s;
17231
- var nsh = this.DB - nbits(pm[pm.t - 1]);
17232
- if (nsh > 0) {
17233
- pm.lShiftTo(nsh, y);
17234
- pt.lShiftTo(nsh, r);
17235
- } else {
17236
- pm.copyTo(y);
17237
- pt.copyTo(r);
17238
- }
17239
- var ys = y.t;
17240
- var y0 = y[ys - 1];
17241
- if (y0 == 0) return;
17242
- var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);
17243
- var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
17244
- var i = r.t, j = i - ys, t = q == null ? nbi() : q;
17245
- y.dlShiftTo(j, t);
17246
- if (r.compareTo(t) >= 0) {
17247
- r[r.t++] = 1;
17248
- r.subTo(t, r);
17249
- }
17250
- BigInteger.ONE.dlShiftTo(ys, t);
17251
- t.subTo(y, y);
17252
- while (y.t < ys) y[y.t++] = 0;
17253
- while (--j >= 0) {
17254
- var qd = r[--i] == y0 ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
17255
- if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {
17256
- y.dlShiftTo(j, t);
17257
- r.subTo(t, r);
17258
- while (r[i] < --qd) r.subTo(t, r);
17259
- }
17260
- }
17261
- if (q != null) {
17262
- r.drShiftTo(ys, q);
17263
- if (ts != ms) BigInteger.ZERO.subTo(q, q);
17264
- }
17265
- r.t = ys;
17266
- r.clamp();
17267
- if (nsh > 0) r.rShiftTo(nsh, r);
17268
- if (ts < 0) BigInteger.ZERO.subTo(r, r);
17269
- }
17270
- function bnMod(a) {
17271
- var r = nbi();
17272
- this.abs().divRemTo(a, null, r);
17273
- if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
17274
- return r;
17275
- }
17276
- function Classic(m) {
17277
- this.m = m;
17278
- }
17279
- function cConvert(x) {
17280
- if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
17281
- else return x;
17282
- }
17283
- function cRevert(x) {
17284
- return x;
17285
- }
17286
- function cReduce(x) {
17287
- x.divRemTo(this.m, null, x);
17288
- }
17289
- function cMulTo(x, y, r) {
17290
- x.multiplyTo(y, r);
17291
- this.reduce(r);
17292
- }
17293
- function cSqrTo(x, r) {
17294
- x.squareTo(r);
17295
- this.reduce(r);
17296
- }
17297
- Classic.prototype.convert = cConvert;
17298
- Classic.prototype.revert = cRevert;
17299
- Classic.prototype.reduce = cReduce;
17300
- Classic.prototype.mulTo = cMulTo;
17301
- Classic.prototype.sqrTo = cSqrTo;
17302
- function bnpInvDigit() {
17303
- if (this.t < 1) return 0;
17304
- var x = this[0];
17305
- if ((x & 1) == 0) return 0;
17306
- var y = x & 3;
17307
- y = y * (2 - (x & 15) * y) & 15;
17308
- y = y * (2 - (x & 255) * y) & 255;
17309
- y = y * (2 - ((x & 65535) * y & 65535)) & 65535;
17310
- y = y * (2 - x * y % this.DV) % this.DV;
17311
- return y > 0 ? this.DV - y : -y;
17312
- }
17313
- function Montgomery(m) {
17314
- this.m = m;
17315
- this.mp = m.invDigit();
17316
- this.mpl = this.mp & 32767;
17317
- this.mph = this.mp >> 15;
17318
- this.um = (1 << m.DB - 15) - 1;
17319
- this.mt2 = 2 * m.t;
17320
- }
17321
- function montConvert(x) {
17322
- var r = nbi();
17323
- x.abs().dlShiftTo(this.m.t, r);
17324
- r.divRemTo(this.m, null, r);
17325
- if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
17326
- return r;
17327
- }
17328
- function montRevert(x) {
17329
- var r = nbi();
17330
- x.copyTo(r);
17331
- this.reduce(r);
17332
- return r;
17333
- }
17334
- function montReduce(x) {
17335
- while (x.t <= this.mt2) x[x.t++] = 0;
17336
- for (var i = 0; i < this.m.t; ++i) {
17337
- var j = x[i] & 32767;
17338
- var u0 = j * this.mpl + ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) & x.DM;
17339
- j = i + this.m.t;
17340
- x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
17341
- while (x[j] >= x.DV) {
17342
- x[j] -= x.DV;
17343
- x[++j]++;
17344
- }
17345
- }
17346
- x.clamp();
17347
- x.drShiftTo(this.m.t, x);
17348
- if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
17349
- }
17350
- function montSqrTo(x, r) {
17351
- x.squareTo(r);
17352
- this.reduce(r);
17353
- }
17354
- function montMulTo(x, y, r) {
17355
- x.multiplyTo(y, r);
17356
- this.reduce(r);
17357
- }
17358
- Montgomery.prototype.convert = montConvert;
17359
- Montgomery.prototype.revert = montRevert;
17360
- Montgomery.prototype.reduce = montReduce;
17361
- Montgomery.prototype.mulTo = montMulTo;
17362
- Montgomery.prototype.sqrTo = montSqrTo;
17363
- function bnpIsEven() {
17364
- return (this.t > 0 ? this[0] & 1 : this.s) == 0;
17365
- }
17366
- function bnpExp(e, z) {
17367
- if (e > 4294967295 || e < 1) return BigInteger.ONE;
17368
- var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e) - 1;
17369
- g.copyTo(r);
17370
- while (--i >= 0) {
17371
- z.sqrTo(r, r2);
17372
- if ((e & 1 << i) > 0) z.mulTo(r2, g, r);
17373
- else {
17374
- var t = r;
17375
- r = r2;
17376
- r2 = t;
17377
- }
17378
- }
17379
- return z.revert(r);
17380
- }
17381
- function bnModPowInt(e, m) {
17382
- var z;
17383
- if (e < 256 || m.isEven()) z = new Classic(m);
17384
- else z = new Montgomery(m);
17385
- return this.exp(e, z);
17386
- }
17387
- BigInteger.prototype.copyTo = bnpCopyTo;
17388
- BigInteger.prototype.fromInt = bnpFromInt;
17389
- BigInteger.prototype.fromString = bnpFromString;
17390
- BigInteger.prototype.clamp = bnpClamp;
17391
- BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
17392
- BigInteger.prototype.drShiftTo = bnpDRShiftTo;
17393
- BigInteger.prototype.lShiftTo = bnpLShiftTo;
17394
- BigInteger.prototype.rShiftTo = bnpRShiftTo;
17395
- BigInteger.prototype.subTo = bnpSubTo;
17396
- BigInteger.prototype.multiplyTo = bnpMultiplyTo;
17397
- BigInteger.prototype.squareTo = bnpSquareTo;
17398
- BigInteger.prototype.divRemTo = bnpDivRemTo;
17399
- BigInteger.prototype.invDigit = bnpInvDigit;
17400
- BigInteger.prototype.isEven = bnpIsEven;
17401
- BigInteger.prototype.exp = bnpExp;
17402
- BigInteger.prototype.toString = bnToString;
17403
- BigInteger.prototype.negate = bnNegate;
17404
- BigInteger.prototype.abs = bnAbs;
17405
- BigInteger.prototype.compareTo = bnCompareTo;
17406
- BigInteger.prototype.bitLength = bnBitLength;
17407
- BigInteger.prototype.mod = bnMod;
17408
- BigInteger.prototype.modPowInt = bnModPowInt;
17409
- BigInteger.ZERO = nbv(0);
17410
- BigInteger.ONE = nbv(1);
17411
- function bnClone() {
17412
- var r = nbi();
17413
- this.copyTo(r);
17414
- return r;
17415
- }
17416
- function bnIntValue() {
17417
- if (this.s < 0) {
17418
- if (this.t == 1) return this[0] - this.DV;
17419
- else if (this.t == 0) return -1;
17420
- } else if (this.t == 1) return this[0];
17421
- else if (this.t == 0) return 0;
17422
- return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0];
17423
- }
17424
- function bnByteValue() {
17425
- return this.t == 0 ? this.s : this[0] << 24 >> 24;
17426
- }
17427
- function bnShortValue() {
17428
- return this.t == 0 ? this.s : this[0] << 16 >> 16;
17429
- }
17430
- function bnpChunkSize(r) {
17431
- return Math.floor(Math.LN2 * this.DB / Math.log(r));
17432
- }
17433
- function bnSigNum() {
17434
- if (this.s < 0) return -1;
17435
- else if (this.t <= 0 || this.t == 1 && this[0] <= 0) return 0;
17436
- else return 1;
17437
- }
17438
- function bnpToRadix(b) {
17439
- if (b == null) b = 10;
17440
- if (this.signum() == 0 || b < 2 || b > 36) return "0";
17441
- var cs = this.chunkSize(b);
17442
- var a = Math.pow(b, cs);
17443
- var d = nbv(a), y = nbi(), z = nbi(), r = "";
17444
- this.divRemTo(d, y, z);
17445
- while (y.signum() > 0) {
17446
- r = (a + z.intValue()).toString(b).substr(1) + r;
17447
- y.divRemTo(d, y, z);
17448
- }
17449
- return z.intValue().toString(b) + r;
17450
- }
17451
- function bnpFromRadix(s, b) {
17452
- this.fromInt(0);
17453
- if (b == null) b = 10;
17454
- var cs = this.chunkSize(b);
17455
- var d = Math.pow(b, cs), mi = false, j = 0, w = 0;
17456
- for (var i = 0; i < s.length; ++i) {
17457
- var x = intAt(s, i);
17458
- if (x < 0) {
17459
- if (s.charAt(i) == "-" && this.signum() == 0) mi = true;
17460
- continue;
17461
- }
17462
- w = b * w + x;
17463
- if (++j >= cs) {
17464
- this.dMultiply(d);
17465
- this.dAddOffset(w, 0);
17466
- j = 0;
17467
- w = 0;
17468
- }
17469
- }
17470
- if (j > 0) {
17471
- this.dMultiply(Math.pow(b, j));
17472
- this.dAddOffset(w, 0);
17473
- }
17474
- if (mi) BigInteger.ZERO.subTo(this, this);
17475
- }
17476
- function bnpFromNumber(a, b, c) {
17477
- if ("number" == typeof b) if (a < 2) this.fromInt(1);
17478
- else {
17479
- this.fromNumber(a, c);
17480
- if (!this.testBit(a - 1)) this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
17481
- if (this.isEven()) this.dAddOffset(1, 0);
17482
- while (!this.isProbablePrime(b)) {
17483
- this.dAddOffset(2, 0);
17484
- if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
17485
- }
17486
- }
17487
- else {
17488
- var x = new Array(), t = a & 7;
17489
- x.length = (a >> 3) + 1;
17490
- b.nextBytes(x);
17491
- if (t > 0) x[0] &= (1 << t) - 1;
17492
- else x[0] = 0;
17493
- this.fromString(x, 256);
17494
- }
17495
- }
17496
- function bnToByteArray() {
17497
- var i = this.t, r = new Array();
17498
- r[0] = this.s;
17499
- var p = this.DB - i * this.DB % 8, d, k = 0;
17500
- if (i-- > 0) {
17501
- if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) r[k++] = d | this.s << this.DB - p;
17502
- while (i >= 0) {
17503
- if (p < 8) {
17504
- d = (this[i] & (1 << p) - 1) << 8 - p;
17505
- d |= this[--i] >> (p += this.DB - 8);
17506
- } else {
17507
- d = this[i] >> (p -= 8) & 255;
17508
- if (p <= 0) {
17509
- p += this.DB;
17510
- --i;
17511
- }
17512
- }
17513
- if ((d & 128) != 0) d |= -256;
17514
- if (k == 0 && (this.s & 128) != (d & 128)) ++k;
17515
- if (k > 0 || d != this.s) r[k++] = d;
17516
- }
17517
- }
17518
- return r;
17519
- }
17520
- function bnEquals(a) {
17521
- return this.compareTo(a) == 0;
17522
- }
17523
- function bnMin(a) {
17524
- return this.compareTo(a) < 0 ? this : a;
17525
- }
17526
- function bnMax(a) {
17527
- return this.compareTo(a) > 0 ? this : a;
17528
- }
17529
- function bnpBitwiseTo(a, op, r) {
17530
- var i, f, m = Math.min(a.t, this.t);
17531
- for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]);
17532
- if (a.t < this.t) {
17533
- f = a.s & this.DM;
17534
- for (i = m; i < this.t; ++i) r[i] = op(this[i], f);
17535
- r.t = this.t;
17536
- } else {
17537
- f = this.s & this.DM;
17538
- for (i = m; i < a.t; ++i) r[i] = op(f, a[i]);
17539
- r.t = a.t;
17540
- }
17541
- r.s = op(this.s, a.s);
17542
- r.clamp();
17543
- }
17544
- function op_and(x, y) {
17545
- return x & y;
17546
- }
17547
- function bnAnd(a) {
17548
- var r = nbi();
17549
- this.bitwiseTo(a, op_and, r);
17550
- return r;
17551
- }
17552
- function op_or(x, y) {
17553
- return x | y;
17554
- }
17555
- function bnOr(a) {
17556
- var r = nbi();
17557
- this.bitwiseTo(a, op_or, r);
17558
- return r;
17559
- }
17560
- function op_xor(x, y) {
17561
- return x ^ y;
17562
- }
17563
- function bnXor(a) {
17564
- var r = nbi();
17565
- this.bitwiseTo(a, op_xor, r);
17566
- return r;
17567
- }
17568
- function op_andnot(x, y) {
17569
- return x & ~y;
17570
- }
17571
- function bnAndNot(a) {
17572
- var r = nbi();
17573
- this.bitwiseTo(a, op_andnot, r);
17574
- return r;
17575
- }
17576
- function bnNot() {
17577
- var r = nbi();
17578
- for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i];
17579
- r.t = this.t;
17580
- r.s = ~this.s;
17581
- return r;
17582
- }
17583
- function bnShiftLeft(n) {
17584
- var r = nbi();
17585
- if (n < 0) this.rShiftTo(-n, r);
17586
- else this.lShiftTo(n, r);
17587
- return r;
17588
- }
17589
- function bnShiftRight(n) {
17590
- var r = nbi();
17591
- if (n < 0) this.lShiftTo(-n, r);
17592
- else this.rShiftTo(n, r);
17593
- return r;
17594
- }
17595
- function lbit(x) {
17596
- if (x == 0) return -1;
17597
- var r = 0;
17598
- if ((x & 65535) == 0) {
17599
- x >>= 16;
17600
- r += 16;
17601
- }
17602
- if ((x & 255) == 0) {
17603
- x >>= 8;
17604
- r += 8;
17605
- }
17606
- if ((x & 15) == 0) {
17607
- x >>= 4;
17608
- r += 4;
17609
- }
17610
- if ((x & 3) == 0) {
17611
- x >>= 2;
17612
- r += 2;
17613
- }
17614
- if ((x & 1) == 0) ++r;
17615
- return r;
17616
- }
17617
- function bnGetLowestSetBit() {
17618
- for (var i = 0; i < this.t; ++i) if (this[i] != 0) return i * this.DB + lbit(this[i]);
17619
- if (this.s < 0) return this.t * this.DB;
17620
- return -1;
17621
- }
17622
- function cbit(x) {
17623
- var r = 0;
17624
- while (x != 0) {
17625
- x &= x - 1;
17626
- ++r;
17627
- }
17628
- return r;
17629
- }
17630
- function bnBitCount() {
17631
- var r = 0, x = this.s & this.DM;
17632
- for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x);
17633
- return r;
17634
- }
17635
- function bnTestBit(n) {
17636
- var j = Math.floor(n / this.DB);
17637
- if (j >= this.t) return this.s != 0;
17638
- return (this[j] & 1 << n % this.DB) != 0;
17639
- }
17640
- function bnpChangeBit(n, op) {
17641
- var r = BigInteger.ONE.shiftLeft(n);
17642
- this.bitwiseTo(r, op, r);
17643
- return r;
17644
- }
17645
- function bnSetBit(n) {
17646
- return this.changeBit(n, op_or);
17647
- }
17648
- function bnClearBit(n) {
17649
- return this.changeBit(n, op_andnot);
17650
- }
17651
- function bnFlipBit(n) {
17652
- return this.changeBit(n, op_xor);
17653
- }
17654
- function bnpAddTo(a, r) {
17655
- var i = 0, c = 0, m = Math.min(a.t, this.t);
17656
- while (i < m) {
17657
- c += this[i] + a[i];
17658
- r[i++] = c & this.DM;
17659
- c >>= this.DB;
17660
- }
17661
- if (a.t < this.t) {
17662
- c += a.s;
17663
- while (i < this.t) {
17664
- c += this[i];
17665
- r[i++] = c & this.DM;
17666
- c >>= this.DB;
17667
- }
17668
- c += this.s;
17669
- } else {
17670
- c += this.s;
17671
- while (i < a.t) {
17672
- c += a[i];
17673
- r[i++] = c & this.DM;
17674
- c >>= this.DB;
17675
- }
17676
- c += a.s;
17677
- }
17678
- r.s = c < 0 ? -1 : 0;
17679
- if (c > 0) r[i++] = c;
17680
- else if (c < -1) r[i++] = this.DV + c;
17681
- r.t = i;
17682
- r.clamp();
17683
- }
17684
- function bnAdd(a) {
17685
- var r = nbi();
17686
- this.addTo(a, r);
17687
- return r;
17688
- }
17689
- function bnSubtract(a) {
17690
- var r = nbi();
17691
- this.subTo(a, r);
17692
- return r;
17693
- }
17694
- function bnMultiply(a) {
17695
- var r = nbi();
17696
- this.multiplyTo(a, r);
17697
- return r;
17698
- }
17699
- function bnSquare() {
17700
- var r = nbi();
17701
- this.squareTo(r);
17702
- return r;
17703
- }
17704
- function bnDivide(a) {
17705
- var r = nbi();
17706
- this.divRemTo(a, r, null);
17707
- return r;
17708
- }
17709
- function bnRemainder(a) {
17710
- var r = nbi();
17711
- this.divRemTo(a, null, r);
17712
- return r;
17713
- }
17714
- function bnDivideAndRemainder(a) {
17715
- var q = nbi(), r = nbi();
17716
- this.divRemTo(a, q, r);
17717
- return new Array(q, r);
17718
- }
17719
- function bnpDMultiply(n) {
17720
- this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
17721
- ++this.t;
17722
- this.clamp();
17723
- }
17724
- function bnpDAddOffset(n, w) {
17725
- if (n == 0) return;
17726
- while (this.t <= w) this[this.t++] = 0;
17727
- this[w] += n;
17728
- while (this[w] >= this.DV) {
17729
- this[w] -= this.DV;
17730
- if (++w >= this.t) this[this.t++] = 0;
17731
- ++this[w];
17732
- }
17733
- }
17734
- function NullExp() {}
17735
- function nNop(x) {
17736
- return x;
17737
- }
17738
- function nMulTo(x, y, r) {
17739
- x.multiplyTo(y, r);
17740
- }
17741
- function nSqrTo(x, r) {
17742
- x.squareTo(r);
17743
- }
17744
- NullExp.prototype.convert = nNop;
17745
- NullExp.prototype.revert = nNop;
17746
- NullExp.prototype.mulTo = nMulTo;
17747
- NullExp.prototype.sqrTo = nSqrTo;
17748
- function bnPow(e) {
17749
- return this.exp(e, new NullExp());
17750
- }
17751
- function bnpMultiplyLowerTo(a, n, r) {
17752
- var i = Math.min(this.t + a.t, n);
17753
- r.s = 0;
17754
- r.t = i;
17755
- while (i > 0) r[--i] = 0;
17756
- var j;
17757
- for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
17758
- for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i);
17759
- r.clamp();
17760
- }
17761
- function bnpMultiplyUpperTo(a, n, r) {
17762
- --n;
17763
- var i = r.t = this.t + a.t - n;
17764
- r.s = 0;
17765
- while (--i >= 0) r[i] = 0;
17766
- for (i = Math.max(n - this.t, 0); i < a.t; ++i) r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
17767
- r.clamp();
17768
- r.drShiftTo(1, r);
17769
- }
17770
- function Barrett(m) {
17771
- this.r2 = nbi();
17772
- this.q3 = nbi();
17773
- BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
17774
- this.mu = this.r2.divide(m);
17775
- this.m = m;
17776
- }
17777
- function barrettConvert(x) {
17778
- if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m);
17779
- else if (x.compareTo(this.m) < 0) return x;
17780
- else {
17781
- var r = nbi();
17782
- x.copyTo(r);
17783
- this.reduce(r);
17784
- return r;
17785
- }
17786
- }
17787
- function barrettRevert(x) {
17788
- return x;
17789
- }
17790
- function barrettReduce(x) {
17791
- x.drShiftTo(this.m.t - 1, this.r2);
17792
- if (x.t > this.m.t + 1) {
17793
- x.t = this.m.t + 1;
17794
- x.clamp();
17795
- }
17796
- this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
17797
- this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
17798
- while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1);
17799
- x.subTo(this.r2, x);
17800
- while (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
17801
- }
17802
- function barrettSqrTo(x, r) {
17803
- x.squareTo(r);
17804
- this.reduce(r);
17805
- }
17806
- function barrettMulTo(x, y, r) {
17807
- x.multiplyTo(y, r);
17808
- this.reduce(r);
17809
- }
17810
- Barrett.prototype.convert = barrettConvert;
17811
- Barrett.prototype.revert = barrettRevert;
17812
- Barrett.prototype.reduce = barrettReduce;
17813
- Barrett.prototype.mulTo = barrettMulTo;
17814
- Barrett.prototype.sqrTo = barrettSqrTo;
17815
- function bnModPow(e, m) {
17816
- var i = e.bitLength(), k, r = nbv(1), z;
17817
- if (i <= 0) return r;
17818
- else if (i < 18) k = 1;
17819
- else if (i < 48) k = 3;
17820
- else if (i < 144) k = 4;
17821
- else if (i < 768) k = 5;
17822
- else k = 6;
17823
- if (i < 8) z = new Classic(m);
17824
- else if (m.isEven()) z = new Barrett(m);
17825
- else z = new Montgomery(m);
17826
- var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;
17827
- g[1] = z.convert(this);
17828
- if (k > 1) {
17829
- var g2 = nbi();
17830
- z.sqrTo(g[1], g2);
17831
- while (n <= km) {
17832
- g[n] = nbi();
17833
- z.mulTo(g2, g[n - 2], g[n]);
17834
- n += 2;
17835
- }
17836
- }
17837
- var j = e.t - 1, w, is1 = true, r2 = nbi(), t;
17838
- i = nbits(e[j]) - 1;
17839
- while (j >= 0) {
17840
- if (i >= k1) w = e[j] >> i - k1 & km;
17841
- else {
17842
- w = (e[j] & (1 << i + 1) - 1) << k1 - i;
17843
- if (j > 0) w |= e[j - 1] >> this.DB + i - k1;
17844
- }
17845
- n = k;
17846
- while ((w & 1) == 0) {
17847
- w >>= 1;
17848
- --n;
17849
- }
17850
- if ((i -= n) < 0) {
17851
- i += this.DB;
17852
- --j;
17853
- }
17854
- if (is1) {
17855
- g[w].copyTo(r);
17856
- is1 = false;
17857
- } else {
17858
- while (n > 1) {
17859
- z.sqrTo(r, r2);
17860
- z.sqrTo(r2, r);
17861
- n -= 2;
17862
- }
17863
- if (n > 0) z.sqrTo(r, r2);
17864
- else {
17865
- t = r;
17866
- r = r2;
17867
- r2 = t;
17868
- }
17869
- z.mulTo(r2, g[w], r);
17870
- }
17871
- while (j >= 0 && (e[j] & 1 << i) == 0) {
17872
- z.sqrTo(r, r2);
17873
- t = r;
17874
- r = r2;
17875
- r2 = t;
17876
- if (--i < 0) {
17877
- i = this.DB - 1;
17878
- --j;
17879
- }
17880
- }
17881
- }
17882
- return z.revert(r);
17883
- }
17884
- function bnGCD(a) {
17885
- var x = this.s < 0 ? this.negate() : this.clone();
17886
- var y = a.s < 0 ? a.negate() : a.clone();
17887
- if (x.compareTo(y) < 0) {
17888
- var t = x;
17889
- x = y;
17890
- y = t;
17891
- }
17892
- var i = x.getLowestSetBit(), g = y.getLowestSetBit();
17893
- if (g < 0) return x;
17894
- if (i < g) g = i;
17895
- if (g > 0) {
17896
- x.rShiftTo(g, x);
17897
- y.rShiftTo(g, y);
17898
- }
17899
- while (x.signum() > 0) {
17900
- if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x);
17901
- if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y);
17902
- if (x.compareTo(y) >= 0) {
17903
- x.subTo(y, x);
17904
- x.rShiftTo(1, x);
17905
- } else {
17906
- y.subTo(x, y);
17907
- y.rShiftTo(1, y);
17908
- }
17909
- }
17910
- if (g > 0) y.lShiftTo(g, y);
17911
- return y;
17912
- }
17913
- function bnpModInt(n) {
17914
- if (n <= 0) return 0;
17915
- var d = this.DV % n, r = this.s < 0 ? n - 1 : 0;
17916
- if (this.t > 0) if (d == 0) r = this[0] % n;
17917
- else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n;
17918
- return r;
17919
- }
17920
- function bnModInverse(m) {
17921
- var ac = m.isEven();
17922
- if (this.isEven() && ac || m.signum() == 0) return BigInteger.ZERO;
17923
- var u = m.clone(), v = this.clone();
17924
- var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
17925
- while (u.signum() != 0) {
17926
- while (u.isEven()) {
17927
- u.rShiftTo(1, u);
17928
- if (ac) {
17929
- if (!a.isEven() || !b.isEven()) {
17930
- a.addTo(this, a);
17931
- b.subTo(m, b);
17932
- }
17933
- a.rShiftTo(1, a);
17934
- } else if (!b.isEven()) b.subTo(m, b);
17935
- b.rShiftTo(1, b);
17936
- }
17937
- while (v.isEven()) {
17938
- v.rShiftTo(1, v);
17939
- if (ac) {
17940
- if (!c.isEven() || !d.isEven()) {
17941
- c.addTo(this, c);
17942
- d.subTo(m, d);
17943
- }
17944
- c.rShiftTo(1, c);
17945
- } else if (!d.isEven()) d.subTo(m, d);
17946
- d.rShiftTo(1, d);
17947
- }
17948
- if (u.compareTo(v) >= 0) {
17949
- u.subTo(v, u);
17950
- if (ac) a.subTo(c, a);
17951
- b.subTo(d, b);
17952
- } else {
17953
- v.subTo(u, v);
17954
- if (ac) c.subTo(a, c);
17955
- d.subTo(b, d);
17956
- }
17957
- }
17958
- if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
17959
- if (d.compareTo(m) >= 0) return d.subtract(m);
17960
- if (d.signum() < 0) d.addTo(m, d);
17961
- else return d;
17962
- if (d.signum() < 0) return d.add(m);
17963
- else return d;
17964
- }
17965
- var lowprimes = [
17966
- 2,
17967
- 3,
17968
- 5,
17969
- 7,
17970
- 11,
17971
- 13,
17972
- 17,
17973
- 19,
17974
- 23,
17975
- 29,
17976
- 31,
17977
- 37,
17978
- 41,
17979
- 43,
17980
- 47,
17981
- 53,
17982
- 59,
17983
- 61,
17984
- 67,
17985
- 71,
17986
- 73,
17987
- 79,
17988
- 83,
17989
- 89,
17990
- 97,
17991
- 101,
17992
- 103,
17993
- 107,
17994
- 109,
17995
- 113,
17996
- 127,
17997
- 131,
17998
- 137,
17999
- 139,
18000
- 149,
18001
- 151,
18002
- 157,
18003
- 163,
18004
- 167,
18005
- 173,
18006
- 179,
18007
- 181,
18008
- 191,
18009
- 193,
18010
- 197,
18011
- 199,
18012
- 211,
18013
- 223,
18014
- 227,
18015
- 229,
18016
- 233,
18017
- 239,
18018
- 241,
18019
- 251,
18020
- 257,
18021
- 263,
18022
- 269,
18023
- 271,
18024
- 277,
18025
- 281,
18026
- 283,
18027
- 293,
18028
- 307,
18029
- 311,
18030
- 313,
18031
- 317,
18032
- 331,
18033
- 337,
18034
- 347,
18035
- 349,
18036
- 353,
18037
- 359,
18038
- 367,
18039
- 373,
18040
- 379,
18041
- 383,
18042
- 389,
18043
- 397,
18044
- 401,
18045
- 409,
18046
- 419,
18047
- 421,
18048
- 431,
18049
- 433,
18050
- 439,
18051
- 443,
18052
- 449,
18053
- 457,
18054
- 461,
18055
- 463,
18056
- 467,
18057
- 479,
18058
- 487,
18059
- 491,
18060
- 499,
18061
- 503,
18062
- 509,
18063
- 521,
18064
- 523,
18065
- 541,
18066
- 547,
18067
- 557,
18068
- 563,
18069
- 569,
18070
- 571,
18071
- 577,
18072
- 587,
18073
- 593,
18074
- 599,
18075
- 601,
18076
- 607,
18077
- 613,
18078
- 617,
18079
- 619,
18080
- 631,
18081
- 641,
18082
- 643,
18083
- 647,
18084
- 653,
18085
- 659,
18086
- 661,
18087
- 673,
18088
- 677,
18089
- 683,
18090
- 691,
18091
- 701,
18092
- 709,
18093
- 719,
18094
- 727,
18095
- 733,
18096
- 739,
18097
- 743,
18098
- 751,
18099
- 757,
18100
- 761,
18101
- 769,
18102
- 773,
18103
- 787,
18104
- 797,
18105
- 809,
18106
- 811,
18107
- 821,
18108
- 823,
18109
- 827,
18110
- 829,
18111
- 839,
18112
- 853,
18113
- 857,
18114
- 859,
18115
- 863,
18116
- 877,
18117
- 881,
18118
- 883,
18119
- 887,
18120
- 907,
18121
- 911,
18122
- 919,
18123
- 929,
18124
- 937,
18125
- 941,
18126
- 947,
18127
- 953,
18128
- 967,
18129
- 971,
18130
- 977,
18131
- 983,
18132
- 991,
18133
- 997
18134
- ];
18135
- var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
18136
- function bnIsProbablePrime(t) {
18137
- var i, x = this.abs();
18138
- if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
18139
- for (i = 0; i < lowprimes.length; ++i) if (x[0] == lowprimes[i]) return true;
18140
- return false;
18141
- }
18142
- if (x.isEven()) return false;
18143
- i = 1;
18144
- while (i < lowprimes.length) {
18145
- var m = lowprimes[i], j = i + 1;
18146
- while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
18147
- m = x.modInt(m);
18148
- while (i < j) if (m % lowprimes[i++] == 0) return false;
18149
- }
18150
- return x.millerRabin(t);
18151
- }
18152
- function bnpMillerRabin(t) {
18153
- var n1 = this.subtract(BigInteger.ONE);
18154
- var k = n1.getLowestSetBit();
18155
- if (k <= 0) return false;
18156
- var r = n1.shiftRight(k);
18157
- t = t + 1 >> 1;
18158
- if (t > lowprimes.length) t = lowprimes.length;
18159
- var a = nbi();
18160
- for (var i = 0; i < t; ++i) {
18161
- a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
18162
- var y = a.modPow(r, this);
18163
- if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
18164
- var j = 1;
18165
- while (j++ < k && y.compareTo(n1) != 0) {
18166
- y = y.modPowInt(2, this);
18167
- if (y.compareTo(BigInteger.ONE) == 0) return false;
18168
- }
18169
- if (y.compareTo(n1) != 0) return false;
18170
- }
18171
- }
18172
- return true;
18173
- }
18174
- BigInteger.prototype.chunkSize = bnpChunkSize;
18175
- BigInteger.prototype.toRadix = bnpToRadix;
18176
- BigInteger.prototype.fromRadix = bnpFromRadix;
18177
- BigInteger.prototype.fromNumber = bnpFromNumber;
18178
- BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
18179
- BigInteger.prototype.changeBit = bnpChangeBit;
18180
- BigInteger.prototype.addTo = bnpAddTo;
18181
- BigInteger.prototype.dMultiply = bnpDMultiply;
18182
- BigInteger.prototype.dAddOffset = bnpDAddOffset;
18183
- BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
18184
- BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
18185
- BigInteger.prototype.modInt = bnpModInt;
18186
- BigInteger.prototype.millerRabin = bnpMillerRabin;
18187
- BigInteger.prototype.clone = bnClone;
18188
- BigInteger.prototype.intValue = bnIntValue;
18189
- BigInteger.prototype.byteValue = bnByteValue;
18190
- BigInteger.prototype.shortValue = bnShortValue;
18191
- BigInteger.prototype.signum = bnSigNum;
18192
- BigInteger.prototype.toByteArray = bnToByteArray;
18193
- BigInteger.prototype.equals = bnEquals;
18194
- BigInteger.prototype.min = bnMin;
18195
- BigInteger.prototype.max = bnMax;
18196
- BigInteger.prototype.and = bnAnd;
18197
- BigInteger.prototype.or = bnOr;
18198
- BigInteger.prototype.xor = bnXor;
18199
- BigInteger.prototype.andNot = bnAndNot;
18200
- BigInteger.prototype.not = bnNot;
18201
- BigInteger.prototype.shiftLeft = bnShiftLeft;
18202
- BigInteger.prototype.shiftRight = bnShiftRight;
18203
- BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
18204
- BigInteger.prototype.bitCount = bnBitCount;
18205
- BigInteger.prototype.testBit = bnTestBit;
18206
- BigInteger.prototype.setBit = bnSetBit;
18207
- BigInteger.prototype.clearBit = bnClearBit;
18208
- BigInteger.prototype.flipBit = bnFlipBit;
18209
- BigInteger.prototype.add = bnAdd;
18210
- BigInteger.prototype.subtract = bnSubtract;
18211
- BigInteger.prototype.multiply = bnMultiply;
18212
- BigInteger.prototype.divide = bnDivide;
18213
- BigInteger.prototype.remainder = bnRemainder;
18214
- BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
18215
- BigInteger.prototype.modPow = bnModPow;
18216
- BigInteger.prototype.modInverse = bnModInverse;
18217
- BigInteger.prototype.pow = bnPow;
18218
- BigInteger.prototype.gcd = bnGCD;
18219
- BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
18220
- BigInteger.prototype.square = bnSquare;
18221
- BigInteger.prototype.Barrett = Barrett;
18222
- var rng_state;
18223
- var rng_pool;
18224
- var rng_pptr;
18225
- function rng_seed_int(x) {
18226
- rng_pool[rng_pptr++] ^= x & 255;
18227
- rng_pool[rng_pptr++] ^= x >> 8 & 255;
18228
- rng_pool[rng_pptr++] ^= x >> 16 & 255;
18229
- rng_pool[rng_pptr++] ^= x >> 24 & 255;
18230
- if (rng_pptr >= rng_psize) rng_pptr -= rng_psize;
18231
- }
18232
- function rng_seed_time() {
18233
- rng_seed_int((/* @__PURE__ */ new Date()).getTime());
18234
- }
18235
- if (rng_pool == null) {
18236
- rng_pool = new Array();
18237
- rng_pptr = 0;
18238
- var t;
18239
- if (typeof window !== "undefined" && window.crypto) {
18240
- if (window.crypto.getRandomValues) {
18241
- var ua = new Uint8Array(32);
18242
- window.crypto.getRandomValues(ua);
18243
- for (t = 0; t < 32; ++t) rng_pool[rng_pptr++] = ua[t];
18244
- } else if (navigator.appName == "Netscape" && navigator.appVersion < "5") {
18245
- var z = window.crypto.random(32);
18246
- for (t = 0; t < z.length; ++t) rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
18247
- }
18248
- }
18249
- while (rng_pptr < rng_psize) {
18250
- t = Math.floor(65536 * Math.random());
18251
- rng_pool[rng_pptr++] = t >>> 8;
18252
- rng_pool[rng_pptr++] = t & 255;
18253
- }
18254
- rng_pptr = 0;
18255
- rng_seed_time();
18256
- }
18257
- function rng_get_byte() {
18258
- if (rng_state == null) {
18259
- rng_seed_time();
18260
- rng_state = prng_newstate();
18261
- rng_state.init(rng_pool);
18262
- for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) rng_pool[rng_pptr] = 0;
18263
- rng_pptr = 0;
18264
- }
18265
- return rng_state.next();
18266
- }
18267
- function rng_get_bytes(ba) {
18268
- var i;
18269
- for (i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
18270
- }
18271
- function SecureRandom() {}
18272
- SecureRandom.prototype.nextBytes = rng_get_bytes;
18273
- function Arcfour() {
18274
- this.i = 0;
18275
- this.j = 0;
18276
- this.S = new Array();
18277
- }
18278
- function ARC4init(key) {
18279
- var i, j, t;
18280
- for (i = 0; i < 256; ++i) this.S[i] = i;
18281
- j = 0;
18282
- for (i = 0; i < 256; ++i) {
18283
- j = j + this.S[i] + key[i % key.length] & 255;
18284
- t = this.S[i];
18285
- this.S[i] = this.S[j];
18286
- this.S[j] = t;
18287
- }
18288
- this.i = 0;
18289
- this.j = 0;
18290
- }
18291
- function ARC4next() {
18292
- var t;
18293
- this.i = this.i + 1 & 255;
18294
- this.j = this.j + this.S[this.i] & 255;
18295
- t = this.S[this.i];
18296
- this.S[this.i] = this.S[this.j];
18297
- this.S[this.j] = t;
18298
- return this.S[t + this.S[this.i] & 255];
18299
- }
18300
- Arcfour.prototype.init = ARC4init;
18301
- Arcfour.prototype.next = ARC4next;
18302
- function prng_newstate() {
18303
- return new Arcfour();
18304
- }
18305
- var rng_psize = 256;
18306
- if (typeof exports !== "undefined") exports = module.exports = {
18307
- default: BigInteger,
18308
- BigInteger,
18309
- SecureRandom
18310
- };
18311
- else this.jsbn = {
18312
- BigInteger,
18313
- SecureRandom
18314
- };
18315
- }).call(exports);
18316
- }));
18317
- //#endregion
18318
- //#region ../../node_modules/sprintf-js/src/sprintf.js
18319
- var require_sprintf = /* @__PURE__ */ __commonJSMin(((exports) => {
18320
- (function() {
18321
- "use strict";
18322
- var re = {
18323
- not_string: /[^s]/,
18324
- not_bool: /[^t]/,
18325
- not_type: /[^T]/,
18326
- not_primitive: /[^v]/,
18327
- number: /[diefg]/,
18328
- numeric_arg: /[bcdiefguxX]/,
18329
- json: /[j]/,
18330
- not_json: /[^j]/,
18331
- text: /^[^\x25]+/,
18332
- modulo: /^\x25{2}/,
18333
- placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
18334
- key: /^([a-z_][a-z_\d]*)/i,
18335
- key_access: /^\.([a-z_][a-z_\d]*)/i,
18336
- index_access: /^\[(\d+)\]/,
18337
- sign: /^[+-]/
18338
- };
18339
- function sprintf(key) {
18340
- return sprintf_format(sprintf_parse(key), arguments);
18341
- }
18342
- function vsprintf(fmt, argv) {
18343
- return sprintf.apply(null, [fmt].concat(argv || []));
18344
- }
18345
- function sprintf_format(parse_tree, argv) {
18346
- var cursor = 1, tree_length = parse_tree.length, arg, output = "", i, k, ph, pad, pad_character, pad_length, is_positive, sign;
18347
- for (i = 0; i < tree_length; i++) if (typeof parse_tree[i] === "string") output += parse_tree[i];
18348
- else if (typeof parse_tree[i] === "object") {
18349
- ph = parse_tree[i];
18350
- if (ph.keys) {
18351
- arg = argv[cursor];
18352
- for (k = 0; k < ph.keys.length; k++) {
18353
- if (arg == void 0) throw new Error(sprintf("[sprintf] Cannot access property \"%s\" of undefined value \"%s\"", ph.keys[k], ph.keys[k - 1]));
18354
- arg = arg[ph.keys[k]];
18355
- }
18356
- } else if (ph.param_no) arg = argv[ph.param_no];
18357
- else arg = argv[cursor++];
18358
- if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) arg = arg();
18359
- if (re.numeric_arg.test(ph.type) && typeof arg !== "number" && isNaN(arg)) throw new TypeError(sprintf("[sprintf] expecting number but found %T", arg));
18360
- if (re.number.test(ph.type)) is_positive = arg >= 0;
18361
- switch (ph.type) {
18362
- case "b":
18363
- arg = parseInt(arg, 10).toString(2);
18364
- break;
18365
- case "c":
18366
- arg = String.fromCharCode(parseInt(arg, 10));
18367
- break;
18368
- case "d":
18369
- case "i":
18370
- arg = parseInt(arg, 10);
18371
- break;
18372
- case "j":
18373
- arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0);
18374
- break;
18375
- case "e":
18376
- arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential();
18377
- break;
18378
- case "f":
18379
- arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg);
18380
- break;
18381
- case "g":
18382
- arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg);
18383
- break;
18384
- case "o":
18385
- arg = (parseInt(arg, 10) >>> 0).toString(8);
18386
- break;
18387
- case "s":
18388
- arg = String(arg);
18389
- arg = ph.precision ? arg.substring(0, ph.precision) : arg;
18390
- break;
18391
- case "t":
18392
- arg = String(!!arg);
18393
- arg = ph.precision ? arg.substring(0, ph.precision) : arg;
18394
- break;
18395
- case "T":
18396
- arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase();
18397
- arg = ph.precision ? arg.substring(0, ph.precision) : arg;
18398
- break;
18399
- case "u":
18400
- arg = parseInt(arg, 10) >>> 0;
18401
- break;
18402
- case "v":
18403
- arg = arg.valueOf();
18404
- arg = ph.precision ? arg.substring(0, ph.precision) : arg;
18405
- break;
18406
- case "x":
18407
- arg = (parseInt(arg, 10) >>> 0).toString(16);
18408
- break;
18409
- case "X":
18410
- arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase();
18411
- break;
18412
- }
18413
- if (re.json.test(ph.type)) output += arg;
18414
- else {
18415
- if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
18416
- sign = is_positive ? "+" : "-";
18417
- arg = arg.toString().replace(re.sign, "");
18418
- } else sign = "";
18419
- pad_character = ph.pad_char ? ph.pad_char === "0" ? "0" : ph.pad_char.charAt(1) : " ";
18420
- pad_length = ph.width - (sign + arg).length;
18421
- pad = ph.width ? pad_length > 0 ? pad_character.repeat(pad_length) : "" : "";
18422
- output += ph.align ? sign + arg + pad : pad_character === "0" ? sign + pad + arg : pad + sign + arg;
18423
- }
18424
- }
18425
- return output;
18426
- }
18427
- var sprintf_cache = Object.create(null);
18428
- function sprintf_parse(fmt) {
18429
- if (sprintf_cache[fmt]) return sprintf_cache[fmt];
18430
- var _fmt = fmt, match, parse_tree = [], arg_names = 0;
18431
- while (_fmt) {
18432
- if ((match = re.text.exec(_fmt)) !== null) parse_tree.push(match[0]);
18433
- else if ((match = re.modulo.exec(_fmt)) !== null) parse_tree.push("%");
18434
- else if ((match = re.placeholder.exec(_fmt)) !== null) {
18435
- if (match[2]) {
18436
- arg_names |= 1;
18437
- var field_list = [], replacement_field = match[2], field_match = [];
18438
- if ((field_match = re.key.exec(replacement_field)) !== null) {
18439
- field_list.push(field_match[1]);
18440
- while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") if ((field_match = re.key_access.exec(replacement_field)) !== null) field_list.push(field_match[1]);
18441
- else if ((field_match = re.index_access.exec(replacement_field)) !== null) field_list.push(field_match[1]);
18442
- else throw new SyntaxError("[sprintf] failed to parse named argument key");
18443
- } else throw new SyntaxError("[sprintf] failed to parse named argument key");
18444
- match[2] = field_list;
18445
- } else arg_names |= 2;
18446
- if (arg_names === 3) throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
18447
- parse_tree.push({
18448
- placeholder: match[0],
18449
- param_no: match[1],
18450
- keys: match[2],
18451
- sign: match[3],
18452
- pad_char: match[4],
18453
- align: match[5],
18454
- width: match[6],
18455
- precision: match[7],
18456
- type: match[8]
18457
- });
18458
- } else throw new SyntaxError("[sprintf] unexpected placeholder");
18459
- _fmt = _fmt.substring(match[0].length);
18460
- }
18461
- return sprintf_cache[fmt] = parse_tree;
18462
- }
18463
- /**
18464
- * export to either browser or node.js
18465
- */
18466
- if (typeof exports !== "undefined") {
18467
- exports["sprintf"] = sprintf;
18468
- exports["vsprintf"] = vsprintf;
18469
- }
18470
- if (typeof window !== "undefined") {
18471
- window["sprintf"] = sprintf;
18472
- window["vsprintf"] = vsprintf;
18473
- if (typeof define === "function" && define["amd"]) define(function() {
18474
- return {
18475
- "sprintf": sprintf,
18476
- "vsprintf": vsprintf
18477
- };
18478
- });
18479
- }
18480
- })();
18481
- }));
18482
- //#endregion
18483
16976
  //#region ../../node_modules/ip-address/dist/ipv4.js
18484
16977
  var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18485
16978
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
@@ -18518,10 +17011,14 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18518
17011
  const common = __importStar(require_common$1());
18519
17012
  const constants = __importStar(require_constants$7());
18520
17013
  const address_error_1 = require_address_error();
18521
- const jsbn_1 = require_jsbn();
18522
- const sprintf_js_1 = require_sprintf();
18523
- exports.Address4 = class Address4 {
17014
+ const isCorrect4 = common.isCorrect(constants.BITS);
17015
+ /**
17016
+ * Represents an IPv4 address
17017
+ * @param {string} address - An IPv4 address string
17018
+ */
17019
+ var Address4 = class Address4 {
18524
17020
  constructor(address) {
17021
+ this.addressMinusSuffix = "";
18525
17022
  this.groups = constants.GROUPS;
18526
17023
  this.parsedAddress = [];
18527
17024
  this.parsedSubnet = "";
@@ -18530,18 +17027,23 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18530
17027
  this.v4 = true;
18531
17028
  /**
18532
17029
  * Returns true if the address is correct, false otherwise
18533
- * @memberof Address4
18534
- * @instance
18535
17030
  * @returns {Boolean}
18536
17031
  */
18537
- this.isCorrect = common.isCorrect(constants.BITS);
17032
+ this.isCorrect = isCorrect4;
18538
17033
  /**
18539
17034
  * Returns true if the given address is in the subnet of the current address
18540
- * @memberof Address4
18541
- * @instance
18542
17035
  * @returns {boolean}
18543
17036
  */
18544
17037
  this.isInSubnet = common.isInSubnet;
17038
+ /**
17039
+ * Returns true if this address's host bits fall inside the given subnet,
17040
+ * ignoring this address's own subnet mask. Prefer this over `isInSubnet`
17041
+ * when classifying a single address, so the answer doesn't change with the
17042
+ * CIDR suffix the caller happened to write — notably when the address came
17043
+ * from untrusted input and the result backs a trust-boundary decision.
17044
+ * @returns {boolean}
17045
+ */
17046
+ this.isHostInSubnet = common.isHostInSubnet;
18545
17047
  this.address = address;
18546
17048
  const subnet = constants.RE_SUBNET_STRING.exec(address);
18547
17049
  if (subnet) {
@@ -18554,59 +17056,118 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18554
17056
  this.addressMinusSuffix = address;
18555
17057
  this.parsedAddress = this.parse(address);
18556
17058
  }
17059
+ /**
17060
+ * Returns true if the given string is a valid IPv4 address (with optional
17061
+ * CIDR subnet), false otherwise. Host bits in the subnet portion are
17062
+ * allowed (e.g. `192.168.1.5/24` is valid); for strict network-address
17063
+ * validation compare `correctForm()` to `startAddress().correctForm()`,
17064
+ * or use `networkForm()`.
17065
+ */
18557
17066
  static isValid(address) {
18558
17067
  try {
18559
17068
  new Address4(address);
18560
17069
  return true;
18561
- } catch (e) {
17070
+ } catch {
18562
17071
  return false;
18563
17072
  }
18564
17073
  }
17074
+ /**
17075
+ * Parses an IPv4 address string into its four octet groups and stores the
17076
+ * result on `this.parsedAddress`. Called automatically by the constructor;
17077
+ * you typically don't need to call it directly. Throws `AddressError` if
17078
+ * the input is not a valid IPv4 address.
17079
+ */
18565
17080
  parse(address) {
18566
17081
  const groups = address.split(".");
17082
+ if (groups.some((group) => /^0\d/.test(group))) throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.");
18567
17083
  if (!address.match(constants.RE_ADDRESS)) throw new address_error_1.AddressError("Invalid IPv4 address.");
18568
17084
  return groups;
18569
17085
  }
18570
17086
  /**
18571
- * Returns the correct form of an address
18572
- * @memberof Address4
18573
- * @instance
18574
- * @returns {String}
17087
+ * Returns the address in correct form: octets joined with `.` and any
17088
+ * leading zeros stripped (e.g. `192.168.1.1`). For IPv4 this matches the
17089
+ * canonical dotted-decimal representation.
18575
17090
  */
18576
17091
  correctForm() {
18577
17092
  return this.parsedAddress.map((part) => parseInt(part, 10)).join(".");
18578
17093
  }
18579
17094
  /**
18580
- * Converts a hex string to an IPv4 address object
18581
- * @memberof Address4
18582
- * @static
17095
+ * Construct an `Address4` from an address and a dotted-decimal subnet
17096
+ * mask given as separate strings (e.g. as returned by Node's
17097
+ * `os.networkInterfaces()`). Throws `AddressError` if the mask is
17098
+ * non-contiguous (e.g. `255.0.255.0`).
17099
+ * @example
17100
+ * var address = Address4.fromAddressAndMask('192.168.1.1', '255.255.255.0');
17101
+ * address.subnetMask; // 24
17102
+ */
17103
+ static fromAddressAndMask(address, mask) {
17104
+ return new Address4(`${address}/${common.prefixLengthFromMask(new Address4(mask).bigInt(), constants.BITS)}`);
17105
+ }
17106
+ /**
17107
+ * Construct an `Address4` from an address and a Cisco-style wildcard mask
17108
+ * given as separate strings (e.g. `0.0.0.255` for a `/24`). The wildcard
17109
+ * mask is the bitwise inverse of the subnet mask. Throws `AddressError`
17110
+ * if the mask is non-contiguous (e.g. `0.255.0.255`).
17111
+ * @example
17112
+ * var address = Address4.fromAddressAndWildcardMask('10.0.0.1', '0.0.0.255');
17113
+ * address.subnetMask; // 24
17114
+ */
17115
+ static fromAddressAndWildcardMask(address, wildcardMask) {
17116
+ const mask = new Address4(wildcardMask).bigInt() ^ (BigInt(1) << BigInt(constants.BITS)) - BigInt(1);
17117
+ return new Address4(`${address}/${common.prefixLengthFromMask(mask, constants.BITS)}`);
17118
+ }
17119
+ /**
17120
+ * Construct an `Address4` from a wildcard pattern with trailing `*`
17121
+ * octets. The number of trailing wildcards determines the prefix
17122
+ * length: each `*` represents 8 bits.
17123
+ *
17124
+ * Only trailing whole-octet wildcards are supported. Partial-octet
17125
+ * wildcards (e.g. `192.168.0.1*`) and interior wildcards (e.g.
17126
+ * `192.*.0.1`) throw `AddressError`.
17127
+ * @example
17128
+ * Address4.fromWildcard('192.168.0.*').subnet; // '/24'
17129
+ * Address4.fromWildcard('192.168.*.*').subnet; // '/16'
17130
+ * Address4.fromWildcard('*.*.*.*').subnet; // '/0'
17131
+ */
17132
+ static fromWildcard(input) {
17133
+ const groups = input.split(".");
17134
+ if (groups.length !== constants.GROUPS) throw new address_error_1.AddressError("Wildcard pattern must have 4 octets");
17135
+ let firstWildcard = -1;
17136
+ for (let i = 0; i < groups.length; i++) if (groups[i] === "*") {
17137
+ if (firstWildcard === -1) firstWildcard = i;
17138
+ } else if (firstWildcard !== -1) throw new address_error_1.AddressError("Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)");
17139
+ const trailing = firstWildcard === -1 ? 0 : groups.length - firstWildcard;
17140
+ const replaced = groups.map((g) => g === "*" ? "0" : g);
17141
+ const subnetBits = constants.BITS - trailing * 8;
17142
+ return new Address4(`${replaced.join(".")}/${subnetBits}`);
17143
+ }
17144
+ /**
17145
+ * Converts a hex string to an IPv4 address object. Accepts 8 hex digits
17146
+ * with optional `:` separators (e.g. `'7f000001'` or `'7f:00:00:01'`).
17147
+ * Throws `AddressError` for any other length or for non-hex characters.
18583
17148
  * @param {string} hex - a hex string to convert
18584
17149
  * @returns {Address4}
18585
17150
  */
18586
17151
  static fromHex(hex) {
18587
- const padded = hex.replace(/:/g, "").padStart(8, "0");
17152
+ const stripped = hex.replace(/:/g, "");
17153
+ if (!/^[0-9a-fA-F]{8}$/.test(stripped)) throw new address_error_1.AddressError("IPv4 hex must be exactly 8 hex digits");
18588
17154
  const groups = [];
18589
- let i;
18590
- for (i = 0; i < 8; i += 2) {
18591
- const h = padded.slice(i, i + 2);
18592
- groups.push(parseInt(h, 16));
18593
- }
17155
+ for (let i = 0; i < 8; i += 2) groups.push(parseInt(stripped.slice(i, i + 2), 16));
18594
17156
  return new Address4(groups.join("."));
18595
17157
  }
18596
17158
  /**
18597
- * Converts an integer into a IPv4 address object
18598
- * @memberof Address4
18599
- * @static
17159
+ * Converts an integer into a IPv4 address object. The integer must be a
17160
+ * non-negative safe integer in the range `[0, 2**32 - 1]`; otherwise
17161
+ * `AddressError` is thrown.
18600
17162
  * @param {integer} integer - a number to convert
18601
17163
  * @returns {Address4}
18602
17164
  */
18603
17165
  static fromInteger(integer) {
18604
- return Address4.fromHex(integer.toString(16));
17166
+ if (!Number.isInteger(integer) || integer < 0 || integer > 4294967295) throw new address_error_1.AddressError("IPv4 integer must be in the range 0 to 2**32 - 1");
17167
+ return Address4.fromHex(integer.toString(16).padStart(8, "0"));
18605
17168
  }
18606
17169
  /**
18607
17170
  * Return an address from in-addr.arpa form
18608
- * @memberof Address4
18609
- * @static
18610
17171
  * @param {string} arpaFormAddress - an 'in-addr.arpa' form ipv4 address
18611
17172
  * @returns {Adress4}
18612
17173
  * @example
@@ -18618,17 +17179,15 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18618
17179
  }
18619
17180
  /**
18620
17181
  * Converts an IPv4 address object to a hex string
18621
- * @memberof Address4
18622
- * @instance
18623
17182
  * @returns {String}
18624
17183
  */
18625
17184
  toHex() {
18626
- return this.parsedAddress.map((part) => (0, sprintf_js_1.sprintf)("%02x", parseInt(part, 10))).join(":");
17185
+ return this.parsedAddress.map((part) => common.stringToPaddedHex(part)).join(":");
18627
17186
  }
18628
17187
  /**
18629
- * Converts an IPv4 address object to an array of bytes
18630
- * @memberof Address4
18631
- * @instance
17188
+ * Converts an IPv4 address object to an array of bytes.
17189
+ *
17190
+ * To get a Node.js `Buffer`, wrap the result: `Buffer.from(address.toArray())`.
18632
17191
  * @returns {Array}
18633
17192
  */
18634
17193
  toArray() {
@@ -18636,103 +17195,136 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18636
17195
  }
18637
17196
  /**
18638
17197
  * Converts an IPv4 address object to an IPv6 address group
18639
- * @memberof Address4
18640
- * @instance
18641
17198
  * @returns {String}
18642
17199
  */
18643
17200
  toGroup6() {
18644
17201
  const output = [];
18645
17202
  let i;
18646
- for (i = 0; i < constants.GROUPS; i += 2) {
18647
- const hex = (0, sprintf_js_1.sprintf)("%02x%02x", parseInt(this.parsedAddress[i], 10), parseInt(this.parsedAddress[i + 1], 10));
18648
- output.push((0, sprintf_js_1.sprintf)("%x", parseInt(hex, 16)));
18649
- }
17203
+ for (i = 0; i < constants.GROUPS; i += 2) output.push(`${common.stringToPaddedHex(this.parsedAddress[i])}${common.stringToPaddedHex(this.parsedAddress[i + 1])}`);
18650
17204
  return output.join(":");
18651
17205
  }
18652
17206
  /**
18653
- * Returns the address as a BigInteger
18654
- * @memberof Address4
18655
- * @instance
18656
- * @returns {BigInteger}
17207
+ * Returns the address as a `bigint`
17208
+ * @returns {bigint}
18657
17209
  */
18658
- bigInteger() {
18659
- return new jsbn_1.BigInteger(this.parsedAddress.map((n) => (0, sprintf_js_1.sprintf)("%02x", parseInt(n, 10))).join(""), 16);
17210
+ bigInt() {
17211
+ return BigInt(`0x${this.parsedAddress.map((n) => common.stringToPaddedHex(n)).join("")}`);
18660
17212
  }
18661
17213
  /**
18662
17214
  * Helper function getting start address.
18663
- * @memberof Address4
18664
- * @instance
18665
- * @returns {BigInteger}
17215
+ * @returns {bigint}
18666
17216
  */
18667
17217
  _startAddress() {
18668
- return new jsbn_1.BigInteger(this.mask() + "0".repeat(constants.BITS - this.subnetMask), 2);
17218
+ return BigInt(`0b${this.mask() + "0".repeat(constants.BITS - this.subnetMask)}`);
18669
17219
  }
18670
17220
  /**
18671
17221
  * The first address in the range given by this address' subnet.
18672
17222
  * Often referred to as the Network Address.
18673
- * @memberof Address4
18674
- * @instance
18675
17223
  * @returns {Address4}
18676
17224
  */
18677
17225
  startAddress() {
18678
- return Address4.fromBigInteger(this._startAddress());
17226
+ return Address4.fromBigInt(this._startAddress());
18679
17227
  }
18680
17228
  /**
18681
17229
  * The first host address in the range given by this address's subnet ie
18682
17230
  * the first address after the Network Address
18683
- * @memberof Address4
18684
- * @instance
18685
17231
  * @returns {Address4}
18686
17232
  */
18687
17233
  startAddressExclusive() {
18688
- const adjust = new jsbn_1.BigInteger("1");
18689
- return Address4.fromBigInteger(this._startAddress().add(adjust));
17234
+ const adjust = BigInt("1");
17235
+ return Address4.fromBigInt(this._startAddress() + adjust);
18690
17236
  }
18691
17237
  /**
18692
17238
  * Helper function getting end address.
18693
- * @memberof Address4
18694
- * @instance
18695
- * @returns {BigInteger}
17239
+ * @returns {bigint}
18696
17240
  */
18697
17241
  _endAddress() {
18698
- return new jsbn_1.BigInteger(this.mask() + "1".repeat(constants.BITS - this.subnetMask), 2);
17242
+ return BigInt(`0b${this.mask() + "1".repeat(constants.BITS - this.subnetMask)}`);
18699
17243
  }
18700
17244
  /**
18701
17245
  * The last address in the range given by this address' subnet
18702
17246
  * Often referred to as the Broadcast
18703
- * @memberof Address4
18704
- * @instance
18705
17247
  * @returns {Address4}
18706
17248
  */
18707
17249
  endAddress() {
18708
- return Address4.fromBigInteger(this._endAddress());
17250
+ return Address4.fromBigInt(this._endAddress());
18709
17251
  }
18710
17252
  /**
18711
17253
  * The last host address in the range given by this address's subnet ie
18712
17254
  * the last address prior to the Broadcast Address
18713
- * @memberof Address4
18714
- * @instance
18715
17255
  * @returns {Address4}
18716
17256
  */
18717
17257
  endAddressExclusive() {
18718
- const adjust = new jsbn_1.BigInteger("1");
18719
- return Address4.fromBigInteger(this._endAddress().subtract(adjust));
17258
+ const adjust = BigInt("1");
17259
+ return Address4.fromBigInt(this._endAddress() - adjust);
17260
+ }
17261
+ /**
17262
+ * The dotted-decimal form of the subnet mask, e.g. `255.255.240.0` for
17263
+ * a `/20`. Returns an `Address4`; call `.correctForm()` for the string.
17264
+ * @returns {Address4}
17265
+ */
17266
+ subnetMaskAddress() {
17267
+ return Address4.fromBigInt(BigInt(`0b${"1".repeat(this.subnetMask)}${"0".repeat(constants.BITS - this.subnetMask)}`));
17268
+ }
17269
+ /**
17270
+ * The Cisco-style wildcard mask, e.g. `0.0.0.255` for a `/24`. This is
17271
+ * the bitwise inverse of `subnetMaskAddress()`. Returns an `Address4`;
17272
+ * call `.correctForm()` for the string.
17273
+ * @returns {Address4}
17274
+ */
17275
+ wildcardMask() {
17276
+ return Address4.fromBigInt(BigInt(`0b${"0".repeat(this.subnetMask)}${"1".repeat(constants.BITS - this.subnetMask)}`));
17277
+ }
17278
+ /**
17279
+ * The network address in CIDR string form, e.g. `192.168.1.0/24` for
17280
+ * `192.168.1.5/24`. For an address with no explicit subnet the prefix is
17281
+ * `/32`, e.g. `networkForm()` on `192.168.1.5` returns `192.168.1.5/32`.
17282
+ * @returns {string}
17283
+ */
17284
+ networkForm() {
17285
+ return `${this.startAddress().correctForm()}/${this.subnetMask}`;
17286
+ }
17287
+ /**
17288
+ * Converts a BigInt to a v4 address object. The value must be in the
17289
+ * range `[0, 2**32 - 1]`; otherwise `AddressError` is thrown.
17290
+ * @param {bigint} bigInt - a BigInt to convert
17291
+ * @returns {Address4}
17292
+ */
17293
+ static fromBigInt(bigInt) {
17294
+ if (bigInt < BigInt(0) || bigInt > BigInt(4294967295)) throw new address_error_1.AddressError("IPv4 BigInt must be in the range 0 to 2**32 - 1");
17295
+ return Address4.fromHex(bigInt.toString(16).padStart(8, "0"));
17296
+ }
17297
+ /**
17298
+ * Convert a byte array to an Address4 object. Throws `AddressError` unless
17299
+ * given exactly 4 integers from 0 to 255. Signed bytes are rejected, so
17300
+ * this differs from `Address6.fromByteArray`, which folds them; the two
17301
+ * contracts converge on this stricter form in the next major version.
17302
+ *
17303
+ * To convert from a Node.js `Buffer`, spread it: `Address4.fromByteArray([...buf])`.
17304
+ * @param {Array<number>} bytes - an array of 4 bytes (0-255)
17305
+ * @returns {Address4}
17306
+ */
17307
+ static fromByteArray(bytes) {
17308
+ common.assertByteArray(bytes, 4, "IPv4", 0);
17309
+ return this.fromUnsignedByteArray(bytes);
18720
17310
  }
18721
17311
  /**
18722
- * Converts a BigInteger to a v4 address object
18723
- * @memberof Address4
18724
- * @static
18725
- * @param {BigInteger} bigInteger - a BigInteger to convert
17312
+ * Convert an unsigned byte array to an Address4 object. Throws
17313
+ * `AddressError` unless given exactly 4 bytes, and rejects values outside
17314
+ * 0 to 255 when parsing the resulting address.
17315
+ *
17316
+ * To convert from a Node.js `Buffer`, spread it:
17317
+ * `Address4.fromUnsignedByteArray([...buf])`.
17318
+ * @param {Array<number>} bytes - an array of 4 unsigned bytes (0-255)
18726
17319
  * @returns {Address4}
18727
17320
  */
18728
- static fromBigInteger(bigInteger) {
18729
- return Address4.fromInteger(parseInt(bigInteger.toString(), 10));
17321
+ static fromUnsignedByteArray(bytes) {
17322
+ if (bytes.length !== 4) throw new address_error_1.AddressError("IPv4 addresses require exactly 4 bytes");
17323
+ return new Address4(bytes.join("."));
18730
17324
  }
18731
17325
  /**
18732
17326
  * Returns the first n bits of the address, defaulting to the
18733
17327
  * subnet mask
18734
- * @memberof Address4
18735
- * @instance
18736
17328
  * @returns {String}
18737
17329
  */
18738
17330
  mask(mask) {
@@ -18741,54 +17333,107 @@ var require_ipv4 = /* @__PURE__ */ __commonJSMin(((exports) => {
18741
17333
  }
18742
17334
  /**
18743
17335
  * Returns the bits in the given range as a base-2 string
18744
- * @memberof Address4
18745
- * @instance
18746
17336
  * @returns {string}
18747
17337
  */
18748
17338
  getBitsBase2(start, end) {
18749
17339
  return this.binaryZeroPad().slice(start, end);
18750
17340
  }
18751
17341
  /**
18752
- * Return the reversed ip6.arpa form of the address
18753
- * @memberof Address4
17342
+ * Return the reversed in-addr.arpa form of the address, e.g.
17343
+ * `42.2.0.192.in-addr.arpa.` for `192.0.2.42`.
18754
17344
  * @param {Object} options
18755
17345
  * @param {boolean} options.omitSuffix - omit the "in-addr.arpa" suffix
18756
- * @instance
18757
17346
  * @returns {String}
18758
17347
  */
18759
17348
  reverseForm(options) {
18760
17349
  if (!options) options = {};
18761
17350
  const reversed = this.correctForm().split(".").reverse().join(".");
18762
17351
  if (options.omitSuffix) return reversed;
18763
- return (0, sprintf_js_1.sprintf)("%s.in-addr.arpa.", reversed);
17352
+ return `${reversed}.in-addr.arpa.`;
18764
17353
  }
18765
17354
  /**
18766
17355
  * Returns true if the given address is a multicast address
18767
- * @memberof Address4
18768
- * @instance
18769
17356
  * @returns {boolean}
18770
17357
  */
18771
17358
  isMulticast() {
18772
- return this.isInSubnet(new Address4("224.0.0.0/4"));
17359
+ return this.isHostInSubnet(MULTICAST_V4);
17360
+ }
17361
+ /**
17362
+ * 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`).
17363
+ * @returns {boolean}
17364
+ */
17365
+ isPrivate() {
17366
+ return PRIVATE_V4.some((subnet) => this.isHostInSubnet(subnet));
17367
+ }
17368
+ /**
17369
+ * Returns true if the address is in the loopback range `127.0.0.0/8` ([RFC 1122](https://datatracker.ietf.org/doc/html/rfc1122)).
17370
+ * @returns {boolean}
17371
+ */
17372
+ isLoopback() {
17373
+ return this.isHostInSubnet(LOOPBACK_V4);
17374
+ }
17375
+ /**
17376
+ * 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)).
17377
+ * @returns {boolean}
17378
+ */
17379
+ isLinkLocal() {
17380
+ return this.isHostInSubnet(LINK_LOCAL_V4);
17381
+ }
17382
+ /**
17383
+ * Returns true if the address is the unspecified address `0.0.0.0`.
17384
+ * @returns {boolean}
17385
+ */
17386
+ isUnspecified() {
17387
+ return this.isHostInSubnet(UNSPECIFIED_V4);
17388
+ }
17389
+ /**
17390
+ * Returns true if the address is the limited broadcast address `255.255.255.255` ([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)).
17391
+ * @returns {boolean}
17392
+ */
17393
+ isBroadcast() {
17394
+ return this.isHostInSubnet(BROADCAST_V4);
17395
+ }
17396
+ /**
17397
+ * 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)).
17398
+ * @returns {boolean}
17399
+ */
17400
+ isCGNAT() {
17401
+ return this.isHostInSubnet(CGNAT_V4);
18773
17402
  }
18774
17403
  /**
18775
17404
  * Returns a zero-padded base-2 string representation of the address
18776
- * @memberof Address4
18777
- * @instance
18778
17405
  * @returns {string}
18779
17406
  */
18780
17407
  binaryZeroPad() {
18781
- return this.bigInteger().toString(2).padStart(constants.BITS, "0");
17408
+ if (this._binaryZeroPad === void 0) this._binaryZeroPad = this.bigInt().toString(2).padStart(constants.BITS, "0");
17409
+ return this._binaryZeroPad;
18782
17410
  }
18783
17411
  /**
18784
- * Groups an IPv4 address for inclusion at the end of an IPv6 address
17412
+ * Groups an IPv4 address for inclusion at the end of an IPv6 address.
17413
+ *
17414
+ * Returns an HTML fragment: each half of the address is wrapped in a
17415
+ * `<span>` carrying the group classes an address-inspector UI hovers on.
17416
+ * The address content is HTML-escaped; anything you concatenate around it
17417
+ * is your responsibility.
18785
17418
  * @returns {String}
18786
17419
  */
18787
17420
  groupForV6() {
18788
17421
  const segments = this.parsedAddress;
18789
- return this.address.replace(constants.RE_ADDRESS, (0, sprintf_js_1.sprintf)("<span class=\"hover-group group-v4 group-6\">%s</span>.<span class=\"hover-group group-v4 group-7\">%s</span>", segments.slice(0, 2).join("."), segments.slice(2, 4).join(".")));
17422
+ return this.correctForm().replace(constants.RE_ADDRESS, `<span class="hover-group group-v4 group-6">${segments.slice(0, 2).join(".")}</span>.<span class="hover-group group-v4 group-7">${segments.slice(2, 4).join(".")}</span>`);
18790
17423
  }
18791
17424
  };
17425
+ exports.Address4 = Address4;
17426
+ const MULTICAST_V4 = new Address4("224.0.0.0/4");
17427
+ const PRIVATE_V4 = [
17428
+ new Address4("10.0.0.0/8"),
17429
+ new Address4("172.16.0.0/12"),
17430
+ new Address4("192.168.0.0/16")
17431
+ ];
17432
+ const LOOPBACK_V4 = new Address4("127.0.0.0/8");
17433
+ const LINK_LOCAL_V4 = new Address4("169.254.0.0/16");
17434
+ const UNSPECIFIED_V4 = new Address4("0.0.0.0/32");
17435
+ const BROADCAST_V4 = new Address4("255.255.255.255/32");
17436
+ const CGNAT_V4 = new Address4("100.64.0.0/10");
18792
17437
  }));
18793
17438
  //#endregion
18794
17439
  //#region ../../node_modules/ip-address/dist/v6/constants.js
@@ -18838,8 +17483,14 @@ var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
18838
17483
  "ff05::1:3/128": "Multicast (All DHCP servers in this site)",
18839
17484
  "::/128": "Unspecified",
18840
17485
  "::1/128": "Loopback",
17486
+ "::ffff:0:0/96": "IPv4-mapped",
18841
17487
  "ff00::/8": "Multicast",
18842
- "fe80::/10": "Link-local unicast"
17488
+ "fe80::/10": "Link-local unicast",
17489
+ "fc00::/7": "Unique local",
17490
+ "2002::/16": "6to4",
17491
+ "2001:db8::/32": "Documentation",
17492
+ "64:ff9b::/96": "NAT64 (well-known)",
17493
+ "64:ff9b:1::/48": "NAT64 (local-use)"
18843
17494
  };
18844
17495
  /**
18845
17496
  * A regular expression that matches bad characters in an IPv6 address
@@ -18865,31 +17516,35 @@ var require_constants$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
18865
17516
  * @static
18866
17517
  */
18867
17518
  exports.RE_ZONE_STRING = /%.*$/;
18868
- exports.RE_URL = /* @__PURE__ */ new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);
18869
- exports.RE_URL_WITH_PORT = /* @__PURE__ */ new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);
17519
+ exports.RE_URL = /^(?:\[([0-9a-f:.]+)\]|([0-9a-f:.]+))(?:[/?#].*)?$/i;
17520
+ exports.RE_URL_WITH_PORT = /^\[([0-9a-f:.]+)\]:([0-9]{1,5})(?:[/?#].*)?$/i;
18870
17521
  }));
18871
17522
  //#endregion
18872
17523
  //#region ../../node_modules/ip-address/dist/v6/helpers.js
18873
17524
  var require_helpers$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
18874
17525
  Object.defineProperty(exports, "__esModule", { value: true });
18875
- exports.simpleGroup = exports.spanLeadingZeroes = exports.spanAll = exports.spanAllZeroes = void 0;
18876
- const sprintf_js_1 = require_sprintf();
17526
+ exports.escapeHtml = escapeHtml;
17527
+ exports.spanAllZeroes = spanAllZeroes;
17528
+ exports.spanAll = spanAll;
17529
+ exports.spanLeadingZeroes = spanLeadingZeroes;
17530
+ exports.simpleGroup = simpleGroup;
17531
+ function escapeHtml(s) {
17532
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
17533
+ }
18877
17534
  /**
18878
17535
  * @returns {String} the string with all zeroes contained in a <span>
18879
17536
  */
18880
17537
  function spanAllZeroes(s) {
18881
- return s.replace(/(0+)/g, "<span class=\"zero\">$1</span>");
17538
+ return escapeHtml(s).replace(/(0+)/g, "<span class=\"zero\">$1</span>");
18882
17539
  }
18883
- exports.spanAllZeroes = spanAllZeroes;
18884
17540
  /**
18885
17541
  * @returns {String} the string with each character contained in a <span>
18886
17542
  */
18887
17543
  function spanAll(s, offset = 0) {
18888
- return s.split("").map((n, i) => (0, sprintf_js_1.sprintf)("<span class=\"digit value-%s position-%d\">%s</span>", n, i + offset, spanAllZeroes(n))).join("");
17544
+ return s.split("").map((n, i) => `<span class="digit value-${escapeHtml(n)} position-${i + offset}">${spanAllZeroes(n)}</span>`).join("");
18889
17545
  }
18890
- exports.spanAll = spanAll;
18891
17546
  function spanLeadingZeroesSimple(group) {
18892
- return group.replace(/^(0+)/, "<span class=\"zero\">$1</span>");
17547
+ return escapeHtml(group).replace(/^(0+)/, "<span class=\"zero\">$1</span>");
18893
17548
  }
18894
17549
  /**
18895
17550
  * @returns {String} the string with leading zeroes contained in a <span>
@@ -18897,7 +17552,6 @@ var require_helpers$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
18897
17552
  function spanLeadingZeroes(address) {
18898
17553
  return address.split(":").map((g) => spanLeadingZeroesSimple(g)).join(":");
18899
17554
  }
18900
- exports.spanLeadingZeroes = spanLeadingZeroes;
18901
17555
  /**
18902
17556
  * Groups an address
18903
17557
  * @returns {String} a grouped address
@@ -18905,10 +17559,9 @@ var require_helpers$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
18905
17559
  function simpleGroup(addressString, offset = 0) {
18906
17560
  return addressString.split(":").map((g, i) => {
18907
17561
  if (/group-v4/.test(g)) return g;
18908
- return (0, sprintf_js_1.sprintf)("<span class=\"hover-group group-%d\">%s</span>", i + offset, spanLeadingZeroesSimple(g));
17562
+ return `<span class="hover-group group-${i + offset}">${spanLeadingZeroesSimple(g)}</span>`;
18909
17563
  });
18910
17564
  }
18911
- exports.simpleGroup = simpleGroup;
18912
17565
  }));
18913
17566
  //#endregion
18914
17567
  //#region ../../node_modules/ip-address/dist/v6/regular-expressions.js
@@ -18945,18 +17598,19 @@ var require_regular_expressions = /* @__PURE__ */ __commonJSMin(((exports) => {
18945
17598
  return result;
18946
17599
  };
18947
17600
  Object.defineProperty(exports, "__esModule", { value: true });
18948
- exports.possibleElisions = exports.simpleRegularExpression = exports.ADDRESS_BOUNDARY = exports.padGroup = exports.groupPossibilities = void 0;
17601
+ exports.ADDRESS_BOUNDARY = void 0;
17602
+ exports.groupPossibilities = groupPossibilities;
17603
+ exports.padGroup = padGroup;
17604
+ exports.simpleRegularExpression = simpleRegularExpression;
17605
+ exports.possibleElisions = possibleElisions;
18949
17606
  const v6 = __importStar(require_constants$6());
18950
- const sprintf_js_1 = require_sprintf();
18951
17607
  function groupPossibilities(possibilities) {
18952
- return (0, sprintf_js_1.sprintf)("(%s)", possibilities.join("|"));
17608
+ return `(${possibilities.join("|")})`;
18953
17609
  }
18954
- exports.groupPossibilities = groupPossibilities;
18955
17610
  function padGroup(group) {
18956
- if (group.length < 4) return (0, sprintf_js_1.sprintf)("0{0,%d}%s", 4 - group.length, group);
17611
+ if (group.length < 4) return `0{0,${4 - group.length}}${group}`;
18957
17612
  return group;
18958
17613
  }
18959
- exports.padGroup = padGroup;
18960
17614
  exports.ADDRESS_BOUNDARY = "[^A-Fa-f0-9:]";
18961
17615
  function simpleRegularExpression(groups) {
18962
17616
  const zeroIndexes = [];
@@ -18973,7 +17627,6 @@ var require_regular_expressions = /* @__PURE__ */ __commonJSMin(((exports) => {
18973
17627
  possibilities.push(groups.map(padGroup).join(":"));
18974
17628
  return groupPossibilities(possibilities);
18975
17629
  }
18976
- exports.simpleRegularExpression = simpleRegularExpression;
18977
17630
  function possibleElisions(elidedGroups, moreLeft, moreRight) {
18978
17631
  const left = moreLeft ? "" : ":";
18979
17632
  const right = moreRight ? "" : ":";
@@ -18981,13 +17634,12 @@ var require_regular_expressions = /* @__PURE__ */ __commonJSMin(((exports) => {
18981
17634
  if (!moreLeft && !moreRight) possibilities.push("::");
18982
17635
  if (moreLeft && moreRight) possibilities.push("");
18983
17636
  if (moreRight && !moreLeft || !moreRight && moreLeft) possibilities.push(":");
18984
- possibilities.push((0, sprintf_js_1.sprintf)("%s(:0{1,4}){1,%d}", left, elidedGroups - 1));
18985
- possibilities.push((0, sprintf_js_1.sprintf)("(0{1,4}:){1,%d}%s", elidedGroups - 1, right));
18986
- possibilities.push((0, sprintf_js_1.sprintf)("(0{1,4}:){%d}0{1,4}", elidedGroups - 1));
18987
- for (let groups = 1; groups < elidedGroups - 1; groups++) for (let position = 1; position < elidedGroups - groups; position++) possibilities.push((0, sprintf_js_1.sprintf)("(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}", position, elidedGroups - position - groups - 1));
17637
+ possibilities.push(`${left}(:0{1,4}){1,${elidedGroups - 1}}`);
17638
+ possibilities.push(`(0{1,4}:){1,${elidedGroups - 1}}${right}`);
17639
+ possibilities.push(`(0{1,4}:){${elidedGroups - 1}}0{1,4}`);
17640
+ for (let groups = 1; groups < elidedGroups - 1; groups++) for (let position = 1; position < elidedGroups - groups; position++) possibilities.push(`(0{1,4}:){${position}}:(0{1,4}:){${elidedGroups - position - groups - 1}}0{1,4}`);
18988
17641
  return groupPossibilities(possibilities);
18989
17642
  }
18990
- exports.possibleElisions = possibleElisions;
18991
17643
  }));
18992
17644
  //#endregion
18993
17645
  //#region ../../node_modules/ip-address/dist/ipv6.js
@@ -19032,8 +17684,8 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19032
17684
  const ipv4_1 = require_ipv4();
19033
17685
  const regular_expressions_1 = require_regular_expressions();
19034
17686
  const address_error_1 = require_address_error();
19035
- const jsbn_1 = require_jsbn();
19036
- const sprintf_js_1 = require_sprintf();
17687
+ const common_1 = require_common$1();
17688
+ const isCorrect6 = common.isCorrect(constants6.BITS);
19037
17689
  function assert(condition) {
19038
17690
  if (!condition) throw new Error("Assertion failed.");
19039
17691
  }
@@ -19056,12 +17708,19 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19056
17708
  return s1.concat(["compact"]).concat(s2);
19057
17709
  }
19058
17710
  function paddedHex(octet) {
19059
- return (0, sprintf_js_1.sprintf)("%04x", parseInt(octet, 16));
17711
+ return parseInt(octet, 16).toString(16).padStart(4, "0");
19060
17712
  }
19061
17713
  function unsignByte(b) {
19062
17714
  return b & 255;
19063
17715
  }
19064
- exports.Address6 = class Address6 {
17716
+ /**
17717
+ * Represents an IPv6 address
17718
+ * @param {string} address - An IPv6 address string
17719
+ * @param {number} [groups=8] - How many octets to parse
17720
+ * @example
17721
+ * var address = new Address6('2001::/32');
17722
+ */
17723
+ var Address6 = class Address6 {
19065
17724
  constructor(address, optionalGroups) {
19066
17725
  this.addressMinusSuffix = "";
19067
17726
  this.parsedSubnet = "";
@@ -19071,18 +17730,23 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19071
17730
  this.zone = "";
19072
17731
  /**
19073
17732
  * Returns true if the given address is in the subnet of the current address
19074
- * @memberof Address6
19075
- * @instance
19076
17733
  * @returns {boolean}
19077
17734
  */
19078
17735
  this.isInSubnet = common.isInSubnet;
19079
17736
  /**
17737
+ * Returns true if this address's host bits fall inside the given subnet,
17738
+ * ignoring this address's own subnet mask. Prefer this over `isInSubnet`
17739
+ * when classifying a single address, so the answer doesn't change with the
17740
+ * CIDR suffix the caller happened to write — notably when the address came
17741
+ * from untrusted input and the result backs a trust-boundary decision.
17742
+ * @returns {boolean}
17743
+ */
17744
+ this.isHostInSubnet = common.isHostInSubnet;
17745
+ /**
19080
17746
  * Returns true if the address is correct, false otherwise
19081
- * @memberof Address6
19082
- * @instance
19083
17747
  * @returns {boolean}
19084
17748
  */
19085
- this.isCorrect = common.isCorrect(constants6.BITS);
17749
+ this.isCorrect = isCorrect6;
19086
17750
  if (optionalGroups === void 0) this.groups = constants6.GROUPS;
19087
17751
  else this.groups = optionalGroups;
19088
17752
  this.address = address;
@@ -19093,7 +17757,8 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19093
17757
  this.subnet = `/${this.subnetMask}`;
19094
17758
  if (Number.isNaN(this.subnetMask) || this.subnetMask < 0 || this.subnetMask > constants6.BITS) throw new address_error_1.AddressError("Invalid subnet mask.");
19095
17759
  address = address.replace(constants6.RE_SUBNET_STRING, "");
19096
- } else if (/\//.test(address)) throw new address_error_1.AddressError("Invalid subnet mask.");
17760
+ }
17761
+ if (/\//.test(address)) throw new address_error_1.AddressError("Invalid subnet mask.");
19097
17762
  const zone = constants6.RE_ZONE_STRING.exec(address);
19098
17763
  if (zone) {
19099
17764
  this.zone = zone[0];
@@ -19102,78 +17767,161 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19102
17767
  this.addressMinusSuffix = address;
19103
17768
  this.parsedAddress = this.parse(this.addressMinusSuffix);
19104
17769
  }
17770
+ /**
17771
+ * Returns true if the given string is a valid IPv6 address (with optional
17772
+ * CIDR subnet and zone identifier), false otherwise. Host bits in the
17773
+ * subnet portion are allowed (e.g. `2001:db8::1/32` is valid); for strict
17774
+ * network-address validation compare `correctForm()` to
17775
+ * `startAddress().correctForm()`, or use `networkForm()`.
17776
+ */
19105
17777
  static isValid(address) {
19106
17778
  try {
19107
17779
  new Address6(address);
19108
17780
  return true;
19109
- } catch (e) {
17781
+ } catch {
19110
17782
  return false;
19111
17783
  }
19112
17784
  }
19113
17785
  /**
19114
- * Convert a BigInteger to a v6 address object
19115
- * @memberof Address6
19116
- * @static
19117
- * @param {BigInteger} bigInteger - a BigInteger to convert
17786
+ * Convert a BigInt to a v6 address object. The value must be in the
17787
+ * range `[0, 2**128 - 1]`; otherwise `AddressError` is thrown.
17788
+ * @param {bigint} bigInt - a BigInt to convert
19118
17789
  * @returns {Address6}
19119
17790
  * @example
19120
- * var bigInteger = new BigInteger('1000000000000');
19121
- * var address = Address6.fromBigInteger(bigInteger);
17791
+ * var bigInt = BigInt('1000000000000');
17792
+ * var address = Address6.fromBigInt(bigInt);
19122
17793
  * address.correctForm(); // '::e8:d4a5:1000'
19123
17794
  */
19124
- static fromBigInteger(bigInteger) {
19125
- const hex = bigInteger.toString(16).padStart(32, "0");
17795
+ static fromBigInt(bigInt) {
17796
+ if (bigInt < BigInt(0) || bigInt > (BigInt(1) << BigInt(constants6.BITS)) - BigInt(1)) throw new address_error_1.AddressError("IPv6 BigInt must be in the range 0 to 2**128 - 1");
17797
+ const hex = bigInt.toString(16).padStart(32, "0");
19126
17798
  const groups = [];
19127
- let i;
19128
- for (i = 0; i < constants6.GROUPS; i++) groups.push(hex.slice(i * 4, (i + 1) * 4));
17799
+ for (let i = 0; i < constants6.GROUPS; i++) groups.push(hex.slice(i * 4, (i + 1) * 4));
19129
17800
  return new Address6(groups.join(":"));
19130
17801
  }
19131
17802
  /**
19132
- * Convert a URL (with optional port number) to an address object
19133
- * @memberof Address6
19134
- * @static
19135
- * @param {string} url - a URL with optional port number
17803
+ * Parse a URL (with optional bracketed host and port) into an address and
17804
+ * port. Returns either `{ address, port }` on success or
17805
+ * `{ error, address: null, port: null }` if the URL could not be parsed.
17806
+ * Ports are returned as numbers (or `null` if absent or out of range).
19136
17807
  * @example
19137
17808
  * var addressAndPort = Address6.fromURL('http://[ffff::]:8080/foo/');
19138
17809
  * addressAndPort.address.correctForm(); // 'ffff::'
19139
17810
  * addressAndPort.port; // 8080
19140
17811
  */
19141
17812
  static fromURL(url) {
17813
+ var _a;
19142
17814
  let host;
19143
17815
  let port = null;
19144
17816
  let result;
19145
- if (url.indexOf("[") !== -1 && url.indexOf("]:") !== -1) {
19146
- result = constants6.RE_URL_WITH_PORT.exec(url);
17817
+ let error;
17818
+ const stripped = url.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
17819
+ if (stripped.indexOf("[") !== -1 && stripped.indexOf("]:") !== -1) {
17820
+ error = "failed to parse address with port";
17821
+ result = constants6.RE_URL_WITH_PORT.exec(stripped);
19147
17822
  if (result === null) return {
19148
- error: "failed to parse address with port",
17823
+ error,
19149
17824
  address: null,
19150
17825
  port: null
19151
17826
  };
19152
17827
  host = result[1];
19153
17828
  port = result[2];
19154
- } else if (url.indexOf("/") !== -1) {
19155
- url = url.replace(/^[a-z0-9]+:\/\//, "");
19156
- result = constants6.RE_URL.exec(url);
17829
+ } else {
17830
+ error = "failed to parse address from URL";
17831
+ result = constants6.RE_URL.exec(stripped);
19157
17832
  if (result === null) return {
19158
- error: "failed to parse address from URL",
17833
+ error,
19159
17834
  address: null,
19160
17835
  port: null
19161
17836
  };
19162
- host = result[1];
19163
- } else host = url;
17837
+ host = (_a = result[1]) !== null && _a !== void 0 ? _a : result[2];
17838
+ }
19164
17839
  if (port) {
19165
17840
  port = parseInt(port, 10);
19166
- if (port < 0 || port > 65536) port = null;
17841
+ if (port < 0 || port > 65535) port = null;
19167
17842
  } else port = null;
17843
+ let address;
17844
+ try {
17845
+ address = new Address6(host);
17846
+ } catch {
17847
+ return {
17848
+ error,
17849
+ address: null,
17850
+ port: null
17851
+ };
17852
+ }
19168
17853
  return {
19169
- address: new Address6(host),
17854
+ address,
19170
17855
  port
19171
17856
  };
19172
17857
  }
19173
17858
  /**
17859
+ * Construct an `Address6` from an address and a hex subnet mask given as
17860
+ * separate strings (e.g. as returned by Node's `os.networkInterfaces()`).
17861
+ * Throws `AddressError` if the mask is non-contiguous (e.g.
17862
+ * `ffff::ffff`).
17863
+ * @example
17864
+ * var address = Address6.fromAddressAndMask('fe80::1', 'ffff:ffff:ffff:ffff::');
17865
+ * address.subnetMask; // 64
17866
+ */
17867
+ static fromAddressAndMask(address, mask) {
17868
+ return new Address6(`${address}/${common.prefixLengthFromMask(new Address6(mask).bigInt(), constants6.BITS)}`);
17869
+ }
17870
+ /**
17871
+ * Construct an `Address6` from an address and a Cisco-style wildcard mask
17872
+ * given as separate strings (e.g. `::ffff:ffff:ffff:ffff` for a `/64`).
17873
+ * The wildcard mask is the bitwise inverse of the subnet mask. Throws
17874
+ * `AddressError` if the mask is non-contiguous.
17875
+ * @example
17876
+ * var address = Address6.fromAddressAndWildcardMask('fe80::1', '::ffff:ffff:ffff:ffff');
17877
+ * address.subnetMask; // 64
17878
+ */
17879
+ static fromAddressAndWildcardMask(address, wildcardMask) {
17880
+ const mask = new Address6(wildcardMask).bigInt() ^ (BigInt(1) << BigInt(constants6.BITS)) - BigInt(1);
17881
+ return new Address6(`${address}/${common.prefixLengthFromMask(mask, constants6.BITS)}`);
17882
+ }
17883
+ /**
17884
+ * Construct an `Address6` from a wildcard pattern with trailing `*`
17885
+ * groups. The number of trailing wildcards determines the prefix
17886
+ * length: each `*` represents 16 bits. `::` is expanded to zero groups
17887
+ * (not wildcards) before evaluating trailing wildcards.
17888
+ *
17889
+ * Only trailing whole-group wildcards are supported. Partial-group
17890
+ * wildcards (e.g. `2001:db8::0*`) and interior wildcards (e.g.
17891
+ * `*::1`) throw `AddressError`.
17892
+ * @example
17893
+ * Address6.fromWildcard('2001:db8:*:*:*:*:*:*').subnet; // '/32'
17894
+ * Address6.fromWildcard('2001:db8::*').subnet; // '/112'
17895
+ * Address6.fromWildcard('*:*:*:*:*:*:*:*').subnet; // '/0'
17896
+ */
17897
+ static fromWildcard(input) {
17898
+ if (input.includes("%") || input.includes("/")) throw new address_error_1.AddressError("Wildcard pattern must not include a zone or CIDR suffix");
17899
+ const halves = input.split("::");
17900
+ if (halves.length > 2) throw new address_error_1.AddressError("Wildcard pattern cannot contain more than one '::'");
17901
+ let groups;
17902
+ if (halves.length === 2) {
17903
+ const left = halves[0] === "" ? [] : halves[0].split(":");
17904
+ const right = halves[1] === "" ? [] : halves[1].split(":");
17905
+ const remaining = constants6.GROUPS - left.length - right.length;
17906
+ if (remaining < 1) throw new address_error_1.AddressError("Wildcard pattern with '::' has too many groups");
17907
+ groups = [
17908
+ ...left,
17909
+ ...new Array(remaining).fill("0"),
17910
+ ...right
17911
+ ];
17912
+ } else groups = input.split(":");
17913
+ if (groups.length !== constants6.GROUPS) throw new address_error_1.AddressError("Wildcard pattern must have 8 groups");
17914
+ let firstWildcard = -1;
17915
+ for (let i = 0; i < groups.length; i++) if (groups[i] === "*") {
17916
+ if (firstWildcard === -1) firstWildcard = i;
17917
+ } else if (firstWildcard !== -1) throw new address_error_1.AddressError("Wildcard `*` must only appear in trailing groups (e.g. `2001:db8:*:*:*:*:*:*`)");
17918
+ const trailing = firstWildcard === -1 ? 0 : groups.length - firstWildcard;
17919
+ const replaced = groups.map((g) => g === "*" ? "0" : g);
17920
+ const subnetBits = constants6.BITS - trailing * 16;
17921
+ return new Address6(`${replaced.join(":")}/${subnetBits}`);
17922
+ }
17923
+ /**
19174
17924
  * Create an IPv6-mapped address given an IPv4 address
19175
- * @memberof Address6
19176
- * @static
19177
17925
  * @param {string} address - An IPv4 address string
19178
17926
  * @returns {Address6}
19179
17927
  * @example
@@ -19188,8 +17936,6 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19188
17936
  }
19189
17937
  /**
19190
17938
  * Return an address from ip6.arpa form
19191
- * @memberof Address6
19192
- * @static
19193
17939
  * @param {string} arpaFormAddress - an 'ip6.arpa' form address
19194
17940
  * @returns {Adress6}
19195
17941
  * @example
@@ -19210,17 +17956,13 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19210
17956
  }
19211
17957
  /**
19212
17958
  * Return the Microsoft UNC transcription of the address
19213
- * @memberof Address6
19214
- * @instance
19215
17959
  * @returns {String} the Microsoft UNC transcription of the address
19216
17960
  */
19217
17961
  microsoftTranscription() {
19218
- return (0, sprintf_js_1.sprintf)("%s.ipv6-literal.net", this.correctForm().replace(/:/g, "-"));
17962
+ return `${this.correctForm().replace(/:/g, "-")}.ipv6-literal.net`;
19219
17963
  }
19220
17964
  /**
19221
17965
  * Return the first n bits of the address, defaulting to the subnet mask
19222
- * @memberof Address6
19223
- * @instance
19224
17966
  * @param {number} [mask=subnet] - the number of bits to mask
19225
17967
  * @returns {String} the first n bits of the address as a string
19226
17968
  */
@@ -19229,110 +17971,124 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19229
17971
  }
19230
17972
  /**
19231
17973
  * Return the number of possible subnets of a given size in the address
19232
- * @memberof Address6
19233
- * @instance
19234
- * @param {number} [size=128] - the subnet size
17974
+ * @param {number} [subnetSize=128] - the subnet size
19235
17975
  * @returns {String}
19236
17976
  */
19237
17977
  possibleSubnets(subnetSize = 128) {
19238
17978
  const subnetPowers = constants6.BITS - this.subnetMask - Math.abs(subnetSize - constants6.BITS);
19239
17979
  if (subnetPowers < 0) return "0";
19240
- return addCommas(new jsbn_1.BigInteger("2", 10).pow(subnetPowers).toString(10));
17980
+ return addCommas((BigInt("2") ** BigInt(subnetPowers)).toString(10));
19241
17981
  }
19242
17982
  /**
19243
17983
  * Helper function getting start address.
19244
- * @memberof Address6
19245
- * @instance
19246
- * @returns {BigInteger}
17984
+ * @returns {bigint}
19247
17985
  */
19248
17986
  _startAddress() {
19249
- return new jsbn_1.BigInteger(this.mask() + "0".repeat(constants6.BITS - this.subnetMask), 2);
17987
+ return BigInt(`0b${this.mask() + "0".repeat(constants6.BITS - this.subnetMask)}`);
19250
17988
  }
19251
17989
  /**
19252
17990
  * The first address in the range given by this address' subnet
19253
17991
  * Often referred to as the Network Address.
19254
- * @memberof Address6
19255
- * @instance
19256
17992
  * @returns {Address6}
19257
17993
  */
19258
17994
  startAddress() {
19259
- return Address6.fromBigInteger(this._startAddress());
17995
+ return Address6.fromBigInt(this._startAddress());
19260
17996
  }
19261
17997
  /**
19262
17998
  * The first host address in the range given by this address's subnet ie
19263
17999
  * the first address after the Network Address
19264
- * @memberof Address6
19265
- * @instance
19266
18000
  * @returns {Address6}
19267
18001
  */
19268
18002
  startAddressExclusive() {
19269
- const adjust = new jsbn_1.BigInteger("1");
19270
- return Address6.fromBigInteger(this._startAddress().add(adjust));
18003
+ const adjust = BigInt("1");
18004
+ return Address6.fromBigInt(this._startAddress() + adjust);
19271
18005
  }
19272
18006
  /**
19273
18007
  * Helper function getting end address.
19274
- * @memberof Address6
19275
- * @instance
19276
- * @returns {BigInteger}
18008
+ * @returns {bigint}
19277
18009
  */
19278
18010
  _endAddress() {
19279
- return new jsbn_1.BigInteger(this.mask() + "1".repeat(constants6.BITS - this.subnetMask), 2);
18011
+ return BigInt(`0b${this.mask() + "1".repeat(constants6.BITS - this.subnetMask)}`);
19280
18012
  }
19281
18013
  /**
19282
18014
  * The last address in the range given by this address' subnet
19283
18015
  * Often referred to as the Broadcast
19284
- * @memberof Address6
19285
- * @instance
19286
18016
  * @returns {Address6}
19287
18017
  */
19288
18018
  endAddress() {
19289
- return Address6.fromBigInteger(this._endAddress());
18019
+ return Address6.fromBigInt(this._endAddress());
19290
18020
  }
19291
18021
  /**
19292
18022
  * The last host address in the range given by this address's subnet ie
19293
18023
  * the last address prior to the Broadcast Address
19294
- * @memberof Address6
19295
- * @instance
19296
18024
  * @returns {Address6}
19297
18025
  */
19298
18026
  endAddressExclusive() {
19299
- const adjust = new jsbn_1.BigInteger("1");
19300
- return Address6.fromBigInteger(this._endAddress().subtract(adjust));
18027
+ const adjust = BigInt("1");
18028
+ return Address6.fromBigInt(this._endAddress() - adjust);
19301
18029
  }
19302
18030
  /**
19303
- * Return the scope of the address
19304
- * @memberof Address6
19305
- * @instance
18031
+ * The hex form of the subnet mask, e.g. `ffff:ffff:ffff:ffff::` for a
18032
+ * `/64`. Returns an `Address6`; call `.correctForm()` for the string.
18033
+ * @returns {Address6}
18034
+ */
18035
+ subnetMaskAddress() {
18036
+ return Address6.fromBigInt(BigInt(`0b${"1".repeat(this.subnetMask)}${"0".repeat(constants6.BITS - this.subnetMask)}`));
18037
+ }
18038
+ /**
18039
+ * The Cisco-style wildcard mask, e.g. `::ffff:ffff:ffff:ffff` for a
18040
+ * `/64`. This is the bitwise inverse of `subnetMaskAddress()`. Returns
18041
+ * an `Address6`; call `.correctForm()` for the string.
18042
+ * @returns {Address6}
18043
+ */
18044
+ wildcardMask() {
18045
+ return Address6.fromBigInt(BigInt(`0b${"0".repeat(this.subnetMask)}${"1".repeat(constants6.BITS - this.subnetMask)}`));
18046
+ }
18047
+ /**
18048
+ * The network address in CIDR string form, e.g. `2001:db8::/32` for
18049
+ * `2001:db8::1/32`. For an address with no explicit subnet the prefix
18050
+ * is `/128`, e.g. `networkForm()` on `2001:db8::1` returns
18051
+ * `2001:db8::1/128`.
18052
+ * @returns {string}
18053
+ */
18054
+ networkForm() {
18055
+ return `${this.startAddress().correctForm()}/${this.subnetMask}`;
18056
+ }
18057
+ /**
18058
+ * Return the scope of the address. The 4-bit scope field
18059
+ * ([RFC 4291 §2.7](https://datatracker.ietf.org/doc/html/rfc4291#section-2.7))
18060
+ * is only defined for multicast addresses; for unicast addresses the scope
18061
+ * is derived from the address type per
18062
+ * [RFC 4007 §6](https://datatracker.ietf.org/doc/html/rfc4007#section-6).
19306
18063
  * @returns {String}
19307
18064
  */
19308
18065
  getScope() {
19309
- let scope = constants6.SCOPES[this.getBits(12, 16).intValue()];
19310
- if (this.getType() === "Global unicast" && scope !== "Link local") scope = "Global";
19311
- return scope || "Unknown";
18066
+ const type = this.getType();
18067
+ if (type === "Multicast" || type.startsWith("Multicast ")) return constants6.SCOPES[parseInt(this.getBits(12, 16).toString(10), 10)] || "Unknown";
18068
+ if (type === "Link-local unicast" || type === "Loopback") return "Link local";
18069
+ if (type === "Unspecified") return "Unknown";
18070
+ return "Global";
19312
18071
  }
19313
18072
  /**
19314
18073
  * Return the type of the address
19315
- * @memberof Address6
19316
- * @instance
19317
18074
  * @returns {String}
19318
18075
  */
19319
18076
  getType() {
19320
- for (const subnet of Object.keys(constants6.TYPES)) if (this.isInSubnet(new Address6(subnet))) return constants6.TYPES[subnet];
18077
+ for (let i = 0; i < TYPE_SUBNETS.length; i++) {
18078
+ const entry = TYPE_SUBNETS[i];
18079
+ if (this.isHostInSubnet(entry[0])) return entry[1];
18080
+ }
19321
18081
  return "Global unicast";
19322
18082
  }
19323
18083
  /**
19324
- * Return the bits in the given range as a BigInteger
19325
- * @memberof Address6
19326
- * @instance
19327
- * @returns {BigInteger}
18084
+ * Return the bits in the given range as a BigInt
18085
+ * @returns {bigint}
19328
18086
  */
19329
18087
  getBits(start, end) {
19330
- return new jsbn_1.BigInteger(this.getBitsBase2(start, end), 2);
18088
+ return BigInt(`0b${this.getBitsBase2(start, end)}`);
19331
18089
  }
19332
18090
  /**
19333
18091
  * Return the bits in the given range as a base-2 string
19334
- * @memberof Address6
19335
- * @instance
19336
18092
  * @returns {String}
19337
18093
  */
19338
18094
  getBitsBase2(start, end) {
@@ -19340,8 +18096,6 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19340
18096
  }
19341
18097
  /**
19342
18098
  * Return the bits in the given range as a base-16 string
19343
- * @memberof Address6
19344
- * @instance
19345
18099
  * @returns {String}
19346
18100
  */
19347
18101
  getBitsBase16(start, end) {
@@ -19351,8 +18105,6 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19351
18105
  }
19352
18106
  /**
19353
18107
  * Return the bits that are set past the subnet mask length
19354
- * @memberof Address6
19355
- * @instance
19356
18108
  * @returns {String}
19357
18109
  */
19358
18110
  getBitsPastSubnet() {
@@ -19360,10 +18112,8 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19360
18112
  }
19361
18113
  /**
19362
18114
  * Return the reversed ip6.arpa form of the address
19363
- * @memberof Address6
19364
18115
  * @param {Object} options
19365
18116
  * @param {boolean} options.omitSuffix - omit the "ip6.arpa" suffix
19366
- * @instance
19367
18117
  * @returns {String}
19368
18118
  */
19369
18119
  reverseForm(options) {
@@ -19372,16 +18122,16 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19372
18122
  const reversed = this.canonicalForm().replace(/:/g, "").split("").slice(0, characters).reverse().join(".");
19373
18123
  if (characters > 0) {
19374
18124
  if (options.omitSuffix) return reversed;
19375
- return (0, sprintf_js_1.sprintf)("%s.ip6.arpa.", reversed);
18125
+ return `${reversed}.ip6.arpa.`;
19376
18126
  }
19377
18127
  if (options.omitSuffix) return "";
19378
18128
  return "ip6.arpa.";
19379
18129
  }
19380
18130
  /**
19381
- * Return the correct form of the address
19382
- * @memberof Address6
19383
- * @instance
19384
- * @returns {String}
18131
+ * Returns the address in correct form, per
18132
+ * [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952): leading zeros
18133
+ * stripped, the longest run of zero groups collapsed to `::`, and hex digits
18134
+ * lowercased (e.g. `2001:db8::1`). This is the recommended form for display.
19385
18135
  */
19386
18136
  correctForm() {
19387
18137
  let i;
@@ -19405,14 +18155,12 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19405
18155
  for (i = 0; i < groups.length; i++) if (groups[i] !== "compact") groups[i] = parseInt(groups[i], 16).toString(16);
19406
18156
  let correct = groups.join(":");
19407
18157
  correct = correct.replace(/^compact$/, "::");
19408
- correct = correct.replace(/^compact|compact$/, ":");
18158
+ correct = correct.replace(/(^compact)|(compact$)/, ":");
19409
18159
  correct = correct.replace(/compact/, "");
19410
18160
  return correct;
19411
18161
  }
19412
18162
  /**
19413
18163
  * Return a zero-padded base-2 string representation of the address
19414
- * @memberof Address6
19415
- * @instance
19416
18164
  * @returns {String}
19417
18165
  * @example
19418
18166
  * var address = new Address6('2001:4860:4001:803::1011');
@@ -19421,27 +18169,52 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19421
18169
  * // 0000000000000000000000000000000000000000000000000001000000010001'
19422
18170
  */
19423
18171
  binaryZeroPad() {
19424
- return this.bigInteger().toString(2).padStart(constants6.BITS, "0");
18172
+ if (this._binaryZeroPad === void 0) this._binaryZeroPad = this.bigInt().toString(2).padStart(constants6.BITS, "0");
18173
+ return this._binaryZeroPad;
19425
18174
  }
18175
+ /**
18176
+ * Parses a v4-in-v6 string (e.g. `::ffff:192.168.0.1`) by extracting the
18177
+ * trailing IPv4 address into `this.address4` / `this.parsedAddress4` and
18178
+ * returning the address with the v4 portion converted to two v6 groups.
18179
+ * Used internally by `parse()`.
18180
+ */
19426
18181
  parse4in6(address) {
18182
+ if (address.indexOf(".") === -1) return address;
19427
18183
  const groups = address.split(":");
19428
- const address4 = groups.slice(-1)[0].match(constants4.RE_ADDRESS);
18184
+ const lastGroup = groups.slice(-1)[0];
18185
+ const v4Octets = lastGroup.split(".");
18186
+ if (v4Octets.length === constants4.GROUPS && v4Octets.every((octet) => /^\d{1,3}$/.test(octet))) {
18187
+ if (v4Octets.some((octet) => /^0\d/.test(octet))) {
18188
+ const highlighted = v4Octets.map(spanLeadingZeroes4).join(".");
18189
+ const prefix = groups.slice(0, -1).map(helpers.escapeHtml).join(":");
18190
+ const separator = groups.length > 1 ? ":" : "";
18191
+ throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", `${prefix}${separator}${highlighted}`);
18192
+ }
18193
+ }
18194
+ const address4 = lastGroup.match(constants4.RE_ADDRESS);
19429
18195
  if (address4) {
19430
18196
  this.parsedAddress4 = address4[0];
19431
- this.address4 = new ipv4_1.Address4(this.parsedAddress4);
19432
- for (let i = 0; i < this.address4.groups; i++) if (/^0[0-9]+/.test(this.address4.parsedAddress[i])) throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", address.replace(constants4.RE_ADDRESS, this.address4.parsedAddress.map(spanLeadingZeroes4).join(".")));
18197
+ const v4Suffix = this.subnetMask >= 96 ? `/${this.subnetMask - 96}` : "";
18198
+ this.address4 = new ipv4_1.Address4(`${this.parsedAddress4}${v4Suffix}`);
19433
18199
  this.v4 = true;
19434
18200
  groups[groups.length - 1] = this.address4.toGroup6();
19435
18201
  address = groups.join(":");
19436
18202
  }
19437
18203
  return address;
19438
18204
  }
18205
+ /**
18206
+ * Parses an IPv6 address string into its 8 hexadecimal groups (expanding
18207
+ * any `::` elision and any trailing v4-in-v6 portion) and stores the result
18208
+ * on `this.parsedAddress`. Called automatically by the constructor; you
18209
+ * typically don't need to call it directly. Throws `AddressError` if the
18210
+ * input is malformed.
18211
+ */
19439
18212
  parse(address) {
19440
18213
  address = this.parse4in6(address);
19441
18214
  const badCharacters = address.match(constants6.RE_BAD_CHARACTERS);
19442
- if (badCharacters) throw new address_error_1.AddressError((0, sprintf_js_1.sprintf)("Bad character%s detected in address: %s", badCharacters.length > 1 ? "s" : "", badCharacters.join("")), address.replace(constants6.RE_BAD_CHARACTERS, "<span class=\"parse-error\">$1</span>"));
18215
+ if (badCharacters) throw new address_error_1.AddressError(`Bad character${badCharacters.length > 1 ? "s" : ""} detected in address: ${badCharacters.join("")}`, address.replace(constants6.RE_BAD_CHARACTERS, "<span class=\"parse-error\">$1</span>"));
19443
18216
  const badAddress = address.match(constants6.RE_BAD_ADDRESS);
19444
- if (badAddress) throw new address_error_1.AddressError((0, sprintf_js_1.sprintf)("Address failed regex: %s", badAddress.join("")), address.replace(constants6.RE_BAD_ADDRESS, "<span class=\"parse-error\">$1</span>"));
18217
+ if (badAddress) throw new address_error_1.AddressError(`Address failed regex: ${badAddress.join("")}`, address.replace(constants6.RE_BAD_ADDRESS, "<span class=\"parse-error\">$1</span>"));
19445
18218
  let groups = [];
19446
18219
  const halves = address.split("::");
19447
18220
  if (halves.length === 2) {
@@ -19461,41 +18234,39 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19461
18234
  groups = address.split(":");
19462
18235
  this.elidedGroups = 0;
19463
18236
  } else throw new address_error_1.AddressError("Too many :: groups found");
19464
- groups = groups.map((group) => (0, sprintf_js_1.sprintf)("%x", parseInt(group, 16)));
18237
+ groups = groups.map((group) => parseInt(group, 16).toString(16));
19465
18238
  if (groups.length !== this.groups) throw new address_error_1.AddressError("Incorrect number of groups found");
19466
18239
  return groups;
19467
18240
  }
19468
18241
  /**
19469
- * Return the canonical form of the address
19470
- * @memberof Address6
19471
- * @instance
19472
- * @returns {String}
18242
+ * Returns the canonical (fully expanded) form of the address: all 8 groups,
18243
+ * each padded to 4 hex digits, with no `::` collapsing
18244
+ * (e.g. `2001:0db8:0000:0000:0000:0000:0000:0001`). Useful for sorting and
18245
+ * byte-exact comparison.
19473
18246
  */
19474
18247
  canonicalForm() {
19475
18248
  return this.parsedAddress.map(paddedHex).join(":");
19476
18249
  }
19477
18250
  /**
19478
18251
  * Return the decimal form of the address
19479
- * @memberof Address6
19480
- * @instance
19481
18252
  * @returns {String}
19482
18253
  */
19483
18254
  decimal() {
19484
- return this.parsedAddress.map((n) => (0, sprintf_js_1.sprintf)("%05d", parseInt(n, 16))).join(":");
18255
+ return this.parsedAddress.map((n) => parseInt(n, 16).toString(10).padStart(5, "0")).join(":");
19485
18256
  }
19486
18257
  /**
19487
- * Return the address as a BigInteger
19488
- * @memberof Address6
19489
- * @instance
19490
- * @returns {BigInteger}
18258
+ * Return the address as a BigInt
18259
+ * @returns {bigint}
19491
18260
  */
19492
- bigInteger() {
19493
- return new jsbn_1.BigInteger(this.parsedAddress.map(paddedHex).join(""), 16);
18261
+ bigInt() {
18262
+ return BigInt(`0x${this.parsedAddress.map(paddedHex).join("")}`);
19494
18263
  }
19495
18264
  /**
19496
- * Return the last two groups of this address as an IPv4 address string
19497
- * @memberof Address6
19498
- * @instance
18265
+ * Return the last two groups of this address as an IPv4 address string.
18266
+ * If this address carries a CIDR prefix that covers the trailing 32 bits
18267
+ * (i.e. `subnetMask >= 96`), the resulting `Address4` inherits the
18268
+ * corresponding v4 prefix (`subnetMask - 96`); otherwise it defaults to
18269
+ * `/32`.
19499
18270
  * @returns {Address4}
19500
18271
  * @example
19501
18272
  * var address = new Address6('2001:4860:4001::1825:bf11');
@@ -19503,12 +18274,17 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19503
18274
  */
19504
18275
  to4() {
19505
18276
  const binary = this.binaryZeroPad().split("");
19506
- return ipv4_1.Address4.fromHex(new jsbn_1.BigInteger(binary.slice(96, 128).join(""), 2).toString(16));
18277
+ const hex = BigInt(`0b${binary.slice(96, 128).join("")}`).toString(16).padStart(8, "0");
18278
+ if (this.subnetMask >= 96) {
18279
+ const v4Mask = this.subnetMask - 96;
18280
+ const groups = [];
18281
+ for (let i = 0; i < 8; i += 2) groups.push(parseInt(hex.slice(i, i + 2), 16));
18282
+ return new ipv4_1.Address4(`${groups.join(".")}/${v4Mask}`);
18283
+ }
18284
+ return ipv4_1.Address4.fromHex(hex);
19507
18285
  }
19508
18286
  /**
19509
18287
  * Return the v4-in-v6 form of the address
19510
- * @memberof Address6
19511
- * @instance
19512
18288
  * @returns {String}
19513
18289
  */
19514
18290
  to4in6() {
@@ -19516,28 +18292,28 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19516
18292
  const correct = new Address6(this.parsedAddress.slice(0, 6).join(":"), 6).correctForm();
19517
18293
  let infix = "";
19518
18294
  if (!/:$/.test(correct)) infix = ":";
19519
- return correct + infix + address4.address;
18295
+ return correct + infix + address4.correctForm();
19520
18296
  }
19521
18297
  /**
19522
- * Return an object containing the Teredo properties of the address
19523
- * @memberof Address6
19524
- * @instance
19525
- * @returns {Object}
18298
+ * Decodes the Teredo tunneling fields embedded in this address. Returns the
18299
+ * Teredo prefix, server IPv4, client IPv4, raw flag bits, cone-NAT flag,
18300
+ * UDP port, and Microsoft-format flag breakdown (reserved, universal/local,
18301
+ * group/individual, nonce). Only meaningful for addresses in `2001::/32`.
19526
18302
  */
19527
18303
  inspectTeredo() {
19528
18304
  const prefix = this.getBitsBase16(0, 32);
19529
- const udpPort = this.getBits(80, 96).xor(new jsbn_1.BigInteger("ffff", 16)).toString();
18305
+ const udpPort = (this.getBits(80, 96) ^ BigInt("0xffff")).toString();
19530
18306
  const server4 = ipv4_1.Address4.fromHex(this.getBitsBase16(32, 64));
19531
- const client4 = ipv4_1.Address4.fromHex(this.getBits(96, 128).xor(new jsbn_1.BigInteger("ffffffff", 16)).toString(16));
19532
- const flags = this.getBits(64, 80);
18307
+ const bitsForClient4 = this.getBits(96, 128);
18308
+ const client4 = ipv4_1.Address4.fromHex((bitsForClient4 ^ BigInt("0xffffffff")).toString(16).padStart(8, "0"));
19533
18309
  const flagsBase2 = this.getBitsBase2(64, 80);
19534
- const coneNat = flags.testBit(15);
19535
- const reserved = flags.testBit(14);
19536
- const groupIndividual = flags.testBit(8);
19537
- const universalLocal = flags.testBit(9);
19538
- const nonce = new jsbn_1.BigInteger(flagsBase2.slice(2, 6) + flagsBase2.slice(8, 16), 2).toString(10);
18310
+ const coneNat = (0, common_1.testBit)(flagsBase2, 15);
18311
+ const reserved = (0, common_1.testBit)(flagsBase2, 14);
18312
+ const groupIndividual = (0, common_1.testBit)(flagsBase2, 8);
18313
+ const universalLocal = (0, common_1.testBit)(flagsBase2, 9);
18314
+ const nonce = BigInt(`0b${flagsBase2.slice(2, 6) + flagsBase2.slice(8, 16)}`).toString(10);
19539
18315
  return {
19540
- prefix: (0, sprintf_js_1.sprintf)("%s:%s", prefix.slice(0, 4), prefix.slice(4, 8)),
18316
+ prefix: `${prefix.slice(0, 4)}:${prefix.slice(4, 8)}`,
19541
18317
  server4: server4.address,
19542
18318
  client4: client4.address,
19543
18319
  flags: flagsBase2,
@@ -19552,23 +18328,20 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19552
18328
  };
19553
18329
  }
19554
18330
  /**
19555
- * Return an object containing the 6to4 properties of the address
19556
- * @memberof Address6
19557
- * @instance
19558
- * @returns {Object}
18331
+ * Decodes the 6to4 tunneling fields embedded in this address. Returns the
18332
+ * 6to4 prefix and the embedded IPv4 gateway address. Only meaningful for
18333
+ * addresses in `2002::/16`.
19559
18334
  */
19560
18335
  inspect6to4() {
19561
18336
  const prefix = this.getBitsBase16(0, 16);
19562
18337
  const gateway = ipv4_1.Address4.fromHex(this.getBitsBase16(16, 48));
19563
18338
  return {
19564
- prefix: (0, sprintf_js_1.sprintf)("%s", prefix.slice(0, 4)),
18339
+ prefix: prefix.slice(0, 4),
19565
18340
  gateway: gateway.address
19566
18341
  };
19567
18342
  }
19568
18343
  /**
19569
18344
  * Return a v6 6to4 address from a v6 v4inv6 address
19570
- * @memberof Address6
19571
- * @instance
19572
18345
  * @returns {Address6}
19573
18346
  */
19574
18347
  to6to4() {
@@ -19582,54 +18355,120 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19582
18355
  ].join(":"));
19583
18356
  }
19584
18357
  /**
19585
- * Return a byte array
19586
- * @memberof Address6
19587
- * @instance
18358
+ * Embed an IPv4 address into a NAT64 IPv6 address using the encoding
18359
+ * defined by [RFC 6052](https://datatracker.ietf.org/doc/html/rfc6052).
18360
+ * The default prefix is the well-known prefix `64:ff9b::/96`. The prefix
18361
+ * length must be one of 32, 40, 48, 56, 64, or 96; for prefixes shorter
18362
+ * than /64 the IPv4 octets are split around the reserved bits 64–71.
18363
+ * @example
18364
+ * Address6.fromAddress4Nat64('192.0.2.33').correctForm(); // '64:ff9b::c000:221'
18365
+ * Address6.fromAddress4Nat64('192.0.2.33', '2001:db8::/32').correctForm(); // '2001:db8:c000:221::'
18366
+ */
18367
+ static fromAddress4Nat64(address, prefix = "64:ff9b::/96") {
18368
+ const v4 = new ipv4_1.Address4(address);
18369
+ const prefix6 = new Address6(prefix);
18370
+ const pl = prefix6.subnetMask;
18371
+ if (pl !== 32 && pl !== 40 && pl !== 48 && pl !== 56 && pl !== 64 && pl !== 96) throw new address_error_1.AddressError("NAT64 prefix length must be 32, 40, 48, 56, 64, or 96");
18372
+ const prefixBits = prefix6.binaryZeroPad();
18373
+ const v4Bits = v4.binaryZeroPad();
18374
+ let bits;
18375
+ if (pl === 96) bits = prefixBits.slice(0, 96) + v4Bits;
18376
+ else {
18377
+ const beforeU = 64 - pl;
18378
+ bits = [
18379
+ prefixBits.slice(0, pl),
18380
+ v4Bits.slice(0, beforeU),
18381
+ "00000000",
18382
+ v4Bits.slice(beforeU),
18383
+ "0".repeat(56 - (32 - beforeU))
18384
+ ].join("");
18385
+ }
18386
+ const hex = BigInt(`0b${bits}`).toString(16).padStart(32, "0");
18387
+ const groups = [];
18388
+ for (let i = 0; i < 8; i++) groups.push(hex.slice(i * 4, (i + 1) * 4));
18389
+ return new Address6(groups.join(":"));
18390
+ }
18391
+ /**
18392
+ * Extract the embedded IPv4 address from a NAT64 IPv6 address using the
18393
+ * encoding defined by [RFC 6052](https://datatracker.ietf.org/doc/html/rfc6052).
18394
+ * The default prefix is the well-known prefix `64:ff9b::/96`. Returns
18395
+ * `null` if this address is not contained within the given prefix.
18396
+ * @example
18397
+ * new Address6('64:ff9b::c000:221').toAddress4Nat64()!.correctForm(); // '192.0.2.33'
18398
+ */
18399
+ toAddress4Nat64(prefix = "64:ff9b::/96") {
18400
+ const prefix6 = new Address6(prefix);
18401
+ const pl = prefix6.subnetMask;
18402
+ if (pl !== 32 && pl !== 40 && pl !== 48 && pl !== 56 && pl !== 64 && pl !== 96) throw new address_error_1.AddressError("NAT64 prefix length must be 32, 40, 48, 56, 64, or 96");
18403
+ if (!this.isHostInSubnet(prefix6)) return null;
18404
+ const bits = this.binaryZeroPad();
18405
+ let v4Bits;
18406
+ if (pl === 96) v4Bits = bits.slice(96, 128);
18407
+ else {
18408
+ const beforeU = 64 - pl;
18409
+ v4Bits = bits.slice(pl, pl + beforeU) + bits.slice(72, 72 + (32 - beforeU));
18410
+ }
18411
+ const octets = [];
18412
+ for (let i = 0; i < 4; i++) octets.push(parseInt(v4Bits.slice(i * 8, (i + 1) * 8), 2).toString());
18413
+ return new ipv4_1.Address4(octets.join("."));
18414
+ }
18415
+ /**
18416
+ * Return a byte array.
18417
+ *
18418
+ * To get a Node.js `Buffer`, wrap the result: `Buffer.from(address.toByteArray())`.
19588
18419
  * @returns {Array}
19589
18420
  */
19590
18421
  toByteArray() {
19591
- const byteArray = this.bigInteger().toByteArray();
19592
- if (byteArray.length === 17 && byteArray[0] === 0) return byteArray.slice(1);
19593
- return byteArray;
18422
+ const value = this.bigInt().toString(16).padStart(constants6.BITS / 4, "0");
18423
+ const bytes = [];
18424
+ for (let i = 0, length = value.length; i < length; i += 2) bytes.push(parseInt(value.substring(i, i + 2), 16));
18425
+ return bytes;
19594
18426
  }
19595
18427
  /**
19596
- * Return an unsigned byte array
19597
- * @memberof Address6
19598
- * @instance
18428
+ * Return an unsigned byte array.
18429
+ *
18430
+ * To get a Node.js `Buffer`, wrap the result: `Buffer.from(address.toUnsignedByteArray())`.
19599
18431
  * @returns {Array}
19600
18432
  */
19601
18433
  toUnsignedByteArray() {
19602
18434
  return this.toByteArray().map(unsignByte);
19603
18435
  }
19604
18436
  /**
19605
- * Convert a byte array to an Address6 object
19606
- * @memberof Address6
19607
- * @static
18437
+ * Convert a byte array to an Address6 object.
18438
+ *
18439
+ * Accepts unsigned bytes (0 to 255) or signed bytes (-128 to 127, as an
18440
+ * `Int8Array` or a Java `byte[]` holds them), folding signed values to their
18441
+ * unsigned equivalent. Throws `AddressError` unless given exactly 16
18442
+ * integers from -128 to 255.
18443
+ *
18444
+ * To convert from a Node.js `Buffer`, spread it: `Address6.fromByteArray([...buf])`.
19608
18445
  * @returns {Address6}
19609
18446
  */
19610
18447
  static fromByteArray(bytes) {
18448
+ common.assertByteArray(bytes, 16, "IPv6", -128);
19611
18449
  return this.fromUnsignedByteArray(bytes.map(unsignByte));
19612
18450
  }
19613
18451
  /**
19614
- * Convert an unsigned byte array to an Address6 object
19615
- * @memberof Address6
19616
- * @static
18452
+ * Convert an unsigned byte array to an Address6 object.
18453
+ *
18454
+ * Throws `AddressError` unless given exactly 16 integers from 0 to 255.
18455
+ *
18456
+ * To convert from a Node.js `Buffer`, spread it: `Address6.fromUnsignedByteArray([...buf])`.
19617
18457
  * @returns {Address6}
19618
18458
  */
19619
18459
  static fromUnsignedByteArray(bytes) {
19620
- const BYTE_MAX = new jsbn_1.BigInteger("256", 10);
19621
- let result = new jsbn_1.BigInteger("0", 10);
19622
- let multiplier = new jsbn_1.BigInteger("1", 10);
18460
+ common.assertByteArray(bytes, 16, "IPv6", 0);
18461
+ const BYTE_MAX = BigInt("256");
18462
+ let result = BigInt("0");
18463
+ let multiplier = BigInt("1");
19623
18464
  for (let i = bytes.length - 1; i >= 0; i--) {
19624
- result = result.add(multiplier.multiply(new jsbn_1.BigInteger(bytes[i].toString(10), 10)));
19625
- multiplier = multiplier.multiply(BYTE_MAX);
18465
+ result += multiplier * BigInt(bytes[i].toString(10));
18466
+ multiplier *= BYTE_MAX;
19626
18467
  }
19627
- return Address6.fromBigInteger(result);
18468
+ return Address6.fromBigInt(result);
19628
18469
  }
19629
18470
  /**
19630
18471
  * Returns true if the address is in the canonical form, false otherwise
19631
- * @memberof Address6
19632
- * @instance
19633
18472
  * @returns {boolean}
19634
18473
  */
19635
18474
  isCanonical() {
@@ -19637,69 +18476,170 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19637
18476
  }
19638
18477
  /**
19639
18478
  * Returns true if the address is a link local address, false otherwise
19640
- * @memberof Address6
19641
- * @instance
19642
18479
  * @returns {boolean}
19643
18480
  */
19644
18481
  isLinkLocal() {
18482
+ const embedded = this.embeddedIPv4();
18483
+ if (embedded) return embedded.isLinkLocal();
19645
18484
  if (this.getBitsBase2(0, 64) === "1111111010000000000000000000000000000000000000000000000000000000") return true;
19646
18485
  return false;
19647
18486
  }
19648
18487
  /**
19649
18488
  * Returns true if the address is a multicast address, false otherwise
19650
- * @memberof Address6
19651
- * @instance
19652
18489
  * @returns {boolean}
19653
18490
  */
19654
18491
  isMulticast() {
19655
- return this.getType() === "Multicast";
18492
+ const embedded = this.embeddedIPv4();
18493
+ if (embedded) return embedded.isMulticast();
18494
+ const type = this.getType();
18495
+ return type === "Multicast" || type.startsWith("Multicast ");
19656
18496
  }
19657
18497
  /**
19658
- * Returns true if the address is a v4-in-v6 address, false otherwise
19659
- * @memberof Address6
19660
- * @instance
18498
+ * Returns true if the address was written in v4-in-v6 dotted-quad notation
18499
+ * (e.g. `::ffff:127.0.0.1`), false otherwise. This is a notation-level flag
18500
+ * and does not reflect whether the address bits lie in the IPv4-mapped
18501
+ * (`::ffff:0:0/96`) subnet — for that, see {@link isMapped4}.
19661
18502
  * @returns {boolean}
19662
18503
  */
19663
18504
  is4() {
19664
18505
  return this.v4;
19665
18506
  }
19666
18507
  /**
18508
+ * Returns true if the address is an IPv4-mapped IPv6 address in
18509
+ * `::ffff:0:0/96` ([RFC 4291 §2.5.5.2](https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.2)),
18510
+ * false otherwise. Unlike {@link is4}, this checks the underlying address
18511
+ * bits rather than the textual notation, so `::ffff:127.0.0.1` and
18512
+ * `::ffff:7f00:1` both return true.
18513
+ * @returns {boolean}
18514
+ */
18515
+ isMapped4() {
18516
+ return this.isHostInSubnet(IPV4_MAPPED_SUBNET);
18517
+ }
18518
+ /**
18519
+ * If this address embeds a routable IPv4 address — i.e. it is IPv4-mapped
18520
+ * (`::ffff:0:0/96`) or sits in the NAT64 well-known prefix (`64:ff9b::/96`,
18521
+ * [RFC 6052](https://datatracker.ietf.org/doc/html/rfc6052)) — return that
18522
+ * embedded address as an {@link Address4}; otherwise return null.
18523
+ *
18524
+ * The special-property checks (`isLoopback`, `isLinkLocal`, `isMulticast`,
18525
+ * `isUnspecified`, `isPrivate`, `isCGNAT`, `isBroadcast`) call this first and
18526
+ * delegate to the embedded {@link Address4} when present, so a literal such as
18527
+ * `::ffff:127.0.0.1` is classified by what it actually reaches (loopback)
18528
+ * rather than by its IPv6 wrapper (which `getType()` reports as IPv4-mapped).
18529
+ * This matters wherever the checks back a trust-boundary decision (e.g. an
18530
+ * SSRF allow/deny filter): without normalization, `::ffff:10.0.0.1`,
18531
+ * `::ffff:169.254.169.254`, `64:ff9b::7f00:1`, etc. would all read as
18532
+ * non-internal.
18533
+ * @returns {Address4 | null}
18534
+ */
18535
+ embeddedIPv4() {
18536
+ if (this.isMapped4() || this.isHostInSubnet(NAT64_WELL_KNOWN_SUBNET)) return this.to4();
18537
+ return null;
18538
+ }
18539
+ /**
19667
18540
  * Returns true if the address is a Teredo address, false otherwise
19668
- * @memberof Address6
19669
- * @instance
19670
18541
  * @returns {boolean}
19671
18542
  */
19672
18543
  isTeredo() {
19673
- return this.isInSubnet(new Address6("2001::/32"));
18544
+ return this.isHostInSubnet(TEREDO_SUBNET);
19674
18545
  }
19675
18546
  /**
19676
18547
  * Returns true if the address is a 6to4 address, false otherwise
19677
- * @memberof Address6
19678
- * @instance
19679
18548
  * @returns {boolean}
19680
18549
  */
19681
18550
  is6to4() {
19682
- return this.isInSubnet(new Address6("2002::/16"));
18551
+ return this.isHostInSubnet(SIX_TO_FOUR_SUBNET);
19683
18552
  }
19684
18553
  /**
19685
18554
  * Returns true if the address is a loopback address, false otherwise
19686
- * @memberof Address6
19687
- * @instance
19688
18555
  * @returns {boolean}
19689
18556
  */
19690
18557
  isLoopback() {
18558
+ const embedded = this.embeddedIPv4();
18559
+ if (embedded) return embedded.isLoopback();
19691
18560
  return this.getType() === "Loopback";
19692
18561
  }
19693
18562
  /**
19694
- * @returns {String} the address in link form with a default port of 80
18563
+ * Returns true if the address is a Unique Local Address in `fc00::/7` ([RFC 4193](https://datatracker.ietf.org/doc/html/rfc4193)). ULAs are the IPv6 equivalent of IPv4 [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private addresses.
18564
+ * @returns {boolean}
18565
+ */
18566
+ isULA() {
18567
+ return this.isHostInSubnet(ULA_SUBNET);
18568
+ }
18569
+ /**
18570
+ * Returns true if the address is private, i.e. a Unique Local Address in
18571
+ * `fc00::/7` ([RFC 4193](https://datatracker.ietf.org/doc/html/rfc4193)) or an
18572
+ * IPv4-mapped / NAT64 address whose embedded IPv4 address is in one of the
18573
+ * [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private ranges
18574
+ * (e.g. `::ffff:10.0.0.1`). This is the IPv6 counterpart to
18575
+ * {@link Address4.isPrivate}; use it instead of {@link isULA} when you need to
18576
+ * catch mapped RFC 1918 addresses as well as native ULAs.
18577
+ * @returns {boolean}
18578
+ */
18579
+ isPrivate() {
18580
+ const embedded = this.embeddedIPv4();
18581
+ if (embedded) return embedded.isPrivate();
18582
+ return this.isULA();
18583
+ }
18584
+ /**
18585
+ * Returns true if the address is an IPv4-mapped / NAT64 address whose embedded
18586
+ * IPv4 address is in the carrier-grade NAT range `100.64.0.0/10`
18587
+ * ([RFC 6598](https://datatracker.ietf.org/doc/html/rfc6598)), false
18588
+ * otherwise. There is no native IPv6 CGNAT range, so this only ever returns
18589
+ * true for an embedded IPv4 address (e.g. `::ffff:100.64.0.1`).
18590
+ * @returns {boolean}
18591
+ */
18592
+ isCGNAT() {
18593
+ const embedded = this.embeddedIPv4();
18594
+ if (embedded) return embedded.isCGNAT();
18595
+ return false;
18596
+ }
18597
+ /**
18598
+ * Returns true if the address is an IPv4-mapped / NAT64 address whose embedded
18599
+ * IPv4 address is the limited broadcast address `255.255.255.255`
18600
+ * ([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)), false otherwise.
18601
+ * There is no IPv6 broadcast, so this only ever returns true for an embedded
18602
+ * IPv4 address (e.g. `::ffff:255.255.255.255`).
18603
+ * @returns {boolean}
18604
+ */
18605
+ isBroadcast() {
18606
+ const embedded = this.embeddedIPv4();
18607
+ if (embedded) return embedded.isBroadcast();
18608
+ return false;
18609
+ }
18610
+ /**
18611
+ * Returns true if the address is the unspecified address `::`.
18612
+ * @returns {boolean}
18613
+ */
18614
+ isUnspecified() {
18615
+ const embedded = this.embeddedIPv4();
18616
+ if (embedded) return embedded.isUnspecified();
18617
+ return this.getType() === "Unspecified";
18618
+ }
18619
+ /**
18620
+ * Returns true if the address is in the documentation prefix `2001:db8::/32` ([RFC 3849](https://datatracker.ietf.org/doc/html/rfc3849)).
18621
+ * @returns {boolean}
18622
+ */
18623
+ isDocumentation() {
18624
+ return this.isHostInSubnet(DOCUMENTATION_SUBNET);
18625
+ }
18626
+ /**
18627
+ * Returns the address as an HTTP URL with the host bracketed, e.g.
18628
+ * `http://[2001:db8::1]/`. If `optionalPort` is provided it is appended,
18629
+ * e.g. `http://[2001:db8::1]:8080/`.
19695
18630
  */
19696
18631
  href(optionalPort) {
19697
18632
  if (optionalPort === void 0) optionalPort = "";
19698
- else optionalPort = (0, sprintf_js_1.sprintf)(":%s", optionalPort);
19699
- return (0, sprintf_js_1.sprintf)("http://[%s]%s/", this.correctForm(), optionalPort);
18633
+ else optionalPort = `:${optionalPort}`;
18634
+ return `http://[${this.correctForm()}]${optionalPort}/`;
19700
18635
  }
19701
18636
  /**
19702
- * @returns {String} a link suitable for conveying the address via a URL hash
18637
+ * Returns an HTML `<a>` element whose `href` encodes the address in a URL
18638
+ * hash fragment (default prefix `/#address=`). Useful for linking between
18639
+ * pages of an address-inspector UI.
18640
+ * @param options.className - CSS class for the rendered `<a>` element
18641
+ * @param options.prefix - hash prefix prepended to the address (default `/#address=`)
18642
+ * @param options.v4 - when true, render the address in v4-in-v6 form
19703
18643
  */
19704
18644
  link(options) {
19705
18645
  if (!options) options = {};
@@ -19708,24 +18648,32 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19708
18648
  if (options.v4 === void 0) options.v4 = false;
19709
18649
  let formFunction = this.correctForm;
19710
18650
  if (options.v4) formFunction = this.to4in6;
19711
- if (options.className) return (0, sprintf_js_1.sprintf)("<a href=\"%1$s%2$s\" class=\"%3$s\">%2$s</a>", options.prefix, formFunction.call(this), options.className);
19712
- return (0, sprintf_js_1.sprintf)("<a href=\"%1$s%2$s\">%2$s</a>", options.prefix, formFunction.call(this));
18651
+ const form = formFunction.call(this);
18652
+ const safeHref = helpers.escapeHtml(`${options.prefix}${form}`);
18653
+ const safeForm = helpers.escapeHtml(form);
18654
+ if (options.className) return `<a href="${safeHref}" class="${helpers.escapeHtml(options.className)}">${safeForm}</a>`;
18655
+ return `<a href="${safeHref}">${safeForm}</a>`;
19713
18656
  }
19714
18657
  /**
19715
- * Groups an address
18658
+ * Groups an address.
18659
+ *
18660
+ * Returns an HTML fragment: each group is wrapped in a `<span>` carrying
18661
+ * the group classes an address-inspector UI hovers on. The address content
18662
+ * is HTML-escaped; anything you concatenate around it is your
18663
+ * responsibility.
19716
18664
  * @returns {String}
19717
18665
  */
19718
18666
  group() {
19719
- if (this.elidedGroups === 0) return helpers.simpleGroup(this.address).join(":");
18667
+ if (this.elidedGroups === 0) return helpers.simpleGroup(this.addressMinusSuffix).join(":");
19720
18668
  assert(typeof this.elidedGroups === "number");
19721
18669
  assert(typeof this.elisionBegin === "number");
19722
18670
  const output = [];
19723
- const [left, right] = this.address.split("::");
18671
+ const [left, right] = this.addressMinusSuffix.split("::");
19724
18672
  if (left.length) output.push(...helpers.simpleGroup(left));
19725
18673
  else output.push("");
19726
18674
  const classes = ["hover-group"];
19727
- for (let i = this.elisionBegin; i < this.elisionBegin + this.elidedGroups; i++) classes.push((0, sprintf_js_1.sprintf)("group-%d", i));
19728
- output.push((0, sprintf_js_1.sprintf)("<span class=\"%s\"></span>", classes.join(" ")));
18675
+ for (let i = this.elisionBegin; i < this.elisionBegin + this.elidedGroups; i++) classes.push(`group-${i}`);
18676
+ output.push(`<span class="${classes.join(" ")}"></span>`);
19729
18677
  if (right.length) output.push(...helpers.simpleGroup(right, this.elisionEnd));
19730
18678
  else output.push("");
19731
18679
  if (this.is4()) {
@@ -19738,8 +18686,6 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19738
18686
  /**
19739
18687
  * Generate a regular expression string that can be used to find or validate
19740
18688
  * all variations of this address
19741
- * @memberof Address6
19742
- * @instance
19743
18689
  * @param {boolean} substringSearch
19744
18690
  * @returns {string}
19745
18691
  */
@@ -19770,8 +18716,6 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19770
18716
  /**
19771
18717
  * Generate a regular expression that can be used to find or validate all
19772
18718
  * variations of this address.
19773
- * @memberof Address6
19774
- * @instance
19775
18719
  * @param {boolean} substringSearch
19776
18720
  * @returns {RegExp}
19777
18721
  */
@@ -19779,6 +18723,14 @@ var require_ipv6 = /* @__PURE__ */ __commonJSMin(((exports) => {
19779
18723
  return new RegExp(this.regularExpressionString(substringSearch), "i");
19780
18724
  }
19781
18725
  };
18726
+ exports.Address6 = Address6;
18727
+ const TYPE_SUBNETS = Object.keys(constants6.TYPES).map((subnet) => [new Address6(subnet), constants6.TYPES[subnet]]);
18728
+ const TEREDO_SUBNET = new Address6("2001::/32");
18729
+ const SIX_TO_FOUR_SUBNET = new Address6("2002::/16");
18730
+ const ULA_SUBNET = new Address6("fc00::/7");
18731
+ const DOCUMENTATION_SUBNET = new Address6("2001:db8::/32");
18732
+ const IPV4_MAPPED_SUBNET = new Address6("::ffff:0:0/96");
18733
+ const NAT64_WELL_KNOWN_SUBNET = new Address6("64:ff9b::/96");
19782
18734
  }));
19783
18735
  //#endregion
19784
18736
  //#region ../../node_modules/ip-address/dist/ip-address.js
@@ -19816,21 +18768,21 @@ var require_ip_address = /* @__PURE__ */ __commonJSMin(((exports) => {
19816
18768
  };
19817
18769
  Object.defineProperty(exports, "__esModule", { value: true });
19818
18770
  exports.v6 = exports.AddressError = exports.Address6 = exports.Address4 = void 0;
19819
- const ipv4_1 = require_ipv4();
18771
+ var ipv4_1 = require_ipv4();
19820
18772
  Object.defineProperty(exports, "Address4", {
19821
18773
  enumerable: true,
19822
18774
  get: function() {
19823
18775
  return ipv4_1.Address4;
19824
18776
  }
19825
18777
  });
19826
- const ipv6_1 = require_ipv6();
18778
+ var ipv6_1 = require_ipv6();
19827
18779
  Object.defineProperty(exports, "Address6", {
19828
18780
  enumerable: true,
19829
18781
  get: function() {
19830
18782
  return ipv6_1.Address6;
19831
18783
  }
19832
18784
  });
19833
- const address_error_1 = require_address_error();
18785
+ var address_error_1 = require_address_error();
19834
18786
  Object.defineProperty(exports, "AddressError", {
19835
18787
  enumerable: true,
19836
18788
  get: function() {
@@ -19896,7 +18848,7 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
19896
18848
  * @param remoteHost { SocksRemoteHost }
19897
18849
  */
19898
18850
  function isValidSocksRemoteHost(remoteHost) {
19899
- return remoteHost && typeof remoteHost.host === "string" && typeof remoteHost.port === "number" && remoteHost.port >= 0 && remoteHost.port <= 65535;
18851
+ return remoteHost && typeof remoteHost.host === "string" && Buffer.byteLength(remoteHost.host) < 256 && typeof remoteHost.port === "number" && remoteHost.port >= 0 && remoteHost.port <= 65535;
19900
18852
  }
19901
18853
  /**
19902
18854
  * Validates a SocksProxy
@@ -19913,7 +18865,7 @@ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
19913
18865
  return typeof value === "number" && value > 0;
19914
18866
  }
19915
18867
  function ipv4ToInt32(ip) {
19916
- return new ip_address_1.Address4(ip).toArray().reduce((acc, part) => (acc << 8) + part, 0);
18868
+ return new ip_address_1.Address4(ip).toArray().reduce((acc, part) => (acc << 8) + part, 0) >>> 0;
19917
18869
  }
19918
18870
  exports.ipv4ToInt32 = ipv4ToInt32;
19919
18871
  function int32ToIpv4(int32) {
@@ -25923,7 +24875,7 @@ var require_utils$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
25923
24875
  })();
25924
24876
  }));
25925
24877
  //#endregion
25926
- //#region ../../node_modules/source-map/lib/base64.js
24878
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/base64.js
25927
24879
  var require_base64 = /* @__PURE__ */ __commonJSMin(((exports) => {
25928
24880
  var intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
25929
24881
  /**
@@ -25957,7 +24909,7 @@ var require_base64 = /* @__PURE__ */ __commonJSMin(((exports) => {
25957
24909
  };
25958
24910
  }));
25959
24911
  //#endregion
25960
- //#region ../../node_modules/source-map/lib/base64-vlq.js
24912
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/base64-vlq.js
25961
24913
  var require_base64_vlq = /* @__PURE__ */ __commonJSMin(((exports) => {
25962
24914
  var base64 = require_base64();
25963
24915
  var VLQ_BASE_SHIFT = 5;
@@ -26022,7 +24974,7 @@ var require_base64_vlq = /* @__PURE__ */ __commonJSMin(((exports) => {
26022
24974
  };
26023
24975
  }));
26024
24976
  //#endregion
26025
- //#region ../../node_modules/source-map/lib/util.js
24977
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/util.js
26026
24978
  var require_util$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
26027
24979
  /**
26028
24980
  * This is a helper function for getting values from parameter/options
@@ -26304,7 +25256,7 @@ var require_util$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
26304
25256
  exports.computeSourceURL = computeSourceURL;
26305
25257
  }));
26306
25258
  //#endregion
26307
- //#region ../../node_modules/source-map/lib/array-set.js
25259
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/array-set.js
26308
25260
  var require_array_set = /* @__PURE__ */ __commonJSMin(((exports) => {
26309
25261
  var util = require_util$7();
26310
25262
  var has = Object.prototype.hasOwnProperty;
@@ -26396,7 +25348,7 @@ var require_array_set = /* @__PURE__ */ __commonJSMin(((exports) => {
26396
25348
  exports.ArraySet = ArraySet;
26397
25349
  }));
26398
25350
  //#endregion
26399
- //#region ../../node_modules/source-map/lib/mapping-list.js
25351
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/mapping-list.js
26400
25352
  var require_mapping_list = /* @__PURE__ */ __commonJSMin(((exports) => {
26401
25353
  var util = require_util$7();
26402
25354
  /**
@@ -26465,7 +25417,7 @@ var require_mapping_list = /* @__PURE__ */ __commonJSMin(((exports) => {
26465
25417
  exports.MappingList = MappingList;
26466
25418
  }));
26467
25419
  //#endregion
26468
- //#region ../../node_modules/source-map/lib/source-map-generator.js
25420
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/source-map-generator.js
26469
25421
  var require_source_map_generator = /* @__PURE__ */ __commonJSMin(((exports) => {
26470
25422
  var base64VLQ = require_base64_vlq();
26471
25423
  var util = require_util$7();
@@ -26734,7 +25686,7 @@ var require_source_map_generator = /* @__PURE__ */ __commonJSMin(((exports) => {
26734
25686
  exports.SourceMapGenerator = SourceMapGenerator;
26735
25687
  }));
26736
25688
  //#endregion
26737
- //#region ../../node_modules/source-map/lib/binary-search.js
25689
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/binary-search.js
26738
25690
  var require_binary_search = /* @__PURE__ */ __commonJSMin(((exports) => {
26739
25691
  exports.GREATEST_LOWER_BOUND = 1;
26740
25692
  exports.LEAST_UPPER_BOUND = 2;
@@ -26795,7 +25747,7 @@ var require_binary_search = /* @__PURE__ */ __commonJSMin(((exports) => {
26795
25747
  };
26796
25748
  }));
26797
25749
  //#endregion
26798
- //#region ../../node_modules/source-map/lib/quick-sort.js
25750
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/quick-sort.js
26799
25751
  var require_quick_sort = /* @__PURE__ */ __commonJSMin(((exports) => {
26800
25752
  /**
26801
25753
  * Swap the elements indexed by `x` and `y` in the array `ary`.
@@ -26864,7 +25816,7 @@ var require_quick_sort = /* @__PURE__ */ __commonJSMin(((exports) => {
26864
25816
  };
26865
25817
  }));
26866
25818
  //#endregion
26867
- //#region ../../node_modules/source-map/lib/source-map-consumer.js
25819
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/source-map-consumer.js
26868
25820
  var require_source_map_consumer = /* @__PURE__ */ __commonJSMin(((exports) => {
26869
25821
  var util = require_util$7();
26870
25822
  var binarySearch = require_binary_search();
@@ -27613,7 +26565,7 @@ var require_source_map_consumer = /* @__PURE__ */ __commonJSMin(((exports) => {
27613
26565
  exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
27614
26566
  }));
27615
26567
  //#endregion
27616
- //#region ../../node_modules/source-map/lib/source-node.js
26568
+ //#region ../../node_modules/escodegen/node_modules/source-map/lib/source-node.js
27617
26569
  var require_source_node = /* @__PURE__ */ __commonJSMin(((exports) => {
27618
26570
  var SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
27619
26571
  var util = require_util$7();
@@ -27897,7 +26849,7 @@ var require_source_node = /* @__PURE__ */ __commonJSMin(((exports) => {
27897
26849
  exports.SourceNode = SourceNode;
27898
26850
  }));
27899
26851
  //#endregion
27900
- //#region ../../node_modules/source-map/source-map.js
26852
+ //#region ../../node_modules/escodegen/node_modules/source-map/source-map.js
27901
26853
  var require_source_map = /* @__PURE__ */ __commonJSMin(((exports) => {
27902
26854
  exports.SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
27903
26855
  exports.SourceMapConsumer = require_source_map_consumer().SourceMapConsumer;