sim-setup 1.0.6-preview.65.1 → 1.0.6-preview.67.1
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/docker-compose.prod.yml +5 -0
- package/dist/index.js +951 -5
- package/package.json +1 -1
|
@@ -50,6 +50,11 @@ services:
|
|
|
50
50
|
# different host:port (e.g. wss://socket.example.com).
|
|
51
51
|
- NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL:-}
|
|
52
52
|
- ADMISSION_GATE_MAX_INFLIGHT=${ADMISSION_GATE_MAX_INFLIGHT:-500}
|
|
53
|
+
# Lets a workflow reach a service on the Docker host. Reaching it also
|
|
54
|
+
# requires naming it in EGRESS_ALLOWED_HOSTS; this only makes the name
|
|
55
|
+
# resolve, which it does not on Linux by default.
|
|
56
|
+
extra_hosts:
|
|
57
|
+
- 'host.docker.internal:host-gateway'
|
|
53
58
|
depends_on:
|
|
54
59
|
db:
|
|
55
60
|
condition: service_healthy
|
package/dist/index.js
CHANGED
|
@@ -35827,6 +35827,923 @@ var init_capability_setup = __esm(() => {
|
|
|
35827
35827
|
init_prompter();
|
|
35828
35828
|
});
|
|
35829
35829
|
|
|
35830
|
+
// ../../node_modules/ipaddr.js/lib/ipaddr.js
|
|
35831
|
+
var require_ipaddr = __commonJS((exports, module) => {
|
|
35832
|
+
(function(root) {
|
|
35833
|
+
const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
|
|
35834
|
+
const ipv4Regexes = {
|
|
35835
|
+
fourOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
|
|
35836
|
+
threeOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
|
|
35837
|
+
twoOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}$`, "i"),
|
|
35838
|
+
longValue: new RegExp(`^${ipv4Part}$`, "i")
|
|
35839
|
+
};
|
|
35840
|
+
const octalRegex = new RegExp(`^0[0-7]+$`, "i");
|
|
35841
|
+
const hexRegex = new RegExp(`^0x[a-f0-9]+$`, "i");
|
|
35842
|
+
const zoneIndex = "%[0-9a-z]{1,}";
|
|
35843
|
+
const ipv6Part = "(?:[0-9a-f]+::?)+";
|
|
35844
|
+
const ipv6Regexes = {
|
|
35845
|
+
zoneIndex: new RegExp(zoneIndex, "i"),
|
|
35846
|
+
native: new RegExp(`^(::)?(${ipv6Part})?([0-9a-f]+)?(::)?(${zoneIndex})?$`, "i"),
|
|
35847
|
+
deprecatedTransitional: new RegExp(`^(?:::)(${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?)$`, "i"),
|
|
35848
|
+
transitional: new RegExp(`^((?:${ipv6Part})|(?:::)(?:${ipv6Part})?)${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?$`, "i")
|
|
35849
|
+
};
|
|
35850
|
+
function expandIPv6(string, parts) {
|
|
35851
|
+
if (string.indexOf("::") !== string.lastIndexOf("::")) {
|
|
35852
|
+
return null;
|
|
35853
|
+
}
|
|
35854
|
+
let colonCount = 0;
|
|
35855
|
+
let lastColon = -1;
|
|
35856
|
+
let zoneId = (string.match(ipv6Regexes.zoneIndex) || [])[0];
|
|
35857
|
+
let replacement, replacementCount;
|
|
35858
|
+
if (zoneId) {
|
|
35859
|
+
zoneId = zoneId.substring(1);
|
|
35860
|
+
string = string.replace(/%.+$/, "");
|
|
35861
|
+
}
|
|
35862
|
+
while ((lastColon = string.indexOf(":", lastColon + 1)) >= 0) {
|
|
35863
|
+
colonCount++;
|
|
35864
|
+
}
|
|
35865
|
+
if (string.substr(0, 2) === "::") {
|
|
35866
|
+
colonCount--;
|
|
35867
|
+
}
|
|
35868
|
+
if (string.substr(-2, 2) === "::") {
|
|
35869
|
+
colonCount--;
|
|
35870
|
+
}
|
|
35871
|
+
if (colonCount > parts) {
|
|
35872
|
+
return null;
|
|
35873
|
+
}
|
|
35874
|
+
replacementCount = parts - colonCount;
|
|
35875
|
+
replacement = ":";
|
|
35876
|
+
while (replacementCount--) {
|
|
35877
|
+
replacement += "0:";
|
|
35878
|
+
}
|
|
35879
|
+
string = string.replace("::", replacement);
|
|
35880
|
+
if (string[0] === ":") {
|
|
35881
|
+
string = string.slice(1);
|
|
35882
|
+
}
|
|
35883
|
+
if (string[string.length - 1] === ":") {
|
|
35884
|
+
string = string.slice(0, -1);
|
|
35885
|
+
}
|
|
35886
|
+
parts = function() {
|
|
35887
|
+
const ref = string.split(":");
|
|
35888
|
+
const results = [];
|
|
35889
|
+
for (let i2 = 0;i2 < ref.length; i2++) {
|
|
35890
|
+
results.push(parseInt(ref[i2], 16));
|
|
35891
|
+
}
|
|
35892
|
+
return results;
|
|
35893
|
+
}();
|
|
35894
|
+
return {
|
|
35895
|
+
parts,
|
|
35896
|
+
zoneId
|
|
35897
|
+
};
|
|
35898
|
+
}
|
|
35899
|
+
function matchCIDR(first, second, partSize, cidrBits) {
|
|
35900
|
+
if (first.length !== second.length) {
|
|
35901
|
+
throw new Error("ipaddr: cannot match CIDR for objects with different lengths");
|
|
35902
|
+
}
|
|
35903
|
+
let part = 0;
|
|
35904
|
+
let shift;
|
|
35905
|
+
while (cidrBits > 0) {
|
|
35906
|
+
shift = partSize - cidrBits;
|
|
35907
|
+
if (shift < 0) {
|
|
35908
|
+
shift = 0;
|
|
35909
|
+
}
|
|
35910
|
+
if (first[part] >> shift !== second[part] >> shift) {
|
|
35911
|
+
return false;
|
|
35912
|
+
}
|
|
35913
|
+
cidrBits -= partSize;
|
|
35914
|
+
part += 1;
|
|
35915
|
+
}
|
|
35916
|
+
return true;
|
|
35917
|
+
}
|
|
35918
|
+
function parseIntAuto(string) {
|
|
35919
|
+
if (hexRegex.test(string)) {
|
|
35920
|
+
return parseInt(string, 16);
|
|
35921
|
+
}
|
|
35922
|
+
if (string[0] === "0" && !isNaN(parseInt(string[1], 10))) {
|
|
35923
|
+
if (octalRegex.test(string)) {
|
|
35924
|
+
return parseInt(string, 8);
|
|
35925
|
+
}
|
|
35926
|
+
throw new Error(`ipaddr: cannot parse ${string} as octal`);
|
|
35927
|
+
}
|
|
35928
|
+
return parseInt(string, 10);
|
|
35929
|
+
}
|
|
35930
|
+
function padPart(part, length) {
|
|
35931
|
+
while (part.length < length) {
|
|
35932
|
+
part = `0${part}`;
|
|
35933
|
+
}
|
|
35934
|
+
return part;
|
|
35935
|
+
}
|
|
35936
|
+
const ipaddr = {};
|
|
35937
|
+
ipaddr.IPv4 = function() {
|
|
35938
|
+
function IPv4(octets) {
|
|
35939
|
+
if (octets.length !== 4) {
|
|
35940
|
+
throw new Error("ipaddr: ipv4 octet count should be 4");
|
|
35941
|
+
}
|
|
35942
|
+
let i2, octet;
|
|
35943
|
+
for (i2 = 0;i2 < octets.length; i2++) {
|
|
35944
|
+
octet = octets[i2];
|
|
35945
|
+
if (!(0 <= octet && octet <= 255)) {
|
|
35946
|
+
throw new Error("ipaddr: ipv4 octet should fit in 8 bits");
|
|
35947
|
+
}
|
|
35948
|
+
}
|
|
35949
|
+
this.octets = octets;
|
|
35950
|
+
}
|
|
35951
|
+
IPv4.prototype.SpecialRanges = {
|
|
35952
|
+
unspecified: [[new IPv4([0, 0, 0, 0]), 8]],
|
|
35953
|
+
broadcast: [[new IPv4([255, 255, 255, 255]), 32]],
|
|
35954
|
+
multicast: [[new IPv4([224, 0, 0, 0]), 4]],
|
|
35955
|
+
linkLocal: [[new IPv4([169, 254, 0, 0]), 16]],
|
|
35956
|
+
loopback: [[new IPv4([127, 0, 0, 0]), 8]],
|
|
35957
|
+
carrierGradeNat: [[new IPv4([100, 64, 0, 0]), 10]],
|
|
35958
|
+
private: [
|
|
35959
|
+
[new IPv4([10, 0, 0, 0]), 8],
|
|
35960
|
+
[new IPv4([172, 16, 0, 0]), 12],
|
|
35961
|
+
[new IPv4([192, 168, 0, 0]), 16]
|
|
35962
|
+
],
|
|
35963
|
+
reserved: [
|
|
35964
|
+
[new IPv4([192, 0, 0, 0]), 24],
|
|
35965
|
+
[new IPv4([192, 0, 2, 0]), 24],
|
|
35966
|
+
[new IPv4([192, 88, 99, 0]), 24],
|
|
35967
|
+
[new IPv4([198, 18, 0, 0]), 15],
|
|
35968
|
+
[new IPv4([198, 51, 100, 0]), 24],
|
|
35969
|
+
[new IPv4([203, 0, 113, 0]), 24],
|
|
35970
|
+
[new IPv4([240, 0, 0, 0]), 4]
|
|
35971
|
+
],
|
|
35972
|
+
as112: [
|
|
35973
|
+
[new IPv4([192, 175, 48, 0]), 24],
|
|
35974
|
+
[new IPv4([192, 31, 196, 0]), 24]
|
|
35975
|
+
],
|
|
35976
|
+
amt: [
|
|
35977
|
+
[new IPv4([192, 52, 193, 0]), 24]
|
|
35978
|
+
]
|
|
35979
|
+
};
|
|
35980
|
+
IPv4.prototype.kind = function() {
|
|
35981
|
+
return "ipv4";
|
|
35982
|
+
};
|
|
35983
|
+
IPv4.prototype.match = function(other, cidrRange) {
|
|
35984
|
+
let ref;
|
|
35985
|
+
if (cidrRange === undefined) {
|
|
35986
|
+
ref = other;
|
|
35987
|
+
other = ref[0];
|
|
35988
|
+
cidrRange = ref[1];
|
|
35989
|
+
}
|
|
35990
|
+
if (other.kind() !== "ipv4") {
|
|
35991
|
+
throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");
|
|
35992
|
+
}
|
|
35993
|
+
return matchCIDR(this.octets, other.octets, 8, cidrRange);
|
|
35994
|
+
};
|
|
35995
|
+
IPv4.prototype.prefixLengthFromSubnetMask = function() {
|
|
35996
|
+
let cidr = 0;
|
|
35997
|
+
let stop = false;
|
|
35998
|
+
const zerotable = {
|
|
35999
|
+
0: 8,
|
|
36000
|
+
128: 7,
|
|
36001
|
+
192: 6,
|
|
36002
|
+
224: 5,
|
|
36003
|
+
240: 4,
|
|
36004
|
+
248: 3,
|
|
36005
|
+
252: 2,
|
|
36006
|
+
254: 1,
|
|
36007
|
+
255: 0
|
|
36008
|
+
};
|
|
36009
|
+
let i2, octet, zeros;
|
|
36010
|
+
for (i2 = 3;i2 >= 0; i2 -= 1) {
|
|
36011
|
+
octet = this.octets[i2];
|
|
36012
|
+
if (octet in zerotable) {
|
|
36013
|
+
zeros = zerotable[octet];
|
|
36014
|
+
if (stop && zeros !== 0) {
|
|
36015
|
+
return null;
|
|
36016
|
+
}
|
|
36017
|
+
if (zeros !== 8) {
|
|
36018
|
+
stop = true;
|
|
36019
|
+
}
|
|
36020
|
+
cidr += zeros;
|
|
36021
|
+
} else {
|
|
36022
|
+
return null;
|
|
36023
|
+
}
|
|
36024
|
+
}
|
|
36025
|
+
return 32 - cidr;
|
|
36026
|
+
};
|
|
36027
|
+
IPv4.prototype.range = function() {
|
|
36028
|
+
return ipaddr.subnetMatch(this, this.SpecialRanges);
|
|
36029
|
+
};
|
|
36030
|
+
IPv4.prototype.toByteArray = function() {
|
|
36031
|
+
return this.octets.slice(0);
|
|
36032
|
+
};
|
|
36033
|
+
IPv4.prototype.toIPv4MappedAddress = function() {
|
|
36034
|
+
return ipaddr.IPv6.parse(`::ffff:${this.toString()}`);
|
|
36035
|
+
};
|
|
36036
|
+
IPv4.prototype.toNormalizedString = function() {
|
|
36037
|
+
return this.toString();
|
|
36038
|
+
};
|
|
36039
|
+
IPv4.prototype.toString = function() {
|
|
36040
|
+
return this.octets.join(".");
|
|
36041
|
+
};
|
|
36042
|
+
return IPv4;
|
|
36043
|
+
}();
|
|
36044
|
+
ipaddr.IPv4.broadcastAddressFromCIDR = function(string) {
|
|
36045
|
+
try {
|
|
36046
|
+
const cidr = this.parseCIDR(string);
|
|
36047
|
+
const ipInterfaceOctets = cidr[0].toByteArray();
|
|
36048
|
+
const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
|
|
36049
|
+
const octets = [];
|
|
36050
|
+
let i2 = 0;
|
|
36051
|
+
while (i2 < 4) {
|
|
36052
|
+
octets.push(parseInt(ipInterfaceOctets[i2], 10) | parseInt(subnetMaskOctets[i2], 10) ^ 255);
|
|
36053
|
+
i2++;
|
|
36054
|
+
}
|
|
36055
|
+
return new this(octets);
|
|
36056
|
+
} catch (e) {
|
|
36057
|
+
throw new Error("ipaddr: the address does not have IPv4 CIDR format");
|
|
36058
|
+
}
|
|
36059
|
+
};
|
|
36060
|
+
ipaddr.IPv4.isIPv4 = function(string) {
|
|
36061
|
+
return this.parser(string) !== null;
|
|
36062
|
+
};
|
|
36063
|
+
ipaddr.IPv4.isValid = function(string) {
|
|
36064
|
+
try {
|
|
36065
|
+
new this(this.parser(string));
|
|
36066
|
+
return true;
|
|
36067
|
+
} catch (e) {
|
|
36068
|
+
return false;
|
|
36069
|
+
}
|
|
36070
|
+
};
|
|
36071
|
+
ipaddr.IPv4.isValidCIDR = function(string) {
|
|
36072
|
+
try {
|
|
36073
|
+
this.parseCIDR(string);
|
|
36074
|
+
return true;
|
|
36075
|
+
} catch (e) {
|
|
36076
|
+
return false;
|
|
36077
|
+
}
|
|
36078
|
+
};
|
|
36079
|
+
ipaddr.IPv4.isValidFourPartDecimal = function(string) {
|
|
36080
|
+
if (ipaddr.IPv4.isValid(string) && string.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/)) {
|
|
36081
|
+
return true;
|
|
36082
|
+
} else {
|
|
36083
|
+
return false;
|
|
36084
|
+
}
|
|
36085
|
+
};
|
|
36086
|
+
ipaddr.IPv4.isValidCIDRFourPartDecimal = function(string) {
|
|
36087
|
+
const match = string.match(/^(.+)\/(\d+)$/);
|
|
36088
|
+
if (!ipaddr.IPv4.isValidCIDR(string) || !match) {
|
|
36089
|
+
return false;
|
|
36090
|
+
}
|
|
36091
|
+
return ipaddr.IPv4.isValidFourPartDecimal(match[1]);
|
|
36092
|
+
};
|
|
36093
|
+
ipaddr.IPv4.networkAddressFromCIDR = function(string) {
|
|
36094
|
+
let cidr, i2, ipInterfaceOctets, octets, subnetMaskOctets;
|
|
36095
|
+
try {
|
|
36096
|
+
cidr = this.parseCIDR(string);
|
|
36097
|
+
ipInterfaceOctets = cidr[0].toByteArray();
|
|
36098
|
+
subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
|
|
36099
|
+
octets = [];
|
|
36100
|
+
i2 = 0;
|
|
36101
|
+
while (i2 < 4) {
|
|
36102
|
+
octets.push(parseInt(ipInterfaceOctets[i2], 10) & parseInt(subnetMaskOctets[i2], 10));
|
|
36103
|
+
i2++;
|
|
36104
|
+
}
|
|
36105
|
+
return new this(octets);
|
|
36106
|
+
} catch (e) {
|
|
36107
|
+
throw new Error("ipaddr: the address does not have IPv4 CIDR format");
|
|
36108
|
+
}
|
|
36109
|
+
};
|
|
36110
|
+
ipaddr.IPv4.parse = function(string) {
|
|
36111
|
+
const parts = this.parser(string);
|
|
36112
|
+
if (parts === null) {
|
|
36113
|
+
throw new Error("ipaddr: string is not formatted like an IPv4 Address");
|
|
36114
|
+
}
|
|
36115
|
+
return new this(parts);
|
|
36116
|
+
};
|
|
36117
|
+
ipaddr.IPv4.parseCIDR = function(string) {
|
|
36118
|
+
let match;
|
|
36119
|
+
if (match = string.match(/^(.+)\/(\d+)$/)) {
|
|
36120
|
+
const maskLength = parseInt(match[2]);
|
|
36121
|
+
if (maskLength >= 0 && maskLength <= 32) {
|
|
36122
|
+
const parsed = [this.parse(match[1]), maskLength];
|
|
36123
|
+
Object.defineProperty(parsed, "toString", {
|
|
36124
|
+
value: function() {
|
|
36125
|
+
return this.join("/");
|
|
36126
|
+
}
|
|
36127
|
+
});
|
|
36128
|
+
return parsed;
|
|
36129
|
+
}
|
|
36130
|
+
}
|
|
36131
|
+
throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range");
|
|
36132
|
+
};
|
|
36133
|
+
ipaddr.IPv4.parser = function(string) {
|
|
36134
|
+
let match, part, value;
|
|
36135
|
+
if (match = string.match(ipv4Regexes.fourOctet)) {
|
|
36136
|
+
return function() {
|
|
36137
|
+
const ref = match.slice(1, 6);
|
|
36138
|
+
const results = [];
|
|
36139
|
+
for (let i2 = 0;i2 < ref.length; i2++) {
|
|
36140
|
+
part = ref[i2];
|
|
36141
|
+
results.push(parseIntAuto(part));
|
|
36142
|
+
}
|
|
36143
|
+
return results;
|
|
36144
|
+
}();
|
|
36145
|
+
} else if (match = string.match(ipv4Regexes.longValue)) {
|
|
36146
|
+
value = parseIntAuto(match[1]);
|
|
36147
|
+
if (value > 4294967295 || value < 0) {
|
|
36148
|
+
throw new Error("ipaddr: address outside defined range");
|
|
36149
|
+
}
|
|
36150
|
+
return function() {
|
|
36151
|
+
const results = [];
|
|
36152
|
+
let shift;
|
|
36153
|
+
for (shift = 0;shift <= 24; shift += 8) {
|
|
36154
|
+
results.push(value >> shift & 255);
|
|
36155
|
+
}
|
|
36156
|
+
return results;
|
|
36157
|
+
}().reverse();
|
|
36158
|
+
} else if (match = string.match(ipv4Regexes.twoOctet)) {
|
|
36159
|
+
return function() {
|
|
36160
|
+
const ref = match.slice(1, 4);
|
|
36161
|
+
const results = [];
|
|
36162
|
+
value = parseIntAuto(ref[1]);
|
|
36163
|
+
if (value > 16777215 || value < 0) {
|
|
36164
|
+
throw new Error("ipaddr: address outside defined range");
|
|
36165
|
+
}
|
|
36166
|
+
results.push(parseIntAuto(ref[0]));
|
|
36167
|
+
results.push(value >> 16 & 255);
|
|
36168
|
+
results.push(value >> 8 & 255);
|
|
36169
|
+
results.push(value & 255);
|
|
36170
|
+
return results;
|
|
36171
|
+
}();
|
|
36172
|
+
} else if (match = string.match(ipv4Regexes.threeOctet)) {
|
|
36173
|
+
return function() {
|
|
36174
|
+
const ref = match.slice(1, 5);
|
|
36175
|
+
const results = [];
|
|
36176
|
+
value = parseIntAuto(ref[2]);
|
|
36177
|
+
if (value > 65535 || value < 0) {
|
|
36178
|
+
throw new Error("ipaddr: address outside defined range");
|
|
36179
|
+
}
|
|
36180
|
+
results.push(parseIntAuto(ref[0]));
|
|
36181
|
+
results.push(parseIntAuto(ref[1]));
|
|
36182
|
+
results.push(value >> 8 & 255);
|
|
36183
|
+
results.push(value & 255);
|
|
36184
|
+
return results;
|
|
36185
|
+
}();
|
|
36186
|
+
} else {
|
|
36187
|
+
return null;
|
|
36188
|
+
}
|
|
36189
|
+
};
|
|
36190
|
+
ipaddr.IPv4.subnetMaskFromPrefixLength = function(prefix) {
|
|
36191
|
+
prefix = parseInt(prefix);
|
|
36192
|
+
if (prefix < 0 || prefix > 32) {
|
|
36193
|
+
throw new Error("ipaddr: invalid IPv4 prefix length");
|
|
36194
|
+
}
|
|
36195
|
+
const octets = [0, 0, 0, 0];
|
|
36196
|
+
let j = 0;
|
|
36197
|
+
const filledOctetCount = Math.floor(prefix / 8);
|
|
36198
|
+
while (j < filledOctetCount) {
|
|
36199
|
+
octets[j] = 255;
|
|
36200
|
+
j++;
|
|
36201
|
+
}
|
|
36202
|
+
if (filledOctetCount < 4) {
|
|
36203
|
+
octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
|
|
36204
|
+
}
|
|
36205
|
+
return new this(octets);
|
|
36206
|
+
};
|
|
36207
|
+
ipaddr.IPv6 = function() {
|
|
36208
|
+
function IPv6(parts, zoneId) {
|
|
36209
|
+
let i2, part;
|
|
36210
|
+
if (parts.length === 16) {
|
|
36211
|
+
this.parts = [];
|
|
36212
|
+
for (i2 = 0;i2 <= 14; i2 += 2) {
|
|
36213
|
+
this.parts.push(parts[i2] << 8 | parts[i2 + 1]);
|
|
36214
|
+
}
|
|
36215
|
+
} else if (parts.length === 8) {
|
|
36216
|
+
this.parts = parts;
|
|
36217
|
+
} else {
|
|
36218
|
+
throw new Error("ipaddr: ipv6 part count should be 8 or 16");
|
|
36219
|
+
}
|
|
36220
|
+
for (i2 = 0;i2 < this.parts.length; i2++) {
|
|
36221
|
+
part = this.parts[i2];
|
|
36222
|
+
if (!(0 <= part && part <= 65535)) {
|
|
36223
|
+
throw new Error("ipaddr: ipv6 part should fit in 16 bits");
|
|
36224
|
+
}
|
|
36225
|
+
}
|
|
36226
|
+
if (zoneId) {
|
|
36227
|
+
this.zoneId = zoneId;
|
|
36228
|
+
}
|
|
36229
|
+
}
|
|
36230
|
+
IPv6.prototype.SpecialRanges = {
|
|
36231
|
+
unspecified: [new IPv6([0, 0, 0, 0, 0, 0, 0, 0]), 128],
|
|
36232
|
+
linkLocal: [new IPv6([65152, 0, 0, 0, 0, 0, 0, 0]), 10],
|
|
36233
|
+
multicast: [new IPv6([65280, 0, 0, 0, 0, 0, 0, 0]), 8],
|
|
36234
|
+
loopback: [new IPv6([0, 0, 0, 0, 0, 0, 0, 1]), 128],
|
|
36235
|
+
uniqueLocal: [new IPv6([64512, 0, 0, 0, 0, 0, 0, 0]), 7],
|
|
36236
|
+
ipv4Mapped: [new IPv6([0, 0, 0, 0, 0, 65535, 0, 0]), 96],
|
|
36237
|
+
discard: [new IPv6([256, 0, 0, 0, 0, 0, 0, 0]), 64],
|
|
36238
|
+
rfc6145: [new IPv6([0, 0, 0, 0, 65535, 0, 0, 0]), 96],
|
|
36239
|
+
rfc6052: [new IPv6([100, 65435, 0, 0, 0, 0, 0, 0]), 96],
|
|
36240
|
+
"6to4": [new IPv6([8194, 0, 0, 0, 0, 0, 0, 0]), 16],
|
|
36241
|
+
teredo: [new IPv6([8193, 0, 0, 0, 0, 0, 0, 0]), 32],
|
|
36242
|
+
benchmarking: [new IPv6([8193, 2, 0, 0, 0, 0, 0, 0]), 48],
|
|
36243
|
+
amt: [new IPv6([8193, 3, 0, 0, 0, 0, 0, 0]), 32],
|
|
36244
|
+
as112v6: [
|
|
36245
|
+
[new IPv6([8193, 4, 274, 0, 0, 0, 0, 0]), 48],
|
|
36246
|
+
[new IPv6([9760, 79, 32768, 0, 0, 0, 0, 0]), 48]
|
|
36247
|
+
],
|
|
36248
|
+
deprecated: [new IPv6([8193, 16, 0, 0, 0, 0, 0, 0]), 28],
|
|
36249
|
+
orchid2: [new IPv6([8193, 32, 0, 0, 0, 0, 0, 0]), 28],
|
|
36250
|
+
droneRemoteIdProtocolEntityTags: [new IPv6([8193, 48, 0, 0, 0, 0, 0, 0]), 28],
|
|
36251
|
+
reserved: [
|
|
36252
|
+
[new IPv6([8193, 0, 0, 0, 0, 0, 0, 0]), 23],
|
|
36253
|
+
[new IPv6([8193, 3512, 0, 0, 0, 0, 0, 0]), 32]
|
|
36254
|
+
]
|
|
36255
|
+
};
|
|
36256
|
+
IPv6.prototype.isIPv4MappedAddress = function() {
|
|
36257
|
+
return this.range() === "ipv4Mapped";
|
|
36258
|
+
};
|
|
36259
|
+
IPv6.prototype.kind = function() {
|
|
36260
|
+
return "ipv6";
|
|
36261
|
+
};
|
|
36262
|
+
IPv6.prototype.match = function(other, cidrRange) {
|
|
36263
|
+
let ref;
|
|
36264
|
+
if (cidrRange === undefined) {
|
|
36265
|
+
ref = other;
|
|
36266
|
+
other = ref[0];
|
|
36267
|
+
cidrRange = ref[1];
|
|
36268
|
+
}
|
|
36269
|
+
if (other.kind() !== "ipv6") {
|
|
36270
|
+
throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");
|
|
36271
|
+
}
|
|
36272
|
+
return matchCIDR(this.parts, other.parts, 16, cidrRange);
|
|
36273
|
+
};
|
|
36274
|
+
IPv6.prototype.prefixLengthFromSubnetMask = function() {
|
|
36275
|
+
let cidr = 0;
|
|
36276
|
+
let stop = false;
|
|
36277
|
+
const zerotable = {
|
|
36278
|
+
0: 16,
|
|
36279
|
+
32768: 15,
|
|
36280
|
+
49152: 14,
|
|
36281
|
+
57344: 13,
|
|
36282
|
+
61440: 12,
|
|
36283
|
+
63488: 11,
|
|
36284
|
+
64512: 10,
|
|
36285
|
+
65024: 9,
|
|
36286
|
+
65280: 8,
|
|
36287
|
+
65408: 7,
|
|
36288
|
+
65472: 6,
|
|
36289
|
+
65504: 5,
|
|
36290
|
+
65520: 4,
|
|
36291
|
+
65528: 3,
|
|
36292
|
+
65532: 2,
|
|
36293
|
+
65534: 1,
|
|
36294
|
+
65535: 0
|
|
36295
|
+
};
|
|
36296
|
+
let part, zeros;
|
|
36297
|
+
for (let i2 = 7;i2 >= 0; i2 -= 1) {
|
|
36298
|
+
part = this.parts[i2];
|
|
36299
|
+
if (part in zerotable) {
|
|
36300
|
+
zeros = zerotable[part];
|
|
36301
|
+
if (stop && zeros !== 0) {
|
|
36302
|
+
return null;
|
|
36303
|
+
}
|
|
36304
|
+
if (zeros !== 16) {
|
|
36305
|
+
stop = true;
|
|
36306
|
+
}
|
|
36307
|
+
cidr += zeros;
|
|
36308
|
+
} else {
|
|
36309
|
+
return null;
|
|
36310
|
+
}
|
|
36311
|
+
}
|
|
36312
|
+
return 128 - cidr;
|
|
36313
|
+
};
|
|
36314
|
+
IPv6.prototype.range = function() {
|
|
36315
|
+
return ipaddr.subnetMatch(this, this.SpecialRanges);
|
|
36316
|
+
};
|
|
36317
|
+
IPv6.prototype.toByteArray = function() {
|
|
36318
|
+
let part;
|
|
36319
|
+
const bytes = [];
|
|
36320
|
+
const ref = this.parts;
|
|
36321
|
+
for (let i2 = 0;i2 < ref.length; i2++) {
|
|
36322
|
+
part = ref[i2];
|
|
36323
|
+
bytes.push(part >> 8);
|
|
36324
|
+
bytes.push(part & 255);
|
|
36325
|
+
}
|
|
36326
|
+
return bytes;
|
|
36327
|
+
};
|
|
36328
|
+
IPv6.prototype.toFixedLengthString = function() {
|
|
36329
|
+
const addr = function() {
|
|
36330
|
+
const results = [];
|
|
36331
|
+
for (let i2 = 0;i2 < this.parts.length; i2++) {
|
|
36332
|
+
results.push(padPart(this.parts[i2].toString(16), 4));
|
|
36333
|
+
}
|
|
36334
|
+
return results;
|
|
36335
|
+
}.call(this).join(":");
|
|
36336
|
+
let suffix = "";
|
|
36337
|
+
if (this.zoneId) {
|
|
36338
|
+
suffix = `%${this.zoneId}`;
|
|
36339
|
+
}
|
|
36340
|
+
return addr + suffix;
|
|
36341
|
+
};
|
|
36342
|
+
IPv6.prototype.toIPv4Address = function() {
|
|
36343
|
+
if (!this.isIPv4MappedAddress()) {
|
|
36344
|
+
throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");
|
|
36345
|
+
}
|
|
36346
|
+
const ref = this.parts.slice(-2);
|
|
36347
|
+
const high = ref[0];
|
|
36348
|
+
const low = ref[1];
|
|
36349
|
+
return new ipaddr.IPv4([high >> 8, high & 255, low >> 8, low & 255]);
|
|
36350
|
+
};
|
|
36351
|
+
IPv6.prototype.toNormalizedString = function() {
|
|
36352
|
+
const addr = function() {
|
|
36353
|
+
const results = [];
|
|
36354
|
+
for (let i2 = 0;i2 < this.parts.length; i2++) {
|
|
36355
|
+
results.push(this.parts[i2].toString(16));
|
|
36356
|
+
}
|
|
36357
|
+
return results;
|
|
36358
|
+
}.call(this).join(":");
|
|
36359
|
+
let suffix = "";
|
|
36360
|
+
if (this.zoneId) {
|
|
36361
|
+
suffix = `%${this.zoneId}`;
|
|
36362
|
+
}
|
|
36363
|
+
return addr + suffix;
|
|
36364
|
+
};
|
|
36365
|
+
IPv6.prototype.toRFC5952String = function() {
|
|
36366
|
+
const regex = /((^|:)(0(:|$)){2,})/g;
|
|
36367
|
+
const string = this.toNormalizedString();
|
|
36368
|
+
let bestMatchIndex = 0;
|
|
36369
|
+
let bestMatchLength = -1;
|
|
36370
|
+
let match;
|
|
36371
|
+
while (match = regex.exec(string)) {
|
|
36372
|
+
if (match[0].length > bestMatchLength) {
|
|
36373
|
+
bestMatchIndex = match.index;
|
|
36374
|
+
bestMatchLength = match[0].length;
|
|
36375
|
+
}
|
|
36376
|
+
}
|
|
36377
|
+
if (bestMatchLength < 0) {
|
|
36378
|
+
return string;
|
|
36379
|
+
}
|
|
36380
|
+
return `${string.substring(0, bestMatchIndex)}::${string.substring(bestMatchIndex + bestMatchLength)}`;
|
|
36381
|
+
};
|
|
36382
|
+
IPv6.prototype.toString = function() {
|
|
36383
|
+
return this.toRFC5952String();
|
|
36384
|
+
};
|
|
36385
|
+
return IPv6;
|
|
36386
|
+
}();
|
|
36387
|
+
ipaddr.IPv6.broadcastAddressFromCIDR = function(string) {
|
|
36388
|
+
try {
|
|
36389
|
+
const cidr = this.parseCIDR(string);
|
|
36390
|
+
const ipInterfaceOctets = cidr[0].toByteArray();
|
|
36391
|
+
const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
|
|
36392
|
+
const octets = [];
|
|
36393
|
+
let i2 = 0;
|
|
36394
|
+
while (i2 < 16) {
|
|
36395
|
+
octets.push(parseInt(ipInterfaceOctets[i2], 10) | parseInt(subnetMaskOctets[i2], 10) ^ 255);
|
|
36396
|
+
i2++;
|
|
36397
|
+
}
|
|
36398
|
+
return new this(octets);
|
|
36399
|
+
} catch (e) {
|
|
36400
|
+
throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`);
|
|
36401
|
+
}
|
|
36402
|
+
};
|
|
36403
|
+
ipaddr.IPv6.isIPv6 = function(string) {
|
|
36404
|
+
return this.parser(string) !== null;
|
|
36405
|
+
};
|
|
36406
|
+
ipaddr.IPv6.isValid = function(string) {
|
|
36407
|
+
if (typeof string === "string" && string.indexOf(":") === -1) {
|
|
36408
|
+
return false;
|
|
36409
|
+
}
|
|
36410
|
+
try {
|
|
36411
|
+
const addr = this.parser(string);
|
|
36412
|
+
new this(addr.parts, addr.zoneId);
|
|
36413
|
+
return true;
|
|
36414
|
+
} catch (e) {
|
|
36415
|
+
return false;
|
|
36416
|
+
}
|
|
36417
|
+
};
|
|
36418
|
+
ipaddr.IPv6.isValidCIDR = function(string) {
|
|
36419
|
+
if (typeof string === "string" && string.indexOf(":") === -1) {
|
|
36420
|
+
return false;
|
|
36421
|
+
}
|
|
36422
|
+
try {
|
|
36423
|
+
this.parseCIDR(string);
|
|
36424
|
+
return true;
|
|
36425
|
+
} catch (e) {
|
|
36426
|
+
return false;
|
|
36427
|
+
}
|
|
36428
|
+
};
|
|
36429
|
+
ipaddr.IPv6.networkAddressFromCIDR = function(string) {
|
|
36430
|
+
let cidr, i2, ipInterfaceOctets, octets, subnetMaskOctets;
|
|
36431
|
+
try {
|
|
36432
|
+
cidr = this.parseCIDR(string);
|
|
36433
|
+
ipInterfaceOctets = cidr[0].toByteArray();
|
|
36434
|
+
subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
|
|
36435
|
+
octets = [];
|
|
36436
|
+
i2 = 0;
|
|
36437
|
+
while (i2 < 16) {
|
|
36438
|
+
octets.push(parseInt(ipInterfaceOctets[i2], 10) & parseInt(subnetMaskOctets[i2], 10));
|
|
36439
|
+
i2++;
|
|
36440
|
+
}
|
|
36441
|
+
return new this(octets);
|
|
36442
|
+
} catch (e) {
|
|
36443
|
+
throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`);
|
|
36444
|
+
}
|
|
36445
|
+
};
|
|
36446
|
+
ipaddr.IPv6.parse = function(string) {
|
|
36447
|
+
const addr = this.parser(string);
|
|
36448
|
+
if (addr.parts === null) {
|
|
36449
|
+
throw new Error("ipaddr: string is not formatted like an IPv6 Address");
|
|
36450
|
+
}
|
|
36451
|
+
return new this(addr.parts, addr.zoneId);
|
|
36452
|
+
};
|
|
36453
|
+
ipaddr.IPv6.parseCIDR = function(string) {
|
|
36454
|
+
let maskLength, match, parsed;
|
|
36455
|
+
if (match = string.match(/^(.+)\/(\d+)$/)) {
|
|
36456
|
+
maskLength = parseInt(match[2]);
|
|
36457
|
+
if (maskLength >= 0 && maskLength <= 128) {
|
|
36458
|
+
parsed = [this.parse(match[1]), maskLength];
|
|
36459
|
+
Object.defineProperty(parsed, "toString", {
|
|
36460
|
+
value: function() {
|
|
36461
|
+
return this.join("/");
|
|
36462
|
+
}
|
|
36463
|
+
});
|
|
36464
|
+
return parsed;
|
|
36465
|
+
}
|
|
36466
|
+
}
|
|
36467
|
+
throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range");
|
|
36468
|
+
};
|
|
36469
|
+
ipaddr.IPv6.parser = function(string) {
|
|
36470
|
+
let addr, i2, match, octet, octets, zoneId;
|
|
36471
|
+
if (match = string.match(ipv6Regexes.deprecatedTransitional)) {
|
|
36472
|
+
return this.parser(`::ffff:${match[1]}`);
|
|
36473
|
+
}
|
|
36474
|
+
if (ipv6Regexes.native.test(string)) {
|
|
36475
|
+
return expandIPv6(string, 8);
|
|
36476
|
+
}
|
|
36477
|
+
if (match = string.match(ipv6Regexes.transitional)) {
|
|
36478
|
+
zoneId = match[6] || "";
|
|
36479
|
+
addr = match[1];
|
|
36480
|
+
if (!match[1].endsWith("::")) {
|
|
36481
|
+
addr = addr.slice(0, -1);
|
|
36482
|
+
}
|
|
36483
|
+
addr = expandIPv6(addr + zoneId, 6);
|
|
36484
|
+
if (addr.parts) {
|
|
36485
|
+
octets = [
|
|
36486
|
+
parseInt(match[2]),
|
|
36487
|
+
parseInt(match[3]),
|
|
36488
|
+
parseInt(match[4]),
|
|
36489
|
+
parseInt(match[5])
|
|
36490
|
+
];
|
|
36491
|
+
for (i2 = 0;i2 < octets.length; i2++) {
|
|
36492
|
+
octet = octets[i2];
|
|
36493
|
+
if (!(0 <= octet && octet <= 255)) {
|
|
36494
|
+
return null;
|
|
36495
|
+
}
|
|
36496
|
+
}
|
|
36497
|
+
addr.parts.push(octets[0] << 8 | octets[1]);
|
|
36498
|
+
addr.parts.push(octets[2] << 8 | octets[3]);
|
|
36499
|
+
return {
|
|
36500
|
+
parts: addr.parts,
|
|
36501
|
+
zoneId: addr.zoneId
|
|
36502
|
+
};
|
|
36503
|
+
}
|
|
36504
|
+
}
|
|
36505
|
+
return null;
|
|
36506
|
+
};
|
|
36507
|
+
ipaddr.IPv6.subnetMaskFromPrefixLength = function(prefix) {
|
|
36508
|
+
prefix = parseInt(prefix);
|
|
36509
|
+
if (prefix < 0 || prefix > 128) {
|
|
36510
|
+
throw new Error("ipaddr: invalid IPv6 prefix length");
|
|
36511
|
+
}
|
|
36512
|
+
const octets = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
36513
|
+
let j = 0;
|
|
36514
|
+
const filledOctetCount = Math.floor(prefix / 8);
|
|
36515
|
+
while (j < filledOctetCount) {
|
|
36516
|
+
octets[j] = 255;
|
|
36517
|
+
j++;
|
|
36518
|
+
}
|
|
36519
|
+
if (filledOctetCount < 16) {
|
|
36520
|
+
octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
|
|
36521
|
+
}
|
|
36522
|
+
return new this(octets);
|
|
36523
|
+
};
|
|
36524
|
+
ipaddr.fromByteArray = function(bytes) {
|
|
36525
|
+
const length = bytes.length;
|
|
36526
|
+
if (length === 4) {
|
|
36527
|
+
return new ipaddr.IPv4(bytes);
|
|
36528
|
+
} else if (length === 16) {
|
|
36529
|
+
return new ipaddr.IPv6(bytes);
|
|
36530
|
+
} else {
|
|
36531
|
+
throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address");
|
|
36532
|
+
}
|
|
36533
|
+
};
|
|
36534
|
+
ipaddr.isValid = function(string) {
|
|
36535
|
+
return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string);
|
|
36536
|
+
};
|
|
36537
|
+
ipaddr.isValidCIDR = function(string) {
|
|
36538
|
+
return ipaddr.IPv6.isValidCIDR(string) || ipaddr.IPv4.isValidCIDR(string);
|
|
36539
|
+
};
|
|
36540
|
+
ipaddr.parse = function(string) {
|
|
36541
|
+
if (ipaddr.IPv6.isValid(string)) {
|
|
36542
|
+
return ipaddr.IPv6.parse(string);
|
|
36543
|
+
} else if (ipaddr.IPv4.isValid(string)) {
|
|
36544
|
+
return ipaddr.IPv4.parse(string);
|
|
36545
|
+
} else {
|
|
36546
|
+
throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format");
|
|
36547
|
+
}
|
|
36548
|
+
};
|
|
36549
|
+
ipaddr.parseCIDR = function(string) {
|
|
36550
|
+
try {
|
|
36551
|
+
return ipaddr.IPv6.parseCIDR(string);
|
|
36552
|
+
} catch (e) {
|
|
36553
|
+
try {
|
|
36554
|
+
return ipaddr.IPv4.parseCIDR(string);
|
|
36555
|
+
} catch (e2) {
|
|
36556
|
+
throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format");
|
|
36557
|
+
}
|
|
36558
|
+
}
|
|
36559
|
+
};
|
|
36560
|
+
ipaddr.process = function(string) {
|
|
36561
|
+
const addr = this.parse(string);
|
|
36562
|
+
if (addr.kind() === "ipv6" && addr.isIPv4MappedAddress()) {
|
|
36563
|
+
return addr.toIPv4Address();
|
|
36564
|
+
} else {
|
|
36565
|
+
return addr;
|
|
36566
|
+
}
|
|
36567
|
+
};
|
|
36568
|
+
ipaddr.subnetMatch = function(address, rangeList, defaultName) {
|
|
36569
|
+
let i2, rangeName, rangeSubnets, subnet;
|
|
36570
|
+
if (defaultName === undefined || defaultName === null) {
|
|
36571
|
+
defaultName = "unicast";
|
|
36572
|
+
}
|
|
36573
|
+
for (rangeName in rangeList) {
|
|
36574
|
+
if (Object.prototype.hasOwnProperty.call(rangeList, rangeName)) {
|
|
36575
|
+
rangeSubnets = rangeList[rangeName];
|
|
36576
|
+
if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) {
|
|
36577
|
+
rangeSubnets = [rangeSubnets];
|
|
36578
|
+
}
|
|
36579
|
+
for (i2 = 0;i2 < rangeSubnets.length; i2++) {
|
|
36580
|
+
subnet = rangeSubnets[i2];
|
|
36581
|
+
if (address.kind() === subnet[0].kind() && address.match.apply(address, subnet)) {
|
|
36582
|
+
return rangeName;
|
|
36583
|
+
}
|
|
36584
|
+
}
|
|
36585
|
+
}
|
|
36586
|
+
}
|
|
36587
|
+
return defaultName;
|
|
36588
|
+
};
|
|
36589
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
36590
|
+
module.exports = ipaddr;
|
|
36591
|
+
} else {
|
|
36592
|
+
root.ipaddr = ipaddr;
|
|
36593
|
+
}
|
|
36594
|
+
})(exports);
|
|
36595
|
+
});
|
|
36596
|
+
|
|
36597
|
+
// ../security/src/hostnames.ts
|
|
36598
|
+
function unwrapIpv6Brackets(host) {
|
|
36599
|
+
return host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
|
|
36600
|
+
}
|
|
36601
|
+
var LOOPBACK_HOSTNAMES;
|
|
36602
|
+
var init_hostnames = __esm(() => {
|
|
36603
|
+
LOOPBACK_HOSTNAMES = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
36604
|
+
});
|
|
36605
|
+
|
|
36606
|
+
// ../security/src/egress.ts
|
|
36607
|
+
function splitEntries(value) {
|
|
36608
|
+
if (value === undefined)
|
|
36609
|
+
return [];
|
|
36610
|
+
const parts = typeof value === "string" ? value.split(",") : value;
|
|
36611
|
+
return parts.map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
36612
|
+
}
|
|
36613
|
+
function normalizeHost(host) {
|
|
36614
|
+
return unwrapIpv6Brackets(host.toLowerCase()).replace(/\.$/, "");
|
|
36615
|
+
}
|
|
36616
|
+
function parseHostPattern(entry, sourceName) {
|
|
36617
|
+
const value = normalizeHost(entry);
|
|
36618
|
+
const wildcard = value.startsWith("*.");
|
|
36619
|
+
const host = wildcard ? value.slice(2) : value;
|
|
36620
|
+
if (host.includes("*")) {
|
|
36621
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}": a wildcard is only supported as a leading "*." label`);
|
|
36622
|
+
}
|
|
36623
|
+
if (host.includes("/") || /\s/.test(host)) {
|
|
36624
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}": expected a hostname, not a URL or CIDR`);
|
|
36625
|
+
}
|
|
36626
|
+
if (host.includes(",") || host.includes(":")) {
|
|
36627
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}": a hostname has no port, comma, or colon`);
|
|
36628
|
+
}
|
|
36629
|
+
if (host.length === 0 || host.split(".").some((label) => label.length === 0)) {
|
|
36630
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}": every label must be non-empty`);
|
|
36631
|
+
}
|
|
36632
|
+
if (/[^\x21-\x7e]/.test(host)) {
|
|
36633
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}": use the punycode form of an internationalized name`);
|
|
36634
|
+
}
|
|
36635
|
+
if (wildcard && !host.includes(".")) {
|
|
36636
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}": a wildcard must cover at least two labels, e.g. "*.example.com"`);
|
|
36637
|
+
}
|
|
36638
|
+
return wildcard ? { value: `.${host}`, wildcard: true } : { value: host, wildcard: false };
|
|
36639
|
+
}
|
|
36640
|
+
function parseCidrRange(entry, sourceName) {
|
|
36641
|
+
if (entry.includes("/")) {
|
|
36642
|
+
if (!ipaddr.isValidCIDR(entry)) {
|
|
36643
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}"`);
|
|
36644
|
+
}
|
|
36645
|
+
const [address2, prefixLength] = ipaddr.parseCIDR(entry);
|
|
36646
|
+
if (prefixLength < 8) {
|
|
36647
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}": catch-all networks are unsafe`);
|
|
36648
|
+
}
|
|
36649
|
+
return { address: address2, prefixLength };
|
|
36650
|
+
}
|
|
36651
|
+
const value = unwrapIpv6Brackets(entry);
|
|
36652
|
+
if (!ipaddr.isValid(value)) {
|
|
36653
|
+
throw new Error(`Invalid ${sourceName} entry "${entry}"`);
|
|
36654
|
+
}
|
|
36655
|
+
const address = ipaddr.parse(value);
|
|
36656
|
+
return { address, prefixLength: address.kind() === "ipv4" ? 32 : 128 };
|
|
36657
|
+
}
|
|
36658
|
+
function createEgressPolicy(spec = {}) {
|
|
36659
|
+
const sourceNames = spec.sourceNames ?? DEFAULT_SOURCE_NAMES;
|
|
36660
|
+
return {
|
|
36661
|
+
insecureHttp: spec.insecureHttp ?? "never",
|
|
36662
|
+
allowLoopback: spec.allowLoopback ?? false,
|
|
36663
|
+
allowPrivate: spec.allowPrivate ?? false,
|
|
36664
|
+
allowedHosts: splitEntries(spec.allowedHosts).map((entry) => parseHostPattern(entry, sourceNames.hosts)),
|
|
36665
|
+
allowedRanges: splitEntries(spec.allowedRanges).map((entry) => parseCidrRange(entry, sourceNames.ranges))
|
|
36666
|
+
};
|
|
36667
|
+
}
|
|
36668
|
+
function embeddedIpv4(parts) {
|
|
36669
|
+
return ipaddr.fromByteArray([
|
|
36670
|
+
parts[6] >> 8 & 255,
|
|
36671
|
+
parts[6] & 255,
|
|
36672
|
+
parts[7] >> 8 & 255,
|
|
36673
|
+
parts[7] & 255
|
|
36674
|
+
]).toString();
|
|
36675
|
+
}
|
|
36676
|
+
function transitionIpv4(parts) {
|
|
36677
|
+
if (parts[0] === 8194) {
|
|
36678
|
+
return ipaddr.fromByteArray([
|
|
36679
|
+
parts[1] >> 8 & 255,
|
|
36680
|
+
parts[1] & 255,
|
|
36681
|
+
parts[2] >> 8 & 255,
|
|
36682
|
+
parts[2] & 255
|
|
36683
|
+
]).toString();
|
|
36684
|
+
}
|
|
36685
|
+
if (isTeredo(parts))
|
|
36686
|
+
return null;
|
|
36687
|
+
if (parts[4] === 0 && parts[5] === 24318)
|
|
36688
|
+
return embeddedIpv4(parts);
|
|
36689
|
+
if (parts[4] === 512 && parts[5] === 24318)
|
|
36690
|
+
return embeddedIpv4(parts);
|
|
36691
|
+
return null;
|
|
36692
|
+
}
|
|
36693
|
+
function isTeredo(parts) {
|
|
36694
|
+
return parts[0] === 8193 && parts[1] === 0;
|
|
36695
|
+
}
|
|
36696
|
+
function canonicalAddress(address) {
|
|
36697
|
+
const clean = unwrapIpv6Brackets(address).split("%")[0];
|
|
36698
|
+
if (!ipaddr.isValid(clean))
|
|
36699
|
+
return null;
|
|
36700
|
+
const parsed = ipaddr.process(clean);
|
|
36701
|
+
if (parsed.kind() === "ipv6") {
|
|
36702
|
+
const parts = parsed.parts;
|
|
36703
|
+
if (IPV4_EMBEDDING_PREFIXES.some((prefix) => prefix.every((part, index) => parts[index] === part))) {
|
|
36704
|
+
return embeddedIpv4(parts);
|
|
36705
|
+
}
|
|
36706
|
+
const embedded = (parts[6] << 16 >>> 0) + parts[7];
|
|
36707
|
+
if (parts.slice(0, 6).every((part) => part === 0) && embedded > 1) {
|
|
36708
|
+
return embeddedIpv4(parts);
|
|
36709
|
+
}
|
|
36710
|
+
const transition = transitionIpv4(parts);
|
|
36711
|
+
if (transition !== null)
|
|
36712
|
+
return transition;
|
|
36713
|
+
}
|
|
36714
|
+
return parsed.toString();
|
|
36715
|
+
}
|
|
36716
|
+
var ipaddr, METADATA_ADDRESSES, DENIED_PORTS, DEFAULT_SOURCE_NAMES, STRICT_EGRESS_POLICY, IPV4_EMBEDDING_PREFIXES, CANONICAL_METADATA_ADDRESSES;
|
|
36717
|
+
var init_egress = __esm(() => {
|
|
36718
|
+
init_hostnames();
|
|
36719
|
+
ipaddr = __toESM(require_ipaddr(), 1);
|
|
36720
|
+
METADATA_ADDRESSES = [
|
|
36721
|
+
"169.254.169.254",
|
|
36722
|
+
"169.254.170.2",
|
|
36723
|
+
"100.100.100.200",
|
|
36724
|
+
"192.0.0.192",
|
|
36725
|
+
"168.63.129.16",
|
|
36726
|
+
"fd00:ec2::254"
|
|
36727
|
+
];
|
|
36728
|
+
DENIED_PORTS = new Set([
|
|
36729
|
+
22,
|
|
36730
|
+
23,
|
|
36731
|
+
25,
|
|
36732
|
+
3306,
|
|
36733
|
+
5432,
|
|
36734
|
+
6379,
|
|
36735
|
+
27017,
|
|
36736
|
+
9200
|
|
36737
|
+
]);
|
|
36738
|
+
DEFAULT_SOURCE_NAMES = { hosts: "allowedHosts", ranges: "allowedRanges" };
|
|
36739
|
+
STRICT_EGRESS_POLICY = createEgressPolicy();
|
|
36740
|
+
IPV4_EMBEDDING_PREFIXES = [
|
|
36741
|
+
[100, 65435, 0, 0, 0, 0],
|
|
36742
|
+
[0, 0, 0, 0, 65535, 0]
|
|
36743
|
+
];
|
|
36744
|
+
CANONICAL_METADATA_ADDRESSES = new Set(METADATA_ADDRESSES.map((address) => canonicalAddress(address) ?? address));
|
|
36745
|
+
});
|
|
36746
|
+
|
|
35830
36747
|
// ../security/src/hash.ts
|
|
35831
36748
|
import { createHash } from "node:crypto";
|
|
35832
36749
|
function sha256Base64Url(input) {
|
|
@@ -36095,6 +37012,18 @@ function collectSecrets(existing) {
|
|
|
36095
37012
|
}
|
|
36096
37013
|
return secrets;
|
|
36097
37014
|
}
|
|
37015
|
+
function validateEgressEntries(spec) {
|
|
37016
|
+
try {
|
|
37017
|
+
createEgressPolicy({
|
|
37018
|
+
allowedHosts: spec.allowedHosts?.trim() || undefined,
|
|
37019
|
+
allowedRanges: spec.allowedRanges?.trim() || undefined,
|
|
37020
|
+
sourceNames: { hosts: "EGRESS_ALLOWED_HOSTS", ranges: "EGRESS_ALLOWED_IP_RANGES" }
|
|
37021
|
+
});
|
|
37022
|
+
return;
|
|
37023
|
+
} catch (error) {
|
|
37024
|
+
return getErrorMessage(error, "invalid entry");
|
|
37025
|
+
}
|
|
37026
|
+
}
|
|
36098
37027
|
async function promptCopilotKey(existing) {
|
|
36099
37028
|
if (existing) {
|
|
36100
37029
|
const keep = await confirm2({
|
|
@@ -36214,12 +37143,28 @@ async function promptSecurity(vars) {
|
|
|
36214
37143
|
sim.DISABLE_AUTH = "true";
|
|
36215
37144
|
mirrorToRealtime.DISABLE_AUTH = "true";
|
|
36216
37145
|
}
|
|
36217
|
-
const
|
|
36218
|
-
|
|
36219
|
-
|
|
37146
|
+
const existingEgressHosts = vars.get("EGRESS_ALLOWED_HOSTS");
|
|
37147
|
+
const egressHosts = await text2({
|
|
37148
|
+
message: "Hosts on your private network that workflows may reach? (comma-separated, blank for none — widens the SSRF guard)",
|
|
37149
|
+
placeholder: "host.docker.internal,*.svc.cluster.local",
|
|
37150
|
+
initialValue: existingEgressHosts ?? "",
|
|
37151
|
+
defaultValue: "",
|
|
37152
|
+
validate: (value) => validateEgressEntries({ allowedHosts: value })
|
|
37153
|
+
});
|
|
37154
|
+
if (typeof egressHosts === "string" && egressHosts.trim()) {
|
|
37155
|
+
sim.EGRESS_ALLOWED_HOSTS = egressHosts.trim();
|
|
37156
|
+
}
|
|
37157
|
+
const existingEgressRanges = vars.get("EGRESS_ALLOWED_IP_RANGES");
|
|
37158
|
+
const egressRanges = await text2({
|
|
37159
|
+
message: "Address ranges on your private network that workflows may reach? (CIDRs, comma-separated)",
|
|
37160
|
+
placeholder: "10.0.0.0/8,192.168.65.254/32",
|
|
37161
|
+
initialValue: existingEgressRanges ?? "",
|
|
37162
|
+
defaultValue: "",
|
|
37163
|
+
validate: (value) => validateEgressEntries({ allowedRanges: value })
|
|
36220
37164
|
});
|
|
36221
|
-
if (
|
|
36222
|
-
sim.
|
|
37165
|
+
if (typeof egressRanges === "string" && egressRanges.trim()) {
|
|
37166
|
+
sim.EGRESS_ALLOWED_IP_RANGES = egressRanges.trim();
|
|
37167
|
+
}
|
|
36223
37168
|
const existingAdminKey = vars.get("ADMIN_API_KEY");
|
|
36224
37169
|
if (!existingAdminKey || isPlaceholder(existingAdminKey)) {
|
|
36225
37170
|
const wantsAdmin = await confirm2({
|
|
@@ -36264,6 +37209,7 @@ async function promptUnlocks(vars) {
|
|
|
36264
37209
|
}
|
|
36265
37210
|
var DEFAULT_CLI_AUTH_ORIGIN = "https://www.sim.ai", PROVIDER_CONSOLES;
|
|
36266
37211
|
var init_steps = __esm(() => {
|
|
37212
|
+
init_egress();
|
|
36267
37213
|
init_capability_config();
|
|
36268
37214
|
init_capability_setup();
|
|
36269
37215
|
init_cli_auth();
|