browserclaw 0.5.5 → 0.5.6

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/index.js CHANGED
@@ -8,9 +8,819 @@ import { lookup as lookup$1 } from 'dns/promises';
8
8
  import { lookup } from 'dns';
9
9
  import { realpath, rename, rm, lstat } from 'fs/promises';
10
10
  import { randomUUID } from 'crypto';
11
- import * as ipaddr from 'ipaddr.js';
12
11
 
13
- // src/chrome-launcher.ts
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf;
17
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
18
+ var __commonJS = (cb, mod) => function __require() {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
35
+ mod
36
+ ));
37
+
38
+ // node_modules/ipaddr.js/lib/ipaddr.js
39
+ var require_ipaddr = __commonJS({
40
+ "node_modules/ipaddr.js/lib/ipaddr.js"(exports$1, module) {
41
+ (function(root) {
42
+ const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
43
+ const ipv4Regexes = {
44
+ fourOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
45
+ threeOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
46
+ twoOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}$`, "i"),
47
+ longValue: new RegExp(`^${ipv4Part}$`, "i")
48
+ };
49
+ const octalRegex = new RegExp(`^0[0-7]+$`, "i");
50
+ const hexRegex = new RegExp(`^0x[a-f0-9]+$`, "i");
51
+ const zoneIndex = "%[0-9a-z]{1,}";
52
+ const ipv6Part = "(?:[0-9a-f]+::?)+";
53
+ const ipv6Regexes = {
54
+ zoneIndex: new RegExp(zoneIndex, "i"),
55
+ "native": new RegExp(`^(::)?(${ipv6Part})?([0-9a-f]+)?(::)?(${zoneIndex})?$`, "i"),
56
+ deprecatedTransitional: new RegExp(`^(?:::)(${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?)$`, "i"),
57
+ transitional: new RegExp(`^((?:${ipv6Part})|(?:::)(?:${ipv6Part})?)${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?$`, "i")
58
+ };
59
+ function expandIPv6(string, parts) {
60
+ if (string.indexOf("::") !== string.lastIndexOf("::")) {
61
+ return null;
62
+ }
63
+ let colonCount = 0;
64
+ let lastColon = -1;
65
+ let zoneId = (string.match(ipv6Regexes.zoneIndex) || [])[0];
66
+ let replacement, replacementCount;
67
+ if (zoneId) {
68
+ zoneId = zoneId.substring(1);
69
+ string = string.replace(/%.+$/, "");
70
+ }
71
+ while ((lastColon = string.indexOf(":", lastColon + 1)) >= 0) {
72
+ colonCount++;
73
+ }
74
+ if (string.substr(0, 2) === "::") {
75
+ colonCount--;
76
+ }
77
+ if (string.substr(-2, 2) === "::") {
78
+ colonCount--;
79
+ }
80
+ if (colonCount > parts) {
81
+ return null;
82
+ }
83
+ replacementCount = parts - colonCount;
84
+ replacement = ":";
85
+ while (replacementCount--) {
86
+ replacement += "0:";
87
+ }
88
+ string = string.replace("::", replacement);
89
+ if (string[0] === ":") {
90
+ string = string.slice(1);
91
+ }
92
+ if (string[string.length - 1] === ":") {
93
+ string = string.slice(0, -1);
94
+ }
95
+ parts = (function() {
96
+ const ref = string.split(":");
97
+ const results = [];
98
+ for (let i = 0; i < ref.length; i++) {
99
+ results.push(parseInt(ref[i], 16));
100
+ }
101
+ return results;
102
+ })();
103
+ return {
104
+ parts,
105
+ zoneId
106
+ };
107
+ }
108
+ function matchCIDR(first, second, partSize, cidrBits) {
109
+ if (first.length !== second.length) {
110
+ throw new Error("ipaddr: cannot match CIDR for objects with different lengths");
111
+ }
112
+ let part = 0;
113
+ let shift;
114
+ while (cidrBits > 0) {
115
+ shift = partSize - cidrBits;
116
+ if (shift < 0) {
117
+ shift = 0;
118
+ }
119
+ if (first[part] >> shift !== second[part] >> shift) {
120
+ return false;
121
+ }
122
+ cidrBits -= partSize;
123
+ part += 1;
124
+ }
125
+ return true;
126
+ }
127
+ function parseIntAuto(string) {
128
+ if (hexRegex.test(string)) {
129
+ return parseInt(string, 16);
130
+ }
131
+ if (string[0] === "0" && !isNaN(parseInt(string[1], 10))) {
132
+ if (octalRegex.test(string)) {
133
+ return parseInt(string, 8);
134
+ }
135
+ throw new Error(`ipaddr: cannot parse ${string} as octal`);
136
+ }
137
+ return parseInt(string, 10);
138
+ }
139
+ function padPart(part, length) {
140
+ while (part.length < length) {
141
+ part = `0${part}`;
142
+ }
143
+ return part;
144
+ }
145
+ const ipaddr2 = {};
146
+ ipaddr2.IPv4 = (function() {
147
+ function IPv42(octets) {
148
+ if (octets.length !== 4) {
149
+ throw new Error("ipaddr: ipv4 octet count should be 4");
150
+ }
151
+ let i, octet;
152
+ for (i = 0; i < octets.length; i++) {
153
+ octet = octets[i];
154
+ if (!(0 <= octet && octet <= 255)) {
155
+ throw new Error("ipaddr: ipv4 octet should fit in 8 bits");
156
+ }
157
+ }
158
+ this.octets = octets;
159
+ }
160
+ IPv42.prototype.SpecialRanges = {
161
+ unspecified: [[new IPv42([0, 0, 0, 0]), 8]],
162
+ broadcast: [[new IPv42([255, 255, 255, 255]), 32]],
163
+ // RFC3171
164
+ multicast: [[new IPv42([224, 0, 0, 0]), 4]],
165
+ // RFC3927
166
+ linkLocal: [[new IPv42([169, 254, 0, 0]), 16]],
167
+ // RFC5735
168
+ loopback: [[new IPv42([127, 0, 0, 0]), 8]],
169
+ // RFC6598
170
+ carrierGradeNat: [[new IPv42([100, 64, 0, 0]), 10]],
171
+ // RFC1918
172
+ "private": [
173
+ [new IPv42([10, 0, 0, 0]), 8],
174
+ [new IPv42([172, 16, 0, 0]), 12],
175
+ [new IPv42([192, 168, 0, 0]), 16]
176
+ ],
177
+ // Reserved and testing-only ranges; RFCs 5735, 5737, 2544, 1700
178
+ reserved: [
179
+ [new IPv42([192, 0, 0, 0]), 24],
180
+ [new IPv42([192, 0, 2, 0]), 24],
181
+ [new IPv42([192, 88, 99, 0]), 24],
182
+ [new IPv42([198, 18, 0, 0]), 15],
183
+ [new IPv42([198, 51, 100, 0]), 24],
184
+ [new IPv42([203, 0, 113, 0]), 24],
185
+ [new IPv42([240, 0, 0, 0]), 4]
186
+ ],
187
+ // RFC7534, RFC7535
188
+ as112: [
189
+ [new IPv42([192, 175, 48, 0]), 24],
190
+ [new IPv42([192, 31, 196, 0]), 24]
191
+ ],
192
+ // RFC7450
193
+ amt: [
194
+ [new IPv42([192, 52, 193, 0]), 24]
195
+ ]
196
+ };
197
+ IPv42.prototype.kind = function() {
198
+ return "ipv4";
199
+ };
200
+ IPv42.prototype.match = function(other, cidrRange) {
201
+ let ref;
202
+ if (cidrRange === void 0) {
203
+ ref = other;
204
+ other = ref[0];
205
+ cidrRange = ref[1];
206
+ }
207
+ if (other.kind() !== "ipv4") {
208
+ throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");
209
+ }
210
+ return matchCIDR(this.octets, other.octets, 8, cidrRange);
211
+ };
212
+ IPv42.prototype.prefixLengthFromSubnetMask = function() {
213
+ let cidr = 0;
214
+ let stop = false;
215
+ const zerotable = {
216
+ 0: 8,
217
+ 128: 7,
218
+ 192: 6,
219
+ 224: 5,
220
+ 240: 4,
221
+ 248: 3,
222
+ 252: 2,
223
+ 254: 1,
224
+ 255: 0
225
+ };
226
+ let i, octet, zeros;
227
+ for (i = 3; i >= 0; i -= 1) {
228
+ octet = this.octets[i];
229
+ if (octet in zerotable) {
230
+ zeros = zerotable[octet];
231
+ if (stop && zeros !== 0) {
232
+ return null;
233
+ }
234
+ if (zeros !== 8) {
235
+ stop = true;
236
+ }
237
+ cidr += zeros;
238
+ } else {
239
+ return null;
240
+ }
241
+ }
242
+ return 32 - cidr;
243
+ };
244
+ IPv42.prototype.range = function() {
245
+ return ipaddr2.subnetMatch(this, this.SpecialRanges);
246
+ };
247
+ IPv42.prototype.toByteArray = function() {
248
+ return this.octets.slice(0);
249
+ };
250
+ IPv42.prototype.toIPv4MappedAddress = function() {
251
+ return ipaddr2.IPv6.parse(`::ffff:${this.toString()}`);
252
+ };
253
+ IPv42.prototype.toNormalizedString = function() {
254
+ return this.toString();
255
+ };
256
+ IPv42.prototype.toString = function() {
257
+ return this.octets.join(".");
258
+ };
259
+ return IPv42;
260
+ })();
261
+ ipaddr2.IPv4.broadcastAddressFromCIDR = function(string) {
262
+ try {
263
+ const cidr = this.parseCIDR(string);
264
+ const ipInterfaceOctets = cidr[0].toByteArray();
265
+ const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
266
+ const octets = [];
267
+ let i = 0;
268
+ while (i < 4) {
269
+ octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
270
+ i++;
271
+ }
272
+ return new this(octets);
273
+ } catch (e) {
274
+ throw new Error("ipaddr: the address does not have IPv4 CIDR format");
275
+ }
276
+ };
277
+ ipaddr2.IPv4.isIPv4 = function(string) {
278
+ return this.parser(string) !== null;
279
+ };
280
+ ipaddr2.IPv4.isValid = function(string) {
281
+ try {
282
+ new this(this.parser(string));
283
+ return true;
284
+ } catch (e) {
285
+ return false;
286
+ }
287
+ };
288
+ ipaddr2.IPv4.isValidCIDR = function(string) {
289
+ try {
290
+ this.parseCIDR(string);
291
+ return true;
292
+ } catch (e) {
293
+ return false;
294
+ }
295
+ };
296
+ ipaddr2.IPv4.isValidFourPartDecimal = function(string) {
297
+ if (ipaddr2.IPv4.isValid(string) && string.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/)) {
298
+ return true;
299
+ } else {
300
+ return false;
301
+ }
302
+ };
303
+ ipaddr2.IPv4.isValidCIDRFourPartDecimal = function(string) {
304
+ const match = string.match(/^(.+)\/(\d+)$/);
305
+ if (!ipaddr2.IPv4.isValidCIDR(string) || !match) {
306
+ return false;
307
+ }
308
+ return ipaddr2.IPv4.isValidFourPartDecimal(match[1]);
309
+ };
310
+ ipaddr2.IPv4.networkAddressFromCIDR = function(string) {
311
+ let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;
312
+ try {
313
+ cidr = this.parseCIDR(string);
314
+ ipInterfaceOctets = cidr[0].toByteArray();
315
+ subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
316
+ octets = [];
317
+ i = 0;
318
+ while (i < 4) {
319
+ octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
320
+ i++;
321
+ }
322
+ return new this(octets);
323
+ } catch (e) {
324
+ throw new Error("ipaddr: the address does not have IPv4 CIDR format");
325
+ }
326
+ };
327
+ ipaddr2.IPv4.parse = function(string) {
328
+ const parts = this.parser(string);
329
+ if (parts === null) {
330
+ throw new Error("ipaddr: string is not formatted like an IPv4 Address");
331
+ }
332
+ return new this(parts);
333
+ };
334
+ ipaddr2.IPv4.parseCIDR = function(string) {
335
+ let match;
336
+ if (match = string.match(/^(.+)\/(\d+)$/)) {
337
+ const maskLength = parseInt(match[2]);
338
+ if (maskLength >= 0 && maskLength <= 32) {
339
+ const parsed = [this.parse(match[1]), maskLength];
340
+ Object.defineProperty(parsed, "toString", {
341
+ value: function() {
342
+ return this.join("/");
343
+ }
344
+ });
345
+ return parsed;
346
+ }
347
+ }
348
+ throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range");
349
+ };
350
+ ipaddr2.IPv4.parser = function(string) {
351
+ let match, part, value;
352
+ if (match = string.match(ipv4Regexes.fourOctet)) {
353
+ return (function() {
354
+ const ref = match.slice(1, 6);
355
+ const results = [];
356
+ for (let i = 0; i < ref.length; i++) {
357
+ part = ref[i];
358
+ results.push(parseIntAuto(part));
359
+ }
360
+ return results;
361
+ })();
362
+ } else if (match = string.match(ipv4Regexes.longValue)) {
363
+ value = parseIntAuto(match[1]);
364
+ if (value > 4294967295 || value < 0) {
365
+ throw new Error("ipaddr: address outside defined range");
366
+ }
367
+ return (function() {
368
+ const results = [];
369
+ let shift;
370
+ for (shift = 0; shift <= 24; shift += 8) {
371
+ results.push(value >> shift & 255);
372
+ }
373
+ return results;
374
+ })().reverse();
375
+ } else if (match = string.match(ipv4Regexes.twoOctet)) {
376
+ return (function() {
377
+ const ref = match.slice(1, 4);
378
+ const results = [];
379
+ value = parseIntAuto(ref[1]);
380
+ if (value > 16777215 || value < 0) {
381
+ throw new Error("ipaddr: address outside defined range");
382
+ }
383
+ results.push(parseIntAuto(ref[0]));
384
+ results.push(value >> 16 & 255);
385
+ results.push(value >> 8 & 255);
386
+ results.push(value & 255);
387
+ return results;
388
+ })();
389
+ } else if (match = string.match(ipv4Regexes.threeOctet)) {
390
+ return (function() {
391
+ const ref = match.slice(1, 5);
392
+ const results = [];
393
+ value = parseIntAuto(ref[2]);
394
+ if (value > 65535 || value < 0) {
395
+ throw new Error("ipaddr: address outside defined range");
396
+ }
397
+ results.push(parseIntAuto(ref[0]));
398
+ results.push(parseIntAuto(ref[1]));
399
+ results.push(value >> 8 & 255);
400
+ results.push(value & 255);
401
+ return results;
402
+ })();
403
+ } else {
404
+ return null;
405
+ }
406
+ };
407
+ ipaddr2.IPv4.subnetMaskFromPrefixLength = function(prefix) {
408
+ prefix = parseInt(prefix);
409
+ if (prefix < 0 || prefix > 32) {
410
+ throw new Error("ipaddr: invalid IPv4 prefix length");
411
+ }
412
+ const octets = [0, 0, 0, 0];
413
+ let j = 0;
414
+ const filledOctetCount = Math.floor(prefix / 8);
415
+ while (j < filledOctetCount) {
416
+ octets[j] = 255;
417
+ j++;
418
+ }
419
+ if (filledOctetCount < 4) {
420
+ octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
421
+ }
422
+ return new this(octets);
423
+ };
424
+ ipaddr2.IPv6 = (function() {
425
+ function IPv62(parts, zoneId) {
426
+ let i, part;
427
+ if (parts.length === 16) {
428
+ this.parts = [];
429
+ for (i = 0; i <= 14; i += 2) {
430
+ this.parts.push(parts[i] << 8 | parts[i + 1]);
431
+ }
432
+ } else if (parts.length === 8) {
433
+ this.parts = parts;
434
+ } else {
435
+ throw new Error("ipaddr: ipv6 part count should be 8 or 16");
436
+ }
437
+ for (i = 0; i < this.parts.length; i++) {
438
+ part = this.parts[i];
439
+ if (!(0 <= part && part <= 65535)) {
440
+ throw new Error("ipaddr: ipv6 part should fit in 16 bits");
441
+ }
442
+ }
443
+ if (zoneId) {
444
+ this.zoneId = zoneId;
445
+ }
446
+ }
447
+ IPv62.prototype.SpecialRanges = {
448
+ // RFC4291, here and after
449
+ unspecified: [new IPv62([0, 0, 0, 0, 0, 0, 0, 0]), 128],
450
+ linkLocal: [new IPv62([65152, 0, 0, 0, 0, 0, 0, 0]), 10],
451
+ multicast: [new IPv62([65280, 0, 0, 0, 0, 0, 0, 0]), 8],
452
+ loopback: [new IPv62([0, 0, 0, 0, 0, 0, 0, 1]), 128],
453
+ uniqueLocal: [new IPv62([64512, 0, 0, 0, 0, 0, 0, 0]), 7],
454
+ ipv4Mapped: [new IPv62([0, 0, 0, 0, 0, 65535, 0, 0]), 96],
455
+ // RFC6666
456
+ discard: [new IPv62([256, 0, 0, 0, 0, 0, 0, 0]), 64],
457
+ // RFC6145
458
+ rfc6145: [new IPv62([0, 0, 0, 0, 65535, 0, 0, 0]), 96],
459
+ // RFC6052
460
+ rfc6052: [new IPv62([100, 65435, 0, 0, 0, 0, 0, 0]), 96],
461
+ // RFC3056
462
+ "6to4": [new IPv62([8194, 0, 0, 0, 0, 0, 0, 0]), 16],
463
+ // RFC6052, RFC6146
464
+ teredo: [new IPv62([8193, 0, 0, 0, 0, 0, 0, 0]), 32],
465
+ // RFC5180
466
+ benchmarking: [new IPv62([8193, 2, 0, 0, 0, 0, 0, 0]), 48],
467
+ // RFC7450
468
+ amt: [new IPv62([8193, 3, 0, 0, 0, 0, 0, 0]), 32],
469
+ as112v6: [
470
+ [new IPv62([8193, 4, 274, 0, 0, 0, 0, 0]), 48],
471
+ [new IPv62([9760, 79, 32768, 0, 0, 0, 0, 0]), 48]
472
+ ],
473
+ deprecated: [new IPv62([8193, 16, 0, 0, 0, 0, 0, 0]), 28],
474
+ orchid2: [new IPv62([8193, 32, 0, 0, 0, 0, 0, 0]), 28],
475
+ droneRemoteIdProtocolEntityTags: [new IPv62([8193, 48, 0, 0, 0, 0, 0, 0]), 28],
476
+ reserved: [
477
+ // RFC3849
478
+ [new IPv62([8193, 0, 0, 0, 0, 0, 0, 0]), 23],
479
+ // RFC2928
480
+ [new IPv62([8193, 3512, 0, 0, 0, 0, 0, 0]), 32]
481
+ ]
482
+ };
483
+ IPv62.prototype.isIPv4MappedAddress = function() {
484
+ return this.range() === "ipv4Mapped";
485
+ };
486
+ IPv62.prototype.kind = function() {
487
+ return "ipv6";
488
+ };
489
+ IPv62.prototype.match = function(other, cidrRange) {
490
+ let ref;
491
+ if (cidrRange === void 0) {
492
+ ref = other;
493
+ other = ref[0];
494
+ cidrRange = ref[1];
495
+ }
496
+ if (other.kind() !== "ipv6") {
497
+ throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");
498
+ }
499
+ return matchCIDR(this.parts, other.parts, 16, cidrRange);
500
+ };
501
+ IPv62.prototype.prefixLengthFromSubnetMask = function() {
502
+ let cidr = 0;
503
+ let stop = false;
504
+ const zerotable = {
505
+ 0: 16,
506
+ 32768: 15,
507
+ 49152: 14,
508
+ 57344: 13,
509
+ 61440: 12,
510
+ 63488: 11,
511
+ 64512: 10,
512
+ 65024: 9,
513
+ 65280: 8,
514
+ 65408: 7,
515
+ 65472: 6,
516
+ 65504: 5,
517
+ 65520: 4,
518
+ 65528: 3,
519
+ 65532: 2,
520
+ 65534: 1,
521
+ 65535: 0
522
+ };
523
+ let part, zeros;
524
+ for (let i = 7; i >= 0; i -= 1) {
525
+ part = this.parts[i];
526
+ if (part in zerotable) {
527
+ zeros = zerotable[part];
528
+ if (stop && zeros !== 0) {
529
+ return null;
530
+ }
531
+ if (zeros !== 16) {
532
+ stop = true;
533
+ }
534
+ cidr += zeros;
535
+ } else {
536
+ return null;
537
+ }
538
+ }
539
+ return 128 - cidr;
540
+ };
541
+ IPv62.prototype.range = function() {
542
+ return ipaddr2.subnetMatch(this, this.SpecialRanges);
543
+ };
544
+ IPv62.prototype.toByteArray = function() {
545
+ let part;
546
+ const bytes = [];
547
+ const ref = this.parts;
548
+ for (let i = 0; i < ref.length; i++) {
549
+ part = ref[i];
550
+ bytes.push(part >> 8);
551
+ bytes.push(part & 255);
552
+ }
553
+ return bytes;
554
+ };
555
+ IPv62.prototype.toFixedLengthString = function() {
556
+ const addr = (function() {
557
+ const results = [];
558
+ for (let i = 0; i < this.parts.length; i++) {
559
+ results.push(padPart(this.parts[i].toString(16), 4));
560
+ }
561
+ return results;
562
+ }).call(this).join(":");
563
+ let suffix = "";
564
+ if (this.zoneId) {
565
+ suffix = `%${this.zoneId}`;
566
+ }
567
+ return addr + suffix;
568
+ };
569
+ IPv62.prototype.toIPv4Address = function() {
570
+ if (!this.isIPv4MappedAddress()) {
571
+ throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");
572
+ }
573
+ const ref = this.parts.slice(-2);
574
+ const high = ref[0];
575
+ const low = ref[1];
576
+ return new ipaddr2.IPv4([high >> 8, high & 255, low >> 8, low & 255]);
577
+ };
578
+ IPv62.prototype.toNormalizedString = function() {
579
+ const addr = (function() {
580
+ const results = [];
581
+ for (let i = 0; i < this.parts.length; i++) {
582
+ results.push(this.parts[i].toString(16));
583
+ }
584
+ return results;
585
+ }).call(this).join(":");
586
+ let suffix = "";
587
+ if (this.zoneId) {
588
+ suffix = `%${this.zoneId}`;
589
+ }
590
+ return addr + suffix;
591
+ };
592
+ IPv62.prototype.toRFC5952String = function() {
593
+ const regex = /((^|:)(0(:|$)){2,})/g;
594
+ const string = this.toNormalizedString();
595
+ let bestMatchIndex = 0;
596
+ let bestMatchLength = -1;
597
+ let match;
598
+ while (match = regex.exec(string)) {
599
+ if (match[0].length > bestMatchLength) {
600
+ bestMatchIndex = match.index;
601
+ bestMatchLength = match[0].length;
602
+ }
603
+ }
604
+ if (bestMatchLength < 0) {
605
+ return string;
606
+ }
607
+ return `${string.substring(0, bestMatchIndex)}::${string.substring(bestMatchIndex + bestMatchLength)}`;
608
+ };
609
+ IPv62.prototype.toString = function() {
610
+ return this.toRFC5952String();
611
+ };
612
+ return IPv62;
613
+ })();
614
+ ipaddr2.IPv6.broadcastAddressFromCIDR = function(string) {
615
+ try {
616
+ const cidr = this.parseCIDR(string);
617
+ const ipInterfaceOctets = cidr[0].toByteArray();
618
+ const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
619
+ const octets = [];
620
+ let i = 0;
621
+ while (i < 16) {
622
+ octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
623
+ i++;
624
+ }
625
+ return new this(octets);
626
+ } catch (e) {
627
+ throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`);
628
+ }
629
+ };
630
+ ipaddr2.IPv6.isIPv6 = function(string) {
631
+ return this.parser(string) !== null;
632
+ };
633
+ ipaddr2.IPv6.isValid = function(string) {
634
+ if (typeof string === "string" && string.indexOf(":") === -1) {
635
+ return false;
636
+ }
637
+ try {
638
+ const addr = this.parser(string);
639
+ new this(addr.parts, addr.zoneId);
640
+ return true;
641
+ } catch (e) {
642
+ return false;
643
+ }
644
+ };
645
+ ipaddr2.IPv6.isValidCIDR = function(string) {
646
+ if (typeof string === "string" && string.indexOf(":") === -1) {
647
+ return false;
648
+ }
649
+ try {
650
+ this.parseCIDR(string);
651
+ return true;
652
+ } catch (e) {
653
+ return false;
654
+ }
655
+ };
656
+ ipaddr2.IPv6.networkAddressFromCIDR = function(string) {
657
+ let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;
658
+ try {
659
+ cidr = this.parseCIDR(string);
660
+ ipInterfaceOctets = cidr[0].toByteArray();
661
+ subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
662
+ octets = [];
663
+ i = 0;
664
+ while (i < 16) {
665
+ octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
666
+ i++;
667
+ }
668
+ return new this(octets);
669
+ } catch (e) {
670
+ throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`);
671
+ }
672
+ };
673
+ ipaddr2.IPv6.parse = function(string) {
674
+ const addr = this.parser(string);
675
+ if (addr.parts === null) {
676
+ throw new Error("ipaddr: string is not formatted like an IPv6 Address");
677
+ }
678
+ return new this(addr.parts, addr.zoneId);
679
+ };
680
+ ipaddr2.IPv6.parseCIDR = function(string) {
681
+ let maskLength, match, parsed;
682
+ if (match = string.match(/^(.+)\/(\d+)$/)) {
683
+ maskLength = parseInt(match[2]);
684
+ if (maskLength >= 0 && maskLength <= 128) {
685
+ parsed = [this.parse(match[1]), maskLength];
686
+ Object.defineProperty(parsed, "toString", {
687
+ value: function() {
688
+ return this.join("/");
689
+ }
690
+ });
691
+ return parsed;
692
+ }
693
+ }
694
+ throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range");
695
+ };
696
+ ipaddr2.IPv6.parser = function(string) {
697
+ let addr, i, match, octet, octets, zoneId;
698
+ if (match = string.match(ipv6Regexes.deprecatedTransitional)) {
699
+ return this.parser(`::ffff:${match[1]}`);
700
+ }
701
+ if (ipv6Regexes.native.test(string)) {
702
+ return expandIPv6(string, 8);
703
+ }
704
+ if (match = string.match(ipv6Regexes.transitional)) {
705
+ zoneId = match[6] || "";
706
+ addr = match[1];
707
+ if (!match[1].endsWith("::")) {
708
+ addr = addr.slice(0, -1);
709
+ }
710
+ addr = expandIPv6(addr + zoneId, 6);
711
+ if (addr.parts) {
712
+ octets = [
713
+ parseInt(match[2]),
714
+ parseInt(match[3]),
715
+ parseInt(match[4]),
716
+ parseInt(match[5])
717
+ ];
718
+ for (i = 0; i < octets.length; i++) {
719
+ octet = octets[i];
720
+ if (!(0 <= octet && octet <= 255)) {
721
+ return null;
722
+ }
723
+ }
724
+ addr.parts.push(octets[0] << 8 | octets[1]);
725
+ addr.parts.push(octets[2] << 8 | octets[3]);
726
+ return {
727
+ parts: addr.parts,
728
+ zoneId: addr.zoneId
729
+ };
730
+ }
731
+ }
732
+ return null;
733
+ };
734
+ ipaddr2.IPv6.subnetMaskFromPrefixLength = function(prefix) {
735
+ prefix = parseInt(prefix);
736
+ if (prefix < 0 || prefix > 128) {
737
+ throw new Error("ipaddr: invalid IPv6 prefix length");
738
+ }
739
+ const octets = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
740
+ let j = 0;
741
+ const filledOctetCount = Math.floor(prefix / 8);
742
+ while (j < filledOctetCount) {
743
+ octets[j] = 255;
744
+ j++;
745
+ }
746
+ if (filledOctetCount < 16) {
747
+ octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
748
+ }
749
+ return new this(octets);
750
+ };
751
+ ipaddr2.fromByteArray = function(bytes) {
752
+ const length = bytes.length;
753
+ if (length === 4) {
754
+ return new ipaddr2.IPv4(bytes);
755
+ } else if (length === 16) {
756
+ return new ipaddr2.IPv6(bytes);
757
+ } else {
758
+ throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address");
759
+ }
760
+ };
761
+ ipaddr2.isValid = function(string) {
762
+ return ipaddr2.IPv6.isValid(string) || ipaddr2.IPv4.isValid(string);
763
+ };
764
+ ipaddr2.isValidCIDR = function(string) {
765
+ return ipaddr2.IPv6.isValidCIDR(string) || ipaddr2.IPv4.isValidCIDR(string);
766
+ };
767
+ ipaddr2.parse = function(string) {
768
+ if (ipaddr2.IPv6.isValid(string)) {
769
+ return ipaddr2.IPv6.parse(string);
770
+ } else if (ipaddr2.IPv4.isValid(string)) {
771
+ return ipaddr2.IPv4.parse(string);
772
+ } else {
773
+ throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format");
774
+ }
775
+ };
776
+ ipaddr2.parseCIDR = function(string) {
777
+ try {
778
+ return ipaddr2.IPv6.parseCIDR(string);
779
+ } catch (e) {
780
+ try {
781
+ return ipaddr2.IPv4.parseCIDR(string);
782
+ } catch (e2) {
783
+ throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format");
784
+ }
785
+ }
786
+ };
787
+ ipaddr2.process = function(string) {
788
+ const addr = this.parse(string);
789
+ if (addr.kind() === "ipv6" && addr.isIPv4MappedAddress()) {
790
+ return addr.toIPv4Address();
791
+ } else {
792
+ return addr;
793
+ }
794
+ };
795
+ ipaddr2.subnetMatch = function(address, rangeList, defaultName) {
796
+ let i, rangeName, rangeSubnets, subnet;
797
+ if (defaultName === void 0 || defaultName === null) {
798
+ defaultName = "unicast";
799
+ }
800
+ for (rangeName in rangeList) {
801
+ if (Object.prototype.hasOwnProperty.call(rangeList, rangeName)) {
802
+ rangeSubnets = rangeList[rangeName];
803
+ if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) {
804
+ rangeSubnets = [rangeSubnets];
805
+ }
806
+ for (i = 0; i < rangeSubnets.length; i++) {
807
+ subnet = rangeSubnets[i];
808
+ if (address.kind() === subnet[0].kind() && address.match.apply(address, subnet)) {
809
+ return rangeName;
810
+ }
811
+ }
812
+ }
813
+ }
814
+ return defaultName;
815
+ };
816
+ if (typeof module !== "undefined" && module.exports) {
817
+ module.exports = ipaddr2;
818
+ } else {
819
+ root.ipaddr = ipaddr2;
820
+ }
821
+ })(exports$1);
822
+ }
823
+ });
14
824
  var CHROMIUM_BUNDLE_IDS = /* @__PURE__ */ new Set([
15
825
  "com.google.Chrome",
16
826
  "com.google.Chrome.beta",
@@ -1475,6 +2285,9 @@ function formatAriaNodes(nodes, limit) {
1475
2285
  }
1476
2286
  return out;
1477
2287
  }
2288
+
2289
+ // src/security.ts
2290
+ var ipaddr = __toESM(require_ipaddr());
1478
2291
  var InvalidBrowserNavigationUrlError = class extends Error {
1479
2292
  constructor(message) {
1480
2293
  super(message);