@elizaos/server 1.6.1-alpha.4 → 1.6.1-alpha.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/client/assets/main-BM2lpId8.js +155 -0
- package/dist/client/assets/main-BM2lpId8.js.map +1 -0
- package/dist/client/assets/{main-BOBWcKWW.css → main-CNv6B3RZ.css} +597 -71
- package/dist/client/assets/{main-C4q5_rtN.js → main-CQAV8tyh.js} +4 -4
- package/dist/client/assets/main-CQAV8tyh.js.map +1 -0
- package/dist/client/assets/react-vendor-C1OK-nqm.js +611 -0
- package/dist/client/assets/react-vendor-C1OK-nqm.js.map +1 -0
- package/dist/client/index.html +1 -1
- package/dist/index.js +1486 -228
- package/package.json +12 -12
- package/dist/client/assets/main-BNtEiK3o.js +0 -141
- package/dist/client/assets/main-BNtEiK3o.js.map +0 -1
- package/dist/client/assets/main-C4q5_rtN.js.map +0 -1
- package/dist/client/assets/react-vendor-pe76PXQl.js +0 -546
- package/dist/client/assets/react-vendor-pe76PXQl.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -370,11 +370,1083 @@ var require_dist = __commonJS((exports) => {
|
|
|
370
370
|
}
|
|
371
371
|
});
|
|
372
372
|
|
|
373
|
+
// ../../node_modules/ip-address/dist/common.js
|
|
374
|
+
var require_common = __commonJS((exports) => {
|
|
375
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
376
|
+
exports.isInSubnet = isInSubnet;
|
|
377
|
+
exports.isCorrect = isCorrect;
|
|
378
|
+
exports.numberToPaddedHex = numberToPaddedHex;
|
|
379
|
+
exports.stringToPaddedHex = stringToPaddedHex;
|
|
380
|
+
exports.testBit = testBit;
|
|
381
|
+
function isInSubnet(address) {
|
|
382
|
+
if (this.subnetMask < address.subnetMask) {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
if (this.mask(address.subnetMask) === address.mask()) {
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
function isCorrect(defaultBits) {
|
|
391
|
+
return function() {
|
|
392
|
+
if (this.addressMinusSuffix !== this.correctForm()) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
if (this.subnetMask === defaultBits && !this.parsedSubnet) {
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
return this.parsedSubnet === String(this.subnetMask);
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function numberToPaddedHex(number) {
|
|
402
|
+
return number.toString(16).padStart(2, "0");
|
|
403
|
+
}
|
|
404
|
+
function stringToPaddedHex(numberString) {
|
|
405
|
+
return numberToPaddedHex(parseInt(numberString, 10));
|
|
406
|
+
}
|
|
407
|
+
function testBit(binaryValue, position) {
|
|
408
|
+
const { length } = binaryValue;
|
|
409
|
+
if (position > length) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
const positionInString = length - position;
|
|
413
|
+
return binaryValue.substring(positionInString, positionInString + 1) === "1";
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// ../../node_modules/ip-address/dist/v4/constants.js
|
|
418
|
+
var require_constants = __commonJS((exports) => {
|
|
419
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
420
|
+
exports.RE_SUBNET_STRING = exports.RE_ADDRESS = exports.GROUPS = exports.BITS = undefined;
|
|
421
|
+
exports.BITS = 32;
|
|
422
|
+
exports.GROUPS = 4;
|
|
423
|
+
exports.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;
|
|
424
|
+
exports.RE_SUBNET_STRING = /\/\d{1,2}$/;
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// ../../node_modules/ip-address/dist/address-error.js
|
|
428
|
+
var require_address_error = __commonJS((exports) => {
|
|
429
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
430
|
+
exports.AddressError = undefined;
|
|
431
|
+
|
|
432
|
+
class AddressError extends Error {
|
|
433
|
+
constructor(message, parseMessage) {
|
|
434
|
+
super(message);
|
|
435
|
+
this.name = "AddressError";
|
|
436
|
+
this.parseMessage = parseMessage;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
exports.AddressError = AddressError;
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
// ../../node_modules/ip-address/dist/ipv4.js
|
|
443
|
+
var require_ipv4 = __commonJS((exports) => {
|
|
444
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
445
|
+
if (k2 === undefined)
|
|
446
|
+
k2 = k;
|
|
447
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
448
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
449
|
+
desc = { enumerable: true, get: function() {
|
|
450
|
+
return m[k];
|
|
451
|
+
} };
|
|
452
|
+
}
|
|
453
|
+
Object.defineProperty(o, k2, desc);
|
|
454
|
+
} : function(o, m, k, k2) {
|
|
455
|
+
if (k2 === undefined)
|
|
456
|
+
k2 = k;
|
|
457
|
+
o[k2] = m[k];
|
|
458
|
+
});
|
|
459
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
460
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
461
|
+
} : function(o, v) {
|
|
462
|
+
o["default"] = v;
|
|
463
|
+
});
|
|
464
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
465
|
+
if (mod && mod.__esModule)
|
|
466
|
+
return mod;
|
|
467
|
+
var result = {};
|
|
468
|
+
if (mod != null) {
|
|
469
|
+
for (var k in mod)
|
|
470
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
471
|
+
__createBinding(result, mod, k);
|
|
472
|
+
}
|
|
473
|
+
__setModuleDefault(result, mod);
|
|
474
|
+
return result;
|
|
475
|
+
};
|
|
476
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
477
|
+
exports.Address4 = undefined;
|
|
478
|
+
var common = __importStar(require_common());
|
|
479
|
+
var constants = __importStar(require_constants());
|
|
480
|
+
var address_error_1 = require_address_error();
|
|
481
|
+
|
|
482
|
+
class Address4 {
|
|
483
|
+
constructor(address) {
|
|
484
|
+
this.groups = constants.GROUPS;
|
|
485
|
+
this.parsedAddress = [];
|
|
486
|
+
this.parsedSubnet = "";
|
|
487
|
+
this.subnet = "/32";
|
|
488
|
+
this.subnetMask = 32;
|
|
489
|
+
this.v4 = true;
|
|
490
|
+
this.isCorrect = common.isCorrect(constants.BITS);
|
|
491
|
+
this.isInSubnet = common.isInSubnet;
|
|
492
|
+
this.address = address;
|
|
493
|
+
const subnet = constants.RE_SUBNET_STRING.exec(address);
|
|
494
|
+
if (subnet) {
|
|
495
|
+
this.parsedSubnet = subnet[0].replace("/", "");
|
|
496
|
+
this.subnetMask = parseInt(this.parsedSubnet, 10);
|
|
497
|
+
this.subnet = `/${this.subnetMask}`;
|
|
498
|
+
if (this.subnetMask < 0 || this.subnetMask > constants.BITS) {
|
|
499
|
+
throw new address_error_1.AddressError("Invalid subnet mask.");
|
|
500
|
+
}
|
|
501
|
+
address = address.replace(constants.RE_SUBNET_STRING, "");
|
|
502
|
+
}
|
|
503
|
+
this.addressMinusSuffix = address;
|
|
504
|
+
this.parsedAddress = this.parse(address);
|
|
505
|
+
}
|
|
506
|
+
static isValid(address) {
|
|
507
|
+
try {
|
|
508
|
+
new Address4(address);
|
|
509
|
+
return true;
|
|
510
|
+
} catch (e) {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
parse(address) {
|
|
515
|
+
const groups = address.split(".");
|
|
516
|
+
if (!address.match(constants.RE_ADDRESS)) {
|
|
517
|
+
throw new address_error_1.AddressError("Invalid IPv4 address.");
|
|
518
|
+
}
|
|
519
|
+
return groups;
|
|
520
|
+
}
|
|
521
|
+
correctForm() {
|
|
522
|
+
return this.parsedAddress.map((part) => parseInt(part, 10)).join(".");
|
|
523
|
+
}
|
|
524
|
+
static fromHex(hex) {
|
|
525
|
+
const padded = hex.replace(/:/g, "").padStart(8, "0");
|
|
526
|
+
const groups = [];
|
|
527
|
+
let i;
|
|
528
|
+
for (i = 0;i < 8; i += 2) {
|
|
529
|
+
const h = padded.slice(i, i + 2);
|
|
530
|
+
groups.push(parseInt(h, 16));
|
|
531
|
+
}
|
|
532
|
+
return new Address4(groups.join("."));
|
|
533
|
+
}
|
|
534
|
+
static fromInteger(integer) {
|
|
535
|
+
return Address4.fromHex(integer.toString(16));
|
|
536
|
+
}
|
|
537
|
+
static fromArpa(arpaFormAddress) {
|
|
538
|
+
const leader = arpaFormAddress.replace(/(\.in-addr\.arpa)?\.$/, "");
|
|
539
|
+
const address = leader.split(".").reverse().join(".");
|
|
540
|
+
return new Address4(address);
|
|
541
|
+
}
|
|
542
|
+
toHex() {
|
|
543
|
+
return this.parsedAddress.map((part) => common.stringToPaddedHex(part)).join(":");
|
|
544
|
+
}
|
|
545
|
+
toArray() {
|
|
546
|
+
return this.parsedAddress.map((part) => parseInt(part, 10));
|
|
547
|
+
}
|
|
548
|
+
toGroup6() {
|
|
549
|
+
const output = [];
|
|
550
|
+
let i;
|
|
551
|
+
for (i = 0;i < constants.GROUPS; i += 2) {
|
|
552
|
+
output.push(`${common.stringToPaddedHex(this.parsedAddress[i])}${common.stringToPaddedHex(this.parsedAddress[i + 1])}`);
|
|
553
|
+
}
|
|
554
|
+
return output.join(":");
|
|
555
|
+
}
|
|
556
|
+
bigInt() {
|
|
557
|
+
return BigInt(`0x${this.parsedAddress.map((n) => common.stringToPaddedHex(n)).join("")}`);
|
|
558
|
+
}
|
|
559
|
+
_startAddress() {
|
|
560
|
+
return BigInt(`0b${this.mask() + "0".repeat(constants.BITS - this.subnetMask)}`);
|
|
561
|
+
}
|
|
562
|
+
startAddress() {
|
|
563
|
+
return Address4.fromBigInt(this._startAddress());
|
|
564
|
+
}
|
|
565
|
+
startAddressExclusive() {
|
|
566
|
+
const adjust = BigInt("1");
|
|
567
|
+
return Address4.fromBigInt(this._startAddress() + adjust);
|
|
568
|
+
}
|
|
569
|
+
_endAddress() {
|
|
570
|
+
return BigInt(`0b${this.mask() + "1".repeat(constants.BITS - this.subnetMask)}`);
|
|
571
|
+
}
|
|
572
|
+
endAddress() {
|
|
573
|
+
return Address4.fromBigInt(this._endAddress());
|
|
574
|
+
}
|
|
575
|
+
endAddressExclusive() {
|
|
576
|
+
const adjust = BigInt("1");
|
|
577
|
+
return Address4.fromBigInt(this._endAddress() - adjust);
|
|
578
|
+
}
|
|
579
|
+
static fromBigInt(bigInt) {
|
|
580
|
+
return Address4.fromHex(bigInt.toString(16));
|
|
581
|
+
}
|
|
582
|
+
mask(mask) {
|
|
583
|
+
if (mask === undefined) {
|
|
584
|
+
mask = this.subnetMask;
|
|
585
|
+
}
|
|
586
|
+
return this.getBitsBase2(0, mask);
|
|
587
|
+
}
|
|
588
|
+
getBitsBase2(start, end) {
|
|
589
|
+
return this.binaryZeroPad().slice(start, end);
|
|
590
|
+
}
|
|
591
|
+
reverseForm(options) {
|
|
592
|
+
if (!options) {
|
|
593
|
+
options = {};
|
|
594
|
+
}
|
|
595
|
+
const reversed = this.correctForm().split(".").reverse().join(".");
|
|
596
|
+
if (options.omitSuffix) {
|
|
597
|
+
return reversed;
|
|
598
|
+
}
|
|
599
|
+
return `${reversed}.in-addr.arpa.`;
|
|
600
|
+
}
|
|
601
|
+
isMulticast() {
|
|
602
|
+
return this.isInSubnet(new Address4("224.0.0.0/4"));
|
|
603
|
+
}
|
|
604
|
+
binaryZeroPad() {
|
|
605
|
+
return this.bigInt().toString(2).padStart(constants.BITS, "0");
|
|
606
|
+
}
|
|
607
|
+
groupForV6() {
|
|
608
|
+
const segments = this.parsedAddress;
|
|
609
|
+
return this.address.replace(constants.RE_ADDRESS, `<span class="hover-group group-v4 group-6">${segments.slice(0, 2).join(".")}</span>.<span class="hover-group group-v4 group-7">${segments.slice(2, 4).join(".")}</span>`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
exports.Address4 = Address4;
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
// ../../node_modules/ip-address/dist/v6/constants.js
|
|
616
|
+
var require_constants2 = __commonJS((exports) => {
|
|
617
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
618
|
+
exports.RE_URL_WITH_PORT = exports.RE_URL = exports.RE_ZONE_STRING = exports.RE_SUBNET_STRING = exports.RE_BAD_ADDRESS = exports.RE_BAD_CHARACTERS = exports.TYPES = exports.SCOPES = exports.GROUPS = exports.BITS = undefined;
|
|
619
|
+
exports.BITS = 128;
|
|
620
|
+
exports.GROUPS = 8;
|
|
621
|
+
exports.SCOPES = {
|
|
622
|
+
0: "Reserved",
|
|
623
|
+
1: "Interface local",
|
|
624
|
+
2: "Link local",
|
|
625
|
+
4: "Admin local",
|
|
626
|
+
5: "Site local",
|
|
627
|
+
8: "Organization local",
|
|
628
|
+
14: "Global",
|
|
629
|
+
15: "Reserved"
|
|
630
|
+
};
|
|
631
|
+
exports.TYPES = {
|
|
632
|
+
"ff01::1/128": "Multicast (All nodes on this interface)",
|
|
633
|
+
"ff01::2/128": "Multicast (All routers on this interface)",
|
|
634
|
+
"ff02::1/128": "Multicast (All nodes on this link)",
|
|
635
|
+
"ff02::2/128": "Multicast (All routers on this link)",
|
|
636
|
+
"ff05::2/128": "Multicast (All routers in this site)",
|
|
637
|
+
"ff02::5/128": "Multicast (OSPFv3 AllSPF routers)",
|
|
638
|
+
"ff02::6/128": "Multicast (OSPFv3 AllDR routers)",
|
|
639
|
+
"ff02::9/128": "Multicast (RIP routers)",
|
|
640
|
+
"ff02::a/128": "Multicast (EIGRP routers)",
|
|
641
|
+
"ff02::d/128": "Multicast (PIM routers)",
|
|
642
|
+
"ff02::16/128": "Multicast (MLDv2 reports)",
|
|
643
|
+
"ff01::fb/128": "Multicast (mDNSv6)",
|
|
644
|
+
"ff02::fb/128": "Multicast (mDNSv6)",
|
|
645
|
+
"ff05::fb/128": "Multicast (mDNSv6)",
|
|
646
|
+
"ff02::1:2/128": "Multicast (All DHCP servers and relay agents on this link)",
|
|
647
|
+
"ff05::1:2/128": "Multicast (All DHCP servers and relay agents in this site)",
|
|
648
|
+
"ff02::1:3/128": "Multicast (All DHCP servers on this link)",
|
|
649
|
+
"ff05::1:3/128": "Multicast (All DHCP servers in this site)",
|
|
650
|
+
"::/128": "Unspecified",
|
|
651
|
+
"::1/128": "Loopback",
|
|
652
|
+
"ff00::/8": "Multicast",
|
|
653
|
+
"fe80::/10": "Link-local unicast"
|
|
654
|
+
};
|
|
655
|
+
exports.RE_BAD_CHARACTERS = /([^0-9a-f:/%])/gi;
|
|
656
|
+
exports.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;
|
|
657
|
+
exports.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/;
|
|
658
|
+
exports.RE_ZONE_STRING = /%.*$/;
|
|
659
|
+
exports.RE_URL = /^\[{0,1}([0-9a-f:]+)\]{0,1}/;
|
|
660
|
+
exports.RE_URL_WITH_PORT = /\[([0-9a-f:]+)\]:([0-9]{1,5})/;
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
// ../../node_modules/ip-address/dist/v6/helpers.js
|
|
664
|
+
var require_helpers = __commonJS((exports) => {
|
|
665
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
666
|
+
exports.spanAllZeroes = spanAllZeroes;
|
|
667
|
+
exports.spanAll = spanAll;
|
|
668
|
+
exports.spanLeadingZeroes = spanLeadingZeroes;
|
|
669
|
+
exports.simpleGroup = simpleGroup;
|
|
670
|
+
function spanAllZeroes(s) {
|
|
671
|
+
return s.replace(/(0+)/g, '<span class="zero">$1</span>');
|
|
672
|
+
}
|
|
673
|
+
function spanAll(s, offset = 0) {
|
|
674
|
+
const letters = s.split("");
|
|
675
|
+
return letters.map((n, i) => `<span class="digit value-${n} position-${i + offset}">${spanAllZeroes(n)}</span>`).join("");
|
|
676
|
+
}
|
|
677
|
+
function spanLeadingZeroesSimple(group) {
|
|
678
|
+
return group.replace(/^(0+)/, '<span class="zero">$1</span>');
|
|
679
|
+
}
|
|
680
|
+
function spanLeadingZeroes(address) {
|
|
681
|
+
const groups = address.split(":");
|
|
682
|
+
return groups.map((g) => spanLeadingZeroesSimple(g)).join(":");
|
|
683
|
+
}
|
|
684
|
+
function simpleGroup(addressString, offset = 0) {
|
|
685
|
+
const groups = addressString.split(":");
|
|
686
|
+
return groups.map((g, i) => {
|
|
687
|
+
if (/group-v4/.test(g)) {
|
|
688
|
+
return g;
|
|
689
|
+
}
|
|
690
|
+
return `<span class="hover-group group-${i + offset}">${spanLeadingZeroesSimple(g)}</span>`;
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
// ../../node_modules/ip-address/dist/v6/regular-expressions.js
|
|
696
|
+
var require_regular_expressions = __commonJS((exports) => {
|
|
697
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
698
|
+
if (k2 === undefined)
|
|
699
|
+
k2 = k;
|
|
700
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
701
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
702
|
+
desc = { enumerable: true, get: function() {
|
|
703
|
+
return m[k];
|
|
704
|
+
} };
|
|
705
|
+
}
|
|
706
|
+
Object.defineProperty(o, k2, desc);
|
|
707
|
+
} : function(o, m, k, k2) {
|
|
708
|
+
if (k2 === undefined)
|
|
709
|
+
k2 = k;
|
|
710
|
+
o[k2] = m[k];
|
|
711
|
+
});
|
|
712
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
713
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
714
|
+
} : function(o, v) {
|
|
715
|
+
o["default"] = v;
|
|
716
|
+
});
|
|
717
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
718
|
+
if (mod && mod.__esModule)
|
|
719
|
+
return mod;
|
|
720
|
+
var result = {};
|
|
721
|
+
if (mod != null) {
|
|
722
|
+
for (var k in mod)
|
|
723
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
724
|
+
__createBinding(result, mod, k);
|
|
725
|
+
}
|
|
726
|
+
__setModuleDefault(result, mod);
|
|
727
|
+
return result;
|
|
728
|
+
};
|
|
729
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
730
|
+
exports.ADDRESS_BOUNDARY = undefined;
|
|
731
|
+
exports.groupPossibilities = groupPossibilities;
|
|
732
|
+
exports.padGroup = padGroup;
|
|
733
|
+
exports.simpleRegularExpression = simpleRegularExpression;
|
|
734
|
+
exports.possibleElisions = possibleElisions;
|
|
735
|
+
var v6 = __importStar(require_constants2());
|
|
736
|
+
function groupPossibilities(possibilities) {
|
|
737
|
+
return `(${possibilities.join("|")})`;
|
|
738
|
+
}
|
|
739
|
+
function padGroup(group) {
|
|
740
|
+
if (group.length < 4) {
|
|
741
|
+
return `0{0,${4 - group.length}}${group}`;
|
|
742
|
+
}
|
|
743
|
+
return group;
|
|
744
|
+
}
|
|
745
|
+
exports.ADDRESS_BOUNDARY = "[^A-Fa-f0-9:]";
|
|
746
|
+
function simpleRegularExpression(groups) {
|
|
747
|
+
const zeroIndexes = [];
|
|
748
|
+
groups.forEach((group, i) => {
|
|
749
|
+
const groupInteger = parseInt(group, 16);
|
|
750
|
+
if (groupInteger === 0) {
|
|
751
|
+
zeroIndexes.push(i);
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
const possibilities = zeroIndexes.map((zeroIndex) => groups.map((group, i) => {
|
|
755
|
+
if (i === zeroIndex) {
|
|
756
|
+
const elision = i === 0 || i === v6.GROUPS - 1 ? ":" : "";
|
|
757
|
+
return groupPossibilities([padGroup(group), elision]);
|
|
758
|
+
}
|
|
759
|
+
return padGroup(group);
|
|
760
|
+
}).join(":"));
|
|
761
|
+
possibilities.push(groups.map(padGroup).join(":"));
|
|
762
|
+
return groupPossibilities(possibilities);
|
|
763
|
+
}
|
|
764
|
+
function possibleElisions(elidedGroups, moreLeft, moreRight) {
|
|
765
|
+
const left = moreLeft ? "" : ":";
|
|
766
|
+
const right = moreRight ? "" : ":";
|
|
767
|
+
const possibilities = [];
|
|
768
|
+
if (!moreLeft && !moreRight) {
|
|
769
|
+
possibilities.push("::");
|
|
770
|
+
}
|
|
771
|
+
if (moreLeft && moreRight) {
|
|
772
|
+
possibilities.push("");
|
|
773
|
+
}
|
|
774
|
+
if (moreRight && !moreLeft || !moreRight && moreLeft) {
|
|
775
|
+
possibilities.push(":");
|
|
776
|
+
}
|
|
777
|
+
possibilities.push(`${left}(:0{1,4}){1,${elidedGroups - 1}}`);
|
|
778
|
+
possibilities.push(`(0{1,4}:){1,${elidedGroups - 1}}${right}`);
|
|
779
|
+
possibilities.push(`(0{1,4}:){${elidedGroups - 1}}0{1,4}`);
|
|
780
|
+
for (let groups = 1;groups < elidedGroups - 1; groups++) {
|
|
781
|
+
for (let position = 1;position < elidedGroups - groups; position++) {
|
|
782
|
+
possibilities.push(`(0{1,4}:){${position}}:(0{1,4}:){${elidedGroups - position - groups - 1}}0{1,4}`);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return groupPossibilities(possibilities);
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
// ../../node_modules/ip-address/dist/ipv6.js
|
|
790
|
+
var require_ipv6 = __commonJS((exports) => {
|
|
791
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
792
|
+
if (k2 === undefined)
|
|
793
|
+
k2 = k;
|
|
794
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
795
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
796
|
+
desc = { enumerable: true, get: function() {
|
|
797
|
+
return m[k];
|
|
798
|
+
} };
|
|
799
|
+
}
|
|
800
|
+
Object.defineProperty(o, k2, desc);
|
|
801
|
+
} : function(o, m, k, k2) {
|
|
802
|
+
if (k2 === undefined)
|
|
803
|
+
k2 = k;
|
|
804
|
+
o[k2] = m[k];
|
|
805
|
+
});
|
|
806
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
807
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
808
|
+
} : function(o, v) {
|
|
809
|
+
o["default"] = v;
|
|
810
|
+
});
|
|
811
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
812
|
+
if (mod && mod.__esModule)
|
|
813
|
+
return mod;
|
|
814
|
+
var result = {};
|
|
815
|
+
if (mod != null) {
|
|
816
|
+
for (var k in mod)
|
|
817
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
818
|
+
__createBinding(result, mod, k);
|
|
819
|
+
}
|
|
820
|
+
__setModuleDefault(result, mod);
|
|
821
|
+
return result;
|
|
822
|
+
};
|
|
823
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
824
|
+
exports.Address6 = undefined;
|
|
825
|
+
var common = __importStar(require_common());
|
|
826
|
+
var constants4 = __importStar(require_constants());
|
|
827
|
+
var constants6 = __importStar(require_constants2());
|
|
828
|
+
var helpers = __importStar(require_helpers());
|
|
829
|
+
var ipv4_1 = require_ipv4();
|
|
830
|
+
var regular_expressions_1 = require_regular_expressions();
|
|
831
|
+
var address_error_1 = require_address_error();
|
|
832
|
+
var common_1 = require_common();
|
|
833
|
+
function assert(condition) {
|
|
834
|
+
if (!condition) {
|
|
835
|
+
throw new Error("Assertion failed.");
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function addCommas(number) {
|
|
839
|
+
const r = /(\d+)(\d{3})/;
|
|
840
|
+
while (r.test(number)) {
|
|
841
|
+
number = number.replace(r, "$1,$2");
|
|
842
|
+
}
|
|
843
|
+
return number;
|
|
844
|
+
}
|
|
845
|
+
function spanLeadingZeroes4(n) {
|
|
846
|
+
n = n.replace(/^(0{1,})([1-9]+)$/, '<span class="parse-error">$1</span>$2');
|
|
847
|
+
n = n.replace(/^(0{1,})(0)$/, '<span class="parse-error">$1</span>$2');
|
|
848
|
+
return n;
|
|
849
|
+
}
|
|
850
|
+
function compact(address, slice) {
|
|
851
|
+
const s1 = [];
|
|
852
|
+
const s2 = [];
|
|
853
|
+
let i;
|
|
854
|
+
for (i = 0;i < address.length; i++) {
|
|
855
|
+
if (i < slice[0]) {
|
|
856
|
+
s1.push(address[i]);
|
|
857
|
+
} else if (i > slice[1]) {
|
|
858
|
+
s2.push(address[i]);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return s1.concat(["compact"]).concat(s2);
|
|
862
|
+
}
|
|
863
|
+
function paddedHex(octet) {
|
|
864
|
+
return parseInt(octet, 16).toString(16).padStart(4, "0");
|
|
865
|
+
}
|
|
866
|
+
function unsignByte(b) {
|
|
867
|
+
return b & 255;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
class Address6 {
|
|
871
|
+
constructor(address, optionalGroups) {
|
|
872
|
+
this.addressMinusSuffix = "";
|
|
873
|
+
this.parsedSubnet = "";
|
|
874
|
+
this.subnet = "/128";
|
|
875
|
+
this.subnetMask = 128;
|
|
876
|
+
this.v4 = false;
|
|
877
|
+
this.zone = "";
|
|
878
|
+
this.isInSubnet = common.isInSubnet;
|
|
879
|
+
this.isCorrect = common.isCorrect(constants6.BITS);
|
|
880
|
+
if (optionalGroups === undefined) {
|
|
881
|
+
this.groups = constants6.GROUPS;
|
|
882
|
+
} else {
|
|
883
|
+
this.groups = optionalGroups;
|
|
884
|
+
}
|
|
885
|
+
this.address = address;
|
|
886
|
+
const subnet = constants6.RE_SUBNET_STRING.exec(address);
|
|
887
|
+
if (subnet) {
|
|
888
|
+
this.parsedSubnet = subnet[0].replace("/", "");
|
|
889
|
+
this.subnetMask = parseInt(this.parsedSubnet, 10);
|
|
890
|
+
this.subnet = `/${this.subnetMask}`;
|
|
891
|
+
if (Number.isNaN(this.subnetMask) || this.subnetMask < 0 || this.subnetMask > constants6.BITS) {
|
|
892
|
+
throw new address_error_1.AddressError("Invalid subnet mask.");
|
|
893
|
+
}
|
|
894
|
+
address = address.replace(constants6.RE_SUBNET_STRING, "");
|
|
895
|
+
} else if (/\//.test(address)) {
|
|
896
|
+
throw new address_error_1.AddressError("Invalid subnet mask.");
|
|
897
|
+
}
|
|
898
|
+
const zone = constants6.RE_ZONE_STRING.exec(address);
|
|
899
|
+
if (zone) {
|
|
900
|
+
this.zone = zone[0];
|
|
901
|
+
address = address.replace(constants6.RE_ZONE_STRING, "");
|
|
902
|
+
}
|
|
903
|
+
this.addressMinusSuffix = address;
|
|
904
|
+
this.parsedAddress = this.parse(this.addressMinusSuffix);
|
|
905
|
+
}
|
|
906
|
+
static isValid(address) {
|
|
907
|
+
try {
|
|
908
|
+
new Address6(address);
|
|
909
|
+
return true;
|
|
910
|
+
} catch (e) {
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
static fromBigInt(bigInt) {
|
|
915
|
+
const hex = bigInt.toString(16).padStart(32, "0");
|
|
916
|
+
const groups = [];
|
|
917
|
+
let i;
|
|
918
|
+
for (i = 0;i < constants6.GROUPS; i++) {
|
|
919
|
+
groups.push(hex.slice(i * 4, (i + 1) * 4));
|
|
920
|
+
}
|
|
921
|
+
return new Address6(groups.join(":"));
|
|
922
|
+
}
|
|
923
|
+
static fromURL(url) {
|
|
924
|
+
let host;
|
|
925
|
+
let port = null;
|
|
926
|
+
let result;
|
|
927
|
+
if (url.indexOf("[") !== -1 && url.indexOf("]:") !== -1) {
|
|
928
|
+
result = constants6.RE_URL_WITH_PORT.exec(url);
|
|
929
|
+
if (result === null) {
|
|
930
|
+
return {
|
|
931
|
+
error: "failed to parse address with port",
|
|
932
|
+
address: null,
|
|
933
|
+
port: null
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
host = result[1];
|
|
937
|
+
port = result[2];
|
|
938
|
+
} else if (url.indexOf("/") !== -1) {
|
|
939
|
+
url = url.replace(/^[a-z0-9]+:\/\//, "");
|
|
940
|
+
result = constants6.RE_URL.exec(url);
|
|
941
|
+
if (result === null) {
|
|
942
|
+
return {
|
|
943
|
+
error: "failed to parse address from URL",
|
|
944
|
+
address: null,
|
|
945
|
+
port: null
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
host = result[1];
|
|
949
|
+
} else {
|
|
950
|
+
host = url;
|
|
951
|
+
}
|
|
952
|
+
if (port) {
|
|
953
|
+
port = parseInt(port, 10);
|
|
954
|
+
if (port < 0 || port > 65536) {
|
|
955
|
+
port = null;
|
|
956
|
+
}
|
|
957
|
+
} else {
|
|
958
|
+
port = null;
|
|
959
|
+
}
|
|
960
|
+
return {
|
|
961
|
+
address: new Address6(host),
|
|
962
|
+
port
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
static fromAddress4(address) {
|
|
966
|
+
const address4 = new ipv4_1.Address4(address);
|
|
967
|
+
const mask6 = constants6.BITS - (constants4.BITS - address4.subnetMask);
|
|
968
|
+
return new Address6(`::ffff:${address4.correctForm()}/${mask6}`);
|
|
969
|
+
}
|
|
970
|
+
static fromArpa(arpaFormAddress) {
|
|
971
|
+
let address = arpaFormAddress.replace(/(\.ip6\.arpa)?\.$/, "");
|
|
972
|
+
const semicolonAmount = 7;
|
|
973
|
+
if (address.length !== 63) {
|
|
974
|
+
throw new address_error_1.AddressError("Invalid 'ip6.arpa' form.");
|
|
975
|
+
}
|
|
976
|
+
const parts = address.split(".").reverse();
|
|
977
|
+
for (let i = semicolonAmount;i > 0; i--) {
|
|
978
|
+
const insertIndex = i * 4;
|
|
979
|
+
parts.splice(insertIndex, 0, ":");
|
|
980
|
+
}
|
|
981
|
+
address = parts.join("");
|
|
982
|
+
return new Address6(address);
|
|
983
|
+
}
|
|
984
|
+
microsoftTranscription() {
|
|
985
|
+
return `${this.correctForm().replace(/:/g, "-")}.ipv6-literal.net`;
|
|
986
|
+
}
|
|
987
|
+
mask(mask = this.subnetMask) {
|
|
988
|
+
return this.getBitsBase2(0, mask);
|
|
989
|
+
}
|
|
990
|
+
possibleSubnets(subnetSize = 128) {
|
|
991
|
+
const availableBits = constants6.BITS - this.subnetMask;
|
|
992
|
+
const subnetBits = Math.abs(subnetSize - constants6.BITS);
|
|
993
|
+
const subnetPowers = availableBits - subnetBits;
|
|
994
|
+
if (subnetPowers < 0) {
|
|
995
|
+
return "0";
|
|
996
|
+
}
|
|
997
|
+
return addCommas((BigInt("2") ** BigInt(subnetPowers)).toString(10));
|
|
998
|
+
}
|
|
999
|
+
_startAddress() {
|
|
1000
|
+
return BigInt(`0b${this.mask() + "0".repeat(constants6.BITS - this.subnetMask)}`);
|
|
1001
|
+
}
|
|
1002
|
+
startAddress() {
|
|
1003
|
+
return Address6.fromBigInt(this._startAddress());
|
|
1004
|
+
}
|
|
1005
|
+
startAddressExclusive() {
|
|
1006
|
+
const adjust = BigInt("1");
|
|
1007
|
+
return Address6.fromBigInt(this._startAddress() + adjust);
|
|
1008
|
+
}
|
|
1009
|
+
_endAddress() {
|
|
1010
|
+
return BigInt(`0b${this.mask() + "1".repeat(constants6.BITS - this.subnetMask)}`);
|
|
1011
|
+
}
|
|
1012
|
+
endAddress() {
|
|
1013
|
+
return Address6.fromBigInt(this._endAddress());
|
|
1014
|
+
}
|
|
1015
|
+
endAddressExclusive() {
|
|
1016
|
+
const adjust = BigInt("1");
|
|
1017
|
+
return Address6.fromBigInt(this._endAddress() - adjust);
|
|
1018
|
+
}
|
|
1019
|
+
getScope() {
|
|
1020
|
+
let scope = constants6.SCOPES[parseInt(this.getBits(12, 16).toString(10), 10)];
|
|
1021
|
+
if (this.getType() === "Global unicast" && scope !== "Link local") {
|
|
1022
|
+
scope = "Global";
|
|
1023
|
+
}
|
|
1024
|
+
return scope || "Unknown";
|
|
1025
|
+
}
|
|
1026
|
+
getType() {
|
|
1027
|
+
for (const subnet of Object.keys(constants6.TYPES)) {
|
|
1028
|
+
if (this.isInSubnet(new Address6(subnet))) {
|
|
1029
|
+
return constants6.TYPES[subnet];
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
return "Global unicast";
|
|
1033
|
+
}
|
|
1034
|
+
getBits(start, end) {
|
|
1035
|
+
return BigInt(`0b${this.getBitsBase2(start, end)}`);
|
|
1036
|
+
}
|
|
1037
|
+
getBitsBase2(start, end) {
|
|
1038
|
+
return this.binaryZeroPad().slice(start, end);
|
|
1039
|
+
}
|
|
1040
|
+
getBitsBase16(start, end) {
|
|
1041
|
+
const length = end - start;
|
|
1042
|
+
if (length % 4 !== 0) {
|
|
1043
|
+
throw new Error("Length of bits to retrieve must be divisible by four");
|
|
1044
|
+
}
|
|
1045
|
+
return this.getBits(start, end).toString(16).padStart(length / 4, "0");
|
|
1046
|
+
}
|
|
1047
|
+
getBitsPastSubnet() {
|
|
1048
|
+
return this.getBitsBase2(this.subnetMask, constants6.BITS);
|
|
1049
|
+
}
|
|
1050
|
+
reverseForm(options) {
|
|
1051
|
+
if (!options) {
|
|
1052
|
+
options = {};
|
|
1053
|
+
}
|
|
1054
|
+
const characters = Math.floor(this.subnetMask / 4);
|
|
1055
|
+
const reversed = this.canonicalForm().replace(/:/g, "").split("").slice(0, characters).reverse().join(".");
|
|
1056
|
+
if (characters > 0) {
|
|
1057
|
+
if (options.omitSuffix) {
|
|
1058
|
+
return reversed;
|
|
1059
|
+
}
|
|
1060
|
+
return `${reversed}.ip6.arpa.`;
|
|
1061
|
+
}
|
|
1062
|
+
if (options.omitSuffix) {
|
|
1063
|
+
return "";
|
|
1064
|
+
}
|
|
1065
|
+
return "ip6.arpa.";
|
|
1066
|
+
}
|
|
1067
|
+
correctForm() {
|
|
1068
|
+
let i;
|
|
1069
|
+
let groups = [];
|
|
1070
|
+
let zeroCounter = 0;
|
|
1071
|
+
const zeroes = [];
|
|
1072
|
+
for (i = 0;i < this.parsedAddress.length; i++) {
|
|
1073
|
+
const value = parseInt(this.parsedAddress[i], 16);
|
|
1074
|
+
if (value === 0) {
|
|
1075
|
+
zeroCounter++;
|
|
1076
|
+
}
|
|
1077
|
+
if (value !== 0 && zeroCounter > 0) {
|
|
1078
|
+
if (zeroCounter > 1) {
|
|
1079
|
+
zeroes.push([i - zeroCounter, i - 1]);
|
|
1080
|
+
}
|
|
1081
|
+
zeroCounter = 0;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
if (zeroCounter > 1) {
|
|
1085
|
+
zeroes.push([this.parsedAddress.length - zeroCounter, this.parsedAddress.length - 1]);
|
|
1086
|
+
}
|
|
1087
|
+
const zeroLengths = zeroes.map((n) => n[1] - n[0] + 1);
|
|
1088
|
+
if (zeroes.length > 0) {
|
|
1089
|
+
const index = zeroLengths.indexOf(Math.max(...zeroLengths));
|
|
1090
|
+
groups = compact(this.parsedAddress, zeroes[index]);
|
|
1091
|
+
} else {
|
|
1092
|
+
groups = this.parsedAddress;
|
|
1093
|
+
}
|
|
1094
|
+
for (i = 0;i < groups.length; i++) {
|
|
1095
|
+
if (groups[i] !== "compact") {
|
|
1096
|
+
groups[i] = parseInt(groups[i], 16).toString(16);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
let correct = groups.join(":");
|
|
1100
|
+
correct = correct.replace(/^compact$/, "::");
|
|
1101
|
+
correct = correct.replace(/(^compact)|(compact$)/, ":");
|
|
1102
|
+
correct = correct.replace(/compact/, "");
|
|
1103
|
+
return correct;
|
|
1104
|
+
}
|
|
1105
|
+
binaryZeroPad() {
|
|
1106
|
+
return this.bigInt().toString(2).padStart(constants6.BITS, "0");
|
|
1107
|
+
}
|
|
1108
|
+
parse4in6(address) {
|
|
1109
|
+
const groups = address.split(":");
|
|
1110
|
+
const lastGroup = groups.slice(-1)[0];
|
|
1111
|
+
const address4 = lastGroup.match(constants4.RE_ADDRESS);
|
|
1112
|
+
if (address4) {
|
|
1113
|
+
this.parsedAddress4 = address4[0];
|
|
1114
|
+
this.address4 = new ipv4_1.Address4(this.parsedAddress4);
|
|
1115
|
+
for (let i = 0;i < this.address4.groups; i++) {
|
|
1116
|
+
if (/^0[0-9]+/.test(this.address4.parsedAddress[i])) {
|
|
1117
|
+
throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", address.replace(constants4.RE_ADDRESS, this.address4.parsedAddress.map(spanLeadingZeroes4).join(".")));
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
this.v4 = true;
|
|
1121
|
+
groups[groups.length - 1] = this.address4.toGroup6();
|
|
1122
|
+
address = groups.join(":");
|
|
1123
|
+
}
|
|
1124
|
+
return address;
|
|
1125
|
+
}
|
|
1126
|
+
parse(address) {
|
|
1127
|
+
address = this.parse4in6(address);
|
|
1128
|
+
const badCharacters = address.match(constants6.RE_BAD_CHARACTERS);
|
|
1129
|
+
if (badCharacters) {
|
|
1130
|
+
throw new address_error_1.AddressError(`Bad character${badCharacters.length > 1 ? "s" : ""} detected in address: ${badCharacters.join("")}`, address.replace(constants6.RE_BAD_CHARACTERS, '<span class="parse-error">$1</span>'));
|
|
1131
|
+
}
|
|
1132
|
+
const badAddress = address.match(constants6.RE_BAD_ADDRESS);
|
|
1133
|
+
if (badAddress) {
|
|
1134
|
+
throw new address_error_1.AddressError(`Address failed regex: ${badAddress.join("")}`, address.replace(constants6.RE_BAD_ADDRESS, '<span class="parse-error">$1</span>'));
|
|
1135
|
+
}
|
|
1136
|
+
let groups = [];
|
|
1137
|
+
const halves = address.split("::");
|
|
1138
|
+
if (halves.length === 2) {
|
|
1139
|
+
let first = halves[0].split(":");
|
|
1140
|
+
let last = halves[1].split(":");
|
|
1141
|
+
if (first.length === 1 && first[0] === "") {
|
|
1142
|
+
first = [];
|
|
1143
|
+
}
|
|
1144
|
+
if (last.length === 1 && last[0] === "") {
|
|
1145
|
+
last = [];
|
|
1146
|
+
}
|
|
1147
|
+
const remaining = this.groups - (first.length + last.length);
|
|
1148
|
+
if (!remaining) {
|
|
1149
|
+
throw new address_error_1.AddressError("Error parsing groups");
|
|
1150
|
+
}
|
|
1151
|
+
this.elidedGroups = remaining;
|
|
1152
|
+
this.elisionBegin = first.length;
|
|
1153
|
+
this.elisionEnd = first.length + this.elidedGroups;
|
|
1154
|
+
groups = groups.concat(first);
|
|
1155
|
+
for (let i = 0;i < remaining; i++) {
|
|
1156
|
+
groups.push("0");
|
|
1157
|
+
}
|
|
1158
|
+
groups = groups.concat(last);
|
|
1159
|
+
} else if (halves.length === 1) {
|
|
1160
|
+
groups = address.split(":");
|
|
1161
|
+
this.elidedGroups = 0;
|
|
1162
|
+
} else {
|
|
1163
|
+
throw new address_error_1.AddressError("Too many :: groups found");
|
|
1164
|
+
}
|
|
1165
|
+
groups = groups.map((group) => parseInt(group, 16).toString(16));
|
|
1166
|
+
if (groups.length !== this.groups) {
|
|
1167
|
+
throw new address_error_1.AddressError("Incorrect number of groups found");
|
|
1168
|
+
}
|
|
1169
|
+
return groups;
|
|
1170
|
+
}
|
|
1171
|
+
canonicalForm() {
|
|
1172
|
+
return this.parsedAddress.map(paddedHex).join(":");
|
|
1173
|
+
}
|
|
1174
|
+
decimal() {
|
|
1175
|
+
return this.parsedAddress.map((n) => parseInt(n, 16).toString(10).padStart(5, "0")).join(":");
|
|
1176
|
+
}
|
|
1177
|
+
bigInt() {
|
|
1178
|
+
return BigInt(`0x${this.parsedAddress.map(paddedHex).join("")}`);
|
|
1179
|
+
}
|
|
1180
|
+
to4() {
|
|
1181
|
+
const binary = this.binaryZeroPad().split("");
|
|
1182
|
+
return ipv4_1.Address4.fromHex(BigInt(`0b${binary.slice(96, 128).join("")}`).toString(16));
|
|
1183
|
+
}
|
|
1184
|
+
to4in6() {
|
|
1185
|
+
const address4 = this.to4();
|
|
1186
|
+
const address6 = new Address6(this.parsedAddress.slice(0, 6).join(":"), 6);
|
|
1187
|
+
const correct = address6.correctForm();
|
|
1188
|
+
let infix = "";
|
|
1189
|
+
if (!/:$/.test(correct)) {
|
|
1190
|
+
infix = ":";
|
|
1191
|
+
}
|
|
1192
|
+
return correct + infix + address4.address;
|
|
1193
|
+
}
|
|
1194
|
+
inspectTeredo() {
|
|
1195
|
+
const prefix = this.getBitsBase16(0, 32);
|
|
1196
|
+
const bitsForUdpPort = this.getBits(80, 96);
|
|
1197
|
+
const udpPort = (bitsForUdpPort ^ BigInt("0xffff")).toString();
|
|
1198
|
+
const server4 = ipv4_1.Address4.fromHex(this.getBitsBase16(32, 64));
|
|
1199
|
+
const bitsForClient4 = this.getBits(96, 128);
|
|
1200
|
+
const client4 = ipv4_1.Address4.fromHex((bitsForClient4 ^ BigInt("0xffffffff")).toString(16));
|
|
1201
|
+
const flagsBase2 = this.getBitsBase2(64, 80);
|
|
1202
|
+
const coneNat = (0, common_1.testBit)(flagsBase2, 15);
|
|
1203
|
+
const reserved = (0, common_1.testBit)(flagsBase2, 14);
|
|
1204
|
+
const groupIndividual = (0, common_1.testBit)(flagsBase2, 8);
|
|
1205
|
+
const universalLocal = (0, common_1.testBit)(flagsBase2, 9);
|
|
1206
|
+
const nonce = BigInt(`0b${flagsBase2.slice(2, 6) + flagsBase2.slice(8, 16)}`).toString(10);
|
|
1207
|
+
return {
|
|
1208
|
+
prefix: `${prefix.slice(0, 4)}:${prefix.slice(4, 8)}`,
|
|
1209
|
+
server4: server4.address,
|
|
1210
|
+
client4: client4.address,
|
|
1211
|
+
flags: flagsBase2,
|
|
1212
|
+
coneNat,
|
|
1213
|
+
microsoft: {
|
|
1214
|
+
reserved,
|
|
1215
|
+
universalLocal,
|
|
1216
|
+
groupIndividual,
|
|
1217
|
+
nonce
|
|
1218
|
+
},
|
|
1219
|
+
udpPort
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
inspect6to4() {
|
|
1223
|
+
const prefix = this.getBitsBase16(0, 16);
|
|
1224
|
+
const gateway = ipv4_1.Address4.fromHex(this.getBitsBase16(16, 48));
|
|
1225
|
+
return {
|
|
1226
|
+
prefix: prefix.slice(0, 4),
|
|
1227
|
+
gateway: gateway.address
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
to6to4() {
|
|
1231
|
+
if (!this.is4()) {
|
|
1232
|
+
return null;
|
|
1233
|
+
}
|
|
1234
|
+
const addr6to4 = [
|
|
1235
|
+
"2002",
|
|
1236
|
+
this.getBitsBase16(96, 112),
|
|
1237
|
+
this.getBitsBase16(112, 128),
|
|
1238
|
+
"",
|
|
1239
|
+
"/16"
|
|
1240
|
+
].join(":");
|
|
1241
|
+
return new Address6(addr6to4);
|
|
1242
|
+
}
|
|
1243
|
+
toByteArray() {
|
|
1244
|
+
const valueWithoutPadding = this.bigInt().toString(16);
|
|
1245
|
+
const leadingPad = "0".repeat(valueWithoutPadding.length % 2);
|
|
1246
|
+
const value = `${leadingPad}${valueWithoutPadding}`;
|
|
1247
|
+
const bytes = [];
|
|
1248
|
+
for (let i = 0, length = value.length;i < length; i += 2) {
|
|
1249
|
+
bytes.push(parseInt(value.substring(i, i + 2), 16));
|
|
1250
|
+
}
|
|
1251
|
+
return bytes;
|
|
1252
|
+
}
|
|
1253
|
+
toUnsignedByteArray() {
|
|
1254
|
+
return this.toByteArray().map(unsignByte);
|
|
1255
|
+
}
|
|
1256
|
+
static fromByteArray(bytes) {
|
|
1257
|
+
return this.fromUnsignedByteArray(bytes.map(unsignByte));
|
|
1258
|
+
}
|
|
1259
|
+
static fromUnsignedByteArray(bytes) {
|
|
1260
|
+
const BYTE_MAX = BigInt("256");
|
|
1261
|
+
let result = BigInt("0");
|
|
1262
|
+
let multiplier = BigInt("1");
|
|
1263
|
+
for (let i = bytes.length - 1;i >= 0; i--) {
|
|
1264
|
+
result += multiplier * BigInt(bytes[i].toString(10));
|
|
1265
|
+
multiplier *= BYTE_MAX;
|
|
1266
|
+
}
|
|
1267
|
+
return Address6.fromBigInt(result);
|
|
1268
|
+
}
|
|
1269
|
+
isCanonical() {
|
|
1270
|
+
return this.addressMinusSuffix === this.canonicalForm();
|
|
1271
|
+
}
|
|
1272
|
+
isLinkLocal() {
|
|
1273
|
+
if (this.getBitsBase2(0, 64) === "1111111010000000000000000000000000000000000000000000000000000000") {
|
|
1274
|
+
return true;
|
|
1275
|
+
}
|
|
1276
|
+
return false;
|
|
1277
|
+
}
|
|
1278
|
+
isMulticast() {
|
|
1279
|
+
return this.getType() === "Multicast";
|
|
1280
|
+
}
|
|
1281
|
+
is4() {
|
|
1282
|
+
return this.v4;
|
|
1283
|
+
}
|
|
1284
|
+
isTeredo() {
|
|
1285
|
+
return this.isInSubnet(new Address6("2001::/32"));
|
|
1286
|
+
}
|
|
1287
|
+
is6to4() {
|
|
1288
|
+
return this.isInSubnet(new Address6("2002::/16"));
|
|
1289
|
+
}
|
|
1290
|
+
isLoopback() {
|
|
1291
|
+
return this.getType() === "Loopback";
|
|
1292
|
+
}
|
|
1293
|
+
href(optionalPort) {
|
|
1294
|
+
if (optionalPort === undefined) {
|
|
1295
|
+
optionalPort = "";
|
|
1296
|
+
} else {
|
|
1297
|
+
optionalPort = `:${optionalPort}`;
|
|
1298
|
+
}
|
|
1299
|
+
return `http://[${this.correctForm()}]${optionalPort}/`;
|
|
1300
|
+
}
|
|
1301
|
+
link(options) {
|
|
1302
|
+
if (!options) {
|
|
1303
|
+
options = {};
|
|
1304
|
+
}
|
|
1305
|
+
if (options.className === undefined) {
|
|
1306
|
+
options.className = "";
|
|
1307
|
+
}
|
|
1308
|
+
if (options.prefix === undefined) {
|
|
1309
|
+
options.prefix = "/#address=";
|
|
1310
|
+
}
|
|
1311
|
+
if (options.v4 === undefined) {
|
|
1312
|
+
options.v4 = false;
|
|
1313
|
+
}
|
|
1314
|
+
let formFunction = this.correctForm;
|
|
1315
|
+
if (options.v4) {
|
|
1316
|
+
formFunction = this.to4in6;
|
|
1317
|
+
}
|
|
1318
|
+
const form = formFunction.call(this);
|
|
1319
|
+
if (options.className) {
|
|
1320
|
+
return `<a href="${options.prefix}${form}" class="${options.className}">${form}</a>`;
|
|
1321
|
+
}
|
|
1322
|
+
return `<a href="${options.prefix}${form}">${form}</a>`;
|
|
1323
|
+
}
|
|
1324
|
+
group() {
|
|
1325
|
+
if (this.elidedGroups === 0) {
|
|
1326
|
+
return helpers.simpleGroup(this.address).join(":");
|
|
1327
|
+
}
|
|
1328
|
+
assert(typeof this.elidedGroups === "number");
|
|
1329
|
+
assert(typeof this.elisionBegin === "number");
|
|
1330
|
+
const output = [];
|
|
1331
|
+
const [left, right] = this.address.split("::");
|
|
1332
|
+
if (left.length) {
|
|
1333
|
+
output.push(...helpers.simpleGroup(left));
|
|
1334
|
+
} else {
|
|
1335
|
+
output.push("");
|
|
1336
|
+
}
|
|
1337
|
+
const classes = ["hover-group"];
|
|
1338
|
+
for (let i = this.elisionBegin;i < this.elisionBegin + this.elidedGroups; i++) {
|
|
1339
|
+
classes.push(`group-${i}`);
|
|
1340
|
+
}
|
|
1341
|
+
output.push(`<span class="${classes.join(" ")}"></span>`);
|
|
1342
|
+
if (right.length) {
|
|
1343
|
+
output.push(...helpers.simpleGroup(right, this.elisionEnd));
|
|
1344
|
+
} else {
|
|
1345
|
+
output.push("");
|
|
1346
|
+
}
|
|
1347
|
+
if (this.is4()) {
|
|
1348
|
+
assert(this.address4 instanceof ipv4_1.Address4);
|
|
1349
|
+
output.pop();
|
|
1350
|
+
output.push(this.address4.groupForV6());
|
|
1351
|
+
}
|
|
1352
|
+
return output.join(":");
|
|
1353
|
+
}
|
|
1354
|
+
regularExpressionString(substringSearch = false) {
|
|
1355
|
+
let output = [];
|
|
1356
|
+
const address6 = new Address6(this.correctForm());
|
|
1357
|
+
if (address6.elidedGroups === 0) {
|
|
1358
|
+
output.push((0, regular_expressions_1.simpleRegularExpression)(address6.parsedAddress));
|
|
1359
|
+
} else if (address6.elidedGroups === constants6.GROUPS) {
|
|
1360
|
+
output.push((0, regular_expressions_1.possibleElisions)(constants6.GROUPS));
|
|
1361
|
+
} else {
|
|
1362
|
+
const halves = address6.address.split("::");
|
|
1363
|
+
if (halves[0].length) {
|
|
1364
|
+
output.push((0, regular_expressions_1.simpleRegularExpression)(halves[0].split(":")));
|
|
1365
|
+
}
|
|
1366
|
+
assert(typeof address6.elidedGroups === "number");
|
|
1367
|
+
output.push((0, regular_expressions_1.possibleElisions)(address6.elidedGroups, halves[0].length !== 0, halves[1].length !== 0));
|
|
1368
|
+
if (halves[1].length) {
|
|
1369
|
+
output.push((0, regular_expressions_1.simpleRegularExpression)(halves[1].split(":")));
|
|
1370
|
+
}
|
|
1371
|
+
output = [output.join(":")];
|
|
1372
|
+
}
|
|
1373
|
+
if (!substringSearch) {
|
|
1374
|
+
output = [
|
|
1375
|
+
"(?=^|",
|
|
1376
|
+
regular_expressions_1.ADDRESS_BOUNDARY,
|
|
1377
|
+
"|[^\\w\\:])(",
|
|
1378
|
+
...output,
|
|
1379
|
+
")(?=[^\\w\\:]|",
|
|
1380
|
+
regular_expressions_1.ADDRESS_BOUNDARY,
|
|
1381
|
+
"|$)"
|
|
1382
|
+
];
|
|
1383
|
+
}
|
|
1384
|
+
return output.join("");
|
|
1385
|
+
}
|
|
1386
|
+
regularExpression(substringSearch = false) {
|
|
1387
|
+
return new RegExp(this.regularExpressionString(substringSearch), "i");
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
exports.Address6 = Address6;
|
|
1391
|
+
});
|
|
1392
|
+
|
|
1393
|
+
// ../../node_modules/ip-address/dist/ip-address.js
|
|
1394
|
+
var require_ip_address = __commonJS((exports) => {
|
|
1395
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
1396
|
+
if (k2 === undefined)
|
|
1397
|
+
k2 = k;
|
|
1398
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1399
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1400
|
+
desc = { enumerable: true, get: function() {
|
|
1401
|
+
return m[k];
|
|
1402
|
+
} };
|
|
1403
|
+
}
|
|
1404
|
+
Object.defineProperty(o, k2, desc);
|
|
1405
|
+
} : function(o, m, k, k2) {
|
|
1406
|
+
if (k2 === undefined)
|
|
1407
|
+
k2 = k;
|
|
1408
|
+
o[k2] = m[k];
|
|
1409
|
+
});
|
|
1410
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
1411
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1412
|
+
} : function(o, v) {
|
|
1413
|
+
o["default"] = v;
|
|
1414
|
+
});
|
|
1415
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
1416
|
+
if (mod && mod.__esModule)
|
|
1417
|
+
return mod;
|
|
1418
|
+
var result = {};
|
|
1419
|
+
if (mod != null) {
|
|
1420
|
+
for (var k in mod)
|
|
1421
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
1422
|
+
__createBinding(result, mod, k);
|
|
1423
|
+
}
|
|
1424
|
+
__setModuleDefault(result, mod);
|
|
1425
|
+
return result;
|
|
1426
|
+
};
|
|
1427
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1428
|
+
exports.v6 = exports.AddressError = exports.Address6 = exports.Address4 = undefined;
|
|
1429
|
+
var ipv4_1 = require_ipv4();
|
|
1430
|
+
Object.defineProperty(exports, "Address4", { enumerable: true, get: function() {
|
|
1431
|
+
return ipv4_1.Address4;
|
|
1432
|
+
} });
|
|
1433
|
+
var ipv6_1 = require_ipv6();
|
|
1434
|
+
Object.defineProperty(exports, "Address6", { enumerable: true, get: function() {
|
|
1435
|
+
return ipv6_1.Address6;
|
|
1436
|
+
} });
|
|
1437
|
+
var address_error_1 = require_address_error();
|
|
1438
|
+
Object.defineProperty(exports, "AddressError", { enumerable: true, get: function() {
|
|
1439
|
+
return address_error_1.AddressError;
|
|
1440
|
+
} });
|
|
1441
|
+
var helpers = __importStar(require_helpers());
|
|
1442
|
+
exports.v6 = { helpers };
|
|
1443
|
+
});
|
|
1444
|
+
|
|
373
1445
|
// ../../node_modules/dotenv/package.json
|
|
374
1446
|
var require_package = __commonJS((exports, module) => {
|
|
375
1447
|
module.exports = {
|
|
376
1448
|
name: "dotenv",
|
|
377
|
-
version: "
|
|
1449
|
+
version: "17.2.3",
|
|
378
1450
|
description: "Loads environment variables from .env file",
|
|
379
1451
|
main: "lib/main.js",
|
|
380
1452
|
types: "lib/main.d.ts",
|
|
@@ -396,8 +1468,8 @@ var require_package = __commonJS((exports, module) => {
|
|
|
396
1468
|
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
397
1469
|
lint: "standard",
|
|
398
1470
|
pretest: "npm run lint && npm run dts-check",
|
|
399
|
-
test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
400
|
-
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
1471
|
+
test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
1472
|
+
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
401
1473
|
prerelease: "npm test",
|
|
402
1474
|
release: "standard-version"
|
|
403
1475
|
},
|
|
@@ -444,6 +1516,39 @@ var require_main = __commonJS((exports, module) => {
|
|
|
444
1516
|
var crypto = __require("crypto");
|
|
445
1517
|
var packageJson = require_package();
|
|
446
1518
|
var version = packageJson.version;
|
|
1519
|
+
var TIPS = [
|
|
1520
|
+
"\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
|
|
1521
|
+
"\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
1522
|
+
"\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
1523
|
+
"\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops",
|
|
1524
|
+
"\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
1525
|
+
"\uD83D\uDDC2️ backup and recover secrets: https://dotenvx.com/ops",
|
|
1526
|
+
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
1527
|
+
"\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
1528
|
+
"\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops",
|
|
1529
|
+
"\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
|
|
1530
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
1531
|
+
"⚙️ enable debug logging with { debug: true }",
|
|
1532
|
+
"⚙️ override existing env vars with { override: true }",
|
|
1533
|
+
"⚙️ suppress all logs with { quiet: true }",
|
|
1534
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
|
1535
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
1536
|
+
];
|
|
1537
|
+
function _getRandomTip() {
|
|
1538
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
1539
|
+
}
|
|
1540
|
+
function parseBoolean(value) {
|
|
1541
|
+
if (typeof value === "string") {
|
|
1542
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
1543
|
+
}
|
|
1544
|
+
return Boolean(value);
|
|
1545
|
+
}
|
|
1546
|
+
function supportsAnsi() {
|
|
1547
|
+
return process.stdout.isTTY;
|
|
1548
|
+
}
|
|
1549
|
+
function dim(text) {
|
|
1550
|
+
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
|
1551
|
+
}
|
|
447
1552
|
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
448
1553
|
function parse(src) {
|
|
449
1554
|
const obj = {};
|
|
@@ -494,7 +1599,7 @@ var require_main = __commonJS((exports, module) => {
|
|
|
494
1599
|
return DotenvModule.parse(decrypted);
|
|
495
1600
|
}
|
|
496
1601
|
function _warn(message) {
|
|
497
|
-
console.
|
|
1602
|
+
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
498
1603
|
}
|
|
499
1604
|
function _debug(message) {
|
|
500
1605
|
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
@@ -568,8 +1673,8 @@ var require_main = __commonJS((exports, module) => {
|
|
|
568
1673
|
return envPath[0] === "~" ? path5.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
569
1674
|
}
|
|
570
1675
|
function _configVault(options) {
|
|
571
|
-
const debug =
|
|
572
|
-
const quiet =
|
|
1676
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
1677
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
573
1678
|
if (debug || !quiet) {
|
|
574
1679
|
_log("Loading env from encrypted .env.vault");
|
|
575
1680
|
}
|
|
@@ -584,8 +1689,12 @@ var require_main = __commonJS((exports, module) => {
|
|
|
584
1689
|
function configDotenv(options) {
|
|
585
1690
|
const dotenvPath = path5.resolve(process.cwd(), ".env");
|
|
586
1691
|
let encoding = "utf8";
|
|
587
|
-
|
|
588
|
-
|
|
1692
|
+
let processEnv = process.env;
|
|
1693
|
+
if (options && options.processEnv != null) {
|
|
1694
|
+
processEnv = options.processEnv;
|
|
1695
|
+
}
|
|
1696
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
1697
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
589
1698
|
if (options && options.encoding) {
|
|
590
1699
|
encoding = options.encoding;
|
|
591
1700
|
} else {
|
|
@@ -617,13 +1726,11 @@ var require_main = __commonJS((exports, module) => {
|
|
|
617
1726
|
lastError = e;
|
|
618
1727
|
}
|
|
619
1728
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
DotenvModule.populate(processEnv, parsedAll, options);
|
|
1729
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
1730
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
1731
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
625
1732
|
if (debug || !quiet) {
|
|
626
|
-
const keysCount = Object.keys(
|
|
1733
|
+
const keysCount = Object.keys(populated).length;
|
|
627
1734
|
const shortPaths = [];
|
|
628
1735
|
for (const filePath of optionPaths) {
|
|
629
1736
|
try {
|
|
@@ -636,7 +1743,7 @@ var require_main = __commonJS((exports, module) => {
|
|
|
636
1743
|
lastError = e;
|
|
637
1744
|
}
|
|
638
1745
|
}
|
|
639
|
-
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
|
|
1746
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
640
1747
|
}
|
|
641
1748
|
if (lastError) {
|
|
642
1749
|
return { parsed: parsedAll, error: lastError };
|
|
@@ -685,6 +1792,7 @@ var require_main = __commonJS((exports, module) => {
|
|
|
685
1792
|
function populate(processEnv, parsed, options = {}) {
|
|
686
1793
|
const debug = Boolean(options && options.debug);
|
|
687
1794
|
const override = Boolean(options && options.override);
|
|
1795
|
+
const populated = {};
|
|
688
1796
|
if (typeof parsed !== "object") {
|
|
689
1797
|
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
690
1798
|
err.code = "OBJECT_REQUIRED";
|
|
@@ -694,6 +1802,7 @@ var require_main = __commonJS((exports, module) => {
|
|
|
694
1802
|
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
695
1803
|
if (override === true) {
|
|
696
1804
|
processEnv[key] = parsed[key];
|
|
1805
|
+
populated[key] = parsed[key];
|
|
697
1806
|
}
|
|
698
1807
|
if (debug) {
|
|
699
1808
|
if (override === true) {
|
|
@@ -704,8 +1813,10 @@ var require_main = __commonJS((exports, module) => {
|
|
|
704
1813
|
}
|
|
705
1814
|
} else {
|
|
706
1815
|
processEnv[key] = parsed[key];
|
|
1816
|
+
populated[key] = parsed[key];
|
|
707
1817
|
}
|
|
708
1818
|
}
|
|
1819
|
+
return populated;
|
|
709
1820
|
}
|
|
710
1821
|
var DotenvModule = {
|
|
711
1822
|
configDotenv,
|
|
@@ -2148,7 +3259,7 @@ var require_suppress_tracing = __commonJS((exports) => {
|
|
|
2148
3259
|
});
|
|
2149
3260
|
|
|
2150
3261
|
// ../../node_modules/@opentelemetry/core/build/src/baggage/constants.js
|
|
2151
|
-
var
|
|
3262
|
+
var require_constants3 = __commonJS((exports) => {
|
|
2152
3263
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2153
3264
|
exports.BAGGAGE_MAX_TOTAL_LENGTH = exports.BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = exports.BAGGAGE_MAX_NAME_VALUE_PAIRS = exports.BAGGAGE_HEADER = exports.BAGGAGE_ITEMS_SEPARATOR = exports.BAGGAGE_PROPERTIES_SEPARATOR = exports.BAGGAGE_KEY_PAIR_SEPARATOR = undefined;
|
|
2154
3265
|
exports.BAGGAGE_KEY_PAIR_SEPARATOR = "=";
|
|
@@ -2165,7 +3276,7 @@ var require_utils3 = __commonJS((exports) => {
|
|
|
2165
3276
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2166
3277
|
exports.parseKeyPairsIntoRecord = exports.parsePairKeyValue = exports.getKeyPairs = exports.serializeKeyPairs = undefined;
|
|
2167
3278
|
var api_1 = require_src();
|
|
2168
|
-
var constants_1 =
|
|
3279
|
+
var constants_1 = require_constants3();
|
|
2169
3280
|
function serializeKeyPairs(keyPairs) {
|
|
2170
3281
|
return keyPairs.reduce((hValue, current) => {
|
|
2171
3282
|
const value = `${hValue}${hValue !== "" ? constants_1.BAGGAGE_ITEMS_SEPARATOR : ""}${current}`;
|
|
@@ -2223,7 +3334,7 @@ var require_W3CBaggagePropagator = __commonJS((exports) => {
|
|
|
2223
3334
|
exports.W3CBaggagePropagator = undefined;
|
|
2224
3335
|
var api_1 = require_src();
|
|
2225
3336
|
var suppress_tracing_1 = require_suppress_tracing();
|
|
2226
|
-
var constants_1 =
|
|
3337
|
+
var constants_1 = require_constants3();
|
|
2227
3338
|
var utils_1 = require_utils3();
|
|
2228
3339
|
|
|
2229
3340
|
class W3CBaggagePropagator {
|
|
@@ -5930,7 +7041,7 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
5930
7041
|
});
|
|
5931
7042
|
|
|
5932
7043
|
// ../../node_modules/debug/src/common.js
|
|
5933
|
-
var
|
|
7044
|
+
var require_common2 = __commonJS((exports, module) => {
|
|
5934
7045
|
function setup(env) {
|
|
5935
7046
|
createDebug.debug = createDebug;
|
|
5936
7047
|
createDebug.default = createDebug;
|
|
@@ -6253,7 +7364,7 @@ var require_browser = __commonJS((exports, module) => {
|
|
|
6253
7364
|
return localStorage;
|
|
6254
7365
|
} catch (error) {}
|
|
6255
7366
|
}
|
|
6256
|
-
module.exports =
|
|
7367
|
+
module.exports = require_common2()(exports);
|
|
6257
7368
|
var { formatters } = module.exports;
|
|
6258
7369
|
formatters.j = function(v) {
|
|
6259
7370
|
try {
|
|
@@ -6543,7 +7654,7 @@ var require_node4 = __commonJS((exports, module) => {
|
|
|
6543
7654
|
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
6544
7655
|
}
|
|
6545
7656
|
}
|
|
6546
|
-
module.exports =
|
|
7657
|
+
module.exports = require_common2()(exports);
|
|
6547
7658
|
var { formatters } = module.exports;
|
|
6548
7659
|
formatters.o = function(v) {
|
|
6549
7660
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -17823,7 +18934,7 @@ var require_autoLoader2 = __commonJS((exports) => {
|
|
|
17823
18934
|
});
|
|
17824
18935
|
|
|
17825
18936
|
// ../../node_modules/semver/internal/constants.js
|
|
17826
|
-
var
|
|
18937
|
+
var require_constants4 = __commonJS((exports, module) => {
|
|
17827
18938
|
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
17828
18939
|
var MAX_LENGTH = 256;
|
|
17829
18940
|
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
@@ -17862,7 +18973,7 @@ var require_re = __commonJS((exports, module) => {
|
|
|
17862
18973
|
MAX_SAFE_COMPONENT_LENGTH,
|
|
17863
18974
|
MAX_SAFE_BUILD_LENGTH,
|
|
17864
18975
|
MAX_LENGTH
|
|
17865
|
-
} =
|
|
18976
|
+
} = require_constants4();
|
|
17866
18977
|
var debug2 = require_debug();
|
|
17867
18978
|
exports = module.exports = {};
|
|
17868
18979
|
var re = exports.re = [];
|
|
@@ -17979,7 +19090,7 @@ var require_identifiers = __commonJS((exports, module) => {
|
|
|
17979
19090
|
// ../../node_modules/semver/classes/semver.js
|
|
17980
19091
|
var require_semver3 = __commonJS((exports, module) => {
|
|
17981
19092
|
var debug2 = require_debug();
|
|
17982
|
-
var { MAX_LENGTH, MAX_SAFE_INTEGER } =
|
|
19093
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants4();
|
|
17983
19094
|
var { safeRe: re, t } = require_re();
|
|
17984
19095
|
var parseOptions2 = require_parse_options();
|
|
17985
19096
|
var { compareIdentifiers } = require_identifiers();
|
|
@@ -18724,7 +19835,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
18724
19835
|
tildeTrimReplace,
|
|
18725
19836
|
caretTrimReplace
|
|
18726
19837
|
} = require_re();
|
|
18727
|
-
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } =
|
|
19838
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants4();
|
|
18728
19839
|
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
18729
19840
|
var isAny = (c) => c.value === "";
|
|
18730
19841
|
var isSatisfiable = (comparators, options) => {
|
|
@@ -19494,7 +20605,7 @@ var require_subset = __commonJS((exports, module) => {
|
|
|
19494
20605
|
// ../../node_modules/semver/index.js
|
|
19495
20606
|
var require_semver4 = __commonJS((exports, module) => {
|
|
19496
20607
|
var internalRe = require_re();
|
|
19497
|
-
var constants2 =
|
|
20608
|
+
var constants2 = require_constants4();
|
|
19498
20609
|
var SemVer = require_semver3();
|
|
19499
20610
|
var identifiers = require_identifiers();
|
|
19500
20611
|
var parse = require_parse();
|
|
@@ -23396,7 +24507,10 @@ function createAgentRunsRouter(elizaOS) {
|
|
|
23396
24507
|
actionName: body.action,
|
|
23397
24508
|
success: body.result?.success !== false,
|
|
23398
24509
|
result: body.result,
|
|
23399
|
-
promptCount: body.promptCount
|
|
24510
|
+
promptCount: body.promptCount,
|
|
24511
|
+
prompts: body.prompts,
|
|
24512
|
+
params: body.params,
|
|
24513
|
+
response: body.response
|
|
23400
24514
|
}
|
|
23401
24515
|
});
|
|
23402
24516
|
}
|
|
@@ -23409,7 +24523,15 @@ function createAgentRunsRouter(elizaOS) {
|
|
|
23409
24523
|
modelType: body.modelType || (typeof e.type === "string" ? e.type.replace("useModel:", "") : undefined),
|
|
23410
24524
|
provider: body.provider,
|
|
23411
24525
|
executionTime: body.executionTime,
|
|
23412
|
-
actionContext: body.actionContext
|
|
24526
|
+
actionContext: body.actionContext,
|
|
24527
|
+
params: body.params,
|
|
24528
|
+
response: body.response,
|
|
24529
|
+
usage: body.usage,
|
|
24530
|
+
prompts: body.prompts,
|
|
24531
|
+
prompt: body.prompt,
|
|
24532
|
+
inputTokens: body.inputTokens,
|
|
24533
|
+
outputTokens: body.outputTokens,
|
|
24534
|
+
cost: body.cost
|
|
23413
24535
|
}
|
|
23414
24536
|
});
|
|
23415
24537
|
}
|
|
@@ -24328,20 +25450,99 @@ var getRuntime = (elizaOS, agentId) => {
|
|
|
24328
25450
|
};
|
|
24329
25451
|
|
|
24330
25452
|
// ../../node_modules/express-rate-limit/dist/index.mjs
|
|
25453
|
+
var import_ip_address = __toESM(require_ip_address(), 1);
|
|
25454
|
+
import { isIPv6 } from "node:net";
|
|
25455
|
+
import { isIPv6 as isIPv62 } from "node:net";
|
|
24331
25456
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
24332
25457
|
import { createHash } from "node:crypto";
|
|
24333
25458
|
import { isIP } from "node:net";
|
|
25459
|
+
function ipKeyGenerator(ip, ipv6Subnet = 56) {
|
|
25460
|
+
if (ipv6Subnet && isIPv6(ip)) {
|
|
25461
|
+
return `${new import_ip_address.Address6(`${ip}/${ipv6Subnet}`).startAddress().correctForm()}/${ipv6Subnet}`;
|
|
25462
|
+
}
|
|
25463
|
+
return ip;
|
|
25464
|
+
}
|
|
25465
|
+
var MemoryStore = class {
|
|
25466
|
+
constructor(validations2) {
|
|
25467
|
+
this.validations = validations2;
|
|
25468
|
+
this.previous = /* @__PURE__ */ new Map;
|
|
25469
|
+
this.current = /* @__PURE__ */ new Map;
|
|
25470
|
+
this.localKeys = true;
|
|
25471
|
+
}
|
|
25472
|
+
init(options) {
|
|
25473
|
+
this.windowMs = options.windowMs;
|
|
25474
|
+
this.validations?.windowMs(this.windowMs);
|
|
25475
|
+
if (this.interval)
|
|
25476
|
+
clearInterval(this.interval);
|
|
25477
|
+
this.interval = setInterval(() => {
|
|
25478
|
+
this.clearExpired();
|
|
25479
|
+
}, this.windowMs);
|
|
25480
|
+
this.interval.unref?.();
|
|
25481
|
+
}
|
|
25482
|
+
async get(key) {
|
|
25483
|
+
return this.current.get(key) ?? this.previous.get(key);
|
|
25484
|
+
}
|
|
25485
|
+
async increment(key) {
|
|
25486
|
+
const client = this.getClient(key);
|
|
25487
|
+
const now = Date.now();
|
|
25488
|
+
if (client.resetTime.getTime() <= now) {
|
|
25489
|
+
this.resetClient(client, now);
|
|
25490
|
+
}
|
|
25491
|
+
client.totalHits++;
|
|
25492
|
+
return client;
|
|
25493
|
+
}
|
|
25494
|
+
async decrement(key) {
|
|
25495
|
+
const client = this.getClient(key);
|
|
25496
|
+
if (client.totalHits > 0)
|
|
25497
|
+
client.totalHits--;
|
|
25498
|
+
}
|
|
25499
|
+
async resetKey(key) {
|
|
25500
|
+
this.current.delete(key);
|
|
25501
|
+
this.previous.delete(key);
|
|
25502
|
+
}
|
|
25503
|
+
async resetAll() {
|
|
25504
|
+
this.current.clear();
|
|
25505
|
+
this.previous.clear();
|
|
25506
|
+
}
|
|
25507
|
+
shutdown() {
|
|
25508
|
+
clearInterval(this.interval);
|
|
25509
|
+
this.resetAll();
|
|
25510
|
+
}
|
|
25511
|
+
resetClient(client, now = Date.now()) {
|
|
25512
|
+
client.totalHits = 0;
|
|
25513
|
+
client.resetTime.setTime(now + this.windowMs);
|
|
25514
|
+
return client;
|
|
25515
|
+
}
|
|
25516
|
+
getClient(key) {
|
|
25517
|
+
if (this.current.has(key))
|
|
25518
|
+
return this.current.get(key);
|
|
25519
|
+
let client;
|
|
25520
|
+
if (this.previous.has(key)) {
|
|
25521
|
+
client = this.previous.get(key);
|
|
25522
|
+
this.previous.delete(key);
|
|
25523
|
+
} else {
|
|
25524
|
+
client = { totalHits: 0, resetTime: /* @__PURE__ */ new Date };
|
|
25525
|
+
this.resetClient(client);
|
|
25526
|
+
}
|
|
25527
|
+
this.current.set(key, client);
|
|
25528
|
+
return client;
|
|
25529
|
+
}
|
|
25530
|
+
clearExpired() {
|
|
25531
|
+
this.previous = this.current;
|
|
25532
|
+
this.current = /* @__PURE__ */ new Map;
|
|
25533
|
+
}
|
|
25534
|
+
};
|
|
24334
25535
|
var SUPPORTED_DRAFT_VERSIONS = [
|
|
24335
25536
|
"draft-6",
|
|
24336
25537
|
"draft-7",
|
|
24337
25538
|
"draft-8"
|
|
24338
25539
|
];
|
|
24339
|
-
var getResetSeconds = (
|
|
24340
|
-
let resetSeconds
|
|
25540
|
+
var getResetSeconds = (windowMs, resetTime) => {
|
|
25541
|
+
let resetSeconds;
|
|
24341
25542
|
if (resetTime) {
|
|
24342
25543
|
const deltaSeconds = Math.ceil((resetTime.getTime() - Date.now()) / 1000);
|
|
24343
25544
|
resetSeconds = Math.max(0, deltaSeconds);
|
|
24344
|
-
} else
|
|
25545
|
+
} else {
|
|
24345
25546
|
resetSeconds = Math.ceil(windowMs / 1000);
|
|
24346
25547
|
}
|
|
24347
25548
|
return resetSeconds;
|
|
@@ -24366,18 +25567,18 @@ var setDraft6Headers = (response, info, windowMs) => {
|
|
|
24366
25567
|
if (response.headersSent)
|
|
24367
25568
|
return;
|
|
24368
25569
|
const windowSeconds = Math.ceil(windowMs / 1000);
|
|
24369
|
-
const resetSeconds = getResetSeconds(info.resetTime);
|
|
25570
|
+
const resetSeconds = getResetSeconds(windowMs, info.resetTime);
|
|
24370
25571
|
response.setHeader("RateLimit-Policy", `${info.limit};w=${windowSeconds}`);
|
|
24371
25572
|
response.setHeader("RateLimit-Limit", info.limit.toString());
|
|
24372
25573
|
response.setHeader("RateLimit-Remaining", info.remaining.toString());
|
|
24373
|
-
if (resetSeconds)
|
|
25574
|
+
if (typeof resetSeconds === "number")
|
|
24374
25575
|
response.setHeader("RateLimit-Reset", resetSeconds.toString());
|
|
24375
25576
|
};
|
|
24376
25577
|
var setDraft7Headers = (response, info, windowMs) => {
|
|
24377
25578
|
if (response.headersSent)
|
|
24378
25579
|
return;
|
|
24379
25580
|
const windowSeconds = Math.ceil(windowMs / 1000);
|
|
24380
|
-
const resetSeconds = getResetSeconds(info.resetTime
|
|
25581
|
+
const resetSeconds = getResetSeconds(windowMs, info.resetTime);
|
|
24381
25582
|
response.setHeader("RateLimit-Policy", `${info.limit};w=${windowSeconds}`);
|
|
24382
25583
|
response.setHeader("RateLimit", `limit=${info.limit}, remaining=${info.remaining}, reset=${resetSeconds}`);
|
|
24383
25584
|
};
|
|
@@ -24385,19 +25586,29 @@ var setDraft8Headers = (response, info, windowMs, name, key) => {
|
|
|
24385
25586
|
if (response.headersSent)
|
|
24386
25587
|
return;
|
|
24387
25588
|
const windowSeconds = Math.ceil(windowMs / 1000);
|
|
24388
|
-
const resetSeconds = getResetSeconds(info.resetTime
|
|
25589
|
+
const resetSeconds = getResetSeconds(windowMs, info.resetTime);
|
|
24389
25590
|
const partitionKey = getPartitionKey(key);
|
|
24390
|
-
const policy = `q=${info.limit}; w=${windowSeconds}; pk=:${partitionKey}:`;
|
|
24391
25591
|
const header = `r=${info.remaining}; t=${resetSeconds}`;
|
|
24392
|
-
|
|
25592
|
+
const policy = `q=${info.limit}; w=${windowSeconds}; pk=:${partitionKey}:`;
|
|
24393
25593
|
response.append("RateLimit", `"${name}"; ${header}`);
|
|
25594
|
+
response.append("RateLimit-Policy", `"${name}"; ${policy}`);
|
|
24394
25595
|
};
|
|
24395
25596
|
var setRetryAfterHeader = (response, info, windowMs) => {
|
|
24396
25597
|
if (response.headersSent)
|
|
24397
25598
|
return;
|
|
24398
|
-
const resetSeconds = getResetSeconds(info.resetTime
|
|
25599
|
+
const resetSeconds = getResetSeconds(windowMs, info.resetTime);
|
|
24399
25600
|
response.setHeader("Retry-After", resetSeconds.toString());
|
|
24400
25601
|
};
|
|
25602
|
+
var omitUndefinedProperties = (passedOptions) => {
|
|
25603
|
+
const omittedOptions = {};
|
|
25604
|
+
for (const k of Object.keys(passedOptions)) {
|
|
25605
|
+
const key = k;
|
|
25606
|
+
if (passedOptions[key] !== undefined) {
|
|
25607
|
+
omittedOptions[key] = passedOptions[key];
|
|
25608
|
+
}
|
|
25609
|
+
}
|
|
25610
|
+
return omittedOptions;
|
|
25611
|
+
};
|
|
24401
25612
|
var ValidationError = class extends Error {
|
|
24402
25613
|
constructor(code, message) {
|
|
24403
25614
|
const url = `https://express-rate-limit.github.io/${code}/`;
|
|
@@ -24437,6 +25648,11 @@ var validations = {
|
|
|
24437
25648
|
throw new ValidationError("ERR_ERL_UNEXPECTED_X_FORWARDED_FOR", `The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users.`);
|
|
24438
25649
|
}
|
|
24439
25650
|
},
|
|
25651
|
+
forwardedHeader(request) {
|
|
25652
|
+
if (request.headers.forwarded && request.ip === request.socket?.remoteAddress) {
|
|
25653
|
+
throw new ValidationError("ERR_ERL_FORWARDED_HEADER", `The 'Forwarded' header (standardized X-Forwarded-For) is set but currently being ignored. Add a custom keyGenerator to use a value from this header.`);
|
|
25654
|
+
}
|
|
25655
|
+
},
|
|
24440
25656
|
positiveHits(hits) {
|
|
24441
25657
|
if (typeof hits !== "number" || hits < 1 || hits !== Math.round(hits)) {
|
|
24442
25658
|
throw new ValidationError("ERR_ERL_INVALID_HITS", `The totalHits value returned from the store must be a positive integer, got ${hits}`);
|
|
@@ -24469,7 +25685,7 @@ var validations = {
|
|
|
24469
25685
|
},
|
|
24470
25686
|
limit(limit) {
|
|
24471
25687
|
if (limit === 0) {
|
|
24472
|
-
throw new ChangeWarning("WRN_ERL_MAX_ZERO",
|
|
25688
|
+
throw new ChangeWarning("WRN_ERL_MAX_ZERO", "Setting limit or max to 0 disables rate limiting in express-rate-limit v6 and older, but will cause all requests to be blocked in v7");
|
|
24473
25689
|
}
|
|
24474
25690
|
},
|
|
24475
25691
|
draftPolliHeaders(draft_polli_ratelimit_headers) {
|
|
@@ -24479,7 +25695,7 @@ var validations = {
|
|
|
24479
25695
|
},
|
|
24480
25696
|
onLimitReached(onLimitReached) {
|
|
24481
25697
|
if (onLimitReached) {
|
|
24482
|
-
throw new ChangeWarning("WRN_ERL_DEPRECATED_ON_LIMIT_REACHED",
|
|
25698
|
+
throw new ChangeWarning("WRN_ERL_DEPRECATED_ON_LIMIT_REACHED", "The onLimitReached configuration option is deprecated and has been removed in express-rate-limit v7.");
|
|
24483
25699
|
}
|
|
24484
25700
|
},
|
|
24485
25701
|
headersDraftVersion(version) {
|
|
@@ -24504,11 +25720,39 @@ var validations = {
|
|
|
24504
25720
|
},
|
|
24505
25721
|
creationStack(store) {
|
|
24506
25722
|
const { stack } = new Error("express-rate-limit validation check (set options.validate.creationStack=false to disable)");
|
|
24507
|
-
if (stack?.includes("Layer.handle [as handle_request]")) {
|
|
25723
|
+
if (stack?.includes("Layer.handle [as handle_request]") || stack?.includes("Layer.handleRequest")) {
|
|
24508
25724
|
if (!store.localKeys) {
|
|
24509
25725
|
throw new ValidationError("ERR_ERL_CREATED_IN_REQUEST_HANDLER", "express-rate-limit instance should *usually* be created at app initialization, not when responding to a request.");
|
|
24510
25726
|
}
|
|
24511
|
-
throw new ValidationError("ERR_ERL_CREATED_IN_REQUEST_HANDLER",
|
|
25727
|
+
throw new ValidationError("ERR_ERL_CREATED_IN_REQUEST_HANDLER", "express-rate-limit instance should be created at app initialization, not when responding to a request.");
|
|
25728
|
+
}
|
|
25729
|
+
},
|
|
25730
|
+
ipv6Subnet(ipv6Subnet) {
|
|
25731
|
+
if (ipv6Subnet === false) {
|
|
25732
|
+
return;
|
|
25733
|
+
}
|
|
25734
|
+
if (!Number.isInteger(ipv6Subnet) || ipv6Subnet < 32 || ipv6Subnet > 64) {
|
|
25735
|
+
throw new ValidationError("ERR_ERL_IPV6_SUBNET", `Unexpected ipv6Subnet value: ${ipv6Subnet}. Expected an integer between 32 and 64 (usually 48-64).`);
|
|
25736
|
+
}
|
|
25737
|
+
},
|
|
25738
|
+
ipv6SubnetOrKeyGenerator(options) {
|
|
25739
|
+
if (options.ipv6Subnet !== undefined && options.keyGenerator) {
|
|
25740
|
+
throw new ValidationError("ERR_ERL_IPV6SUBNET_OR_KEYGENERATOR", `Incompatible options: the 'ipv6Subnet' option is ignored when a custom 'keyGenerator' function is also set.`);
|
|
25741
|
+
}
|
|
25742
|
+
},
|
|
25743
|
+
keyGeneratorIpFallback(keyGenerator) {
|
|
25744
|
+
if (!keyGenerator) {
|
|
25745
|
+
return;
|
|
25746
|
+
}
|
|
25747
|
+
const src = keyGenerator.toString();
|
|
25748
|
+
if ((src.includes("req.ip") || src.includes("request.ip")) && !src.includes("ipKeyGenerator")) {
|
|
25749
|
+
throw new ValidationError("ERR_ERL_KEY_GEN_IPV6", "Custom keyGenerator appears to use request IP without calling the ipKeyGenerator helper function for IPv6 addresses. This could allow IPv6 users to bypass limits.");
|
|
25750
|
+
}
|
|
25751
|
+
},
|
|
25752
|
+
windowMs(windowMs) {
|
|
25753
|
+
const SET_TIMEOUT_MAX = 2 ** 31 - 1;
|
|
25754
|
+
if (typeof windowMs !== "number" || Number.isNaN(windowMs) || windowMs < 1 || windowMs > SET_TIMEOUT_MAX) {
|
|
25755
|
+
throw new ValidationError("ERR_ERL_WINDOW_MS", `Invalid windowMs value: ${windowMs}${typeof windowMs !== "number" ? ` (${typeof windowMs})` : ""}, must be a number between 1 and ${SET_TIMEOUT_MAX} when using the default MemoryStore`);
|
|
24512
25756
|
}
|
|
24513
25757
|
}
|
|
24514
25758
|
};
|
|
@@ -24524,9 +25768,7 @@ var getValidations = (_enabled) => {
|
|
|
24524
25768
|
..._enabled
|
|
24525
25769
|
};
|
|
24526
25770
|
}
|
|
24527
|
-
const wrappedValidations = {
|
|
24528
|
-
enabled
|
|
24529
|
-
};
|
|
25771
|
+
const wrappedValidations = { enabled };
|
|
24530
25772
|
for (const [name, validation] of Object.entries(validations)) {
|
|
24531
25773
|
if (typeof validation === "function")
|
|
24532
25774
|
wrappedValidations[name] = (...args) => {
|
|
@@ -24545,75 +25787,6 @@ var getValidations = (_enabled) => {
|
|
|
24545
25787
|
}
|
|
24546
25788
|
return wrappedValidations;
|
|
24547
25789
|
};
|
|
24548
|
-
var MemoryStore = class {
|
|
24549
|
-
constructor() {
|
|
24550
|
-
this.previous = /* @__PURE__ */ new Map;
|
|
24551
|
-
this.current = /* @__PURE__ */ new Map;
|
|
24552
|
-
this.localKeys = true;
|
|
24553
|
-
}
|
|
24554
|
-
init(options) {
|
|
24555
|
-
this.windowMs = options.windowMs;
|
|
24556
|
-
if (this.interval)
|
|
24557
|
-
clearInterval(this.interval);
|
|
24558
|
-
this.interval = setInterval(() => {
|
|
24559
|
-
this.clearExpired();
|
|
24560
|
-
}, this.windowMs);
|
|
24561
|
-
if (this.interval.unref)
|
|
24562
|
-
this.interval.unref();
|
|
24563
|
-
}
|
|
24564
|
-
async get(key) {
|
|
24565
|
-
return this.current.get(key) ?? this.previous.get(key);
|
|
24566
|
-
}
|
|
24567
|
-
async increment(key) {
|
|
24568
|
-
const client = this.getClient(key);
|
|
24569
|
-
const now = Date.now();
|
|
24570
|
-
if (client.resetTime.getTime() <= now) {
|
|
24571
|
-
this.resetClient(client, now);
|
|
24572
|
-
}
|
|
24573
|
-
client.totalHits++;
|
|
24574
|
-
return client;
|
|
24575
|
-
}
|
|
24576
|
-
async decrement(key) {
|
|
24577
|
-
const client = this.getClient(key);
|
|
24578
|
-
if (client.totalHits > 0)
|
|
24579
|
-
client.totalHits--;
|
|
24580
|
-
}
|
|
24581
|
-
async resetKey(key) {
|
|
24582
|
-
this.current.delete(key);
|
|
24583
|
-
this.previous.delete(key);
|
|
24584
|
-
}
|
|
24585
|
-
async resetAll() {
|
|
24586
|
-
this.current.clear();
|
|
24587
|
-
this.previous.clear();
|
|
24588
|
-
}
|
|
24589
|
-
shutdown() {
|
|
24590
|
-
clearInterval(this.interval);
|
|
24591
|
-
this.resetAll();
|
|
24592
|
-
}
|
|
24593
|
-
resetClient(client, now = Date.now()) {
|
|
24594
|
-
client.totalHits = 0;
|
|
24595
|
-
client.resetTime.setTime(now + this.windowMs);
|
|
24596
|
-
return client;
|
|
24597
|
-
}
|
|
24598
|
-
getClient(key) {
|
|
24599
|
-
if (this.current.has(key))
|
|
24600
|
-
return this.current.get(key);
|
|
24601
|
-
let client;
|
|
24602
|
-
if (this.previous.has(key)) {
|
|
24603
|
-
client = this.previous.get(key);
|
|
24604
|
-
this.previous.delete(key);
|
|
24605
|
-
} else {
|
|
24606
|
-
client = { totalHits: 0, resetTime: /* @__PURE__ */ new Date };
|
|
24607
|
-
this.resetClient(client);
|
|
24608
|
-
}
|
|
24609
|
-
this.current.set(key, client);
|
|
24610
|
-
return client;
|
|
24611
|
-
}
|
|
24612
|
-
clearExpired() {
|
|
24613
|
-
this.previous = this.current;
|
|
24614
|
-
this.current = /* @__PURE__ */ new Map;
|
|
24615
|
-
}
|
|
24616
|
-
};
|
|
24617
25790
|
var isLegacyStore = (store) => typeof store.incr === "function" && typeof store.increment !== "function";
|
|
24618
25791
|
var promisifyStore = (passedStore) => {
|
|
24619
25792
|
if (!isLegacyStore(passedStore)) {
|
|
@@ -24651,22 +25824,17 @@ var getOptionsFromConfig = (config) => {
|
|
|
24651
25824
|
validate: validations2.enabled
|
|
24652
25825
|
};
|
|
24653
25826
|
};
|
|
24654
|
-
var omitUndefinedOptions = (passedOptions) => {
|
|
24655
|
-
const omittedOptions = {};
|
|
24656
|
-
for (const k of Object.keys(passedOptions)) {
|
|
24657
|
-
const key = k;
|
|
24658
|
-
if (passedOptions[key] !== undefined) {
|
|
24659
|
-
omittedOptions[key] = passedOptions[key];
|
|
24660
|
-
}
|
|
24661
|
-
}
|
|
24662
|
-
return omittedOptions;
|
|
24663
|
-
};
|
|
24664
25827
|
var parseOptions = (passedOptions) => {
|
|
24665
|
-
const notUndefinedOptions =
|
|
25828
|
+
const notUndefinedOptions = omitUndefinedProperties(passedOptions);
|
|
24666
25829
|
const validations2 = getValidations(notUndefinedOptions?.validate ?? true);
|
|
24667
25830
|
validations2.validationsConfig();
|
|
24668
25831
|
validations2.draftPolliHeaders(notUndefinedOptions.draft_polli_ratelimit_headers);
|
|
24669
25832
|
validations2.onLimitReached(notUndefinedOptions.onLimitReached);
|
|
25833
|
+
if (notUndefinedOptions.ipv6Subnet !== undefined && typeof notUndefinedOptions.ipv6Subnet !== "function") {
|
|
25834
|
+
validations2.ipv6Subnet(notUndefinedOptions.ipv6Subnet);
|
|
25835
|
+
}
|
|
25836
|
+
validations2.keyGeneratorIpFallback(notUndefinedOptions.keyGenerator);
|
|
25837
|
+
validations2.ipv6SubnetOrKeyGenerator(notUndefinedOptions);
|
|
24670
25838
|
let standardHeaders = notUndefinedOptions.standardHeaders ?? false;
|
|
24671
25839
|
if (standardHeaders === true)
|
|
24672
25840
|
standardHeaders = "draft-6";
|
|
@@ -24699,23 +25867,31 @@ var parseOptions = (passedOptions) => {
|
|
|
24699
25867
|
skipSuccessfulRequests: false,
|
|
24700
25868
|
requestWasSuccessful: (_request, response) => response.statusCode < 400,
|
|
24701
25869
|
skip: (_request, _response) => false,
|
|
24702
|
-
keyGenerator(request,
|
|
25870
|
+
async keyGenerator(request, response) {
|
|
24703
25871
|
validations2.ip(request.ip);
|
|
24704
25872
|
validations2.trustProxy(request);
|
|
24705
25873
|
validations2.xForwardedForHeader(request);
|
|
24706
|
-
|
|
25874
|
+
validations2.forwardedHeader(request);
|
|
25875
|
+
const ip = request.ip;
|
|
25876
|
+
let subnet = 56;
|
|
25877
|
+
if (isIPv62(ip)) {
|
|
25878
|
+
subnet = typeof config.ipv6Subnet === "function" ? await config.ipv6Subnet(request, response) : config.ipv6Subnet;
|
|
25879
|
+
if (typeof config.ipv6Subnet === "function")
|
|
25880
|
+
validations2.ipv6Subnet(subnet);
|
|
25881
|
+
}
|
|
25882
|
+
return ipKeyGenerator(ip, subnet);
|
|
24707
25883
|
},
|
|
25884
|
+
ipv6Subnet: 56,
|
|
24708
25885
|
async handler(request, response, _next, _optionsUsed) {
|
|
24709
25886
|
response.status(config.statusCode);
|
|
24710
25887
|
const message = typeof config.message === "function" ? await config.message(request, response) : config.message;
|
|
24711
|
-
if (!response.writableEnded)
|
|
25888
|
+
if (!response.writableEnded)
|
|
24712
25889
|
response.send(message);
|
|
24713
|
-
}
|
|
24714
25890
|
},
|
|
24715
25891
|
passOnStoreError: false,
|
|
24716
25892
|
...notUndefinedOptions,
|
|
24717
25893
|
standardHeaders,
|
|
24718
|
-
store: promisifyStore(notUndefinedOptions.store ?? new MemoryStore),
|
|
25894
|
+
store: promisifyStore(notUndefinedOptions.store ?? new MemoryStore(validations2)),
|
|
24719
25895
|
validations: validations2
|
|
24720
25896
|
};
|
|
24721
25897
|
if (typeof config.store.increment !== "function" || typeof config.store.decrement !== "function" || typeof config.store.resetKey !== "function" || config.store.resetAll !== undefined && typeof config.store.resetAll !== "function" || config.store.init !== undefined && typeof config.store.init !== "function") {
|
|
@@ -24768,7 +25944,8 @@ var rateLimit = (passedOptions) => {
|
|
|
24768
25944
|
limit,
|
|
24769
25945
|
used: totalHits,
|
|
24770
25946
|
remaining: Math.max(limit - totalHits, 0),
|
|
24771
|
-
resetTime
|
|
25947
|
+
resetTime,
|
|
25948
|
+
key
|
|
24772
25949
|
};
|
|
24773
25950
|
Object.defineProperty(info, "current", {
|
|
24774
25951
|
configurable: false,
|
|
@@ -24848,7 +26025,7 @@ var rateLimit = (passedOptions) => {
|
|
|
24848
26025
|
middleware.getKey = typeof config.store.get === "function" ? config.store.get.bind(config.store) : getThrowFn;
|
|
24849
26026
|
return middleware;
|
|
24850
26027
|
};
|
|
24851
|
-
var
|
|
26028
|
+
var rate_limit_default = rateLimit;
|
|
24852
26029
|
|
|
24853
26030
|
// src/api/shared/middleware.ts
|
|
24854
26031
|
var securityMiddleware = () => {
|
|
@@ -24922,7 +26099,7 @@ var validateContentTypeMiddleware = () => {
|
|
|
24922
26099
|
};
|
|
24923
26100
|
};
|
|
24924
26101
|
var createApiRateLimit = () => {
|
|
24925
|
-
return
|
|
26102
|
+
return rate_limit_default({
|
|
24926
26103
|
windowMs: 15 * 60 * 1000,
|
|
24927
26104
|
max: 1000,
|
|
24928
26105
|
message: {
|
|
@@ -24948,7 +26125,7 @@ var createApiRateLimit = () => {
|
|
|
24948
26125
|
});
|
|
24949
26126
|
};
|
|
24950
26127
|
var createFileSystemRateLimit = () => {
|
|
24951
|
-
return
|
|
26128
|
+
return rate_limit_default({
|
|
24952
26129
|
windowMs: 5 * 60 * 1000,
|
|
24953
26130
|
max: 100,
|
|
24954
26131
|
message: {
|
|
@@ -24974,7 +26151,7 @@ var createFileSystemRateLimit = () => {
|
|
|
24974
26151
|
});
|
|
24975
26152
|
};
|
|
24976
26153
|
var createUploadRateLimit = () => {
|
|
24977
|
-
return
|
|
26154
|
+
return rate_limit_default({
|
|
24978
26155
|
windowMs: 15 * 60 * 1000,
|
|
24979
26156
|
max: 50,
|
|
24980
26157
|
message: {
|
|
@@ -25729,7 +26906,7 @@ import {
|
|
|
25729
26906
|
} from "@elizaos/core";
|
|
25730
26907
|
import express13 from "express";
|
|
25731
26908
|
|
|
25732
|
-
// ../../node_modules/uuid/dist/
|
|
26909
|
+
// ../../node_modules/uuid/dist-node/stringify.js
|
|
25733
26910
|
var byteToHex = [];
|
|
25734
26911
|
for (let i = 0;i < 256; ++i) {
|
|
25735
26912
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
@@ -25738,8 +26915,8 @@ function unsafeStringify(arr, offset = 0) {
|
|
|
25738
26915
|
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
25739
26916
|
}
|
|
25740
26917
|
|
|
25741
|
-
// ../../node_modules/uuid/dist/
|
|
25742
|
-
import { randomFillSync } from "crypto";
|
|
26918
|
+
// ../../node_modules/uuid/dist-node/rng.js
|
|
26919
|
+
import { randomFillSync } from "node:crypto";
|
|
25743
26920
|
var rnds8Pool = new Uint8Array(256);
|
|
25744
26921
|
var poolPtr = rnds8Pool.length;
|
|
25745
26922
|
function rng() {
|
|
@@ -25750,15 +26927,12 @@ function rng() {
|
|
|
25750
26927
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
25751
26928
|
}
|
|
25752
26929
|
|
|
25753
|
-
// ../../node_modules/uuid/dist/
|
|
25754
|
-
import { randomUUID } from "crypto";
|
|
26930
|
+
// ../../node_modules/uuid/dist-node/native.js
|
|
26931
|
+
import { randomUUID } from "node:crypto";
|
|
25755
26932
|
var native_default = { randomUUID };
|
|
25756
26933
|
|
|
25757
|
-
// ../../node_modules/uuid/dist/
|
|
25758
|
-
function
|
|
25759
|
-
if (native_default.randomUUID && !buf && !options) {
|
|
25760
|
-
return native_default.randomUUID();
|
|
25761
|
-
}
|
|
26934
|
+
// ../../node_modules/uuid/dist-node/v4.js
|
|
26935
|
+
function _v4(options, buf, offset) {
|
|
25762
26936
|
options = options || {};
|
|
25763
26937
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
25764
26938
|
if (rnds.length < 16) {
|
|
@@ -25778,6 +26952,12 @@ function v4(options, buf, offset) {
|
|
|
25778
26952
|
}
|
|
25779
26953
|
return unsafeStringify(rnds);
|
|
25780
26954
|
}
|
|
26955
|
+
function v4(options, buf, offset) {
|
|
26956
|
+
if (native_default.randomUUID && !buf && !options) {
|
|
26957
|
+
return native_default.randomUUID();
|
|
26958
|
+
}
|
|
26959
|
+
return _v4(options, buf, offset);
|
|
26960
|
+
}
|
|
25781
26961
|
var v4_default = v4;
|
|
25782
26962
|
// src/api/messaging/errors/SessionErrors.ts
|
|
25783
26963
|
class SessionError extends Error {
|
|
@@ -26736,7 +27916,7 @@ async function saveUploadedFile2(file, channelId) {
|
|
|
26736
27916
|
}
|
|
26737
27917
|
function createChannelMediaRouter() {
|
|
26738
27918
|
const router = express16.Router();
|
|
26739
|
-
const uploadMediaRateLimiter =
|
|
27919
|
+
const uploadMediaRateLimiter = rate_limit_default({
|
|
26740
27920
|
windowMs: 15 * 60 * 1000,
|
|
26741
27921
|
max: 100,
|
|
26742
27922
|
message: { success: false, error: "Too many requests, please try again later." }
|
|
@@ -27616,7 +28796,7 @@ import express30 from "express";
|
|
|
27616
28796
|
// package.json
|
|
27617
28797
|
var package_default = {
|
|
27618
28798
|
name: "@elizaos/server",
|
|
27619
|
-
version: "1.6.1-alpha.
|
|
28799
|
+
version: "1.6.1-alpha.6",
|
|
27620
28800
|
description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
|
|
27621
28801
|
publishConfig: {
|
|
27622
28802
|
access: "public",
|
|
@@ -27662,23 +28842,23 @@ var package_default = {
|
|
|
27662
28842
|
devDependencies: {
|
|
27663
28843
|
"@elizaos/client": "workspace:*",
|
|
27664
28844
|
"@types/node": "^24.0.1",
|
|
27665
|
-
prettier: "3.
|
|
27666
|
-
tsx: "4.
|
|
28845
|
+
prettier: "3.6.2",
|
|
28846
|
+
tsx: "4.20.6",
|
|
27667
28847
|
typescript: "^5.5.4",
|
|
27668
|
-
which: "^
|
|
28848
|
+
which: "^5.0.0",
|
|
27669
28849
|
ws: "^8.18.0"
|
|
27670
28850
|
},
|
|
27671
28851
|
gitHead: "255e37c0e4a76da0b776219db5ebb9dadf20e89f",
|
|
27672
28852
|
dependencies: {
|
|
27673
28853
|
"@elizaos/core": "workspace:*",
|
|
27674
28854
|
"@elizaos/plugin-sql": "workspace:*",
|
|
27675
|
-
"@sentry/node": "^10.
|
|
28855
|
+
"@sentry/node": "^10.16.0",
|
|
27676
28856
|
"@types/express": "^5.0.2",
|
|
27677
28857
|
"@types/helmet": "^4.0.0",
|
|
27678
|
-
"@types/multer": "^
|
|
27679
|
-
dotenv: "^
|
|
28858
|
+
"@types/multer": "^2.0.0",
|
|
28859
|
+
dotenv: "^17.2.3",
|
|
27680
28860
|
express: "^5.1.0",
|
|
27681
|
-
"express-rate-limit": "^
|
|
28861
|
+
"express-rate-limit": "^8.1.0",
|
|
27682
28862
|
helmet: "^8.1.0",
|
|
27683
28863
|
multer: "^2.0.1",
|
|
27684
28864
|
"path-to-regexp": "^8.2.0",
|
|
@@ -29173,7 +30353,7 @@ var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
|
29173
30353
|
var GLOBAL_OBJ = globalThis;
|
|
29174
30354
|
|
|
29175
30355
|
// ../../node_modules/@sentry/core/build/esm/utils/version.js
|
|
29176
|
-
var SDK_VERSION = "10.
|
|
30356
|
+
var SDK_VERSION = "10.16.0";
|
|
29177
30357
|
|
|
29178
30358
|
// ../../node_modules/@sentry/core/build/esm/carrier.js
|
|
29179
30359
|
function getMainCarrier() {
|
|
@@ -33636,48 +34816,38 @@ function estimatePrimitiveSizeInBytes(value) {
|
|
|
33636
34816
|
}
|
|
33637
34817
|
// ../../node_modules/@sentry/core/build/esm/utils/promisebuffer.js
|
|
33638
34818
|
var SENTRY_BUFFER_FULL_ERROR = Symbol.for("SentryBufferFullError");
|
|
33639
|
-
function makePromiseBuffer(limit) {
|
|
33640
|
-
const buffer =
|
|
34819
|
+
function makePromiseBuffer(limit = 100) {
|
|
34820
|
+
const buffer = new Set;
|
|
33641
34821
|
function isReady() {
|
|
33642
|
-
return
|
|
34822
|
+
return buffer.size < limit;
|
|
33643
34823
|
}
|
|
33644
34824
|
function remove(task) {
|
|
33645
|
-
|
|
34825
|
+
buffer.delete(task);
|
|
33646
34826
|
}
|
|
33647
34827
|
function add(taskProducer) {
|
|
33648
34828
|
if (!isReady()) {
|
|
33649
34829
|
return rejectedSyncPromise(SENTRY_BUFFER_FULL_ERROR);
|
|
33650
34830
|
}
|
|
33651
34831
|
const task = taskProducer();
|
|
33652
|
-
|
|
33653
|
-
|
|
33654
|
-
}
|
|
33655
|
-
task.then(() => remove(task)).then(null, () => remove(task).then(null, () => {}));
|
|
34832
|
+
buffer.add(task);
|
|
34833
|
+
task.then(() => remove(task), () => remove(task));
|
|
33656
34834
|
return task;
|
|
33657
34835
|
}
|
|
33658
34836
|
function drain(timeout) {
|
|
33659
|
-
|
|
33660
|
-
|
|
33661
|
-
|
|
33662
|
-
|
|
33663
|
-
|
|
33664
|
-
|
|
33665
|
-
|
|
33666
|
-
|
|
33667
|
-
|
|
33668
|
-
}, timeout);
|
|
33669
|
-
buffer.forEach((item) => {
|
|
33670
|
-
resolvedSyncPromise(item).then(() => {
|
|
33671
|
-
if (!--counter) {
|
|
33672
|
-
clearTimeout(capturedSetTimeout);
|
|
33673
|
-
resolve(true);
|
|
33674
|
-
}
|
|
33675
|
-
}, reject);
|
|
33676
|
-
});
|
|
33677
|
-
});
|
|
34837
|
+
if (!buffer.size) {
|
|
34838
|
+
return resolvedSyncPromise(true);
|
|
34839
|
+
}
|
|
34840
|
+
const drainPromise = Promise.allSettled(Array.from(buffer)).then(() => true);
|
|
34841
|
+
if (!timeout) {
|
|
34842
|
+
return drainPromise;
|
|
34843
|
+
}
|
|
34844
|
+
const promises = [drainPromise, new Promise((resolve) => setTimeout(() => resolve(false), timeout))];
|
|
34845
|
+
return Promise.race(promises);
|
|
33678
34846
|
}
|
|
33679
34847
|
return {
|
|
33680
|
-
|
|
34848
|
+
get $() {
|
|
34849
|
+
return Array.from(buffer);
|
|
34850
|
+
},
|
|
33681
34851
|
add,
|
|
33682
34852
|
drain
|
|
33683
34853
|
};
|
|
@@ -35371,7 +36541,42 @@ function processEvent(event, state, recordOutputs, span) {
|
|
|
35371
36541
|
handleContentBlockDelta(event, state, recordOutputs);
|
|
35372
36542
|
handleContentBlockStop(event, state);
|
|
35373
36543
|
}
|
|
35374
|
-
|
|
36544
|
+
function finalizeStreamSpan(state, span, recordOutputs) {
|
|
36545
|
+
if (!span.isRecording()) {
|
|
36546
|
+
return;
|
|
36547
|
+
}
|
|
36548
|
+
if (state.responseId) {
|
|
36549
|
+
span.setAttributes({
|
|
36550
|
+
[GEN_AI_RESPONSE_ID_ATTRIBUTE]: state.responseId
|
|
36551
|
+
});
|
|
36552
|
+
}
|
|
36553
|
+
if (state.responseModel) {
|
|
36554
|
+
span.setAttributes({
|
|
36555
|
+
[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: state.responseModel
|
|
36556
|
+
});
|
|
36557
|
+
}
|
|
36558
|
+
setTokenUsageAttributes2(span, state.promptTokens, state.completionTokens, state.cacheCreationInputTokens, state.cacheReadInputTokens);
|
|
36559
|
+
span.setAttributes({
|
|
36560
|
+
[GEN_AI_RESPONSE_STREAMING_ATTRIBUTE]: true
|
|
36561
|
+
});
|
|
36562
|
+
if (state.finishReasons.length > 0) {
|
|
36563
|
+
span.setAttributes({
|
|
36564
|
+
[GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE]: JSON.stringify(state.finishReasons)
|
|
36565
|
+
});
|
|
36566
|
+
}
|
|
36567
|
+
if (recordOutputs && state.responseTexts.length > 0) {
|
|
36568
|
+
span.setAttributes({
|
|
36569
|
+
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: state.responseTexts.join("")
|
|
36570
|
+
});
|
|
36571
|
+
}
|
|
36572
|
+
if (recordOutputs && state.toolCalls.length > 0) {
|
|
36573
|
+
span.setAttributes({
|
|
36574
|
+
[GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(state.toolCalls)
|
|
36575
|
+
});
|
|
36576
|
+
}
|
|
36577
|
+
span.end();
|
|
36578
|
+
}
|
|
36579
|
+
async function* instrumentAsyncIterableStream(stream, span, recordOutputs) {
|
|
35375
36580
|
const state = {
|
|
35376
36581
|
responseTexts: [],
|
|
35377
36582
|
finishReasons: [],
|
|
@@ -35422,6 +36627,39 @@ async function* instrumentStream2(stream, span, recordOutputs) {
|
|
|
35422
36627
|
span.end();
|
|
35423
36628
|
}
|
|
35424
36629
|
}
|
|
36630
|
+
function instrumentMessageStream(stream, span, recordOutputs) {
|
|
36631
|
+
const state = {
|
|
36632
|
+
responseTexts: [],
|
|
36633
|
+
finishReasons: [],
|
|
36634
|
+
responseId: "",
|
|
36635
|
+
responseModel: "",
|
|
36636
|
+
promptTokens: undefined,
|
|
36637
|
+
completionTokens: undefined,
|
|
36638
|
+
cacheCreationInputTokens: undefined,
|
|
36639
|
+
cacheReadInputTokens: undefined,
|
|
36640
|
+
toolCalls: [],
|
|
36641
|
+
activeToolBlocks: {}
|
|
36642
|
+
};
|
|
36643
|
+
stream.on("streamEvent", (event) => {
|
|
36644
|
+
processEvent(event, state, recordOutputs, span);
|
|
36645
|
+
});
|
|
36646
|
+
stream.on("message", () => {
|
|
36647
|
+
finalizeStreamSpan(state, span, recordOutputs);
|
|
36648
|
+
});
|
|
36649
|
+
stream.on("error", (error2) => {
|
|
36650
|
+
captureException(error2, {
|
|
36651
|
+
mechanism: {
|
|
36652
|
+
handled: false,
|
|
36653
|
+
type: "auto.ai.anthropic.stream_error"
|
|
36654
|
+
}
|
|
36655
|
+
});
|
|
36656
|
+
if (span.isRecording()) {
|
|
36657
|
+
span.setStatus({ code: SPAN_STATUS_ERROR, message: "stream_error" });
|
|
36658
|
+
span.end();
|
|
36659
|
+
}
|
|
36660
|
+
});
|
|
36661
|
+
return stream;
|
|
36662
|
+
}
|
|
35425
36663
|
|
|
35426
36664
|
// ../../node_modules/@sentry/core/build/esm/utils/anthropic-ai/constants.js
|
|
35427
36665
|
var ANTHROPIC_AI_INTEGRATION_NAME = "Anthropic_AI";
|
|
@@ -35553,28 +36791,70 @@ function addResponseAttributes2(span, response, recordOutputs) {
|
|
|
35553
36791
|
}
|
|
35554
36792
|
addMetadataAttributes(span, response);
|
|
35555
36793
|
}
|
|
36794
|
+
function handleStreamingError(error2, span, methodPath) {
|
|
36795
|
+
captureException(error2, {
|
|
36796
|
+
mechanism: { handled: false, type: "auto.ai.anthropic", data: { function: methodPath } }
|
|
36797
|
+
});
|
|
36798
|
+
if (span.isRecording()) {
|
|
36799
|
+
span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
|
|
36800
|
+
span.end();
|
|
36801
|
+
}
|
|
36802
|
+
throw error2;
|
|
36803
|
+
}
|
|
36804
|
+
function handleStreamingRequest(originalMethod, target, context, args, requestAttributes, operationName, methodPath, params, options, isStreamRequested) {
|
|
36805
|
+
const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
|
|
36806
|
+
const spanConfig = {
|
|
36807
|
+
name: `${operationName} ${model} stream-response`,
|
|
36808
|
+
op: getSpanOperation2(methodPath),
|
|
36809
|
+
attributes: requestAttributes
|
|
36810
|
+
};
|
|
36811
|
+
if (isStreamRequested) {
|
|
36812
|
+
return startSpanManual(spanConfig, async (span) => {
|
|
36813
|
+
try {
|
|
36814
|
+
if (options.recordInputs && params) {
|
|
36815
|
+
addPrivateRequestAttributes(span, params);
|
|
36816
|
+
}
|
|
36817
|
+
const result = await originalMethod.apply(context, args);
|
|
36818
|
+
return instrumentAsyncIterableStream(result, span, options.recordOutputs ?? false);
|
|
36819
|
+
} catch (error2) {
|
|
36820
|
+
return handleStreamingError(error2, span, methodPath);
|
|
36821
|
+
}
|
|
36822
|
+
});
|
|
36823
|
+
} else {
|
|
36824
|
+
return startSpanManual(spanConfig, (span) => {
|
|
36825
|
+
try {
|
|
36826
|
+
if (options.recordInputs && params) {
|
|
36827
|
+
addPrivateRequestAttributes(span, params);
|
|
36828
|
+
}
|
|
36829
|
+
const messageStream = target.apply(context, args);
|
|
36830
|
+
return instrumentMessageStream(messageStream, span, options.recordOutputs ?? false);
|
|
36831
|
+
} catch (error2) {
|
|
36832
|
+
return handleStreamingError(error2, span, methodPath);
|
|
36833
|
+
}
|
|
36834
|
+
});
|
|
36835
|
+
}
|
|
36836
|
+
}
|
|
35556
36837
|
function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
35557
|
-
return
|
|
35558
|
-
|
|
35559
|
-
|
|
35560
|
-
|
|
35561
|
-
|
|
35562
|
-
|
|
35563
|
-
|
|
35564
|
-
|
|
35565
|
-
|
|
35566
|
-
|
|
36838
|
+
return new Proxy(originalMethod, {
|
|
36839
|
+
apply(target, thisArg, args) {
|
|
36840
|
+
const requestAttributes = extractRequestAttributes2(args, methodPath);
|
|
36841
|
+
const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? "unknown";
|
|
36842
|
+
const operationName = getFinalOperationName(methodPath);
|
|
36843
|
+
const params = typeof args[0] === "object" ? args[0] : undefined;
|
|
36844
|
+
const isStreamRequested = Boolean(params?.stream);
|
|
36845
|
+
const isStreamingMethod = methodPath === "messages.stream";
|
|
36846
|
+
if (isStreamRequested || isStreamingMethod) {
|
|
36847
|
+
return handleStreamingRequest(originalMethod, target, context, args, requestAttributes, operationName, methodPath, params, options, isStreamRequested);
|
|
36848
|
+
}
|
|
36849
|
+
return startSpan({
|
|
36850
|
+
name: `${operationName} ${model}`,
|
|
35567
36851
|
op: getSpanOperation2(methodPath),
|
|
35568
36852
|
attributes: requestAttributes
|
|
35569
|
-
},
|
|
35570
|
-
|
|
35571
|
-
|
|
35572
|
-
|
|
35573
|
-
|
|
35574
|
-
const result = await originalMethod.apply(context, args);
|
|
35575
|
-
return instrumentStream2(result, span, options.recordOutputs ?? false);
|
|
35576
|
-
} catch (error2) {
|
|
35577
|
-
span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
|
|
36853
|
+
}, (span) => {
|
|
36854
|
+
if (options.recordInputs && params) {
|
|
36855
|
+
addPrivateRequestAttributes(span, params);
|
|
36856
|
+
}
|
|
36857
|
+
return handleCallbackErrors(() => target.apply(context, args), (error2) => {
|
|
35578
36858
|
captureException(error2, {
|
|
35579
36859
|
mechanism: {
|
|
35580
36860
|
handled: false,
|
|
@@ -35584,32 +36864,10 @@ function instrumentMethod2(originalMethod, methodPath, context, options) {
|
|
|
35584
36864
|
}
|
|
35585
36865
|
}
|
|
35586
36866
|
});
|
|
35587
|
-
|
|
35588
|
-
throw error2;
|
|
35589
|
-
}
|
|
36867
|
+
}, () => {}, (result) => addResponseAttributes2(span, result, options.recordOutputs));
|
|
35590
36868
|
});
|
|
35591
36869
|
}
|
|
35592
|
-
|
|
35593
|
-
name: `${operationName} ${model}`,
|
|
35594
|
-
op: getSpanOperation2(methodPath),
|
|
35595
|
-
attributes: requestAttributes
|
|
35596
|
-
}, (span) => {
|
|
35597
|
-
if (options.recordInputs && params) {
|
|
35598
|
-
addPrivateRequestAttributes(span, params);
|
|
35599
|
-
}
|
|
35600
|
-
return handleCallbackErrors(() => originalMethod.apply(context, args), (error2) => {
|
|
35601
|
-
captureException(error2, {
|
|
35602
|
-
mechanism: {
|
|
35603
|
-
handled: false,
|
|
35604
|
-
type: "auto.ai.anthropic",
|
|
35605
|
-
data: {
|
|
35606
|
-
function: methodPath
|
|
35607
|
-
}
|
|
35608
|
-
}
|
|
35609
|
-
});
|
|
35610
|
-
}, () => {}, (result) => addResponseAttributes2(span, result, options.recordOutputs));
|
|
35611
|
-
});
|
|
35612
|
-
};
|
|
36870
|
+
});
|
|
35613
36871
|
}
|
|
35614
36872
|
function createDeepProxy2(target, currentPath = "", options) {
|
|
35615
36873
|
return new Proxy(target, {
|
|
@@ -38704,7 +39962,7 @@ function functionNamesMatch(a, b) {
|
|
|
38704
39962
|
}
|
|
38705
39963
|
|
|
38706
39964
|
// ../../node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js
|
|
38707
|
-
var base64WorkerScript = "
|
|
39965
|
+
var base64WorkerScript = "LyohIEBzZW50cnkvbm9kZS1jb3JlIDEwLjE2LjAgKDc0YzUyMTMpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsaT17fTtjb25zdCBvPSJfX1NFTlRSWV9FUlJPUl9MT0NBTF9WQVJJQUJMRVNfXyI7Y29uc3QgYT10O2Z1bmN0aW9uIHMoLi4uZSl7YS5kZWJ1ZyYmZnVuY3Rpb24oZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30sYT1PYmplY3Qua2V5cyhpKTthLmZvckVhY2goZT0+e2NvbnN0IG49aVtlXTtvW2VdPXRbZV0sdFtlXT1ufSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXthLmZvckVhY2goZT0+e3RbZV09b1tlXX0pfX0oKCk9PmNvbnNvbGUubG9nKCJbTG9jYWxWYXJpYWJsZXMgV29ya2VyXSIsLi4uZSkpfWFzeW5jIGZ1bmN0aW9uIGMoZSx0LG4saSl7Y29uc3Qgbz1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pO2lbbl09by5yZXN1bHQuZmlsdGVyKGU9PiJsZW5ndGgiIT09ZS5uYW1lJiYhaXNOYU4ocGFyc2VJbnQoZS5uYW1lLDEwKSkpLnNvcnQoKGUsdCk9PnBhcnNlSW50KGUubmFtZSwxMCktcGFyc2VJbnQodC5uYW1lLDEwKSkubWFwKGU9PmUudmFsdWU/LnZhbHVlKX1hc3luYyBmdW5jdGlvbiByKGUsdCxuLGkpe2NvbnN0IG89YXdhaXQgZS5wb3N0KCJSdW50aW1lLmdldFByb3BlcnRpZXMiLHtvYmplY3RJZDp0LG93blByb3BlcnRpZXM6ITB9KTtpW25dPW8ucmVzdWx0Lm1hcChlPT5bZS5uYW1lLGUudmFsdWU/LnZhbHVlXSkucmVkdWNlKChlLFt0LG5dKT0+KGVbdF09bixlKSx7fSl9ZnVuY3Rpb24gdShlLHQpe2UudmFsdWUmJigidmFsdWUiaW4gZS52YWx1ZT92b2lkIDA9PT1lLnZhbHVlLnZhbHVlfHxudWxsPT09ZS52YWx1ZS52YWx1ZT90W2UubmFtZV09YDwke2UudmFsdWUudmFsdWV9PmA6dFtlLm5hbWVdPWUudmFsdWUudmFsdWU6ImRlc2NyaXB0aW9uImluIGUudmFsdWUmJiJmdW5jdGlvbiIhPT1lLnZhbHVlLnR5cGU/dFtlLm5hbWVdPWA8JHtlLnZhbHVlLmRlc2NyaXB0aW9ufT5gOiJ1bmRlZmluZWQiPT09ZS52YWx1ZS50eXBlJiYodFtlLm5hbWVdPSI8dW5kZWZpbmVkPiIpKX1hc3luYyBmdW5jdGlvbiBsKGUsdCl7Y29uc3Qgbj1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuZ2V0UHJvcGVydGllcyIse29iamVjdElkOnQsb3duUHJvcGVydGllczohMH0pLGk9e307Zm9yKGNvbnN0IHQgb2Ygbi5yZXN1bHQpaWYodC52YWx1ZT8ub2JqZWN0SWQmJiJBcnJheSI9PT10LnZhbHVlLmNsYXNzTmFtZSl7Y29uc3Qgbj10LnZhbHVlLm9iamVjdElkO2F3YWl0IGMoZSxuLHQubmFtZSxpKX1lbHNlIGlmKHQudmFsdWU/Lm9iamVjdElkJiYiT2JqZWN0Ij09PXQudmFsdWUuY2xhc3NOYW1lKXtjb25zdCBuPXQudmFsdWUub2JqZWN0SWQ7YXdhaXQgcihlLG4sdC5uYW1lLGkpfWVsc2UgdC52YWx1ZSYmdSh0LGkpO3JldHVybiBpfWxldCBmOyhhc3luYyBmdW5jdGlvbigpe2NvbnN0IHQ9bmV3IGU7dC5jb25uZWN0VG9NYWluVGhyZWFkKCkscygiQ29ubmVjdGVkIHRvIG1haW4gdGhyZWFkIik7bGV0IG49ITE7dC5vbigiRGVidWdnZXIucmVzdW1lZCIsKCk9PntuPSExfSksdC5vbigiRGVidWdnZXIucGF1c2VkIixlPT57bj0hMCxhc3luYyBmdW5jdGlvbihlLHtyZWFzb246dCxkYXRhOntvYmplY3RJZDpufSxjYWxsRnJhbWVzOml9KXtpZigiZXhjZXB0aW9uIiE9PXQmJiJwcm9taXNlUmVqZWN0aW9uIiE9PXQpcmV0dXJuO2lmKGY/LigpLG51bGw9PW4pcmV0dXJuO2NvbnN0IGE9W107Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2NvbnN0e3Njb3BlQ2hhaW46bixmdW5jdGlvbk5hbWU6byx0aGlzOnN9PWlbdF0sYz1uLmZpbmQoZT0+ImxvY2FsIj09PWUudHlwZSkscj0iZ2xvYmFsIiE9PXMuY2xhc3NOYW1lJiZzLmNsYXNzTmFtZT9gJHtzLmNsYXNzTmFtZX0uJHtvfWA6bztpZih2b2lkIDA9PT1jPy5vYmplY3Qub2JqZWN0SWQpYVt0XT17ZnVuY3Rpb246cn07ZWxzZXtjb25zdCBuPWF3YWl0IGwoZSxjLm9iamVjdC5vYmplY3RJZCk7YVt0XT17ZnVuY3Rpb246cix2YXJzOm59fX1hd2FpdCBlLnBvc3QoIlJ1bnRpbWUuY2FsbEZ1bmN0aW9uT24iLHtmdW5jdGlvbkRlY2xhcmF0aW9uOmBmdW5jdGlvbigpIHsgdGhpcy4ke299ID0gdGhpcy4ke299IHx8ICR7SlNPTi5zdHJpbmdpZnkoYSl9OyB9YCxzaWxlbnQ6ITAsb2JqZWN0SWQ6bn0pLGF3YWl0IGUucG9zdCgiUnVudGltZS5yZWxlYXNlT2JqZWN0Iix7b2JqZWN0SWQ6bn0pfSh0LGUucGFyYW1zKS50aGVuKGFzeW5jKCk9PntuJiZhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnJlc3VtZSIpfSxhc3luYyBlPT57biYmYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5yZXN1bWUiKX0pfSksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5lbmFibGUiKTtjb25zdCBpPSExIT09YS5jYXB0dXJlQWxsRXhjZXB0aW9ucztpZihhd2FpdCB0LnBvc3QoIkRlYnVnZ2VyLnNldFBhdXNlT25FeGNlcHRpb25zIix7c3RhdGU6aT8iYWxsIjoidW5jYXVnaHQifSksaSl7Y29uc3QgZT1hLm1heEV4Y2VwdGlvbnNQZXJTZWNvbmR8fDUwO2Y9ZnVuY3Rpb24oZSx0LG4pe2xldCBpPTAsbz01LGE9MDtyZXR1cm4gc2V0SW50ZXJ2YWwoKCk9PnswPT09YT9pPmUmJihvKj0yLG4obyksbz44NjQwMCYmKG89ODY0MDApLGE9byk6KGEtPTEsMD09PWEmJnQoKSksaT0wfSwxZTMpLnVucmVmKCksKCk9PntpKz0xfX0oZSxhc3luYygpPT57cygiUmF0ZS1saW1pdCBsaWZ0ZWQuIiksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJhbGwifSl9LGFzeW5jIGU9PntzKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pfX0pKCkuY2F0Y2goZT0+e3MoIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSxzZXRJbnRlcnZhbCgoKT0+e30sMWU0KTs=";
|
|
38708
39966
|
function log2(...args) {
|
|
38709
39967
|
debug.log("[LocalVariables]", ...args);
|
|
38710
39968
|
}
|