@prosopo/cli 3.7.23 → 3.7.25
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/.turbo/turbo-build$colon$cjs.log +5 -5
- package/.turbo/turbo-build$colon$tsc.log +28 -28
- package/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +30 -0
- package/dist/bundle/{i18nBackend-F6WgK5_c.js → i18nBackend-7CE4gNGi.js} +6 -3
- package/dist/bundle/{i18nFrontend-D7DSDiLn.js → i18nFrontend-BRs22JVq.js} +158 -110
- package/dist/bundle/prosopo-native-ja4.node +0 -0
- package/dist/bundle/prosopo-native-merkle.node +0 -0
- package/dist/bundle/provider.cli.bundle.js +16120 -14210
- package/dist/bundle/src-CFhgWFIS.js +905 -0
- package/package.json +16 -16
- package/dist/bundle/src-DhRyWllF.js +0 -1880
|
@@ -0,0 +1,905 @@
|
|
|
1
|
+
import { i as e, l as t, s as n } from "./provider.cli.bundle.js";
|
|
2
|
+
//#region ../../node_modules/mmdb-lib/lib/utils.js
|
|
3
|
+
var r = /* @__PURE__ */ e(((e) => {
|
|
4
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.default = {
|
|
5
|
+
assert: (e, t) => {
|
|
6
|
+
if (!e) throw Error(t);
|
|
7
|
+
},
|
|
8
|
+
legacyErrorMessage: "Maxmind v2 module has changed API.\nUpgrade instructions can be found here: https://github.com/runk/node-maxmind/wiki/Migration-guide\nIf you want to use legacy library then explicitly install maxmind@1"
|
|
9
|
+
};
|
|
10
|
+
})), i = /* @__PURE__ */ e(((e) => {
|
|
11
|
+
var t = e && e.__importDefault || function(e) {
|
|
12
|
+
return e && e.__esModule ? e : { default: e };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
15
|
+
var n = t(r());
|
|
16
|
+
n.default.assert(typeof BigInt < "u", "Apparently you are using old version of node. Please upgrade to node 10.4.x or above.");
|
|
17
|
+
var i = 2147483647, a;
|
|
18
|
+
(function(e) {
|
|
19
|
+
e[e.Extended = 0] = "Extended", e[e.Pointer = 1] = "Pointer", e[e.Utf8String = 2] = "Utf8String", e[e.Double = 3] = "Double", e[e.Bytes = 4] = "Bytes", e[e.Uint16 = 5] = "Uint16", e[e.Uint32 = 6] = "Uint32", e[e.Map = 7] = "Map", e[e.Int32 = 8] = "Int32", e[e.Uint64 = 9] = "Uint64", e[e.Uint128 = 10] = "Uint128", e[e.Array = 11] = "Array", e[e.Container = 12] = "Container", e[e.EndMarker = 13] = "EndMarker", e[e.Boolean = 14] = "Boolean", e[e.Float = 15] = "Float";
|
|
20
|
+
})(a ||= {});
|
|
21
|
+
var o = [
|
|
22
|
+
0,
|
|
23
|
+
2048,
|
|
24
|
+
526336,
|
|
25
|
+
0
|
|
26
|
+
], s = {
|
|
27
|
+
get: () => void 0,
|
|
28
|
+
set: () => void 0
|
|
29
|
+
}, c = (e, t) => ({
|
|
30
|
+
value: e,
|
|
31
|
+
offset: t
|
|
32
|
+
});
|
|
33
|
+
e.default = class {
|
|
34
|
+
constructor(e, t = 0, r = s) {
|
|
35
|
+
this.telemetry = {}, n.default.assert(!!e, "Database buffer is required"), this.db = e, this.baseOffset = t, this.cache = r;
|
|
36
|
+
}
|
|
37
|
+
decode(e) {
|
|
38
|
+
let t, n = this.db[e++], r = n >> 5;
|
|
39
|
+
if (r === a.Pointer) return t = this.decodePointer(n, e), c(this.decodeFast(t.value).value, t.offset);
|
|
40
|
+
if (r === a.Extended) {
|
|
41
|
+
if (t = this.db[e] + 7, t < 8) throw Error("Invalid Extended Type at offset " + e + " val " + t);
|
|
42
|
+
r = t, e++;
|
|
43
|
+
}
|
|
44
|
+
let i = this.sizeFromCtrlByte(n, e);
|
|
45
|
+
return this.decodeByType(r, i.offset, i.value);
|
|
46
|
+
}
|
|
47
|
+
decodeFast(e) {
|
|
48
|
+
let t = this.cache.get(e);
|
|
49
|
+
if (t) return t;
|
|
50
|
+
let n = this.decode(e);
|
|
51
|
+
return this.cache.set(e, n), n;
|
|
52
|
+
}
|
|
53
|
+
decodeByType(e, t, n) {
|
|
54
|
+
let r = t + n;
|
|
55
|
+
switch (e) {
|
|
56
|
+
case a.Utf8String: return c(this.decodeString(t, n), r);
|
|
57
|
+
case a.Map: return this.decodeMap(n, t);
|
|
58
|
+
case a.Uint32: return c(this.decodeUint(t, n), r);
|
|
59
|
+
case a.Double: return c(this.decodeDouble(t), r);
|
|
60
|
+
case a.Array: return this.decodeArray(n, t);
|
|
61
|
+
case a.Boolean: return c(this.decodeBoolean(n), t);
|
|
62
|
+
case a.Float: return c(this.decodeFloat(t), r);
|
|
63
|
+
case a.Bytes: return c(this.decodeBytes(t, n), r);
|
|
64
|
+
case a.Uint16: return c(this.decodeUint(t, n), r);
|
|
65
|
+
case a.Int32: return c(this.decodeInt32(t, n), r);
|
|
66
|
+
case a.Uint64: return c(this.decodeBigUint(t, n), r);
|
|
67
|
+
case a.Uint128: return c(this.decodeBigUint(t, n), r);
|
|
68
|
+
}
|
|
69
|
+
throw Error("Unknown type " + e + " at offset " + t);
|
|
70
|
+
}
|
|
71
|
+
sizeFromCtrlByte(e, t) {
|
|
72
|
+
let n = e & 31;
|
|
73
|
+
return n < 29 ? c(n, t) : n === 29 ? c(29 + this.db[t], t + 1) : n === 30 ? c(285 + this.db.readUInt16BE(t), t + 2) : c(65821 + this.db.readUIntBE(t, 3), t + 3);
|
|
74
|
+
}
|
|
75
|
+
decodeBytes(e, t) {
|
|
76
|
+
return this.db.subarray(e, e + t);
|
|
77
|
+
}
|
|
78
|
+
decodePointer(e, t) {
|
|
79
|
+
let n = e >> 3 & 3, r = this.baseOffset + o[n], i = 0;
|
|
80
|
+
return i = n === 0 ? (e & 7) << 8 | this.db[t] : n === 1 ? (e & 7) << 16 | this.db.readUInt16BE(t) : n === 2 ? (e & 7) << 24 | this.db.readUIntBE(t, 3) : this.db.readUInt32BE(t), t += n + 1, c(r + i, t);
|
|
81
|
+
}
|
|
82
|
+
decodeArray(e, t) {
|
|
83
|
+
let n, r = Array(e);
|
|
84
|
+
for (let i = 0; i < e; i++) n = this.decode(t), t = n.offset, r[i] = n.value;
|
|
85
|
+
return c(r, t);
|
|
86
|
+
}
|
|
87
|
+
decodeBoolean(e) {
|
|
88
|
+
return e !== 0;
|
|
89
|
+
}
|
|
90
|
+
decodeDouble(e) {
|
|
91
|
+
return this.db.readDoubleBE(e);
|
|
92
|
+
}
|
|
93
|
+
decodeFloat(e) {
|
|
94
|
+
return this.db.readFloatBE(e);
|
|
95
|
+
}
|
|
96
|
+
decodeMap(e, t) {
|
|
97
|
+
let n, r, i = {};
|
|
98
|
+
for (let a = 0; a < e; a++) n = this.decode(t), r = n.value, n = this.decode(n.offset), t = n.offset, i[r] = n.value;
|
|
99
|
+
return c(i, t);
|
|
100
|
+
}
|
|
101
|
+
decodeInt32(e, t) {
|
|
102
|
+
return t === 0 ? 0 : t < 4 ? this.db.readUIntBE(e, t) : this.db.readInt32BE(e);
|
|
103
|
+
}
|
|
104
|
+
decodeUint(e, t) {
|
|
105
|
+
if (t === 0) return 0;
|
|
106
|
+
if (t <= 4) return this.db.readUIntBE(e, t);
|
|
107
|
+
throw Error(`Invalid size for unsigned integer: ${t}`);
|
|
108
|
+
}
|
|
109
|
+
decodeString(e, t) {
|
|
110
|
+
let n = e + t;
|
|
111
|
+
return n >= i ? this.db.subarray(e, n).toString("utf8") : this.db.toString("utf8", e, n);
|
|
112
|
+
}
|
|
113
|
+
decodeBigUint(e, t) {
|
|
114
|
+
if (t > 16) throw Error(`Invalid size for big unsigned integer: ${t}`);
|
|
115
|
+
let n = 0n;
|
|
116
|
+
for (let r = 0; r < t; r++) n <<= 8n, n |= BigInt(this.db.readUInt8(e + r));
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
})), a = /* @__PURE__ */ e(((e) => {
|
|
121
|
+
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
122
|
+
var t = "(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])", n = `(?:${t}\\.){3}${t}`, r = RegExp(`^${n}$`), i = "(?:[0-9a-fA-F]{1,4})", a = RegExp(`^(?:(?:${i}:){7}(?:${i}|:)|(?:${i}:){6}(?:${n}|:${i}|:)|(?:${i}:){5}(?::${n}|(?::${i}){1,2}|:)|(?:${i}:){4}(?:(?::${i}){0,1}:${n}|(?::${i}){1,3}|:)|(?:${i}:){3}(?:(?::${i}){0,2}:${n}|(?::${i}){1,4}|:)|(?:${i}:){2}(?:(?::${i}){0,3}:${n}|(?::${i}){1,5}|:)|(?:${i}:){1}(?:(?::${i}){0,4}:${n}|(?::${i}){1,6}|:)|(?::(?:(?::${i}){0,5}:${n}|(?::${i}){1,7}|:)))(?:%[0-9a-zA-Z-.:]{1,})?\$`), o = (e) => {
|
|
123
|
+
let t = e.split(".", 4);
|
|
124
|
+
return [
|
|
125
|
+
parseInt(t[0]),
|
|
126
|
+
parseInt(t[1]),
|
|
127
|
+
parseInt(t[2]),
|
|
128
|
+
parseInt(t[3])
|
|
129
|
+
];
|
|
130
|
+
}, s = (e) => {
|
|
131
|
+
let t = parseInt(e, 10).toString(16);
|
|
132
|
+
return t.length === 2 ? t : "0" + t;
|
|
133
|
+
}, c = (e) => {
|
|
134
|
+
let t = [
|
|
135
|
+
0,
|
|
136
|
+
0,
|
|
137
|
+
0,
|
|
138
|
+
0,
|
|
139
|
+
0,
|
|
140
|
+
0,
|
|
141
|
+
0,
|
|
142
|
+
0,
|
|
143
|
+
0,
|
|
144
|
+
0,
|
|
145
|
+
0,
|
|
146
|
+
0,
|
|
147
|
+
0,
|
|
148
|
+
0,
|
|
149
|
+
0,
|
|
150
|
+
0
|
|
151
|
+
], n, r, i, [a, o] = (e.indexOf(".") > -1 ? e.replace(/(\d+)\.(\d+)\.(\d+)\.(\d+)/, (e, t, n, r, i) => s(t) + s(n) + ":" + s(r) + s(i)) : e).split("::", 2);
|
|
152
|
+
if (a) for (r = a.split(":"), n = 0; n < r.length; n++) i = parseInt(r[n], 16), t[n * 2] = i >> 8, t[n * 2 + 1] = i & 255;
|
|
153
|
+
if (o) {
|
|
154
|
+
r = o.split(":");
|
|
155
|
+
let e = 16 - r.length * 2;
|
|
156
|
+
for (n = 0; n < r.length; n++) i = parseInt(r[n], 16), t[e + n * 2] = i >> 8, t[e + (n * 2 + 1)] = i & 255;
|
|
157
|
+
}
|
|
158
|
+
return t;
|
|
159
|
+
};
|
|
160
|
+
e.default = {
|
|
161
|
+
bitAt: (e, t) => {
|
|
162
|
+
let n = t >> 3, r = 7 ^ t & 7;
|
|
163
|
+
return e[n] >>> r & 1;
|
|
164
|
+
},
|
|
165
|
+
parse: (e) => e.indexOf(":") === -1 ? o(e) : c(e),
|
|
166
|
+
validate: (e) => r.test(e) || a.test(e)
|
|
167
|
+
};
|
|
168
|
+
})), o = /* @__PURE__ */ e(((e) => {
|
|
169
|
+
var t = e && e.__importDefault || function(e) {
|
|
170
|
+
return e && e.__esModule ? e : { default: e };
|
|
171
|
+
};
|
|
172
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.isLegacyFormat = e.parseMetadata = void 0;
|
|
173
|
+
var n = t(i()), a = t(r()), o = Buffer.from("ABCDEF4D61784D696E642E636F6D", "hex");
|
|
174
|
+
e.parseMetadata = (t) => {
|
|
175
|
+
let r = s(t), i = new n.default(t, r).decode(r).value;
|
|
176
|
+
if (!i) throw Error((0, e.isLegacyFormat)(t) ? a.default.legacyErrorMessage : "Cannot parse binary database");
|
|
177
|
+
return a.default.assert([
|
|
178
|
+
24,
|
|
179
|
+
28,
|
|
180
|
+
32
|
|
181
|
+
].indexOf(i.record_size) > -1, "Unsupported record size"), {
|
|
182
|
+
binaryFormatMajorVersion: i.binary_format_major_version,
|
|
183
|
+
binaryFormatMinorVersion: i.binary_format_minor_version,
|
|
184
|
+
buildEpoch: /* @__PURE__ */ new Date(Number(i.build_epoch) * 1e3),
|
|
185
|
+
databaseType: i.database_type,
|
|
186
|
+
description: i.description,
|
|
187
|
+
ipVersion: i.ip_version,
|
|
188
|
+
languages: i.languages,
|
|
189
|
+
nodeByteSize: i.record_size / 4,
|
|
190
|
+
nodeCount: i.node_count,
|
|
191
|
+
recordSize: i.record_size,
|
|
192
|
+
searchTreeSize: i.node_count * i.record_size / 4,
|
|
193
|
+
treeDepth: 2 ** (i.ip_version + 1)
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
var s = (e) => {
|
|
197
|
+
let t = 0, n = e.length - 1, r = o.length - 1;
|
|
198
|
+
for (; t <= r && n-- > 0;) t += e[n] === o[r - t] ? 1 : -t;
|
|
199
|
+
return n + t;
|
|
200
|
+
};
|
|
201
|
+
e.isLegacyFormat = (e) => {
|
|
202
|
+
for (let t = 0; t < 20; t++) {
|
|
203
|
+
let n = e.slice(e.length - 3 - t, e.length - t);
|
|
204
|
+
if (n[0] === 255 && n[1] === 255 && n[2] === 255) return !0;
|
|
205
|
+
}
|
|
206
|
+
return !1;
|
|
207
|
+
};
|
|
208
|
+
})), s = /* @__PURE__ */ e(((e) => {
|
|
209
|
+
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
210
|
+
var t = (e) => (t) => e.readUIntBE(t + 3, 3), n = (e) => (t) => e.readUIntBE(t, 3), r = (e) => (t) => (e[t + 3] & 240) << 20 | e.readUIntBE(t, 3), i = (e) => (t) => (e[t + 3] & 15) << 24 | e.readUIntBE(t + 4, 3), a = (e) => (t) => e.readUInt32BE(t), o = (e) => (t) => e.readUInt32BE(t + 4);
|
|
211
|
+
e.default = (e, s) => {
|
|
212
|
+
switch (s) {
|
|
213
|
+
case 24: return {
|
|
214
|
+
left: n(e),
|
|
215
|
+
right: t(e)
|
|
216
|
+
};
|
|
217
|
+
case 28: return {
|
|
218
|
+
left: r(e),
|
|
219
|
+
right: i(e)
|
|
220
|
+
};
|
|
221
|
+
case 32: return {
|
|
222
|
+
left: a(e),
|
|
223
|
+
right: o(e)
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
throw Error("Unsupported record size");
|
|
227
|
+
};
|
|
228
|
+
})), c = /* @__PURE__ */ e(((e) => {
|
|
229
|
+
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
230
|
+
})), l = /* @__PURE__ */ e(((e) => {
|
|
231
|
+
var t = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
|
|
232
|
+
r === void 0 && (r = n);
|
|
233
|
+
var i = Object.getOwnPropertyDescriptor(t, n);
|
|
234
|
+
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
|
|
235
|
+
enumerable: !0,
|
|
236
|
+
get: function() {
|
|
237
|
+
return t[n];
|
|
238
|
+
}
|
|
239
|
+
}), Object.defineProperty(e, r, i);
|
|
240
|
+
}) : (function(e, t, n, r) {
|
|
241
|
+
r === void 0 && (r = n), e[r] = t[n];
|
|
242
|
+
})), n = e && e.__exportStar || function(e, n) {
|
|
243
|
+
for (var r in e) r !== "default" && !Object.prototype.hasOwnProperty.call(n, r) && t(n, e, r);
|
|
244
|
+
}, r = e && e.__importDefault || function(e) {
|
|
245
|
+
return e && e.__esModule ? e : { default: e };
|
|
246
|
+
};
|
|
247
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.Reader = void 0;
|
|
248
|
+
var l = r(i()), u = r(a()), d = o(), f = r(s()), p = 16;
|
|
249
|
+
e.Reader = class {
|
|
250
|
+
constructor(e, t = {}) {
|
|
251
|
+
this.opts = t, this.load(e);
|
|
252
|
+
}
|
|
253
|
+
load(e) {
|
|
254
|
+
if (!Buffer.isBuffer(e)) throw Error(`mmdb-lib expects an instance of Buffer, got: ${typeof e}`);
|
|
255
|
+
this.db = e, this.metadata = (0, d.parseMetadata)(this.db), this.decoder = new l.default(this.db, this.metadata.searchTreeSize + p, this.opts.cache), this.walker = (0, f.default)(this.db, this.metadata.recordSize), this.ipv4StartNodeNumber = this.ipv4Start();
|
|
256
|
+
}
|
|
257
|
+
get(e) {
|
|
258
|
+
let [t] = this.getWithPrefixLength(e);
|
|
259
|
+
return t;
|
|
260
|
+
}
|
|
261
|
+
getWithPrefixLength(e) {
|
|
262
|
+
let [t, n] = this.findAddressInTree(e);
|
|
263
|
+
return [t ? this.resolveDataPointer(t) : null, n];
|
|
264
|
+
}
|
|
265
|
+
findAddressInTree(e) {
|
|
266
|
+
let t = u.default.parse(e), n = this.metadata.nodeCount, r = t.length * 8, i, a = 0, o, s = 0;
|
|
267
|
+
for (t.length === 4 && (a = this.ipv4StartNodeNumber); s < r && a < n; s++) i = u.default.bitAt(t, s), o = a * this.metadata.nodeByteSize, a = i ? this.walker.right(o) : this.walker.left(o);
|
|
268
|
+
return a > n ? [a, s] : [null, s];
|
|
269
|
+
}
|
|
270
|
+
resolveDataPointer(e) {
|
|
271
|
+
let t = e - this.metadata.nodeCount + this.metadata.searchTreeSize;
|
|
272
|
+
return this.decoder.decodeFast(t).value;
|
|
273
|
+
}
|
|
274
|
+
ipv4Start() {
|
|
275
|
+
if (this.metadata.ipVersion === 4) return 0;
|
|
276
|
+
let e = this.metadata.nodeCount, t = 0, n = 0;
|
|
277
|
+
for (; n < 96 && t < e; n++) {
|
|
278
|
+
let e = t * this.metadata.nodeByteSize;
|
|
279
|
+
t = this.walker.left(e);
|
|
280
|
+
}
|
|
281
|
+
return t;
|
|
282
|
+
}
|
|
283
|
+
}, n(c(), e);
|
|
284
|
+
})), u = /* @__PURE__ */ e(((e) => {
|
|
285
|
+
var t = class {
|
|
286
|
+
#e;
|
|
287
|
+
#t;
|
|
288
|
+
constructor(e = 0, t = 0, n = !1) {
|
|
289
|
+
this.first = null, this.items = Object.create(null), this.last = null, this.max = e, this.resetTTL = n, this.size = 0, this.ttl = t, this.#e = {
|
|
290
|
+
hits: 0,
|
|
291
|
+
misses: 0,
|
|
292
|
+
sets: 0,
|
|
293
|
+
deletes: 0,
|
|
294
|
+
evictions: 0
|
|
295
|
+
}, this.#t = null;
|
|
296
|
+
}
|
|
297
|
+
clear() {
|
|
298
|
+
for (let e = this.first; e !== null;) {
|
|
299
|
+
let t = e.next;
|
|
300
|
+
e.prev = null, e.next = null, e = t;
|
|
301
|
+
}
|
|
302
|
+
return this.first = null, this.items = Object.create(null), this.last = null, this.size = 0, this.#e.hits = 0, this.#e.misses = 0, this.#e.sets = 0, this.#e.deletes = 0, this.#e.evictions = 0, this;
|
|
303
|
+
}
|
|
304
|
+
delete(e) {
|
|
305
|
+
let t = this.items[e];
|
|
306
|
+
return t !== void 0 && (delete this.items[e], this.size--, this.#e.deletes++, this.#r(t), t.prev = null, t.next = null), this;
|
|
307
|
+
}
|
|
308
|
+
entries(e) {
|
|
309
|
+
e === void 0 && (e = this.keys());
|
|
310
|
+
let t = Array.from({ length: e.length });
|
|
311
|
+
for (let n = 0; n < e.length; n++) {
|
|
312
|
+
let r = e[n], i = this.items[r];
|
|
313
|
+
t[n] = [r, i === void 0 ? void 0 : i.value];
|
|
314
|
+
}
|
|
315
|
+
return t;
|
|
316
|
+
}
|
|
317
|
+
evict() {
|
|
318
|
+
if (this.size === 0) return this;
|
|
319
|
+
let e = this.first;
|
|
320
|
+
return delete this.items[e.key], this.#e.evictions++, --this.size === 0 ? (this.first = null, this.last = null) : this.#r(e), e.prev = null, e.next = null, this.#t !== null && this.#t({
|
|
321
|
+
key: e.key,
|
|
322
|
+
value: e.value,
|
|
323
|
+
expiry: e.expiry
|
|
324
|
+
}), this;
|
|
325
|
+
}
|
|
326
|
+
expiresAt(e) {
|
|
327
|
+
let t = this.items[e];
|
|
328
|
+
return t === void 0 ? void 0 : t.expiry;
|
|
329
|
+
}
|
|
330
|
+
#n(e) {
|
|
331
|
+
return this.ttl === 0 || e.expiry === 0 ? !1 : e.expiry <= Date.now();
|
|
332
|
+
}
|
|
333
|
+
peek(e) {
|
|
334
|
+
let t = this.items[e];
|
|
335
|
+
return t === void 0 ? void 0 : t.value;
|
|
336
|
+
}
|
|
337
|
+
get(e) {
|
|
338
|
+
let t = this.items[e];
|
|
339
|
+
if (t !== void 0) {
|
|
340
|
+
if (!this.#n(t)) return this.moveToEnd(t), this.#e.hits++, t.value;
|
|
341
|
+
this.delete(e), this.#e.misses++;
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
this.#e.misses++;
|
|
345
|
+
}
|
|
346
|
+
has(e) {
|
|
347
|
+
let t = this.items[e];
|
|
348
|
+
return t !== void 0 && !this.#n(t);
|
|
349
|
+
}
|
|
350
|
+
#r(e) {
|
|
351
|
+
e.prev !== null && (e.prev.next = e.next), e.next !== null && (e.next.prev = e.prev), this.first === e && (this.first = e.next), this.last === e && (this.last = e.prev);
|
|
352
|
+
}
|
|
353
|
+
moveToEnd(e) {
|
|
354
|
+
this.last !== e && (this.#r(e), e.prev = this.last, e.next = null, this.last.next = e, this.last = e);
|
|
355
|
+
}
|
|
356
|
+
keys() {
|
|
357
|
+
let e = Array.from({ length: this.size }), t = this.first, n = 0;
|
|
358
|
+
for (; t !== null;) e[n++] = t.key, t = t.next;
|
|
359
|
+
return e;
|
|
360
|
+
}
|
|
361
|
+
setWithEvicted(e, t) {
|
|
362
|
+
let n = null, r = this.items[e];
|
|
363
|
+
return r === void 0 ? (this.max > 0 && this.size === this.max && (n = {
|
|
364
|
+
key: this.first.key,
|
|
365
|
+
value: this.first.value,
|
|
366
|
+
expiry: this.first.expiry
|
|
367
|
+
}, this.evict()), r = this.items[e] = {
|
|
368
|
+
expiry: this.ttl > 0 ? Date.now() + this.ttl : this.ttl,
|
|
369
|
+
key: e,
|
|
370
|
+
prev: this.last,
|
|
371
|
+
next: null,
|
|
372
|
+
value: t
|
|
373
|
+
}, ++this.size === 1 ? this.first = r : this.last.next = r, this.last = r) : (r.value = t, this.resetTTL && (r.expiry = this.ttl > 0 ? Date.now() + this.ttl : this.ttl), this.moveToEnd(r)), this.#e.sets++, n;
|
|
374
|
+
}
|
|
375
|
+
set(e, t) {
|
|
376
|
+
let n = this.items[e];
|
|
377
|
+
return n === void 0 ? (this.max > 0 && this.size === this.max && this.evict(), n = this.items[e] = {
|
|
378
|
+
expiry: this.ttl > 0 ? Date.now() + this.ttl : this.ttl,
|
|
379
|
+
key: e,
|
|
380
|
+
prev: this.last,
|
|
381
|
+
next: null,
|
|
382
|
+
value: t
|
|
383
|
+
}, ++this.size === 1 ? this.first = n : this.last.next = n, this.last = n) : (n.value = t, this.resetTTL && (n.expiry = this.ttl > 0 ? Date.now() + this.ttl : this.ttl), this.moveToEnd(n)), this.#e.sets++, this;
|
|
384
|
+
}
|
|
385
|
+
values(e) {
|
|
386
|
+
if (e === void 0) {
|
|
387
|
+
let e = Array.from({ length: this.size }), t = 0;
|
|
388
|
+
for (let n = this.first; n !== null; n = n.next) e[t++] = n.value;
|
|
389
|
+
return e;
|
|
390
|
+
}
|
|
391
|
+
let t = Array.from({ length: e.length });
|
|
392
|
+
for (let n = 0; n < e.length; n++) {
|
|
393
|
+
let r = this.items[e[n]];
|
|
394
|
+
t[n] = r === void 0 ? void 0 : r.value;
|
|
395
|
+
}
|
|
396
|
+
return t;
|
|
397
|
+
}
|
|
398
|
+
forEach(e, t) {
|
|
399
|
+
for (let n = this.first; n !== null; n = n.next) e.call(t, n.value, n.key, this);
|
|
400
|
+
return this;
|
|
401
|
+
}
|
|
402
|
+
getMany(e) {
|
|
403
|
+
let t = Object.create(null);
|
|
404
|
+
for (let n = 0; n < e.length; n++) {
|
|
405
|
+
let r = e[n];
|
|
406
|
+
t[r] = this.get(r);
|
|
407
|
+
}
|
|
408
|
+
return t;
|
|
409
|
+
}
|
|
410
|
+
hasAll(e) {
|
|
411
|
+
for (let t = 0; t < e.length; t++) if (!this.has(e[t])) return !1;
|
|
412
|
+
return !0;
|
|
413
|
+
}
|
|
414
|
+
hasAny(e) {
|
|
415
|
+
for (let t = 0; t < e.length; t++) if (this.has(e[t])) return !0;
|
|
416
|
+
return !1;
|
|
417
|
+
}
|
|
418
|
+
cleanup() {
|
|
419
|
+
if (this.ttl === 0 || this.size === 0) return 0;
|
|
420
|
+
let e = 0;
|
|
421
|
+
for (let t = this.first; t !== null;) {
|
|
422
|
+
let n = t.next;
|
|
423
|
+
if (this.#n(t)) {
|
|
424
|
+
let n = t.key;
|
|
425
|
+
this.items[n] !== void 0 && (delete this.items[n], this.size--, e++, this.#r(t), t.prev = null, t.next = null);
|
|
426
|
+
}
|
|
427
|
+
t = n;
|
|
428
|
+
}
|
|
429
|
+
return e > 0 && this.#i(), e;
|
|
430
|
+
}
|
|
431
|
+
toJSON() {
|
|
432
|
+
let e = [];
|
|
433
|
+
for (let t = this.first; t !== null; t = t.next) e.push({
|
|
434
|
+
key: t.key,
|
|
435
|
+
value: t.value,
|
|
436
|
+
expiry: t.expiry
|
|
437
|
+
});
|
|
438
|
+
return e;
|
|
439
|
+
}
|
|
440
|
+
stats() {
|
|
441
|
+
return { ...this.#e };
|
|
442
|
+
}
|
|
443
|
+
onEvict(e) {
|
|
444
|
+
if (typeof e != "function") throw TypeError("onEvict callback must be a function");
|
|
445
|
+
return this.#t = e, this;
|
|
446
|
+
}
|
|
447
|
+
sizeByTTL() {
|
|
448
|
+
if (this.ttl === 0) return {
|
|
449
|
+
valid: this.size,
|
|
450
|
+
expired: 0,
|
|
451
|
+
noTTL: this.size
|
|
452
|
+
};
|
|
453
|
+
let e = Date.now(), t = 0, n = 0, r = 0;
|
|
454
|
+
for (let i = this.first; i !== null; i = i.next) i.expiry === 0 ? (r++, t++) : i.expiry > e ? t++ : n++;
|
|
455
|
+
return {
|
|
456
|
+
valid: t,
|
|
457
|
+
expired: n,
|
|
458
|
+
noTTL: r
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
keysByTTL() {
|
|
462
|
+
if (this.ttl === 0) return {
|
|
463
|
+
valid: this.keys(),
|
|
464
|
+
expired: [],
|
|
465
|
+
noTTL: this.keys()
|
|
466
|
+
};
|
|
467
|
+
let e = Date.now(), t = [], n = [], r = [];
|
|
468
|
+
for (let i = this.first; i !== null; i = i.next) i.expiry === 0 ? (t.push(i.key), r.push(i.key)) : i.expiry > e ? t.push(i.key) : n.push(i.key);
|
|
469
|
+
return {
|
|
470
|
+
valid: t,
|
|
471
|
+
expired: n,
|
|
472
|
+
noTTL: r
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
valuesByTTL() {
|
|
476
|
+
let e = this.keysByTTL();
|
|
477
|
+
return {
|
|
478
|
+
valid: this.values(e.valid),
|
|
479
|
+
expired: this.values(e.expired),
|
|
480
|
+
noTTL: this.values(e.noTTL)
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
#i() {
|
|
484
|
+
if (this.size === 0) {
|
|
485
|
+
this.first = null, this.last = null;
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
let e = this.keys();
|
|
489
|
+
this.first = null, this.last = null;
|
|
490
|
+
for (let t = 0; t < e.length; t++) {
|
|
491
|
+
let n = this.items[e[t]];
|
|
492
|
+
n != null && (this.first === null ? (this.first = n, n.prev = null) : (n.prev = this.last, this.last.next = n), n.next = null, this.last = n);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
function n(e = 1e3, n = 0, r = !1) {
|
|
497
|
+
if (isNaN(e) || e < 0) throw TypeError("Invalid max value");
|
|
498
|
+
if (isNaN(n) || n < 0) throw TypeError("Invalid ttl value");
|
|
499
|
+
if (typeof r != "boolean") throw TypeError("Invalid resetTTL value");
|
|
500
|
+
return new t(e, n, r);
|
|
501
|
+
}
|
|
502
|
+
e.LRU = t, e.lru = n;
|
|
503
|
+
})), d = /* @__PURE__ */ e(((e) => {
|
|
504
|
+
var t = e && e.__importDefault || function(e) {
|
|
505
|
+
return e && e.__esModule ? e : { default: e };
|
|
506
|
+
};
|
|
507
|
+
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
508
|
+
var r = t(n("fs")), i = t(n("util"));
|
|
509
|
+
e.default = {
|
|
510
|
+
existsSync: r.default.existsSync,
|
|
511
|
+
readFile: i.default.promisify(r.default.readFile),
|
|
512
|
+
watchFile: r.default.watchFile,
|
|
513
|
+
createReadStream: r.default.createReadStream,
|
|
514
|
+
stat: i.default.promisify(r.default.stat)
|
|
515
|
+
};
|
|
516
|
+
})), f = /* @__PURE__ */ e(((e) => {
|
|
517
|
+
var t = e && e.__importDefault || function(e) {
|
|
518
|
+
return e && e.__esModule ? e : { default: e };
|
|
519
|
+
};
|
|
520
|
+
Object.defineProperty(e, "__esModule", { value: !0 });
|
|
521
|
+
var r = t(n("net")), i = (e) => {
|
|
522
|
+
let t = e.split(".", 4);
|
|
523
|
+
return [
|
|
524
|
+
parseInt(t[0]),
|
|
525
|
+
parseInt(t[1]),
|
|
526
|
+
parseInt(t[2]),
|
|
527
|
+
parseInt(t[3])
|
|
528
|
+
];
|
|
529
|
+
}, a = (e) => (e = parseInt(e, 10).toString(16), e.length === 2 ? e : "0" + e), o = (e) => {
|
|
530
|
+
let t = [
|
|
531
|
+
0,
|
|
532
|
+
0,
|
|
533
|
+
0,
|
|
534
|
+
0,
|
|
535
|
+
0,
|
|
536
|
+
0,
|
|
537
|
+
0,
|
|
538
|
+
0,
|
|
539
|
+
0,
|
|
540
|
+
0,
|
|
541
|
+
0,
|
|
542
|
+
0,
|
|
543
|
+
0,
|
|
544
|
+
0,
|
|
545
|
+
0,
|
|
546
|
+
0
|
|
547
|
+
], n, r, i;
|
|
548
|
+
e.indexOf(".") > -1 && (e = e.replace(/(\d+)\.(\d+)\.(\d+)\.(\d+)/, (e, t, n, r, i) => a(t) + a(n) + ":" + a(r) + a(i)));
|
|
549
|
+
let [o, s] = e.split("::", 2);
|
|
550
|
+
if (o) for (r = o.split(":"), n = 0; n < r.length; n++) i = parseInt(r[n], 16), t[n * 2] = i >> 8, t[n * 2 + 1] = i & 255;
|
|
551
|
+
if (s) {
|
|
552
|
+
r = s.split(":");
|
|
553
|
+
let e = 16 - r.length * 2;
|
|
554
|
+
for (n = 0; n < r.length; n++) i = parseInt(r[n], 16), t[e + n * 2] = i >> 8, t[e + (n * 2 + 1)] = i & 255;
|
|
555
|
+
}
|
|
556
|
+
return t;
|
|
557
|
+
};
|
|
558
|
+
e.default = {
|
|
559
|
+
bitAt: (e, t) => {
|
|
560
|
+
let n = t >> 3, r = 7 ^ t & 7;
|
|
561
|
+
return e[n] >>> r & 1;
|
|
562
|
+
},
|
|
563
|
+
parse: (e) => e.indexOf(":") === -1 ? i(e) : o(e),
|
|
564
|
+
validate: (e) => {
|
|
565
|
+
let t = r.default.isIP(e);
|
|
566
|
+
return t === 4 || t === 6;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
})), p = /* @__PURE__ */ e(((e) => {
|
|
570
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.default = (e) => !e || e.length < 3 ? !1 : e[0] === 31 && e[1] === 139 && e[2] === 8;
|
|
571
|
+
})), m = /* @__PURE__ */ e(((e) => {
|
|
572
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.default = {
|
|
573
|
+
concat2: (e, t) => e << 8 | t,
|
|
574
|
+
concat3: (e, t, n) => e << 16 | t << 8 | n,
|
|
575
|
+
concat4: (e, t, n, r) => e << 24 | t << 16 | n << 8 | r,
|
|
576
|
+
legacyErrorMessage: "Maxmind v2 module has changed API.\nUpgrade instructions can be found here: https://github.com/runk/node-maxmind/wiki/Migration-guide\nIf you want to use legacy libary then explicitly install maxmind@1"
|
|
577
|
+
};
|
|
578
|
+
})), h = /* @__PURE__ */ t((/* @__PURE__ */ e(((e) => {
|
|
579
|
+
var t = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
|
|
580
|
+
r === void 0 && (r = n);
|
|
581
|
+
var i = Object.getOwnPropertyDescriptor(t, n);
|
|
582
|
+
(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
|
|
583
|
+
enumerable: !0,
|
|
584
|
+
get: function() {
|
|
585
|
+
return t[n];
|
|
586
|
+
}
|
|
587
|
+
}), Object.defineProperty(e, r, i);
|
|
588
|
+
}) : (function(e, t, n, r) {
|
|
589
|
+
r === void 0 && (r = n), e[r] = t[n];
|
|
590
|
+
})), r = e && e.__exportStar || function(e, n) {
|
|
591
|
+
for (var r in e) r !== "default" && !Object.prototype.hasOwnProperty.call(n, r) && t(n, e, r);
|
|
592
|
+
}, i = e && e.__importDefault || function(e) {
|
|
593
|
+
return e && e.__esModule ? e : { default: e };
|
|
594
|
+
};
|
|
595
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.Reader = e.validate = e.init = e.openSync = e.open = void 0;
|
|
596
|
+
var a = i(n("assert")), o = l();
|
|
597
|
+
Object.defineProperty(e, "Reader", {
|
|
598
|
+
enumerable: !0,
|
|
599
|
+
get: function() {
|
|
600
|
+
return o.Reader;
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
var s = u(), c = i(d()), h = i(f()), g = i(p()), _ = i(m()), v = 512 * 1024 * 1024, y = 8 * 1024 * 1024, b = async (e, t) => new Promise((n, r) => {
|
|
604
|
+
let i = Buffer.allocUnsafe(t), a = 0, o = c.default.createReadStream(e, { highWaterMark: y });
|
|
605
|
+
o.on("data", (e) => {
|
|
606
|
+
if (Buffer.isBuffer(e)) e.copy(i, a), a += e.length;
|
|
607
|
+
else {
|
|
608
|
+
let t = Buffer.from(e);
|
|
609
|
+
t.copy(i, a), a += t.length;
|
|
610
|
+
}
|
|
611
|
+
}), o.on("end", () => {
|
|
612
|
+
o.close(), n(i);
|
|
613
|
+
}), o.on("error", (e) => {
|
|
614
|
+
r(e);
|
|
615
|
+
});
|
|
616
|
+
}), x = async (e) => {
|
|
617
|
+
let t = await c.default.stat(e);
|
|
618
|
+
return t.size < v ? c.default.readFile(e) : b(e, t.size);
|
|
619
|
+
};
|
|
620
|
+
e.open = async (e, t, n) => {
|
|
621
|
+
(0, a.default)(!n, _.default.legacyErrorMessage);
|
|
622
|
+
let r = await x(e);
|
|
623
|
+
if ((0, g.default)(r)) throw Error("Looks like you are passing in a file in gzip format, please use mmdb database instead.");
|
|
624
|
+
let i = (0, s.lru)(t?.cache?.max || 1e4), l = new o.Reader(r, { cache: i });
|
|
625
|
+
if (t && t.watchForUpdates) {
|
|
626
|
+
if (t.watchForUpdatesHook && typeof t.watchForUpdatesHook != "function") throw Error("opts.watchForUpdatesHook should be a function");
|
|
627
|
+
let n = { persistent: t.watchForUpdatesNonPersistent !== !0 };
|
|
628
|
+
c.default.watchFile(e, n, async () => {
|
|
629
|
+
if (!await (async () => {
|
|
630
|
+
for (let t = 0; t < 3; t++) {
|
|
631
|
+
if (c.default.existsSync(e)) return !0;
|
|
632
|
+
await new Promise((e) => setTimeout(e, 500));
|
|
633
|
+
}
|
|
634
|
+
return !1;
|
|
635
|
+
})()) return;
|
|
636
|
+
let n = await x(e);
|
|
637
|
+
i.clear(), l.load(n), t.watchForUpdatesHook && t.watchForUpdatesHook();
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
return l;
|
|
641
|
+
}, e.openSync = () => {
|
|
642
|
+
throw Error(_.default.legacyErrorMessage);
|
|
643
|
+
}, e.init = () => {
|
|
644
|
+
throw Error(_.default.legacyErrorMessage);
|
|
645
|
+
}, e.validate = h.default.validate, r(l(), e), e.default = {
|
|
646
|
+
init: e.init,
|
|
647
|
+
open: e.open,
|
|
648
|
+
openSync: e.openSync,
|
|
649
|
+
validate: h.default.validate
|
|
650
|
+
};
|
|
651
|
+
})))(), 1), g = class extends Error {
|
|
652
|
+
code;
|
|
653
|
+
error;
|
|
654
|
+
url;
|
|
655
|
+
constructor(e, t) {
|
|
656
|
+
super(e.error, t), this.code = e.code, this.error = e.error, e.status !== void 0 && (this.status = e.status), this.url = e.url;
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
g.prototype.name = "WebServiceError";
|
|
660
|
+
var _ = class extends Error {
|
|
661
|
+
constructor(e, t) {
|
|
662
|
+
super(e, t), this.name = this.constructor.name;
|
|
663
|
+
}
|
|
664
|
+
}, v = class extends Error {
|
|
665
|
+
constructor(e, t) {
|
|
666
|
+
super(e, t), this.name = this.constructor.name;
|
|
667
|
+
}
|
|
668
|
+
}, y = class extends Error {
|
|
669
|
+
constructor(e, t) {
|
|
670
|
+
super(e, t), this.name = this.constructor.name;
|
|
671
|
+
}
|
|
672
|
+
}, b = class extends Error {
|
|
673
|
+
constructor(e, t) {
|
|
674
|
+
super(e, t), this.name = this.constructor.name;
|
|
675
|
+
}
|
|
676
|
+
}, x = class {
|
|
677
|
+
ipAddress;
|
|
678
|
+
isAnonymous;
|
|
679
|
+
isAnonymousVpn;
|
|
680
|
+
isHostingProvider;
|
|
681
|
+
isPublicProxy;
|
|
682
|
+
isResidentialProxy;
|
|
683
|
+
isTorExitNode;
|
|
684
|
+
network;
|
|
685
|
+
constructor(e, t, n) {
|
|
686
|
+
this.ipAddress = t, this.isAnonymous = !!e.is_anonymous, this.isAnonymousVpn = !!e.is_anonymous_vpn, this.isHostingProvider = !!e.is_hosting_provider, this.isPublicProxy = !!e.is_public_proxy, this.isResidentialProxy = !!e.is_residential_proxy, this.isTorExitNode = !!e.is_tor_exit_node, this.network = n;
|
|
687
|
+
}
|
|
688
|
+
}, S = class extends x {
|
|
689
|
+
anonymizerConfidence;
|
|
690
|
+
networkLastSeen;
|
|
691
|
+
providerName;
|
|
692
|
+
constructor(e, t, n) {
|
|
693
|
+
super(e, t, n), this.anonymizerConfidence = e.anonymizer_confidence, this.networkLastSeen = e.network_last_seen, this.providerName = e.provider_name;
|
|
694
|
+
}
|
|
695
|
+
}, C = class {
|
|
696
|
+
autonomousSystemNumber;
|
|
697
|
+
autonomousSystemOrganization;
|
|
698
|
+
ipAddress;
|
|
699
|
+
network;
|
|
700
|
+
constructor(e, t, n) {
|
|
701
|
+
this.autonomousSystemNumber = e.autonomous_system_number, this.autonomousSystemOrganization = e.autonomous_system_organization, this.ipAddress = t, this.network = n;
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region ../../node_modules/@maxmind/geoip2-node/dist/src/utils.js
|
|
706
|
+
function w(e) {
|
|
707
|
+
return e.replace(/_+(\w?)/g, (e, t, n) => n === 0 ? t : t.toUpperCase());
|
|
708
|
+
}
|
|
709
|
+
var T = (e) => typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof RegExp) && !(e instanceof Error) && !(e instanceof Date);
|
|
710
|
+
function E(e, t) {
|
|
711
|
+
let n = e.includes(":"), r = k(D(n && e.includes(".") ? e.replace(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/, (e, t) => N(D(t, !1))) : e, n), t);
|
|
712
|
+
return `${n ? j(r) : A(r)}/${t}`;
|
|
713
|
+
}
|
|
714
|
+
function D(e, t) {
|
|
715
|
+
if (t) {
|
|
716
|
+
let t = /* @__PURE__ */ new Uint8Array(16), n = O(e);
|
|
717
|
+
for (let e = 0; e < 8; e++) {
|
|
718
|
+
let r = parseInt(n[e], 16);
|
|
719
|
+
t[2 * e] = r >> 8, t[2 * e + 1] = r & 255;
|
|
720
|
+
}
|
|
721
|
+
return t;
|
|
722
|
+
} else return new Uint8Array(e.split(".").map((e) => parseInt(e)));
|
|
723
|
+
}
|
|
724
|
+
function O(e) {
|
|
725
|
+
let t = e.split(":");
|
|
726
|
+
if (t.length < 8) {
|
|
727
|
+
let e = t.indexOf(""), n = 8 - t.length + 1;
|
|
728
|
+
return [
|
|
729
|
+
...t.slice(0, e),
|
|
730
|
+
...Array(n).fill("0"),
|
|
731
|
+
...t.slice(e + 1)
|
|
732
|
+
];
|
|
733
|
+
}
|
|
734
|
+
return t;
|
|
735
|
+
}
|
|
736
|
+
function k(e, t) {
|
|
737
|
+
let n = Math.floor(t / 8);
|
|
738
|
+
if (e.length == n) return e;
|
|
739
|
+
let r = new Uint8Array(e.length);
|
|
740
|
+
for (let t = 0; t < n; t++) r[t] = e[t];
|
|
741
|
+
return r[n] = e[n] & 255 << 8 - t % 8, r;
|
|
742
|
+
}
|
|
743
|
+
function A(e) {
|
|
744
|
+
return e.join(".");
|
|
745
|
+
}
|
|
746
|
+
function j(e) {
|
|
747
|
+
if (e.length !== 16) throw Error("Invalid input, IPv6 address requires exactly 16 octets.");
|
|
748
|
+
if (M(e)) return "::ffff:" + A(e.slice(12));
|
|
749
|
+
let [t, n] = P(e);
|
|
750
|
+
return t == n ? N(e) : N(e.slice(0, t)) + "::" + N(e.slice(n));
|
|
751
|
+
}
|
|
752
|
+
function M(e) {
|
|
753
|
+
return e[0] === 0 && e[1] === 0 && e[2] === 0 && e[3] === 0 && e[4] === 0 && e[5] === 0 && e[6] === 0 && e[7] === 0 && e[8] === 0 && e[9] === 0 && e[10] === 255 && e[11] === 255;
|
|
754
|
+
}
|
|
755
|
+
function N(e) {
|
|
756
|
+
if (e.length == 0) return "";
|
|
757
|
+
let t = Array(e.length / 2);
|
|
758
|
+
for (let n = 0; n < t.length; n++) {
|
|
759
|
+
let r = e[2 * n], i = e[2 * n + 1];
|
|
760
|
+
r == 0 ? t[n] = i.toString(16) : t[n] = r.toString(16) + i.toString(16).padStart(2, "0");
|
|
761
|
+
}
|
|
762
|
+
return t.join(":");
|
|
763
|
+
}
|
|
764
|
+
function P(e) {
|
|
765
|
+
let t = 0, n = 0, r = 0, i = 0;
|
|
766
|
+
for (let a = 0; a < e.length / 2; a++) e[2 * a] === 0 && e[2 * a + 1] === 0 ? (i === 0 && (r = 2 * a), i++) : (i > n && (n = i, t = r), i = 0);
|
|
767
|
+
return i > n && (n = i, t = r), [t, t + 2 * n];
|
|
768
|
+
}
|
|
769
|
+
var F = (e) => e.map((e) => Array.isArray(e) ? F(e) : T(e) ? I(e) : e);
|
|
770
|
+
function I(e) {
|
|
771
|
+
if (Array.isArray(e)) return F(e);
|
|
772
|
+
if (!T(e)) return e;
|
|
773
|
+
let t = {};
|
|
774
|
+
for (let [n, r] of Object.entries(e)) Array.isArray(r) ? t[w(n)] = F(r) : T(r) ? t[w(n)] = I(r) : t[w(n)] = r;
|
|
775
|
+
return t;
|
|
776
|
+
}
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region ../../node_modules/@maxmind/geoip2-node/dist/src/models/Country.js
|
|
779
|
+
var L = class {
|
|
780
|
+
continent;
|
|
781
|
+
country;
|
|
782
|
+
maxmind;
|
|
783
|
+
registeredCountry;
|
|
784
|
+
representedCountry;
|
|
785
|
+
traits;
|
|
786
|
+
constructor(e, t, n) {
|
|
787
|
+
let r = I(e);
|
|
788
|
+
this.continent = r.continent || void 0, this.country = r.country || void 0, this.maxmind = r.maxmind || void 0, this.registeredCountry = this.setBooleanRegisteredCountry(r.registeredCountry) || void 0, this.representedCountry = r.representedCountry || void 0, this.traits = this.setBooleanTraits(r.traits || {}), this.traits.ipAddress ??= t, this.traits.network ??= n;
|
|
789
|
+
}
|
|
790
|
+
setBooleanTraits(e) {
|
|
791
|
+
return [
|
|
792
|
+
"isAnonymous",
|
|
793
|
+
"isAnonymousProxy",
|
|
794
|
+
"isAnonymousVpn",
|
|
795
|
+
"isAnycast",
|
|
796
|
+
"isHostingProvider",
|
|
797
|
+
"isLegitimateProxy",
|
|
798
|
+
"isPublicProxy",
|
|
799
|
+
"isResidentialProxy",
|
|
800
|
+
"isSatelliteProvider",
|
|
801
|
+
"isTorExitNode"
|
|
802
|
+
].forEach((t) => {
|
|
803
|
+
e[t] = !!e[t];
|
|
804
|
+
}), e;
|
|
805
|
+
}
|
|
806
|
+
setBooleanRegisteredCountry(e) {
|
|
807
|
+
return e && (e.isInEuropeanUnion = !!e.isInEuropeanUnion), e;
|
|
808
|
+
}
|
|
809
|
+
}, R = class extends L {
|
|
810
|
+
city;
|
|
811
|
+
location;
|
|
812
|
+
postal;
|
|
813
|
+
subdivisions;
|
|
814
|
+
constructor(e, t, n) {
|
|
815
|
+
super(e, t, n);
|
|
816
|
+
let r = I(e);
|
|
817
|
+
this.city = r.city || void 0, this.location = r.location || void 0, this.postal = r.postal || void 0, this.subdivisions = r.subdivisions || void 0;
|
|
818
|
+
}
|
|
819
|
+
}, z = class {
|
|
820
|
+
connectionType;
|
|
821
|
+
ipAddress;
|
|
822
|
+
network;
|
|
823
|
+
constructor(e, t, n) {
|
|
824
|
+
this.connectionType = e.connection_type, this.ipAddress = t, this.network = n;
|
|
825
|
+
}
|
|
826
|
+
}, B = class {
|
|
827
|
+
domain;
|
|
828
|
+
ipAddress;
|
|
829
|
+
network;
|
|
830
|
+
constructor(e, t, n) {
|
|
831
|
+
this.domain = e.domain, this.ipAddress = t, this.network = n;
|
|
832
|
+
}
|
|
833
|
+
}, V = class extends R {
|
|
834
|
+
constructor(e, t, n) {
|
|
835
|
+
super(e, t, n);
|
|
836
|
+
}
|
|
837
|
+
}, H = class extends C {
|
|
838
|
+
isp;
|
|
839
|
+
mobileCountryCode;
|
|
840
|
+
mobileNetworkCode;
|
|
841
|
+
organization;
|
|
842
|
+
constructor(e, t, n) {
|
|
843
|
+
super(e, t, n), this.isp = e.isp, this.mobileCountryCode = e.mobile_country_code, this.mobileNetworkCode = e.mobile_network_code, this.organization = e.organization;
|
|
844
|
+
}
|
|
845
|
+
}, U = class {
|
|
846
|
+
mmdbReader;
|
|
847
|
+
constructor(e) {
|
|
848
|
+
this.mmdbReader = e;
|
|
849
|
+
}
|
|
850
|
+
anonymousIP(e) {
|
|
851
|
+
return this.modelFor(x, "GeoIP2-Anonymous-IP", e, "anonymousIP()");
|
|
852
|
+
}
|
|
853
|
+
anonymousPlus(e) {
|
|
854
|
+
return this.modelFor(S, "GeoIP-Anonymous-Plus", e, "anonymousPlus()");
|
|
855
|
+
}
|
|
856
|
+
city(e) {
|
|
857
|
+
return this.modelFor(R, "City", e, "city()");
|
|
858
|
+
}
|
|
859
|
+
country(e) {
|
|
860
|
+
return this.modelFor(L, "Country", e, "country()");
|
|
861
|
+
}
|
|
862
|
+
asn(e) {
|
|
863
|
+
return this.modelFor(C, "ASN", e, "asn()");
|
|
864
|
+
}
|
|
865
|
+
connectionType(e) {
|
|
866
|
+
return this.modelFor(z, "Connection-Type", e, "connectionType()");
|
|
867
|
+
}
|
|
868
|
+
domain(e) {
|
|
869
|
+
return this.modelFor(B, "Domain", e, "domain()");
|
|
870
|
+
}
|
|
871
|
+
isp(e) {
|
|
872
|
+
return this.modelFor(H, "ISP", e, "isp()");
|
|
873
|
+
}
|
|
874
|
+
enterprise(e) {
|
|
875
|
+
return this.modelFor(V, "Enterprise", e, "enterprise()");
|
|
876
|
+
}
|
|
877
|
+
getRecord(e, t, n) {
|
|
878
|
+
let r = this.mmdbReader.metadata.databaseType;
|
|
879
|
+
if (!h.validate(t)) throw new b(`${t} is invalid`);
|
|
880
|
+
if (!r.includes(e)) throw new v(`The ${n} method cannot be used with the ${r} database`);
|
|
881
|
+
let [i, a] = this.mmdbReader.getWithPrefixLength(t);
|
|
882
|
+
if (!i) throw new _(`The address ${t} is not in the database`);
|
|
883
|
+
return [i, E(t, a)];
|
|
884
|
+
}
|
|
885
|
+
modelFor(e, t, n, r) {
|
|
886
|
+
let [i, a] = this.getRecord(t, n, r);
|
|
887
|
+
return new e(i, n, a);
|
|
888
|
+
}
|
|
889
|
+
}, W = class {
|
|
890
|
+
static async open(e, t) {
|
|
891
|
+
return new U(await h.open(e, t));
|
|
892
|
+
}
|
|
893
|
+
static openBuffer(e) {
|
|
894
|
+
let t;
|
|
895
|
+
try {
|
|
896
|
+
t = new h.Reader(e);
|
|
897
|
+
} catch (e) {
|
|
898
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
899
|
+
throw new y(t.message, { cause: t });
|
|
900
|
+
}
|
|
901
|
+
return new U(t);
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
//#endregion
|
|
905
|
+
export { W as Reader };
|