Skip to content

Commit 5516583

Browse files
committed
1 parent 6a392f3 commit 5516583

27 files changed

+171
-1965
lines changed

DEPENDENCIES.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,6 @@ graph LR;
302302
init-package-json-->semver;
303303
init-package-json-->validate-npm-package-license;
304304
init-package-json-->validate-npm-package-name;
305-
ip-address-->jsbn;
306-
ip-address-->sprintf-js;
307305
is-cidr-->cidr-regex;
308306
isaacs-brace-expansion-->isaacs-balanced-match["@isaacs/balanced-match"];
309307
isaacs-cliui-->string-width-cjs;

node_modules/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
!/is-cidr
103103
!/is-fullwidth-code-point
104104
!/jackspeak
105-
!/jsbn
106105
!/json-parse-even-better-errors
107106
!/json-stringify-nice
108107
!/jsonparse
@@ -197,7 +196,6 @@
197196
!/spdx-exceptions
198197
!/spdx-expression-parse
199198
!/spdx-license-ids
200-
!/sprintf-js
201199
!/ssri
202200
!/string-width-cjs
203201
!/string-width

node_modules/ip-address/dist/address-error.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ class AddressError extends Error {
55
constructor(message, parseMessage) {
66
super(message);
77
this.name = 'AddressError';
8-
if (parseMessage !== null) {
9-
this.parseMessage = parseMessage;
10-
}
8+
this.parseMessage = parseMessage;
119
}
1210
}
1311
exports.AddressError = AddressError;

