@nomicfoundation/hardhat-utils 4.2.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/src/abi.d.ts +79 -0
- package/dist/src/abi.d.ts.map +1 -0
- package/dist/src/abi.js +114 -0
- package/dist/src/abi.js.map +1 -0
- package/dist/src/errors/abi.d.ts +93 -0
- package/dist/src/errors/abi.d.ts.map +1 -0
- package/dist/src/errors/abi.js +117 -0
- package/dist/src/errors/abi.js.map +1 -0
- package/dist/src/errors/request.d.ts +4 -0
- package/dist/src/errors/request.d.ts.map +1 -1
- package/dist/src/errors/request.js +7 -0
- package/dist/src/errors/request.js.map +1 -1
- package/dist/src/eth.d.ts +9 -0
- package/dist/src/eth.d.ts.map +1 -1
- package/dist/src/eth.js +16 -1
- package/dist/src/eth.js.map +1 -1
- package/dist/src/internal/abi.d.ts +50 -0
- package/dist/src/internal/abi.d.ts.map +1 -0
- package/dist/src/internal/abi.js +248 -0
- package/dist/src/internal/abi.js.map +1 -0
- package/dist/src/internal/bytes.js +3 -3
- package/dist/src/internal/bytes.js.map +1 -1
- package/dist/src/internal/eth.d.ts +14 -5
- package/dist/src/internal/eth.d.ts.map +1 -1
- package/dist/src/internal/eth.js +16 -6
- package/dist/src/internal/eth.js.map +1 -1
- package/dist/src/internal/request.d.ts +37 -0
- package/dist/src/internal/request.d.ts.map +1 -1
- package/dist/src/internal/request.js +168 -1
- package/dist/src/internal/request.js.map +1 -1
- package/dist/src/request.d.ts +26 -9
- package/dist/src/request.d.ts.map +1 -1
- package/dist/src/request.js +31 -38
- package/dist/src/request.js.map +1 -1
- package/package.json +5 -3
- package/src/abi.ts +199 -0
- package/src/errors/abi.ts +156 -0
- package/src/errors/request.ts +12 -0
- package/src/eth.ts +22 -0
- package/src/internal/abi.ts +431 -0
- package/src/internal/bytes.ts +4 -4
- package/src/internal/eth.ts +23 -6
- package/src/internal/request.ts +218 -0
- package/src/request.ts +38 -45
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { getIntTypeRange, parseIntType } from "../abi.js";
|
|
2
|
+
import { AbiValueOutOfBoundsError, DuplicateAbiParameterNameError, InvalidAbiValueError, UnsupportedAbiTypeError, } from "../errors/abi.js";
|
|
3
|
+
import { isAddress, isValidChecksumAddress } from "../eth.js";
|
|
4
|
+
import { getPrefixedHexString, getUnprefixedHexString, hexStringToBytes, isHexString, isPrefixedHexString, } from "../hex.js";
|
|
5
|
+
import { isObject } from "../lang.js";
|
|
6
|
+
// In Solidity the rightmost suffix is the outermost array, so `uint256[2][]` is
|
|
7
|
+
// a dynamic array of `uint256[2]`. The greedy `.+` matches that last suffix.
|
|
8
|
+
const ARRAY_REGEX = /^(.+)(\[(\d+)?\])$/;
|
|
9
|
+
const BYTES_N_REGEX = /^bytes([0-9]{1,2})$/;
|
|
10
|
+
const DECIMAL_REGEX = /^\d+$/;
|
|
11
|
+
const HEX_REGEX = /^0x[0-9a-f]+$/i;
|
|
12
|
+
/**
|
|
13
|
+
* Throws if two of the given parameters share a name.
|
|
14
|
+
*
|
|
15
|
+
* This is checked against the parameter list rather than the value, so that the
|
|
16
|
+
* array and object input shapes fail the same way.
|
|
17
|
+
*
|
|
18
|
+
* @param parameters The parameters to check.
|
|
19
|
+
* @param path The path of their container, or undefined at the top level.
|
|
20
|
+
* @throws DuplicateAbiParameterNameError If a name is repeated.
|
|
21
|
+
*/
|
|
22
|
+
export function assertNoDuplicateAbiParameterNames(parameters, path) {
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
for (const { name } of parameters) {
|
|
25
|
+
if (name === undefined || name === "") {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (seen.has(name)) {
|
|
29
|
+
throw new DuplicateAbiParameterNameError(path, name);
|
|
30
|
+
}
|
|
31
|
+
seen.add(name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Removes the names of a list of ABI parameters, recursively.
|
|
36
|
+
*
|
|
37
|
+
* The encoder derives the shape of the value it expects from whether the
|
|
38
|
+
* parameters are named: named ones take an object keyed by name, unnamed ones
|
|
39
|
+
* take a positional array. Dropping the names makes every aggregate positional,
|
|
40
|
+
* at every nesting level.
|
|
41
|
+
*
|
|
42
|
+
* @param parameters The parameters to strip.
|
|
43
|
+
* @returns The same parameters, without their names.
|
|
44
|
+
*/
|
|
45
|
+
export function toUnnamedAbiParameters(parameters) {
|
|
46
|
+
return parameters.map(({ type, components }) => components === undefined
|
|
47
|
+
? { type }
|
|
48
|
+
: { type, components: toUnnamedAbiParameters(components) });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Converts a value into the shape that the encoder expects for a parameter,
|
|
52
|
+
* validating it against the parameter's Solidity type.
|
|
53
|
+
*
|
|
54
|
+
* @param parameter The ABI parameter to normalize the value for.
|
|
55
|
+
* @param value The value to normalize.
|
|
56
|
+
* @param path The path of the parameter, used to report errors.
|
|
57
|
+
* @returns The normalized value.
|
|
58
|
+
* @throws InvalidAbiValueError If the value can't be encoded as the type.
|
|
59
|
+
* @throws AbiValueOutOfBoundsError If a numeric value is out of the type's range.
|
|
60
|
+
* @throws UnsupportedAbiTypeError If the type itself can't be encoded.
|
|
61
|
+
*/
|
|
62
|
+
export async function normalizeAbiValue(parameter, value, path) {
|
|
63
|
+
const { type } = parameter;
|
|
64
|
+
// Arrays must be checked first, as the check is recursive.
|
|
65
|
+
const arrayMatch = ARRAY_REGEX.exec(type);
|
|
66
|
+
if (arrayMatch !== null) {
|
|
67
|
+
return await normalizeArray(parameter, value, path, arrayMatch);
|
|
68
|
+
}
|
|
69
|
+
if (type === "tuple") {
|
|
70
|
+
return await normalizeTuple(parameter, value, path);
|
|
71
|
+
}
|
|
72
|
+
if (type === "address") {
|
|
73
|
+
return await normalizeAddress(value, path);
|
|
74
|
+
}
|
|
75
|
+
if (type === "bool") {
|
|
76
|
+
return normalizeBool(value, path);
|
|
77
|
+
}
|
|
78
|
+
if (type === "string") {
|
|
79
|
+
if (typeof value !== "string") {
|
|
80
|
+
throw new InvalidAbiValueError(path, type, value, "invalid string value");
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
if (type === "bytes") {
|
|
85
|
+
return normalizeBytes(value, path, type, undefined);
|
|
86
|
+
}
|
|
87
|
+
const bytesNMatch = BYTES_N_REGEX.exec(type);
|
|
88
|
+
if (bytesNMatch !== null) {
|
|
89
|
+
const length = Number(bytesNMatch[1]);
|
|
90
|
+
if (length < 1 || length > 32) {
|
|
91
|
+
throw new UnsupportedAbiTypeError(path, type);
|
|
92
|
+
}
|
|
93
|
+
return normalizeBytes(value, path, type, length);
|
|
94
|
+
}
|
|
95
|
+
const intType = parseIntType(type);
|
|
96
|
+
if (intType !== undefined) {
|
|
97
|
+
return normalizeInt(value, path, type, intType);
|
|
98
|
+
}
|
|
99
|
+
throw new UnsupportedAbiTypeError(path, type);
|
|
100
|
+
}
|
|
101
|
+
async function normalizeArray(parameter, value, path, arrayMatch) {
|
|
102
|
+
const { type } = parameter;
|
|
103
|
+
const elementType = arrayMatch[1];
|
|
104
|
+
const fixedLength = arrayMatch[3];
|
|
105
|
+
if (!Array.isArray(value)) {
|
|
106
|
+
throw new InvalidAbiValueError(path, type, value, "invalid array value, expected a JS array");
|
|
107
|
+
}
|
|
108
|
+
if (fixedLength !== undefined && value.length !== Number(fixedLength)) {
|
|
109
|
+
throw new InvalidAbiValueError(path, type, value, `invalid array length, expected ${fixedLength} elements but got ${value.length}`);
|
|
110
|
+
}
|
|
111
|
+
const elementParameter = { ...parameter, type: elementType };
|
|
112
|
+
const normalized = [];
|
|
113
|
+
for (const [i, element] of value.entries()) {
|
|
114
|
+
normalized.push(await normalizeAbiValue(elementParameter, element, `${path}[${i}]`));
|
|
115
|
+
}
|
|
116
|
+
return normalized;
|
|
117
|
+
}
|
|
118
|
+
async function normalizeTuple(parameter, value, path) {
|
|
119
|
+
const { type, components } = parameter;
|
|
120
|
+
// The encoder rejects zero-sized tuples, as arrays of them can be used to
|
|
121
|
+
// DoS the decoder.
|
|
122
|
+
if (components === undefined || components.length === 0) {
|
|
123
|
+
throw new UnsupportedAbiTypeError(path, type);
|
|
124
|
+
}
|
|
125
|
+
assertNoDuplicateAbiParameterNames(components, path);
|
|
126
|
+
if (Array.isArray(value)) {
|
|
127
|
+
if (value.length !== components.length) {
|
|
128
|
+
throw new InvalidAbiValueError(path, type, value, `invalid tuple length, expected ${components.length} components but got ${value.length}`);
|
|
129
|
+
}
|
|
130
|
+
const normalized = [];
|
|
131
|
+
for (const [i, component] of components.entries()) {
|
|
132
|
+
normalized.push(await normalizeAbiValue(component, value[i], component.name === undefined
|
|
133
|
+
? `${path}[${i}]`
|
|
134
|
+
: `${path}.${component.name}`));
|
|
135
|
+
}
|
|
136
|
+
return normalized;
|
|
137
|
+
}
|
|
138
|
+
if (isObject(value)) {
|
|
139
|
+
const normalized = [];
|
|
140
|
+
for (const component of components) {
|
|
141
|
+
const { name } = component;
|
|
142
|
+
if (name === undefined || name === "") {
|
|
143
|
+
throw new InvalidAbiValueError(path, type, value, "invalid tuple value, it has unnamed components so it must be provided as an array");
|
|
144
|
+
}
|
|
145
|
+
const componentPath = `${path}.${name}`;
|
|
146
|
+
if (!Object.hasOwn(value, name)) {
|
|
147
|
+
throw new InvalidAbiValueError(componentPath, component.type, undefined, `missing value for the tuple component "${name}"`);
|
|
148
|
+
}
|
|
149
|
+
normalized.push(await normalizeAbiValue(component, value[name], componentPath));
|
|
150
|
+
}
|
|
151
|
+
return normalized;
|
|
152
|
+
}
|
|
153
|
+
throw new InvalidAbiValueError(path, type, value, "invalid tuple value, expected an array or an object");
|
|
154
|
+
}
|
|
155
|
+
function normalizeBool(value, path) {
|
|
156
|
+
if (typeof value === "boolean") {
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
// Command line arguments always arrive as strings, so the two Solidity
|
|
160
|
+
// literals are accepted. Any other string is rejected.
|
|
161
|
+
if (value === "true") {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
if (value === "false") {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
throw new InvalidAbiValueError(path, "bool", value, "invalid boolean value");
|
|
168
|
+
}
|
|
169
|
+
async function normalizeAddress(value, path) {
|
|
170
|
+
if (typeof value !== "string") {
|
|
171
|
+
throw new InvalidAbiValueError(path, "address", value, "invalid address value, expected a string");
|
|
172
|
+
}
|
|
173
|
+
// The prefix is re-added in lowercase, so that a "0X"-prefixed address still
|
|
174
|
+
// matches the checksummed form it is compared against below.
|
|
175
|
+
const address = getPrefixedHexString(getUnprefixedHexString(value));
|
|
176
|
+
if (!isAddress(address)) {
|
|
177
|
+
throw new InvalidAbiValueError(path, "address", value, "invalid address value");
|
|
178
|
+
}
|
|
179
|
+
// A mixed-case address carries an EIP-55 checksum, so it is validated to
|
|
180
|
+
// catch mistyped addresses here instead of failing later, somewhere else.
|
|
181
|
+
// An all-lowercase or all-uppercase one carries no checksum to validate.
|
|
182
|
+
const hexAddress = getUnprefixedHexString(address);
|
|
183
|
+
const isCaseless = hexAddress === hexAddress.toLowerCase() ||
|
|
184
|
+
hexAddress === hexAddress.toUpperCase();
|
|
185
|
+
if (!isCaseless && !(await isValidChecksumAddress(address))) {
|
|
186
|
+
throw new InvalidAbiValueError(path, "address", value, "invalid address checksum");
|
|
187
|
+
}
|
|
188
|
+
return address.toLowerCase();
|
|
189
|
+
}
|
|
190
|
+
function normalizeBytes(value, path, type, length) {
|
|
191
|
+
let bytes;
|
|
192
|
+
if (value instanceof Uint8Array) {
|
|
193
|
+
bytes = value;
|
|
194
|
+
// The "0x" prefix is required, as an unprefixed string is more likely to
|
|
195
|
+
// be a value that was meant to be something other than bytes.
|
|
196
|
+
}
|
|
197
|
+
else if (typeof value === "string" &&
|
|
198
|
+
isPrefixedHexString(value) &&
|
|
199
|
+
isHexString(value)) {
|
|
200
|
+
const unprefixed = getUnprefixedHexString(value);
|
|
201
|
+
if (unprefixed.length % 2 !== 0) {
|
|
202
|
+
throw new InvalidAbiValueError(path, type, value, "invalid bytes value, the hex string has an odd length");
|
|
203
|
+
}
|
|
204
|
+
bytes =
|
|
205
|
+
unprefixed.length === 0 ? new Uint8Array() : hexStringToBytes(unprefixed);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
throw new InvalidAbiValueError(path, type, value, 'invalid bytes value, expected a "0x"-prefixed hex string or a Uint8Array');
|
|
209
|
+
}
|
|
210
|
+
if (length !== undefined && bytes.length !== length) {
|
|
211
|
+
throw new InvalidAbiValueError(path, type, value, `invalid bytes length, expected ${length} bytes but got ${bytes.length}`);
|
|
212
|
+
}
|
|
213
|
+
return bytes;
|
|
214
|
+
}
|
|
215
|
+
function normalizeInt(value, path, type, intType) {
|
|
216
|
+
let normalized;
|
|
217
|
+
if (typeof value === "bigint") {
|
|
218
|
+
normalized = value;
|
|
219
|
+
}
|
|
220
|
+
else if (typeof value === "number") {
|
|
221
|
+
if (!Number.isSafeInteger(value)) {
|
|
222
|
+
throw new InvalidAbiValueError(path, type, value, "invalid numeric value, it is not a safe integer; use a bigint or a string instead");
|
|
223
|
+
}
|
|
224
|
+
normalized = BigInt(value);
|
|
225
|
+
}
|
|
226
|
+
else if (typeof value === "string") {
|
|
227
|
+
normalized = parseIntValue(value, path, type);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
throw new InvalidAbiValueError(path, type, value, "invalid numeric value");
|
|
231
|
+
}
|
|
232
|
+
const { min, max } = getIntTypeRange(intType);
|
|
233
|
+
if (normalized < min || normalized > max) {
|
|
234
|
+
throw new AbiValueOutOfBoundsError(path, type, value, min, max);
|
|
235
|
+
}
|
|
236
|
+
return normalized;
|
|
237
|
+
}
|
|
238
|
+
function parseIntValue(value, path, type) {
|
|
239
|
+
// BigInt() throws on a signed hex string, so the sign is handled here.
|
|
240
|
+
const negative = value.startsWith("-");
|
|
241
|
+
const magnitude = negative ? value.slice(1) : value;
|
|
242
|
+
if (!DECIMAL_REGEX.test(magnitude) && !HEX_REGEX.test(magnitude)) {
|
|
243
|
+
throw new InvalidAbiValueError(path, type, value, "invalid numeric value");
|
|
244
|
+
}
|
|
245
|
+
const parsed = BigInt(magnitude);
|
|
246
|
+
return negative ? -parsed : parsed;
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=abi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../../../src/internal/abi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAiBtC,gFAAgF;AAChF,6EAA6E;AAC7E,MAAM,WAAW,GAAG,oBAAoB,CAAC;AACzC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAC5C,MAAM,aAAa,GAAG,OAAO,CAAC;AAC9B,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC;;;;;;;;;GASG;AACH,MAAM,UAAU,kCAAkC,CAChD,UAAmC,EACnC,IAAa;IAEb,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,UAAU,EAAE,CAAC;QAClC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YACtC,SAAS;QACX,CAAC;QAED,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,MAA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AAU,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAEpD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACrC,CAAC"}
|
|
@@ -13,10 +13,10 @@ export async function parseJsonStream(stream) {
|
|
|
13
13
|
if (streamParserJson === undefined) {
|
|
14
14
|
streamParserJson = await import("@streamparser/json-node");
|
|
15
15
|
}
|
|
16
|
-
//
|
|
17
|
-
//
|
|
16
|
+
// We only emit the root value, as it's the only one we use, and emitting
|
|
17
|
+
// every nested value is much slower.
|
|
18
18
|
const jsonParser = new streamParserJson.JSONParser({
|
|
19
|
-
|
|
19
|
+
paths: ["$"],
|
|
20
20
|
});
|
|
21
21
|
const result = await pipeline(stream, jsonParser, async (elements) => {
|
|
22
22
|
let value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../../src/internal/bytes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,qEAAqE;AACrE,6CAA6C;AAC7C,IAAI,gBAAqD,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAI,MAAgB;IACvD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,gBAAgB,GAAG,MAAM,MAAM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C,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1B,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC;QACxB,CAAC;aAAM,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;YACxB,QAAQ,GAAG,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PrefixedHexString } from "../hex.js";
|
|
1
2
|
declare class RandomBytesGenerator {
|
|
2
3
|
#private;
|
|
3
4
|
private constructor();
|
|
@@ -7,15 +8,23 @@ declare class RandomBytesGenerator {
|
|
|
7
8
|
export declare function getHashGenerator(): Promise<RandomBytesGenerator>;
|
|
8
9
|
export declare function getAddressGenerator(): Promise<RandomBytesGenerator>;
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
* This method is
|
|
11
|
+
* Converts an Ethereum address to its EIP-55 checksummed representation.
|
|
12
|
+
* This method is an adaptation of the ethereumjs methods at this link:
|
|
12
13
|
* https://github.com/ethereumjs/ethereumjs-monorepo/blob/47f388bfeec553519d11259fee7e7161a77b29b2/packages/util/src/account.ts#L440-L478
|
|
13
14
|
* The main differences are:
|
|
14
|
-
* - the
|
|
15
|
-
* - tha `eip1191ChainId` parameter has been removed.
|
|
15
|
+
* - the `eip1191ChainId` parameter has been removed.
|
|
16
16
|
* - the code has been modified to use the `hardhat-utils` methods
|
|
17
17
|
*
|
|
18
|
+
* It doesn't validate that the input is an Ethereum address; callers must
|
|
19
|
+
* check that first (see the public wrappers in `../eth.ts`).
|
|
18
20
|
*/
|
|
19
|
-
export declare function
|
|
21
|
+
export declare function toChecksumAddress(hexAddress: PrefixedHexString): Promise<PrefixedHexString>;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the checksum of an address is valid.
|
|
24
|
+
*
|
|
25
|
+
* It doesn't validate that the input is an Ethereum address; callers must
|
|
26
|
+
* check that first (see the public wrappers in `../eth.ts`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function isValidChecksum(hexAddress: PrefixedHexString): Promise<boolean>;
|
|
20
29
|
export {};
|
|
21
30
|
//# sourceMappingURL=eth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth.d.ts","sourceRoot":"","sources":["../../../src/internal/eth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eth.d.ts","sourceRoot":"","sources":["../../../src/internal/eth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAMnD,cAAM,oBAAoB;;IAGxB,OAAO;WAIa,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAM1D,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;CAOzC;AAKD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAKtE;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAKzE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAiB5B;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAElB"}
|
package/dist/src/internal/eth.js
CHANGED
|
@@ -31,16 +31,17 @@ export async function getAddressGenerator() {
|
|
|
31
31
|
return addressGenerator;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* This method is
|
|
34
|
+
* Converts an Ethereum address to its EIP-55 checksummed representation.
|
|
35
|
+
* This method is an adaptation of the ethereumjs methods at this link:
|
|
36
36
|
* https://github.com/ethereumjs/ethereumjs-monorepo/blob/47f388bfeec553519d11259fee7e7161a77b29b2/packages/util/src/account.ts#L440-L478
|
|
37
37
|
* The main differences are:
|
|
38
|
-
* - the
|
|
39
|
-
* - tha `eip1191ChainId` parameter has been removed.
|
|
38
|
+
* - the `eip1191ChainId` parameter has been removed.
|
|
40
39
|
* - the code has been modified to use the `hardhat-utils` methods
|
|
41
40
|
*
|
|
41
|
+
* It doesn't validate that the input is an Ethereum address; callers must
|
|
42
|
+
* check that first (see the public wrappers in `../eth.ts`).
|
|
42
43
|
*/
|
|
43
|
-
export async function
|
|
44
|
+
export async function toChecksumAddress(hexAddress) {
|
|
44
45
|
const address = getUnprefixedHexString(hexAddress).toLowerCase();
|
|
45
46
|
const bytes = utf8StringToBytes(address);
|
|
46
47
|
const hash = bytesToHexString(await keccak256(bytes)).slice(2);
|
|
@@ -53,6 +54,15 @@ export async function isValidChecksum(hexAddress) {
|
|
|
53
54
|
ret += address[i];
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
return `0x${ret}
|
|
57
|
+
return `0x${ret}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Checks if the checksum of an address is valid.
|
|
61
|
+
*
|
|
62
|
+
* It doesn't validate that the input is an Ethereum address; callers must
|
|
63
|
+
* check that first (see the public wrappers in `../eth.ts`).
|
|
64
|
+
*/
|
|
65
|
+
export async function isValidChecksum(hexAddress) {
|
|
66
|
+
return (await toChecksumAddress(hexAddress)) === hexAddress;
|
|
57
67
|
}
|
|
58
68
|
//# sourceMappingURL=eth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth.js","sourceRoot":"","sources":["../../../src/internal/eth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eth.js","sourceRoot":"","sources":["../../../src/internal/eth.ts"],"names":[],"mapp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7B,MAAM,OAAO,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IAEjE,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAEzC,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE/D,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,GAAG,EAAE,CAAC;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAA6B;IAE7B,OAAO,CAAC,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC,KAAK,UAAU,CAAC;AAC9D,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { DispatcherOptions, RequestOptions } from "../request.js";
|
|
2
2
|
import type EventEmitter from "node:events";
|
|
3
3
|
import type * as UndiciT from "undici";
|
|
4
|
+
export interface ProxyEnvVar {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
4
8
|
export declare function generateTempFilePath(filePath: string): Promise<string>;
|
|
5
9
|
export declare function getBaseRequestOptions(requestUrl: string, { extraHeaders, abortSignal, queryParams }?: RequestOptions, dispatcherOrDispatcherOptions?: UndiciT.Dispatcher | DispatcherOptions): Promise<{
|
|
6
10
|
query?: Record<string, any> | undefined;
|
|
@@ -10,6 +14,39 @@ export declare function getBaseRequestOptions(requestUrl: string, { extraHeaders
|
|
|
10
14
|
}>;
|
|
11
15
|
export declare function getHeaders(requestUrl: string, extraHeaders?: Record<string, string>): Record<string, string>;
|
|
12
16
|
export declare function getAuthHeader(requestUrl: string): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Determines whether a url points at the loopback interface.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isLoopbackUrl(parsedUrl: URL): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Determines whether `NO_PROXY` (or `no_proxy`) excludes a url from being
|
|
23
|
+
* proxied. A value of `*` excludes everything; the other entries are matched as
|
|
24
|
+
* described in {@link parseNoProxy}.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isExcludedByNoProxy(parsedUrl: URL): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Finds the environment variable that configures the proxy for a given url,
|
|
29
|
+
* following the usual precedence: the variable matching the url's protocol
|
|
30
|
+
* first, lowercase before uppercase, then the other protocol's as a fallback.
|
|
31
|
+
*
|
|
32
|
+
* Empty and whitespace-only values are treated as unset, as that's how users
|
|
33
|
+
* disable a variable inherited from a parent environment. The returned value is
|
|
34
|
+
* trimmed, but not validated.
|
|
35
|
+
*
|
|
36
|
+
* @param requestUrl The url the proxy would be used for.
|
|
37
|
+
* @returns The variable's name and value, or `undefined` if none is set or the
|
|
38
|
+
* url's protocol isn't proxyable.
|
|
39
|
+
*/
|
|
40
|
+
export declare function findProxyEnvVar(requestUrl: string): ProxyEnvVar | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves the proxy to use for a given url from the environment.
|
|
43
|
+
*
|
|
44
|
+
* @param requestUrl The url the proxy would be used for.
|
|
45
|
+
* @returns The proxy url, or `undefined` if the environment configures none,
|
|
46
|
+
* `NO_PROXY` excludes the url, or the url can't be proxied.
|
|
47
|
+
* @throws InvalidProxyUrlError If the configured proxy isn't a valid http(s) url.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveProxyFromEnv(requestUrl: string): string | undefined;
|
|
13
50
|
export declare function getProxyDispatcher(proxy: string, options: Omit<UndiciT.ProxyAgent.Options, "uri">): Promise<UndiciT.ProxyAgent>;
|
|
14
51
|
export declare function getPoolDispatcher(requestUrl: string, options: UndiciT.Pool.Options): Promise<UndiciT.Pool>;
|
|
15
52
|
export declare function getBasicDispatcher(options: UndiciT.Agent.Options): Promise<UndiciT.Agent>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/internal/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,YAAY,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,KAAK,OAAO,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/internal/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,YAAY,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,KAAK,OAAO,MAAM,QAAQ,CAAC;AAqBvC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AA4BD,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU5E;AAED,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,EAClB,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,GAAE,cAAmB,EAC/D,6BAA6B,CAAC,EAAE,OAAO,CAAC,UAAU,GAAG,iBAAiB,GACrE,OAAO,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;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E,MAAwC,EACjD,gBAAgB,GAAE,OAAe,GAChC,OAAO,CAAC,MAAM,CAAC,OAAO,CAaxB;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAuB9D"}
|
|
@@ -3,10 +3,24 @@ import { STATUS_CODES } from "node:http";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { mkdir } from "../fs.js";
|
|
5
5
|
import { isObject } from "../lang.js";
|
|
6
|
-
import { ConnectionRefusedError, DEFAULT_MAX_REDIRECTS, DEFAULT_TIMEOUT_IN_MILLISECONDS, DEFAULT_USER_AGENT, getDispatcher, RequestTimeoutError, ResponseStatusCodeError, } from "../request.js";
|
|
6
|
+
import { ConnectionRefusedError, DEFAULT_MAX_REDIRECTS, DEFAULT_TIMEOUT_IN_MILLISECONDS, DEFAULT_USER_AGENT, getDispatcher, InvalidProxyUrlError, isValidUrl, RequestTimeoutError, ResponseStatusCodeError, shouldUseProxy, } from "../request.js";
|
|
7
7
|
// We don't load undici on startup because this package is transitively imported
|
|
8
8
|
// from too many places and it's too complex to optimize case by case.
|
|
9
9
|
let undici;
|
|
10
|
+
const HTTPS_PROXY_ENV_VARS = ["https_proxy", "HTTPS_PROXY"];
|
|
11
|
+
const HTTP_PROXY_ENV_VARS = ["http_proxy", "HTTP_PROXY"];
|
|
12
|
+
const NO_PROXY_ENV_VARS = ["no_proxy", "NO_PROXY"];
|
|
13
|
+
// `URL` normalizes IPv6 loopback to `[::1]` and alternate IPv4 forms to
|
|
14
|
+
// dotted decimal. Only IPv6 hostnames include brackets.
|
|
15
|
+
const LOOPBACK_HOSTNAMES = new Set([
|
|
16
|
+
"localhost",
|
|
17
|
+
"0.0.0.0",
|
|
18
|
+
"[::1]",
|
|
19
|
+
]);
|
|
20
|
+
const DEFAULT_PORTS = new Map([
|
|
21
|
+
["http:", 80],
|
|
22
|
+
["https:", 443],
|
|
23
|
+
]);
|
|
10
24
|
export async function generateTempFilePath(filePath) {
|
|
11
25
|
const { dir, ext, name } = path.parse(filePath);
|
|
12
26
|
await mkdir(dir);
|
|
@@ -54,6 +68,125 @@ export function getAuthHeader(requestUrl) {
|
|
|
54
68
|
}
|
|
55
69
|
return `Basic ${Buffer.from(`${parsedUrl.username}:${parsedUrl.password}`).toString("base64")}`;
|
|
56
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Determines whether a url points at the loopback interface.
|
|
73
|
+
*/
|
|
74
|
+
export function isLoopbackUrl(parsedUrl) {
|
|
75
|
+
const hostname = parsedUrl.hostname.toLowerCase();
|
|
76
|
+
if (LOOPBACK_HOSTNAMES.has(hostname)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
// Subdomains of localhost, e.g. `api.localhost`.
|
|
80
|
+
if (hostname.endsWith(".localhost")) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
// The whole 127.0.0.0/8 range is loopback, not just 127.0.0.1.
|
|
84
|
+
return /^127(?:\.\d{1,3}){3}$/.test(hostname);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Determines whether `NO_PROXY` (or `no_proxy`) excludes a url from being
|
|
88
|
+
* proxied. A value of `*` excludes everything; the other entries are matched as
|
|
89
|
+
* described in {@link parseNoProxy}.
|
|
90
|
+
*/
|
|
91
|
+
export function isExcludedByNoProxy(parsedUrl) {
|
|
92
|
+
// An empty or whitespace-only value means unset, so it falls through to the
|
|
93
|
+
// other casing instead of shadowing it.
|
|
94
|
+
const noProxy = NO_PROXY_ENV_VARS.map((name) => process.env[name]?.trim()).find((value) => value !== undefined && value !== "");
|
|
95
|
+
if (noProxy === undefined) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (noProxy === "*") {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
const hostname = normalizeHostname(parsedUrl.hostname);
|
|
102
|
+
const parsedPort = Number.parseInt(parsedUrl.port, 10);
|
|
103
|
+
const port = Number.isNaN(parsedPort)
|
|
104
|
+
? DEFAULT_PORTS.get(parsedUrl.protocol)
|
|
105
|
+
: parsedPort;
|
|
106
|
+
for (const entry of parseNoProxy(noProxy)) {
|
|
107
|
+
// A portless entry matches every port.
|
|
108
|
+
if (entry.port !== 0 && entry.port !== port) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (hostname === entry.hostname ||
|
|
112
|
+
hostname.endsWith(`.${entry.hostname}`)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Finds the environment variable that configures the proxy for a given url,
|
|
120
|
+
* following the usual precedence: the variable matching the url's protocol
|
|
121
|
+
* first, lowercase before uppercase, then the other protocol's as a fallback.
|
|
122
|
+
*
|
|
123
|
+
* Empty and whitespace-only values are treated as unset, as that's how users
|
|
124
|
+
* disable a variable inherited from a parent environment. The returned value is
|
|
125
|
+
* trimmed, but not validated.
|
|
126
|
+
*
|
|
127
|
+
* @param requestUrl The url the proxy would be used for.
|
|
128
|
+
* @returns The variable's name and value, or `undefined` if none is set or the
|
|
129
|
+
* url's protocol isn't proxyable.
|
|
130
|
+
*/
|
|
131
|
+
export function findProxyEnvVar(requestUrl) {
|
|
132
|
+
const { protocol } = new URL(requestUrl);
|
|
133
|
+
let names;
|
|
134
|
+
if (protocol === "https:") {
|
|
135
|
+
names = HTTPS_PROXY_ENV_VARS.concat(HTTP_PROXY_ENV_VARS);
|
|
136
|
+
}
|
|
137
|
+
else if (protocol === "http:") {
|
|
138
|
+
names = HTTP_PROXY_ENV_VARS.concat(HTTPS_PROXY_ENV_VARS);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
for (const name of names) {
|
|
144
|
+
const value = process.env[name]?.trim();
|
|
145
|
+
if (value !== undefined && value !== "") {
|
|
146
|
+
return { name, value };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolves the proxy to use for a given url from the environment.
|
|
153
|
+
*
|
|
154
|
+
* @param requestUrl The url the proxy would be used for.
|
|
155
|
+
* @returns The proxy url, or `undefined` if the environment configures none,
|
|
156
|
+
* `NO_PROXY` excludes the url, or the url can't be proxied.
|
|
157
|
+
* @throws InvalidProxyUrlError If the configured proxy isn't a valid http(s) url.
|
|
158
|
+
*/
|
|
159
|
+
export function resolveProxyFromEnv(requestUrl) {
|
|
160
|
+
// `shouldUseProxy` and `findProxyEnvVar` both parse the url. Requests to an
|
|
161
|
+
// invalid one fail later with a better error than anything we'd raise here.
|
|
162
|
+
if (!isValidUrl(requestUrl) || !shouldUseProxy(requestUrl)) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
const proxyEnvVar = findProxyEnvVar(requestUrl);
|
|
166
|
+
if (proxyEnvVar === undefined) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
if (!isValidProxyUrl(proxyEnvVar.value)) {
|
|
170
|
+
throw new InvalidProxyUrlError(proxyEnvVar.name);
|
|
171
|
+
}
|
|
172
|
+
return proxyEnvVar.value;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Determines whether a value can be used as a proxy url.
|
|
176
|
+
*
|
|
177
|
+
* undici's `ProxyAgent` only speaks http(s). Checking the protocol here, rather
|
|
178
|
+
* than leaving it to undici, catches two cases that would otherwise surface as
|
|
179
|
+
* opaque errors: a scheme-less `host:port`, which parses as a url whose
|
|
180
|
+
* protocol is the host and so never looks like a missing scheme, and `socks5:`,
|
|
181
|
+
* which undici accepts before failing at request time.
|
|
182
|
+
*/
|
|
183
|
+
function isValidProxyUrl(value) {
|
|
184
|
+
if (!isValidUrl(value)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
const { protocol } = new URL(value);
|
|
188
|
+
return protocol === "http:" || protocol === "https:";
|
|
189
|
+
}
|
|
57
190
|
export async function getProxyDispatcher(proxy, options) {
|
|
58
191
|
if (undici === undefined) {
|
|
59
192
|
undici = await import("undici");
|
|
@@ -133,4 +266,38 @@ function describeResponseError(e) {
|
|
|
133
266
|
const reason = STATUS_CODES[statusCode];
|
|
134
267
|
e.message = `Response status code ${statusCode}${reason !== undefined ? `: ${reason}` : ""}`;
|
|
135
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Strips the brackets an IPv6 literal carries in a url, so that an entry can be
|
|
271
|
+
* written either way. `URL` keeps them on `hostname`, while `NO_PROXY` entries
|
|
272
|
+
* are commonly written without them.
|
|
273
|
+
*/
|
|
274
|
+
function normalizeHostname(hostname) {
|
|
275
|
+
return hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Parses a `NO_PROXY` value into its entries.
|
|
279
|
+
*
|
|
280
|
+
* Entries are separated by commas or whitespace. A leading `.` or `*.` marks
|
|
281
|
+
* the suffix form (`.example.com`), but a bare `example.com` matches its
|
|
282
|
+
* subdomains too, so both are stored the same way. An entry may carry a port,
|
|
283
|
+
* as in `example.com:8080`, which restricts it to that port. CIDR ranges aren't
|
|
284
|
+
* supported.
|
|
285
|
+
*/
|
|
286
|
+
function parseNoProxy(noProxy) {
|
|
287
|
+
const entries = [];
|
|
288
|
+
for (const rawEntry of noProxy.split(/[,\s]/)) {
|
|
289
|
+
const entry = rawEntry.trim();
|
|
290
|
+
if (entry === "") {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
// Only a bracketed literal or a colon-free host can carry a port, so that
|
|
294
|
+
// the trailing group of a bare IPv6 entry isn't read as one.
|
|
295
|
+
const withPort = entry.match(/^(\[[^\]]+\]|[^:]+):(\d+)$/);
|
|
296
|
+
entries.push({
|
|
297
|
+
hostname: normalizeHostname((withPort !== null ? withPort[1] : entry).replace(/^\*?\./, "")),
|
|
298
|
+
port: withPort !== null ? Number.parseInt(withPort[2], 10) : 0,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return entries;
|
|
302
|
+
}
|
|
136
303
|
//# sourceMappingURL=request.js.map
|