@ssv-labs/ssv-sdk 0.1.2 → 1.0.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/README.html +4 -7
- package/README.md +37 -26
- package/dist/{KeyShares-7biQfDev.js → KeyShares-Bk9uzOlK.js} +255 -75
- package/dist/{KeyShares-DEqBZits.mjs → KeyShares-Dlp4Pa3b.mjs} +259 -79
- package/dist/abi/mainnet/v4/getter.d.ts +699 -74
- package/dist/abi/mainnet/v4/setter.d.ts +939 -59
- package/dist/api/subgraph/index.d.ts +36 -1
- package/dist/config/create.d.ts +2 -2
- package/dist/config/globals.d.ts +3 -0
- package/dist/{globals-CDOcDUnk.mjs → config-BdEJjnYA.mjs} +107 -79
- package/dist/{globals-DsaKgq3v.js → config-ClGS9Tic.js} +73 -45
- package/dist/contract-interactions/create.d.ts +1 -1
- package/dist/contract-interactions/types.d.ts +9 -3
- package/dist/graphql/graphql.d.ts +4663 -922
- package/dist/keys.js +1 -1
- package/dist/keys.mjs +5 -5
- package/dist/libs/api/index.d.ts +2 -0
- package/dist/libs/cluster/index.d.ts +3 -1
- package/dist/libs/cluster/methods/deposit.d.ts +150 -5
- package/dist/libs/cluster/methods/exit-validators.d.ts +149 -0
- package/dist/libs/cluster/methods/index.d.ts +3 -1
- package/dist/libs/cluster/methods/liquidate-cluster.d.ts +149 -0
- package/dist/libs/cluster/methods/liquidate-ssv.d.ts +430 -0
- package/dist/libs/cluster/methods/migrate-cluster-to-eth.d.ts +431 -0
- package/dist/libs/cluster/methods/reactivate-cluster.d.ts +149 -0
- package/dist/libs/cluster/methods/register-validators.d.ts +2222 -309
- package/dist/libs/cluster/methods/remove-validators.d.ts +149 -0
- package/dist/libs/cluster/methods/set-fee-recipient.d.ts +149 -0
- package/dist/libs/cluster/methods/withdraw.d.ts +149 -0
- package/dist/libs/dao/index.d.ts +8 -0
- package/dist/libs/dao/methods/commit-root.d.ts +432 -0
- package/dist/libs/dao/methods/index.d.ts +3 -0
- package/dist/libs/dao/methods/update-network-fee-ssv.d.ts +430 -0
- package/dist/libs/dao/methods/withdraw-network-ssv-earnings.d.ts +430 -0
- package/dist/libs/operator/index.d.ts +1525 -32
- package/dist/libs/operator/methods.d.ts +1731 -2
- package/dist/libs/ssv-keys/Encryption/__test__/RsaKeys.d.ts +1 -1
- package/dist/libs/ssv-keys/KeyShares/KeySharesItem.d.ts +1 -1
- package/dist/libs/ssv-keys/SSVKeys.d.ts +1 -1
- package/dist/libs/ssv-keys/exceptions/index.d.ts +1 -1
- package/dist/libs/ssv-keys/index.d.ts +1 -1
- package/dist/libs/ssv-keys/interfaces/index.d.ts +2 -2
- package/dist/libs/utils/index.d.ts +6 -4
- package/dist/libs/utils/methods/calc-deposit-from-runway.d.ts +11 -0
- package/dist/libs/utils/methods/get-cluster-balance.d.ts +3 -1
- package/dist/libs/utils/methods/keyshares.d.ts +4 -2
- package/dist/libs/utils/methods/keystores.d.ts +4 -4
- package/dist/main.d.ts +1 -0
- package/dist/main.js +2714 -729
- package/dist/main.mjs +2746 -761
- package/dist/sdk.d.ts +8 -4
- package/dist/types/contract-interactions.d.ts +11 -0
- package/dist/types/methods.d.ts +4 -3
- package/dist/utils/cluster.d.ts +3 -3
- package/dist/utils/funding.d.ts +29 -0
- package/dist/utils/zod/config.d.ts +1 -1
- package/dist/utils.js +38 -38
- package/dist/utils.mjs +34 -34
- package/package.json +29 -17
|
@@ -3,10 +3,6 @@ const bls = require("bls-eth-wasm");
|
|
|
3
3
|
const crypto$1 = require("crypto");
|
|
4
4
|
const viem = require("viem");
|
|
5
5
|
const classValidator = require("class-validator");
|
|
6
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
7
|
-
function getDefaultExportFromCjs(x) {
|
|
8
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
9
|
-
}
|
|
10
6
|
(async () => {
|
|
11
7
|
await bls.init(bls.BLS12_381);
|
|
12
8
|
})();
|
|
@@ -65,6 +61,10 @@ class OwnerNonceFormatError extends SSVKeysException {
|
|
|
65
61
|
this.data = data;
|
|
66
62
|
}
|
|
67
63
|
}
|
|
64
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
65
|
+
function getDefaultExportFromCjs(x) {
|
|
66
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
67
|
+
}
|
|
68
68
|
var forge$C = {
|
|
69
69
|
// default options
|
|
70
70
|
options: {
|
|
@@ -1327,6 +1327,9 @@ util$1.format = function(format) {
|
|
|
1327
1327
|
parts.push("<?>");
|
|
1328
1328
|
}
|
|
1329
1329
|
break;
|
|
1330
|
+
// FIXME: do proper formatting for numbers, etc
|
|
1331
|
+
//case 'f':
|
|
1332
|
+
//case 'd':
|
|
1330
1333
|
case "%":
|
|
1331
1334
|
parts.push("%");
|
|
1332
1335
|
break;
|
|
@@ -2737,6 +2740,7 @@ asn1$8.Type = {
|
|
|
2737
2740
|
GENERALIZEDTIME: 24,
|
|
2738
2741
|
BMPSTRING: 30
|
|
2739
2742
|
};
|
|
2743
|
+
asn1$8.maxDepth = 256;
|
|
2740
2744
|
asn1$8.create = function(tagClass, type, constructed, value, options) {
|
|
2741
2745
|
if (forge$w.util.isArray(value)) {
|
|
2742
2746
|
var tmp = [];
|
|
@@ -2878,6 +2882,9 @@ asn1$8.fromDer = function(bytes, options) {
|
|
|
2878
2882
|
if (!("decodeBitStrings" in options)) {
|
|
2879
2883
|
options.decodeBitStrings = true;
|
|
2880
2884
|
}
|
|
2885
|
+
if (!("maxDepth" in options)) {
|
|
2886
|
+
options.maxDepth = asn1$8.maxDepth;
|
|
2887
|
+
}
|
|
2881
2888
|
if (typeof bytes === "string") {
|
|
2882
2889
|
bytes = forge$w.util.createBuffer(bytes);
|
|
2883
2890
|
}
|
|
@@ -2892,6 +2899,9 @@ asn1$8.fromDer = function(bytes, options) {
|
|
|
2892
2899
|
return value;
|
|
2893
2900
|
};
|
|
2894
2901
|
function _fromDer(bytes, remaining, depth, options) {
|
|
2902
|
+
if (depth >= options.maxDepth) {
|
|
2903
|
+
throw new Error("ASN.1 parsing error: Max depth exceeded.");
|
|
2904
|
+
}
|
|
2895
2905
|
var start;
|
|
2896
2906
|
_checkBufferLength(bytes, remaining, 2);
|
|
2897
2907
|
var b1 = bytes.getByte();
|
|
@@ -3067,6 +3077,9 @@ asn1$8.oidToDer = function(oid) {
|
|
|
3067
3077
|
last = true;
|
|
3068
3078
|
valueBytes = [];
|
|
3069
3079
|
value = parseInt(values[i], 10);
|
|
3080
|
+
if (value > 4294967295) {
|
|
3081
|
+
throw new Error("OID value too large; max is 32-bits.");
|
|
3082
|
+
}
|
|
3070
3083
|
do {
|
|
3071
3084
|
b = value & 127;
|
|
3072
3085
|
value = value >>> 7;
|
|
@@ -3091,8 +3104,11 @@ asn1$8.derToOid = function(bytes) {
|
|
|
3091
3104
|
oid = Math.floor(b / 40) + "." + b % 40;
|
|
3092
3105
|
var value = 0;
|
|
3093
3106
|
while (bytes.length() > 0) {
|
|
3107
|
+
if (value > 70368744177663) {
|
|
3108
|
+
throw new Error("OID value too large; max is 53-bits.");
|
|
3109
|
+
}
|
|
3094
3110
|
b = bytes.getByte();
|
|
3095
|
-
value = value
|
|
3111
|
+
value = value * 128;
|
|
3096
3112
|
if (b & 128) {
|
|
3097
3113
|
value += b & 127;
|
|
3098
3114
|
} else {
|
|
@@ -3253,19 +3269,40 @@ asn1$8.validate = function(obj, v, capture, errors) {
|
|
|
3253
3269
|
if (v.value && forge$w.util.isArray(v.value)) {
|
|
3254
3270
|
var j = 0;
|
|
3255
3271
|
for (var i = 0; rval && i < v.value.length; ++i) {
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3272
|
+
var schemaItem = v.value[i];
|
|
3273
|
+
rval = !!schemaItem.optional;
|
|
3274
|
+
var objChild = obj.value[j];
|
|
3275
|
+
if (!objChild) {
|
|
3276
|
+
if (!schemaItem.optional) {
|
|
3277
|
+
rval = false;
|
|
3278
|
+
if (errors) {
|
|
3279
|
+
errors.push("[" + v.name + '] Missing required element. Expected tag class "' + schemaItem.tagClass + '", type "' + schemaItem.type + '"');
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
continue;
|
|
3283
|
+
}
|
|
3284
|
+
var schemaHasTag = typeof schemaItem.tagClass !== "undefined" && typeof schemaItem.type !== "undefined";
|
|
3285
|
+
if (schemaHasTag && (objChild.tagClass !== schemaItem.tagClass || objChild.type !== schemaItem.type)) {
|
|
3286
|
+
if (schemaItem.optional) {
|
|
3262
3287
|
rval = true;
|
|
3288
|
+
continue;
|
|
3289
|
+
} else {
|
|
3290
|
+
rval = false;
|
|
3291
|
+
if (errors) {
|
|
3292
|
+
errors.push("[" + v.name + "] Tag mismatch. Expected (" + schemaItem.tagClass + "," + schemaItem.type + "), got (" + objChild.tagClass + "," + objChild.type + ")");
|
|
3293
|
+
}
|
|
3294
|
+
break;
|
|
3263
3295
|
}
|
|
3264
3296
|
}
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3297
|
+
var childRval = asn1$8.validate(objChild, schemaItem, capture, errors);
|
|
3298
|
+
if (childRval) {
|
|
3299
|
+
++j;
|
|
3300
|
+
rval = true;
|
|
3301
|
+
} else if (schemaItem.optional) {
|
|
3302
|
+
rval = true;
|
|
3303
|
+
} else {
|
|
3304
|
+
rval = false;
|
|
3305
|
+
break;
|
|
3269
3306
|
}
|
|
3270
3307
|
}
|
|
3271
3308
|
}
|
|
@@ -7173,7 +7210,7 @@ var digestInfoValidator = {
|
|
|
7173
7210
|
constructed: false,
|
|
7174
7211
|
capture: "algorithmIdentifier"
|
|
7175
7212
|
}, {
|
|
7176
|
-
// NULL
|
|
7213
|
+
// NULL parameters
|
|
7177
7214
|
name: "DigestInfo.DigestAlgorithm.parameters",
|
|
7178
7215
|
tagClass: asn1$7.Class.UNIVERSAL,
|
|
7179
7216
|
type: asn1$7.Type.NULL,
|
|
@@ -7686,7 +7723,7 @@ pki$4.setRsaPublicKey = pki$4.rsa.setPublicKey = function(n, e) {
|
|
|
7686
7723
|
if (oid === forge$h.oids.md2 || oid === forge$h.oids.md5) {
|
|
7687
7724
|
if (!("parameters" in capture)) {
|
|
7688
7725
|
throw new Error(
|
|
7689
|
-
"ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm
|
|
7726
|
+
"ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters."
|
|
7690
7727
|
);
|
|
7691
7728
|
}
|
|
7692
7729
|
}
|
|
@@ -9842,6 +9879,7 @@ var _readSignatureParameters = function(oid, obj, fillDefaults) {
|
|
|
9842
9879
|
var _createSignatureDigest = function(options) {
|
|
9843
9880
|
switch (oids[options.signatureOid]) {
|
|
9844
9881
|
case "sha1WithRSAEncryption":
|
|
9882
|
+
// deprecated alias
|
|
9845
9883
|
case "sha1WithRSASignature":
|
|
9846
9884
|
return forge$b.md.sha1.create();
|
|
9847
9885
|
case "md5WithRSAEncryption":
|
|
@@ -9867,6 +9905,7 @@ var _verifySignature = function(options) {
|
|
|
9867
9905
|
var scheme;
|
|
9868
9906
|
switch (cert.signatureOid) {
|
|
9869
9907
|
case oids.sha1WithRSAEncryption:
|
|
9908
|
+
// deprecated alias
|
|
9870
9909
|
case oids.sha1WithRSASignature:
|
|
9871
9910
|
break;
|
|
9872
9911
|
case oids["RSASSA-PSS"]:
|
|
@@ -10357,13 +10396,18 @@ pki$2.certificateExtensionFromAsn1 = function(ext) {
|
|
|
10357
10396
|
};
|
|
10358
10397
|
e.altNames.push(altName);
|
|
10359
10398
|
switch (gn.type) {
|
|
10399
|
+
// rfc822Name
|
|
10360
10400
|
case 1:
|
|
10401
|
+
// dNSName
|
|
10361
10402
|
case 2:
|
|
10403
|
+
// uniformResourceIdentifier (URI)
|
|
10362
10404
|
case 6:
|
|
10363
10405
|
break;
|
|
10406
|
+
// IPAddress
|
|
10364
10407
|
case 7:
|
|
10365
10408
|
altName.ip = forge$b.util.bytesToIP(gn.value);
|
|
10366
10409
|
break;
|
|
10410
|
+
// registeredID
|
|
10367
10411
|
case 8:
|
|
10368
10412
|
altName.oid = asn1$4.derToOid(gn.value);
|
|
10369
10413
|
break;
|
|
@@ -11517,6 +11561,7 @@ var pfxValidator = {
|
|
|
11517
11561
|
capture: "macAlgorithm"
|
|
11518
11562
|
}, {
|
|
11519
11563
|
name: "PFX.macData.mac.digestAlgorithm.parameters",
|
|
11564
|
+
optional: true,
|
|
11520
11565
|
tagClass: asn1$3.Class.UNIVERSAL,
|
|
11521
11566
|
captureAsn1: "macAlgorithmParameters"
|
|
11522
11567
|
}]
|
|
@@ -11795,6 +11840,8 @@ p12.pkcs12FromAsn1 = function(obj, strict, password) {
|
|
|
11795
11840
|
if (macValue.getBytes() !== capture.macDigest) {
|
|
11796
11841
|
throw new Error("PKCS#12 MAC could not be verified. Invalid password?");
|
|
11797
11842
|
}
|
|
11843
|
+
} else if (Array.isArray(obj.value) && obj.value.length > 2) {
|
|
11844
|
+
throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");
|
|
11798
11845
|
}
|
|
11799
11846
|
_decodeAuthenticatedSafe(pfx, data.value, strict, password);
|
|
11800
11847
|
return pfx;
|
|
@@ -11915,6 +11962,7 @@ function _decodeSafeContents(safeContents, strict, password) {
|
|
|
11915
11962
|
"Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?"
|
|
11916
11963
|
);
|
|
11917
11964
|
}
|
|
11965
|
+
/* fall through */
|
|
11918
11966
|
case pki$1.oids.keyBag:
|
|
11919
11967
|
try {
|
|
11920
11968
|
bag.key = pki$1.privateKeyFromAsn1(bagAsn1);
|
|
@@ -11923,6 +11971,7 @@ function _decodeSafeContents(safeContents, strict, password) {
|
|
|
11923
11971
|
bag.asn1 = bagAsn1;
|
|
11924
11972
|
}
|
|
11925
11973
|
continue;
|
|
11974
|
+
/* Nothing more to do. */
|
|
11926
11975
|
case pki$1.oids.certBag:
|
|
11927
11976
|
validator = certBagValidator;
|
|
11928
11977
|
decoder = function() {
|
|
@@ -17420,7 +17469,10 @@ class ForgeEncrypt {
|
|
|
17420
17469
|
}
|
|
17421
17470
|
try {
|
|
17422
17471
|
const encryptedBytes = lib.util.decode64(encryptedData);
|
|
17423
|
-
const decrypted = this.privateKey.decrypt(
|
|
17472
|
+
const decrypted = this.privateKey.decrypt(
|
|
17473
|
+
encryptedBytes,
|
|
17474
|
+
"RSAES-PKCS1-V1_5"
|
|
17475
|
+
);
|
|
17424
17476
|
return decrypted;
|
|
17425
17477
|
} catch (error) {
|
|
17426
17478
|
return false;
|
|
@@ -17485,12 +17537,16 @@ const OperatorPublicKeyValidator$1 = (publicKey) => {
|
|
|
17485
17537
|
let decodedPublicKey = "";
|
|
17486
17538
|
if (!publicKey.startsWith(begin)) {
|
|
17487
17539
|
if (publicKey.length < 98) {
|
|
17488
|
-
throw new Error(
|
|
17540
|
+
throw new Error(
|
|
17541
|
+
"The length of the operator public key must be at least 98 characters."
|
|
17542
|
+
);
|
|
17489
17543
|
}
|
|
17490
17544
|
try {
|
|
17491
17545
|
decodedPublicKey = lib.util.decode64(publicKey).trim();
|
|
17492
17546
|
} catch (error) {
|
|
17493
|
-
throw new Error(
|
|
17547
|
+
throw new Error(
|
|
17548
|
+
"Failed to decode the operator public key. Ensure it's correctly base64 encoded."
|
|
17549
|
+
);
|
|
17494
17550
|
}
|
|
17495
17551
|
if (!decodedPublicKey.startsWith(begin)) {
|
|
17496
17552
|
throw new Error(`Operator public key does not start with '${begin}'`);
|
|
@@ -17505,12 +17561,16 @@ const OperatorPublicKeyValidator$1 = (publicKey) => {
|
|
|
17505
17561
|
const content = decodedPublicKey.slice(begin.length, publicKey.length - end.length).trim();
|
|
17506
17562
|
decodedOperator = lib.util.decode64(content);
|
|
17507
17563
|
} catch {
|
|
17508
|
-
throw new Error(
|
|
17564
|
+
throw new Error(
|
|
17565
|
+
"Failed to decode the RSA public key. Ensure it's correctly base64 encoded."
|
|
17566
|
+
);
|
|
17509
17567
|
}
|
|
17510
17568
|
try {
|
|
17511
17569
|
encrypt.setPublicKey(decodedOperator);
|
|
17512
17570
|
} catch {
|
|
17513
|
-
throw new Error(
|
|
17571
|
+
throw new Error(
|
|
17572
|
+
"Invalid operator key format, make sure the operator exists in the network."
|
|
17573
|
+
);
|
|
17514
17574
|
}
|
|
17515
17575
|
} catch (error) {
|
|
17516
17576
|
throw new OperatorPublicKeyError(
|
|
@@ -17554,7 +17614,10 @@ class Threshold {
|
|
|
17554
17614
|
*/
|
|
17555
17615
|
async create(privateKeyString, operatorIds) {
|
|
17556
17616
|
if (!privateKeyString.startsWith("0x")) {
|
|
17557
|
-
throw new PrivateKeyFormatError(
|
|
17617
|
+
throw new PrivateKeyFormatError(
|
|
17618
|
+
privateKeyString,
|
|
17619
|
+
"The private key must be provided in the 0x format."
|
|
17620
|
+
);
|
|
17558
17621
|
}
|
|
17559
17622
|
operatorIds.map((operatorId) => {
|
|
17560
17623
|
if (!Number.isInteger(operatorId)) {
|
|
@@ -17575,7 +17638,9 @@ class Threshold {
|
|
|
17575
17638
|
if (!bls.deserializeHexStrToSecretKey) {
|
|
17576
17639
|
await bls.init(bls.BLS12_381);
|
|
17577
17640
|
}
|
|
17578
|
-
this.privateKey = bls.deserializeHexStrToSecretKey(
|
|
17641
|
+
this.privateKey = bls.deserializeHexStrToSecretKey(
|
|
17642
|
+
privateKeyString.replace("0x", "")
|
|
17643
|
+
);
|
|
17579
17644
|
this.publicKey = this.privateKey.getPublicKey();
|
|
17580
17645
|
msk.push(this.privateKey);
|
|
17581
17646
|
mpk.push(this.publicKey);
|
|
@@ -17609,7 +17674,7 @@ class Threshold {
|
|
|
17609
17674
|
}
|
|
17610
17675
|
}
|
|
17611
17676
|
var scrypt = { exports: {} };
|
|
17612
|
-
(function(module2,
|
|
17677
|
+
(function(module2, exports$1) {
|
|
17613
17678
|
(function(root) {
|
|
17614
17679
|
const MAX_VALUE = 2147483647;
|
|
17615
17680
|
function SHA256(m) {
|
|
@@ -17949,6 +18014,7 @@ var scrypt = { exports: {} };
|
|
|
17949
18014
|
arraycopy(B, Bi, XY, 0, Yi);
|
|
17950
18015
|
state = 1;
|
|
17951
18016
|
i1 = 0;
|
|
18017
|
+
// Fall through
|
|
17952
18018
|
case 1:
|
|
17953
18019
|
steps = N - i1;
|
|
17954
18020
|
if (steps > limit) {
|
|
@@ -17975,6 +18041,7 @@ var scrypt = { exports: {} };
|
|
|
17975
18041
|
}
|
|
17976
18042
|
i1 = 0;
|
|
17977
18043
|
state = 2;
|
|
18044
|
+
// Fall through
|
|
17978
18045
|
case 2:
|
|
17979
18046
|
steps = N - i1;
|
|
17980
18047
|
if (steps > limit) {
|
|
@@ -18071,11 +18138,17 @@ class EthereumKeyStore {
|
|
|
18071
18138
|
privateKey = "";
|
|
18072
18139
|
constructor(keyStoreData) {
|
|
18073
18140
|
if (!keyStoreData) {
|
|
18074
|
-
throw new KeyStoreDataFormatError(
|
|
18141
|
+
throw new KeyStoreDataFormatError(
|
|
18142
|
+
keyStoreData,
|
|
18143
|
+
"Key store data should be JSON or string"
|
|
18144
|
+
);
|
|
18075
18145
|
}
|
|
18076
18146
|
this.keyStoreData = typeof keyStoreData === "string" ? JSON.parse(keyStoreData) : keyStoreData;
|
|
18077
18147
|
if (!this.keyStoreData.version) {
|
|
18078
|
-
throw new KeyStoreInvalidError(
|
|
18148
|
+
throw new KeyStoreInvalidError(
|
|
18149
|
+
this.keyStoreData,
|
|
18150
|
+
"Invalid keystore file"
|
|
18151
|
+
);
|
|
18079
18152
|
}
|
|
18080
18153
|
}
|
|
18081
18154
|
// getPublicKey(): string {
|
|
@@ -18115,15 +18188,32 @@ class EthereumKeyStore {
|
|
|
18115
18188
|
const dklen = kdfparams.dklen;
|
|
18116
18189
|
let derivedKey;
|
|
18117
18190
|
if (json.crypto.kdf === "scrypt") {
|
|
18118
|
-
derivedKey = scryptExports.syncScrypt(
|
|
18191
|
+
derivedKey = scryptExports.syncScrypt(
|
|
18192
|
+
Buffer.from(password),
|
|
18193
|
+
salt,
|
|
18194
|
+
kdfparams.n,
|
|
18195
|
+
kdfparams.r,
|
|
18196
|
+
kdfparams.p,
|
|
18197
|
+
dklen
|
|
18198
|
+
);
|
|
18119
18199
|
} else if (json.crypto.kdf === "pbkdf2") {
|
|
18120
|
-
if (kdfparams.prf !== "hmac-sha256")
|
|
18121
|
-
|
|
18200
|
+
if (kdfparams.prf !== "hmac-sha256")
|
|
18201
|
+
throw new EthereumWalletError("Unsupported PBKDF2 params");
|
|
18202
|
+
derivedKey = crypto$1.pbkdf2Sync(
|
|
18203
|
+
Buffer.from(password),
|
|
18204
|
+
salt,
|
|
18205
|
+
kdfparams.c,
|
|
18206
|
+
dklen,
|
|
18207
|
+
"sha256"
|
|
18208
|
+
);
|
|
18122
18209
|
} else {
|
|
18123
18210
|
throw new EthereumWalletError("Unsupported kdf type");
|
|
18124
18211
|
}
|
|
18125
18212
|
const ciphertext = Buffer.from(json.crypto.ciphertext, "hex");
|
|
18126
|
-
const macCheck = Buffer.concat([
|
|
18213
|
+
const macCheck = Buffer.concat([
|
|
18214
|
+
Buffer.from(derivedKey.slice(16, 32)),
|
|
18215
|
+
ciphertext
|
|
18216
|
+
]);
|
|
18127
18217
|
const mac = viem.keccak256(viem.toHex(macCheck)).replace(/^0x/, "");
|
|
18128
18218
|
if (mac !== json.crypto.mac.toLowerCase()) {
|
|
18129
18219
|
throw new EthereumWalletError("Invalid password");
|
|
@@ -18152,12 +18242,21 @@ class EthereumKeyStore {
|
|
|
18152
18242
|
if (prf !== "hmac-sha256") {
|
|
18153
18243
|
throw new EthereumWalletError("Unsupported parameters to PBKDF2");
|
|
18154
18244
|
}
|
|
18155
|
-
derivedKey = crypto$1.pbkdf2Sync(
|
|
18245
|
+
derivedKey = crypto$1.pbkdf2Sync(
|
|
18246
|
+
Buffer.from(password),
|
|
18247
|
+
salt,
|
|
18248
|
+
c,
|
|
18249
|
+
dklen,
|
|
18250
|
+
"sha256"
|
|
18251
|
+
);
|
|
18156
18252
|
} else {
|
|
18157
18253
|
throw new EthereumWalletError("Unsupported key derivation scheme");
|
|
18158
18254
|
}
|
|
18159
18255
|
const ciphertext = Buffer.from(cipher.message, "hex");
|
|
18160
|
-
const checksumBuffer = Buffer.concat([
|
|
18256
|
+
const checksumBuffer = Buffer.concat([
|
|
18257
|
+
Buffer.from(derivedKey.slice(16, 32)),
|
|
18258
|
+
ciphertext
|
|
18259
|
+
]);
|
|
18161
18260
|
const hashFn = checksum.function === "sha256" ? viem.sha256 : viem.keccak256;
|
|
18162
18261
|
const calculatedMac = hashFn(viem.toHex(checksumBuffer));
|
|
18163
18262
|
if (calculatedMac.replace(/^0x/, "") !== checksum.message.toLowerCase()) {
|
|
@@ -18192,7 +18291,9 @@ class Encryption {
|
|
|
18192
18291
|
OperatorPublicKeyValidator$1(operatorPublicKey);
|
|
18193
18292
|
const forgeEncrypt = new ForgeEncrypt();
|
|
18194
18293
|
forgeEncrypt.setPublicKey(operatorPublicKey);
|
|
18195
|
-
const encryptedPrivateKey = forgeEncrypt.encrypt(
|
|
18294
|
+
const encryptedPrivateKey = forgeEncrypt.encrypt(
|
|
18295
|
+
this.shares[idx].privateKey
|
|
18296
|
+
);
|
|
18196
18297
|
if (!encryptedPrivateKey) {
|
|
18197
18298
|
throw new OperatorPublicKeyError(
|
|
18198
18299
|
{
|
|
@@ -18283,10 +18384,18 @@ const operatorSortedList = (operators) => {
|
|
|
18283
18384
|
const validatedOperators = operators.map((operator) => {
|
|
18284
18385
|
const id = parseInt(`${operator.id}`, 10);
|
|
18285
18386
|
if (isNaN(id)) {
|
|
18286
|
-
throw new OperatorsCountsMismatchError(
|
|
18387
|
+
throw new OperatorsCountsMismatchError(
|
|
18388
|
+
ids,
|
|
18389
|
+
operatorKeys,
|
|
18390
|
+
`Invalid operator ID: ${operator.id}`
|
|
18391
|
+
);
|
|
18287
18392
|
}
|
|
18288
18393
|
if (!operator.operatorKey) {
|
|
18289
|
-
throw new OperatorsCountsMismatchError(
|
|
18394
|
+
throw new OperatorsCountsMismatchError(
|
|
18395
|
+
ids,
|
|
18396
|
+
operatorKeys,
|
|
18397
|
+
`Operator key is missing for operator ID: ${id}`
|
|
18398
|
+
);
|
|
18290
18399
|
}
|
|
18291
18400
|
return { ...operator, id };
|
|
18292
18401
|
});
|
|
@@ -18308,14 +18417,18 @@ class SingleSharesSignatureInvalid extends SSVKeysException {
|
|
|
18308
18417
|
}
|
|
18309
18418
|
}
|
|
18310
18419
|
const hexArrayToBytes = (hexArr) => {
|
|
18311
|
-
const uint8Array = new Uint8Array(
|
|
18420
|
+
const uint8Array = new Uint8Array(
|
|
18421
|
+
hexArr.flatMap((hex) => Array.from(viem.toBytes(hex)))
|
|
18422
|
+
);
|
|
18312
18423
|
return Buffer.from(uint8Array);
|
|
18313
18424
|
};
|
|
18314
18425
|
const buildSignature = async (dataToSign, privateKeyHex) => {
|
|
18315
18426
|
if (!bls.deserializeHexStrToSecretKey) {
|
|
18316
18427
|
await bls.init(bls.BLS12_381);
|
|
18317
18428
|
}
|
|
18318
|
-
const privateKey = bls.deserializeHexStrToSecretKey(
|
|
18429
|
+
const privateKey = bls.deserializeHexStrToSecretKey(
|
|
18430
|
+
privateKeyHex.replace("0x", "")
|
|
18431
|
+
);
|
|
18319
18432
|
const messageHash = viem.keccak256(viem.toBytes(dataToSign));
|
|
18320
18433
|
const messageBytes = viem.fromHex(messageHash, "bytes");
|
|
18321
18434
|
const signature = privateKey.sign(messageBytes);
|
|
@@ -18323,12 +18436,19 @@ const buildSignature = async (dataToSign, privateKeyHex) => {
|
|
|
18323
18436
|
return `0x${signatureHex}`;
|
|
18324
18437
|
};
|
|
18325
18438
|
const validateSignature = async (signedData, signatureHex, publicKey) => {
|
|
18326
|
-
const blsPublicKey = bls.deserializeHexStrToPublicKey(
|
|
18327
|
-
|
|
18439
|
+
const blsPublicKey = bls.deserializeHexStrToPublicKey(
|
|
18440
|
+
publicKey.replace("0x", "")
|
|
18441
|
+
);
|
|
18442
|
+
const signature = bls.deserializeHexStrToSignature(
|
|
18443
|
+
signatureHex.replace("0x", "")
|
|
18444
|
+
);
|
|
18328
18445
|
const messageHashHex = viem.keccak256(viem.toBytes(signedData));
|
|
18329
18446
|
const messageHashBytes = viem.fromHex(messageHashHex, "bytes");
|
|
18330
18447
|
if (!blsPublicKey.verify(signature, messageHashBytes)) {
|
|
18331
|
-
throw new SingleSharesSignatureInvalid(
|
|
18448
|
+
throw new SingleSharesSignatureInvalid(
|
|
18449
|
+
signatureHex,
|
|
18450
|
+
"Single shares signature is invalid"
|
|
18451
|
+
);
|
|
18332
18452
|
}
|
|
18333
18453
|
};
|
|
18334
18454
|
const privateToPublicKey = async (privateKey) => {
|
|
@@ -18350,11 +18470,17 @@ let OpeatorsListValidatorConstraint = class {
|
|
|
18350
18470
|
const operatorIds = /* @__PURE__ */ new Set(), operatorPublicKeys = /* @__PURE__ */ new Set();
|
|
18351
18471
|
for (const operator of operatorsList || []) {
|
|
18352
18472
|
if (operatorIds.has(operator.id)) {
|
|
18353
|
-
throw new DuplicatedOperatorIdError(
|
|
18473
|
+
throw new DuplicatedOperatorIdError(
|
|
18474
|
+
operator,
|
|
18475
|
+
`The operator ID '${operator.id}' is duplicated in the list`
|
|
18476
|
+
);
|
|
18354
18477
|
}
|
|
18355
18478
|
operatorIds.add(operator.id);
|
|
18356
18479
|
if (operatorPublicKeys.has(operator.operatorKey)) {
|
|
18357
|
-
throw new DuplicatedOperatorPublicKeyError(
|
|
18480
|
+
throw new DuplicatedOperatorPublicKeyError(
|
|
18481
|
+
operator,
|
|
18482
|
+
`The public key for operator ID ${operator.id} is duplicated in the list`
|
|
18483
|
+
);
|
|
18358
18484
|
}
|
|
18359
18485
|
operatorPublicKeys.add(operator.operatorKey);
|
|
18360
18486
|
}
|
|
@@ -18392,10 +18518,15 @@ let PublicKeyValidatorConstraint = class {
|
|
|
18392
18518
|
if (typeof value === "string") {
|
|
18393
18519
|
bls.deserializeHexStrToPublicKey(value.replace("0x", ""));
|
|
18394
18520
|
} else {
|
|
18395
|
-
value.forEach(
|
|
18521
|
+
value.forEach(
|
|
18522
|
+
(item) => bls.deserializeHexStrToPublicKey(item.replace("0x", ""))
|
|
18523
|
+
);
|
|
18396
18524
|
}
|
|
18397
18525
|
} catch (e) {
|
|
18398
|
-
throw new BLSDeserializeError(
|
|
18526
|
+
throw new BLSDeserializeError(
|
|
18527
|
+
value,
|
|
18528
|
+
"Failed to BLS deserialize validator public key"
|
|
18529
|
+
);
|
|
18399
18530
|
}
|
|
18400
18531
|
return true;
|
|
18401
18532
|
}
|
|
@@ -18435,7 +18566,10 @@ let OwnerAddressValidatorConstraint = class {
|
|
|
18435
18566
|
try {
|
|
18436
18567
|
viem.getAddress(value);
|
|
18437
18568
|
} catch {
|
|
18438
|
-
throw new OwnerAddressFormatError(
|
|
18569
|
+
throw new OwnerAddressFormatError(
|
|
18570
|
+
value,
|
|
18571
|
+
"Owner address is not a valid Ethereum address"
|
|
18572
|
+
);
|
|
18439
18573
|
}
|
|
18440
18574
|
return true;
|
|
18441
18575
|
}
|
|
@@ -18468,7 +18602,10 @@ var __decorateClass$5 = (decorators, target, key, kind) => {
|
|
|
18468
18602
|
let OwnerNonceValidatorConstraint = class {
|
|
18469
18603
|
validate(value) {
|
|
18470
18604
|
if (!Number.isInteger(value) || value < 0) {
|
|
18471
|
-
throw new OwnerNonceFormatError(
|
|
18605
|
+
throw new OwnerNonceFormatError(
|
|
18606
|
+
value,
|
|
18607
|
+
"Owner nonce is not positive integer"
|
|
18608
|
+
);
|
|
18472
18609
|
}
|
|
18473
18610
|
return true;
|
|
18474
18611
|
}
|
|
@@ -18505,12 +18642,20 @@ let MatchLengthValidatorConstraint = class {
|
|
|
18505
18642
|
if (!Array.isArray(value)) {
|
|
18506
18643
|
Object.values(value).forEach((arr) => {
|
|
18507
18644
|
if (relatedLength !== arr.length) {
|
|
18508
|
-
throw new OperatorsCountsMismatchError(
|
|
18645
|
+
throw new OperatorsCountsMismatchError(
|
|
18646
|
+
args.object[relatedPropertyName],
|
|
18647
|
+
value,
|
|
18648
|
+
customError.message
|
|
18649
|
+
);
|
|
18509
18650
|
}
|
|
18510
18651
|
});
|
|
18511
18652
|
} else {
|
|
18512
18653
|
if (relatedLength !== value.length) {
|
|
18513
|
-
throw new OperatorsCountsMismatchError(
|
|
18654
|
+
throw new OperatorsCountsMismatchError(
|
|
18655
|
+
args.object[relatedPropertyName],
|
|
18656
|
+
value,
|
|
18657
|
+
customError.message
|
|
18658
|
+
);
|
|
18514
18659
|
}
|
|
18515
18660
|
}
|
|
18516
18661
|
return true;
|
|
@@ -18690,7 +18835,10 @@ const _KeySharesItem = class _KeySharesItem2 {
|
|
|
18690
18835
|
async buildPayload(metaData, toSignatureData) {
|
|
18691
18836
|
const { ownerAddress, ownerNonce, privateKey } = toSignatureData;
|
|
18692
18837
|
if (!Number.isInteger(ownerNonce) || ownerNonce < 0) {
|
|
18693
|
-
throw new OwnerNonceFormatError(
|
|
18838
|
+
throw new OwnerNonceFormatError(
|
|
18839
|
+
ownerNonce,
|
|
18840
|
+
"Owner nonce is not positive integer"
|
|
18841
|
+
);
|
|
18694
18842
|
}
|
|
18695
18843
|
let address;
|
|
18696
18844
|
try {
|
|
@@ -18703,10 +18851,15 @@ const _KeySharesItem = class _KeySharesItem2 {
|
|
|
18703
18851
|
}
|
|
18704
18852
|
const payload = this.payload.build({
|
|
18705
18853
|
publicKey: metaData.publicKey,
|
|
18706
|
-
operatorIds: operatorSortedList(metaData.operators).map(
|
|
18854
|
+
operatorIds: operatorSortedList(metaData.operators).map(
|
|
18855
|
+
(operator) => operator.id
|
|
18856
|
+
),
|
|
18707
18857
|
encryptedShares: metaData.encryptedShares
|
|
18708
18858
|
});
|
|
18709
|
-
const signature = await buildSignature(
|
|
18859
|
+
const signature = await buildSignature(
|
|
18860
|
+
`${address}:${ownerNonce}`,
|
|
18861
|
+
privateKey
|
|
18862
|
+
);
|
|
18710
18863
|
const signSharesBytes = hexArrayToBytes([signature, payload.sharesData]);
|
|
18711
18864
|
payload.sharesData = `0x${signSharesBytes.toString("hex")}`;
|
|
18712
18865
|
await this.validateSingleShares(payload.sharesData, {
|
|
@@ -18719,11 +18872,18 @@ const _KeySharesItem = class _KeySharesItem2 {
|
|
|
18719
18872
|
async validateSingleShares(shares, fromSignatureData) {
|
|
18720
18873
|
const { ownerAddress, ownerNonce, publicKey } = fromSignatureData;
|
|
18721
18874
|
if (!Number.isInteger(ownerNonce) || ownerNonce < 0) {
|
|
18722
|
-
throw new OwnerNonceFormatError(
|
|
18875
|
+
throw new OwnerNonceFormatError(
|
|
18876
|
+
ownerNonce,
|
|
18877
|
+
"Owner nonce is not positive integer"
|
|
18878
|
+
);
|
|
18723
18879
|
}
|
|
18724
18880
|
const address = viem.getAddress(ownerAddress);
|
|
18725
18881
|
const signaturePt = shares.replace("0x", "").substring(0, SIGNATURE_LENGTH);
|
|
18726
|
-
await validateSignature(
|
|
18882
|
+
await validateSignature(
|
|
18883
|
+
`${address}:${ownerNonce}`,
|
|
18884
|
+
`0x${signaturePt}`,
|
|
18885
|
+
publicKey
|
|
18886
|
+
);
|
|
18727
18887
|
}
|
|
18728
18888
|
/**
|
|
18729
18889
|
* Build shares from bytes string and operators list length
|
|
@@ -18740,7 +18900,9 @@ const _KeySharesItem = class _KeySharesItem2 {
|
|
|
18740
18900
|
const sharesPt = bytes.slice(2 + SIGNATURE_LENGTH);
|
|
18741
18901
|
const pkSplit = sharesPt.substring(0, operatorCount * PUBLIC_KEY_LENGTH);
|
|
18742
18902
|
const pkBytes = viem.toBytes("0x" + pkSplit);
|
|
18743
|
-
const sharesPublicKeys = this.splitArray(operatorCount, pkBytes).map(
|
|
18903
|
+
const sharesPublicKeys = this.splitArray(operatorCount, pkBytes).map(
|
|
18904
|
+
(item) => viem.toHex(item)
|
|
18905
|
+
);
|
|
18744
18906
|
const eSplit = bytes.substring(operatorCount * PUBLIC_KEY_LENGTH);
|
|
18745
18907
|
const eBytes = viem.toBytes("0x" + eSplit);
|
|
18746
18908
|
const encryptedKeys = this.splitArray(operatorCount, eBytes).map(
|
|
@@ -18842,7 +19004,10 @@ class SSVKeys {
|
|
|
18842
19004
|
*/
|
|
18843
19005
|
async createThreshold(privateKey, operators) {
|
|
18844
19006
|
const sortedOperators = operatorSortedList(operators);
|
|
18845
|
-
this.threshold = await new Threshold().create(
|
|
19007
|
+
this.threshold = await new Threshold().create(
|
|
19008
|
+
privateKey,
|
|
19009
|
+
sortedOperators.map((item) => item.id)
|
|
19010
|
+
);
|
|
18846
19011
|
return this.threshold;
|
|
18847
19012
|
}
|
|
18848
19013
|
/**
|
|
@@ -18852,7 +19017,9 @@ class SSVKeys {
|
|
|
18852
19017
|
*/
|
|
18853
19018
|
async encryptShares(operators, shares) {
|
|
18854
19019
|
const sortedOperators = operatorSortedList(operators);
|
|
18855
|
-
const decodedOperatorPublicKeys = sortedOperators.map(
|
|
19020
|
+
const decodedOperatorPublicKeys = sortedOperators.map(
|
|
19021
|
+
(item) => Buffer.from(item.operatorKey, "base64").toString()
|
|
19022
|
+
);
|
|
18856
19023
|
return new Encryption(decodedOperatorPublicKeys, shares).encrypt();
|
|
18857
19024
|
}
|
|
18858
19025
|
/**
|
|
@@ -18888,7 +19055,10 @@ class SSVKeys {
|
|
|
18888
19055
|
let signatureErrorMessage = "";
|
|
18889
19056
|
let errorMessage = "";
|
|
18890
19057
|
try {
|
|
18891
|
-
const restoredShares = keySharesItem.buildSharesFromBytes(
|
|
19058
|
+
const restoredShares = keySharesItem.buildSharesFromBytes(
|
|
19059
|
+
shares,
|
|
19060
|
+
operatorsCount
|
|
19061
|
+
);
|
|
18892
19062
|
const { sharesPublicKeys, encryptedKeys } = restoredShares;
|
|
18893
19063
|
restoredSharesPublicKeys = sharesPublicKeys;
|
|
18894
19064
|
restoredSharesEncryptedKeys = encryptedKeys;
|
|
@@ -18898,7 +19068,11 @@ class SSVKeys {
|
|
|
18898
19068
|
errorMessage = "Can not extract shares from bytes";
|
|
18899
19069
|
}
|
|
18900
19070
|
if (!sharesError && !errorMessage) {
|
|
18901
|
-
const signatureData = {
|
|
19071
|
+
const signatureData = {
|
|
19072
|
+
ownerNonce,
|
|
19073
|
+
publicKey: validatorPublicKey,
|
|
19074
|
+
ownerAddress
|
|
19075
|
+
};
|
|
18902
19076
|
try {
|
|
18903
19077
|
await keySharesItem.validateSingleShares(shares, signatureData);
|
|
18904
19078
|
} catch (e) {
|
|
@@ -18921,12 +19095,14 @@ class SSVKeys {
|
|
|
18921
19095
|
isSharesValid: !sharesError,
|
|
18922
19096
|
sharesPublicKeys: restoredSharesPublicKeys,
|
|
18923
19097
|
encryptedKeys: restoredSharesEncryptedKeys,
|
|
18924
|
-
memo: !!sharesError || !!signatureError ? [
|
|
18925
|
-
|
|
18926
|
-
|
|
18927
|
-
|
|
18928
|
-
|
|
18929
|
-
|
|
19098
|
+
memo: !!sharesError || !!signatureError ? [
|
|
19099
|
+
{
|
|
19100
|
+
message: errorMessage,
|
|
19101
|
+
error: sharesError || signatureError,
|
|
19102
|
+
data: `${sharesErrorMessage}${signatureErrorMessage ? ". " + signatureErrorMessage : ""}`,
|
|
19103
|
+
blockNumber
|
|
19104
|
+
}
|
|
19105
|
+
] : []
|
|
18930
19106
|
};
|
|
18931
19107
|
}
|
|
18932
19108
|
}
|
|
@@ -18945,19 +19121,19 @@ var constants = {
|
|
|
18945
19121
|
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1
|
|
18946
19122
|
};
|
|
18947
19123
|
var re$1 = { exports: {} };
|
|
18948
|
-
(function(module2,
|
|
19124
|
+
(function(module2, exports$1) {
|
|
18949
19125
|
const {
|
|
18950
19126
|
MAX_SAFE_COMPONENT_LENGTH: MAX_SAFE_COMPONENT_LENGTH2,
|
|
18951
19127
|
MAX_SAFE_BUILD_LENGTH: MAX_SAFE_BUILD_LENGTH2,
|
|
18952
19128
|
MAX_LENGTH: MAX_LENGTH2
|
|
18953
19129
|
} = constants;
|
|
18954
19130
|
const debug2 = debug_1;
|
|
18955
|
-
|
|
18956
|
-
const re2 =
|
|
18957
|
-
const safeRe =
|
|
18958
|
-
const src =
|
|
18959
|
-
const safeSrc =
|
|
18960
|
-
const t2 =
|
|
19131
|
+
exports$1 = module2.exports = {};
|
|
19132
|
+
const re2 = exports$1.re = [];
|
|
19133
|
+
const safeRe = exports$1.safeRe = [];
|
|
19134
|
+
const src = exports$1.src = [];
|
|
19135
|
+
const safeSrc = exports$1.safeSrc = [];
|
|
19136
|
+
const t2 = exports$1.t = {};
|
|
18961
19137
|
let R = 0;
|
|
18962
19138
|
const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
18963
19139
|
const safeRegexReplacements = [
|
|
@@ -19010,18 +19186,18 @@ var re$1 = { exports: {} };
|
|
|
19010
19186
|
createToken("COERCERTLFULL", src[t2.COERCEFULL], true);
|
|
19011
19187
|
createToken("LONETILDE", "(?:~>?)");
|
|
19012
19188
|
createToken("TILDETRIM", `(\\s*)${src[t2.LONETILDE]}\\s+`, true);
|
|
19013
|
-
|
|
19189
|
+
exports$1.tildeTrimReplace = "$1~";
|
|
19014
19190
|
createToken("TILDE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAIN]}$`);
|
|
19015
19191
|
createToken("TILDELOOSE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAINLOOSE]}$`);
|
|
19016
19192
|
createToken("LONECARET", "(?:\\^)");
|
|
19017
19193
|
createToken("CARETTRIM", `(\\s*)${src[t2.LONECARET]}\\s+`, true);
|
|
19018
|
-
|
|
19194
|
+
exports$1.caretTrimReplace = "$1^";
|
|
19019
19195
|
createToken("CARET", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAIN]}$`);
|
|
19020
19196
|
createToken("CARETLOOSE", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAINLOOSE]}$`);
|
|
19021
19197
|
createToken("COMPARATORLOOSE", `^${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]})$|^$`);
|
|
19022
19198
|
createToken("COMPARATOR", `^${src[t2.GTLT]}\\s*(${src[t2.FULLPLAIN]})$|^$`);
|
|
19023
19199
|
createToken("COMPARATORTRIM", `(\\s*)${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]}|${src[t2.XRANGEPLAIN]})`, true);
|
|
19024
|
-
|
|
19200
|
+
exports$1.comparatorTrimReplace = "$1$2$3";
|
|
19025
19201
|
createToken("HYPHENRANGE", `^\\s*(${src[t2.XRANGEPLAIN]})\\s+-\\s+(${src[t2.XRANGEPLAIN]})\\s*$`);
|
|
19026
19202
|
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t2.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t2.XRANGEPLAINLOOSE]})\\s*$`);
|
|
19027
19203
|
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
@@ -19226,6 +19402,8 @@ let SemVer$2 = class SemVer {
|
|
|
19226
19402
|
this.inc("patch", identifier, identifierBase);
|
|
19227
19403
|
this.inc("pre", identifier, identifierBase);
|
|
19228
19404
|
break;
|
|
19405
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
19406
|
+
// prepatch.
|
|
19229
19407
|
case "prerelease":
|
|
19230
19408
|
if (this.prerelease.length === 0) {
|
|
19231
19409
|
this.inc("patch", identifier, identifierBase);
|
|
@@ -19259,6 +19437,8 @@ let SemVer$2 = class SemVer {
|
|
|
19259
19437
|
}
|
|
19260
19438
|
this.prerelease = [];
|
|
19261
19439
|
break;
|
|
19440
|
+
// This probably shouldn't be used publicly.
|
|
19441
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
19262
19442
|
case "pre": {
|
|
19263
19443
|
const base = Number(identifierBase) ? 1 : 0;
|
|
19264
19444
|
if (this.prerelease.length === 0) {
|