node_modules/ip-address/dist/common.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.isCorrect = exports.isInSubnet = void 0;
3+
exports.isInSubnet = isInSubnet;
4+
exports.isCorrect = isCorrect;
5+
exports.numberToPaddedHex = numberToPaddedHex;
6+
exports.stringToPaddedHex = stringToPaddedHex;
7+
exports.testBit = testBit;
48
function isInSubnet(address) {
59
if (this.subnetMask < address.subnetMask) {
610
return false;
@@ -10,7 +14,6 @@ function isInSubnet(address) {
1014
}
1115
return false;
1216
}
13-
exports.isInSubnet = isInSubnet;
1417
function isCorrect(defaultBits) {
1518
return function () {
1619
if (this.addressMinusSuffix !== this.correctForm()) {
@@ -22,5 +25,22 @@ function isCorrect(defaultBits) {
2225
return this.parsedSubnet === String(this.subnetMask);
2326
};
2427
}
25-
exports.isCorrect = isCorrect;
28+
function numberToPaddedHex(number) {
29+
return number.toString(16).padStart(2, '0');
30+
}
31+
function stringToPaddedHex(numberString) {
32+
return numberToPaddedHex(parseInt(numberString, 10));
33+
}
34+
/**
35+
* @param binaryValue Binary representation of a value (e.g. `10`)
36+
* @param position Byte position, where 0 is the least significant bit
37+
*/
38+
function testBit(binaryValue, position) {
39+
const { length } = binaryValue;
40+
if (position > length) {
41+
return false;
42+
}
43+
const positionInString = length - position;
44+
return binaryValue.substring(positionInString, positionInString + 1) === '1';
45+
}
2646
//# sourceMappingURL=common.js.map

node_modules/ip-address/dist/ip-address.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
2424
};
2525
Object.defineProperty(exports, "__esModule", { value: true });
2626
exports.v6 = exports.AddressError = exports.Address6 = exports.Address4 = void 0;
27-
const ipv4_1 = require("./ipv4");
27+
var ipv4_1 = require("./ipv4");
2828
Object.defineProperty(exports, "Address4", { enumerable: true, get: function () { return ipv4_1.Address4; } });
29-
const ipv6_1 = require("./ipv6");
29+
var ipv6_1 = require("./ipv6");
3030
Object.defineProperty(exports, "Address6", { enumerable: true, get: function () { return ipv6_1.Address6; } });
31-
const address_error_1 = require("./address-error");
31+
var address_error_1 = require("./address-error");
3232
Object.defineProperty(exports, "AddressError", { enumerable: true, get: function () { return address_error_1.AddressError; } });
3333
const helpers = __importStar(require("./v6/helpers"));
3434
exports.v6 = { helpers };

node_modules/ip-address/dist/ipv4.js

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ exports.Address4 = void 0;
2828
const common = __importStar(require("./common"));
2929
const constants = __importStar(require("./v4/constants"));
3030
const address_error_1 = require("./address-error");
31-
const jsbn_1 = require("jsbn");
32-
const sprintf_js_1 = require("sprintf-js");
3331
/**
3432
* Represents an IPv4 address
3533
* @class Address4
@@ -150,7 +148,7 @@ class Address4 {
150148
* @returns {String}
151149
*/
152150
toHex() {
153-
return this.parsedAddress.map((part) => (0, sprintf_js_1.sprintf)('%02x', parseInt(part, 10))).join(':');
151+
return this.parsedAddress.map((part) => common.stringToPaddedHex(part)).join(':');
154152
}
155153
/**
156154
* Converts an IPv4 address object to an array of bytes
@@ -171,28 +169,27 @@ class Address4 {
171169
const output = [];
172170
let i;
173171
for (i = 0; i < constants.GROUPS; i += 2) {
174-
const hex = (0, sprintf_js_1.sprintf)('%02x%02x', parseInt(this.parsedAddress[i], 10), parseInt(this.parsedAddress[i + 1], 10));
175-
output.push((0, sprintf_js_1.sprintf)('%x', parseInt(hex, 16)));
172+
output.push(`${common.stringToPaddedHex(this.parsedAddress[i])}${common.stringToPaddedHex(this.parsedAddress[i + 1])}`);
176173
}
177174
return output.join(':');
178175
}
179176
/**
180-
* Returns the address as a BigInteger
177+
* Returns the address as a `bigint`
181178
* @memberof Address4
182179
* @instance
183-
* @returns {BigInteger}
180+
* @returns {bigint}
184181
*/
185-
bigInteger() {
186-
return new jsbn_1.BigInteger(this.parsedAddress.map((n) => (0, sprintf_js_1.sprintf)('%02x', parseInt(n, 10))).join(''), 16);
182+
bigInt() {
183+
return BigInt(`0x${this.parsedAddress.map((n) => common.stringToPaddedHex(n)).join('')}`);
187184
}
188185
/**
189186
* Helper function getting start address.
190187
* @memberof Address4
191188
* @instance
192-
* @returns {BigInteger}
189+
* @returns {bigint}
193190
*/
194191
_startAddress() {
195-
return new jsbn_1.BigInteger(this.mask() + '0'.repeat(constants.BITS - this.subnetMask), 2);
192+
return BigInt(`0b${this.mask() + '0'.repeat(constants.BITS - this.subnetMask)}`);
196193
}
197194
/**
198195
* The first address in the range given by this address' subnet.
@@ -202,7 +199,7 @@ class Address4 {
202199
* @returns {Address4}
203200
*/
204201
startAddress() {
205-
return Address4.fromBigInteger(this._startAddress());
202+
return Address4.fromBigInt(this._startAddress());
206203
}
207204
/**
208205
* The first host address in the range given by this address's subnet ie
@@ -212,17 +209,17 @@ class Address4 {
212209
* @returns {Address4}
213210
*/
214211
startAddressExclusive() {
215-
const adjust = new jsbn_1.BigInteger('1');
216-
return Address4.fromBigInteger(this._startAddress().add(adjust));
212+
const adjust = BigInt('1');
213+
return Address4.fromBigInt(this._startAddress() + adjust);
217214
}
218215
/**
219216
* Helper function getting end address.
220217
* @memberof Address4
221218
* @instance
222-
* @returns {BigInteger}
219+
* @returns {bigint}
223220
*/
224221
_endAddress() {
225-
return new jsbn_1.BigInteger(this.mask() + '1'.repeat(constants.BITS - this.subnetMask), 2);
222+
return BigInt(`0b${this.mask() + '1'.repeat(constants.BITS - this.subnetMask)}`);
226223
}
227224
/**
228225
* The last address in the range given by this address' subnet
@@ -232,7 +229,7 @@ class Address4 {
232229
* @returns {Address4}
233230
*/
234231
endAddress() {
235-
return Address4.fromBigInteger(this._endAddress());
232+
return Address4.fromBigInt(this._endAddress());
236233
}
237234
/**
238235
* The last host address in the range given by this address's subnet ie
@@ -242,18 +239,18 @@ class Address4 {
242239
* @returns {Address4}
243240
*/
244241
endAddressExclusive() {
245-
const adjust = new jsbn_1.BigInteger('1');
246-
return Address4.fromBigInteger(this._endAddress().subtract(adjust));
242+
const adjust = BigInt('1');
243+
return Address4.fromBigInt(this._endAddress() - adjust);
247244
}
248245
/**
249-
* Converts a BigInteger to a v4 address object
246+
* Converts a BigInt to a v4 address object
250247
* @memberof Address4
251248
* @static
252-
* @param {BigInteger} bigInteger - a BigInteger to convert
249+
* @param {bigint} bigInt - a BigInt to convert
253250
* @returns {Address4}
254251
*/
255-
static fromBigInteger(bigInteger) {
256-
return Address4.fromInteger(parseInt(bigInteger.toString(), 10));
252+
static fromBigInt(bigInt) {
253+
return Address4.fromHex(bigInt.toString(16));
257254
}
258255
/**
259256
* Returns the first n bits of the address, defaulting to the
@@ -293,7 +290,7 @@ class Address4 {
293290
if (options.omitSuffix) {
294291
return reversed;
295292
}
296-
return (0, sprintf_js_1.sprintf)('%s.in-addr.arpa.', reversed);
293+
return `${reversed}.in-addr.arpa.`;
297294
}
298295
/**
299296
* Returns true if the given address is a multicast address
@@ -311,15 +308,19 @@ class Address4 {
311308
* @returns {string}
312309
*/
313310
binaryZeroPad() {
314-
return this.bigInteger().toString(2).padStart(constants.BITS, '0');
311+
return this.bigInt().toString(2).padStart(constants.BITS, '0');
315312
}
316313
/**
317314
* Groups an IPv4 address for inclusion at the end of an IPv6 address
318315
* @returns {String}
319316
*/
320317
groupForV6() {
321318
const segments = this.parsedAddress;
322-
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('.')));
319+
return this.address.replace(constants.RE_ADDRESS, `<span class="hover-group group-v4 group-6">${segments
320+
.slice(0, 2)
321+
.join('.')}</span>.<span class="hover-group group-v4 group-7">${segments
322+
.slice(2, 4)
323+
.join('.')}</span>`);
323324
}
324325
}
325326
exports.Address4 = Address4;

0 commit comments

Comments
 (0)