@degenerate/generic 0.4.0 → 0.6.0
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/_settings/cryptography-settings.d.ts +5 -1
- package/dist/_settings/cryptography-settings.d.ts.map +1 -1
- package/dist/_settings/cryptography-settings.js +5 -1
- package/dist/crypto/index.d.ts +5 -9
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +7 -9
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts +22 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.js +65 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts +11 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.js +15 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts +16 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/create-ed25519-signature.js +26 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts +25 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts.map +1 -0
- package/dist/crypto/signature/ed25519-primitives.js +65 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts +13 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/verify-ed25519-signature.js +31 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -0
- package/dist/errors/settlement/settlement-errors.d.ts +74 -0
- package/dist/errors/settlement/settlement-errors.d.ts.map +1 -0
- package/dist/errors/settlement/settlement-errors.js +93 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts +5 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts.map +1 -1
- package/dist/models/settlement/settlement-models.d.ts +221 -0
- package/dist/models/settlement/settlement-models.d.ts.map +1 -0
- package/dist/models/settlement/settlement-models.js +152 -0
- package/dist/models/share-data/share-data-persistence-models.d.ts +3 -0
- package/dist/models/share-data/share-data-persistence-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.d.ts +179 -3
- package/dist/models/shareblock/shareblock-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.js +95 -3
- package/package.json +3 -4
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts +0 -12
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.js +0 -54
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +0 -50
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.js +0 -51
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts +0 -10
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.js +0 -51
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts +0 -11
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/generate-key-pair.js +0 -49
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts +0 -15
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.js +0 -21
- package/dist/crypto/signature/create-crypto-signature.d.ts +0 -20
- package/dist/crypto/signature/create-crypto-signature.d.ts.map +0 -1
- package/dist/crypto/signature/create-crypto-signature.js +0 -26
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-data.js +0 -61
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-hash.js +0 -58
|
@@ -30,7 +30,11 @@ export declare enum EllipticalCurvesEncryption {
|
|
|
30
30
|
P521 = "p521"
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* This contains the values for the elliptical
|
|
33
|
+
* This contains the values for the elliptical curves for signing.
|
|
34
|
+
*
|
|
35
|
+
* `Curve25519 = 'ed25519'` selects the Edwards25519 curve, signed with true
|
|
36
|
+
* EdDSA (RFC 8032) via `@noble/ed25519`. `P521` is retained as a recorded curve
|
|
37
|
+
* label for persistence forward-compatibility; no shipped factory uses it.
|
|
34
38
|
*/
|
|
35
39
|
export declare enum EllipticalCurvesSigning {
|
|
36
40
|
Curve25519 = "ed25519",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cryptography-settings.d.ts","sourceRoot":"","sources":["../../src/_settings/cryptography-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;gBAIF,MAAM,CAAC,oBAAoB;;;;;;kBAMxB,MAAM,CAAC,QAAQ;CAC1C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAe,cAAc,CAAC;AACzD,eAAO,MAAM,WAAW,EAAY,cAAc,CAAC;AAGnD,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;GAEG;AACH,oBAAY,0BAA0B;IAClC,UAAU,eAAe;IACzB,IAAI,SAAS;CAChB;AAED
|
|
1
|
+
{"version":3,"file":"cryptography-settings.d.ts","sourceRoot":"","sources":["../../src/_settings/cryptography-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;gBAIF,MAAM,CAAC,oBAAoB;;;;;;kBAMxB,MAAM,CAAC,QAAQ;CAC1C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAe,cAAc,CAAC;AACzD,eAAO,MAAM,WAAW,EAAY,cAAc,CAAC;AAGnD,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;GAEG;AACH,oBAAY,0BAA0B;IAClC,UAAU,eAAe;IACzB,IAAI,SAAS;CAChB;AAED;;;;;;GAMG;AACH,oBAAY,uBAAuB;IAC/B,UAAU,YAAY;IACtB,IAAI,SAAS;CAChB"}
|
|
@@ -32,7 +32,11 @@ var EllipticalCurvesEncryption;
|
|
|
32
32
|
EllipticalCurvesEncryption["P521"] = "p521";
|
|
33
33
|
})(EllipticalCurvesEncryption || (exports.EllipticalCurvesEncryption = EllipticalCurvesEncryption = {}));
|
|
34
34
|
/**
|
|
35
|
-
* This contains the values for the elliptical
|
|
35
|
+
* This contains the values for the elliptical curves for signing.
|
|
36
|
+
*
|
|
37
|
+
* `Curve25519 = 'ed25519'` selects the Edwards25519 curve, signed with true
|
|
38
|
+
* EdDSA (RFC 8032) via `@noble/ed25519`. `P521` is retained as a recorded curve
|
|
39
|
+
* label for persistence forward-compatibility; no shipped factory uses it.
|
|
36
40
|
*/
|
|
37
41
|
var EllipticalCurvesSigning;
|
|
38
42
|
(function (EllipticalCurvesSigning) {
|
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
export * from './calculate-hash';
|
|
2
2
|
export * from './calculate-combined-hash';
|
|
3
3
|
export * from './private-public-keys/generation/create-256-private-key-from-mnemonic';
|
|
4
|
-
export * from './private-public-keys/generation/create-entropy-for-elliptical-curve';
|
|
5
4
|
export * from './private-public-keys/generation/create-random-256-private-key';
|
|
6
5
|
export * from './private-public-keys/generation/create-random-512-key-pair';
|
|
7
|
-
export * from './private-public-keys/
|
|
8
|
-
export * from './private-public-keys/
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './signature/create-crypto-signature';
|
|
13
|
-
export * from './signature/verify-crypto-signature-by-data';
|
|
14
|
-
export * from './signature/verify-crypto-signature-by-hash';
|
|
6
|
+
export * from './private-public-keys/create-ed25519-keys-from-mnemonic';
|
|
7
|
+
export * from './private-public-keys/get-ed25519-public-key-from-private-key';
|
|
8
|
+
export * from './signature/ed25519-primitives';
|
|
9
|
+
export * from './signature/create-ed25519-signature';
|
|
10
|
+
export * from './signature/verify-ed25519-signature';
|
|
15
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAK1C,cAAc,uEAAuE,CAAC;AACtF,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAK1C,cAAc,uEAAuE,CAAC;AACtF,cAAc,gEAAgE,CAAC;AAC/E,cAAc,6DAA6D,CAAC;AAI5E,cAAc,yDAAyD,CAAC;AACxE,cAAc,+DAA+D,CAAC;AAO9E,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC"}
|
package/dist/crypto/index.js
CHANGED
|
@@ -19,18 +19,16 @@ __exportStar(require("./calculate-combined-hash"), exports);
|
|
|
19
19
|
//#region folder private-public-keys
|
|
20
20
|
//#region folder generation
|
|
21
21
|
__exportStar(require("./private-public-keys/generation/create-256-private-key-from-mnemonic"), exports);
|
|
22
|
-
__exportStar(require("./private-public-keys/generation/create-entropy-for-elliptical-curve"), exports);
|
|
23
22
|
__exportStar(require("./private-public-keys/generation/create-random-256-private-key"), exports);
|
|
24
23
|
__exportStar(require("./private-public-keys/generation/create-random-512-key-pair"), exports);
|
|
25
|
-
__exportStar(require("./private-public-keys/generation/generate-key-pair"), exports);
|
|
26
|
-
__exportStar(require("./private-public-keys/generation/get-private-public-key-from-keypair"), exports);
|
|
27
24
|
//#endregion folder generation
|
|
28
|
-
|
|
29
|
-
__exportStar(require("./private-public-keys/create-
|
|
30
|
-
__exportStar(require("./private-public-keys/
|
|
25
|
+
// EdDSA (true Ed25519) key derivation — the sole signing-key path.
|
|
26
|
+
__exportStar(require("./private-public-keys/create-ed25519-keys-from-mnemonic"), exports);
|
|
27
|
+
__exportStar(require("./private-public-keys/get-ed25519-public-key-from-private-key"), exports);
|
|
31
28
|
//#endregion folder private-public-keys
|
|
32
29
|
//#region folder signature
|
|
33
|
-
|
|
34
|
-
__exportStar(require("./signature/
|
|
35
|
-
__exportStar(require("./signature/
|
|
30
|
+
// EdDSA (true Ed25519) signing primitives — the sole signature path.
|
|
31
|
+
__exportStar(require("./signature/ed25519-primitives"), exports);
|
|
32
|
+
__exportStar(require("./signature/create-ed25519-signature"), exports);
|
|
33
|
+
__exportStar(require("./signature/verify-ed25519-signature"), exports);
|
|
36
34
|
//#endregion folder signature
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives a true Ed25519 (EdDSA) keypair from a mnemonic.
|
|
3
|
+
*
|
|
4
|
+
* Derivation (pinned, RFC 8032): the 32-byte Ed25519 secret SEED is
|
|
5
|
+
* `SHA-256(mnemonic)` — the same 32 bytes the legacy `elliptic` path fed into
|
|
6
|
+
* `keyFromPrivate`, but here interpreted as an Ed25519 seed rather than an ECDSA
|
|
7
|
+
* private scalar. The public key is `ed25519.getPublicKey(seed)`.
|
|
8
|
+
*
|
|
9
|
+
* Because EdDSA hashes-and-clamps the seed to form its scalar, the PUBLIC KEY for
|
|
10
|
+
* a given mnemonic differs from the legacy ECDSA-over-ed25519 public key derived
|
|
11
|
+
* from the same mnemonic. The mnemonic still works, but the identity it maps to
|
|
12
|
+
* changes — the "same mnemonic → different identity" break in the migration plan
|
|
13
|
+
* (§3c). Any record of "this mnemonic owns public key X" must be re-derived.
|
|
14
|
+
*
|
|
15
|
+
* @param mnemonic the BIP39 mnemonic phrase.
|
|
16
|
+
* @returns hex-encoded `{ privateKey (32-byte seed), publicKey (32-byte) }`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createEd25519KeysFromMnemonic: (mnemonic: string) => {
|
|
19
|
+
privateKey: string;
|
|
20
|
+
publicKey: string;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=create-ed25519-keys-from-mnemonic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-ed25519-keys-from-mnemonic.d.ts","sourceRoot":"","sources":["../../../src/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,6BAA6B,GACtC,UAAU,MAAM,KACjB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAOzC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createEd25519KeysFromMnemonic = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
const ed25519_primitives_1 = require("../signature/ed25519-primitives");
|
|
39
|
+
const cryptography_settings_1 = require("../../_settings/cryptography-settings");
|
|
40
|
+
/**
|
|
41
|
+
* Derives a true Ed25519 (EdDSA) keypair from a mnemonic.
|
|
42
|
+
*
|
|
43
|
+
* Derivation (pinned, RFC 8032): the 32-byte Ed25519 secret SEED is
|
|
44
|
+
* `SHA-256(mnemonic)` — the same 32 bytes the legacy `elliptic` path fed into
|
|
45
|
+
* `keyFromPrivate`, but here interpreted as an Ed25519 seed rather than an ECDSA
|
|
46
|
+
* private scalar. The public key is `ed25519.getPublicKey(seed)`.
|
|
47
|
+
*
|
|
48
|
+
* Because EdDSA hashes-and-clamps the seed to form its scalar, the PUBLIC KEY for
|
|
49
|
+
* a given mnemonic differs from the legacy ECDSA-over-ed25519 public key derived
|
|
50
|
+
* from the same mnemonic. The mnemonic still works, but the identity it maps to
|
|
51
|
+
* changes — the "same mnemonic → different identity" break in the migration plan
|
|
52
|
+
* (§3c). Any record of "this mnemonic owns public key X" must be re-derived.
|
|
53
|
+
*
|
|
54
|
+
* @param mnemonic the BIP39 mnemonic phrase.
|
|
55
|
+
* @returns hex-encoded `{ privateKey (32-byte seed), publicKey (32-byte) }`.
|
|
56
|
+
*/
|
|
57
|
+
const createEd25519KeysFromMnemonic = (mnemonic) => {
|
|
58
|
+
const seedHex = crypto
|
|
59
|
+
.createHash(cryptography_settings_1.CryptoSettings.Hash.Algorithm)
|
|
60
|
+
.update(mnemonic, cryptography_settings_1.CryptoSettings.TextEncoding)
|
|
61
|
+
.digest(cryptography_settings_1.CryptoSettings.Hash.Digest);
|
|
62
|
+
const publicKey = ed25519_primitives_1.ed.etc.bytesToHex(ed25519_primitives_1.ed.getPublicKey(ed25519_primitives_1.ed.etc.hexToBytes(seedHex)));
|
|
63
|
+
return { privateKey: seedHex, publicKey };
|
|
64
|
+
};
|
|
65
|
+
exports.createEd25519KeysFromMnemonic = createEd25519KeysFromMnemonic;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives the 32-byte Ed25519 public key (hex) from a 32-byte Ed25519 secret
|
|
3
|
+
* seed (hex). The EdDSA counterpart to `getPublicKeyFromKeyPair` for the legacy
|
|
4
|
+
* path — useful when only the private seed is on hand (e.g. recovered from a
|
|
5
|
+
* mnemonic) and the matching public identity is needed.
|
|
6
|
+
*
|
|
7
|
+
* @param privateKey 32-byte Ed25519 secret seed as hex.
|
|
8
|
+
* @returns the 32-byte Ed25519 public key as hex (64 chars).
|
|
9
|
+
*/
|
|
10
|
+
export declare const getEd25519PublicKeyFromPrivateKey: (privateKey: string) => string;
|
|
11
|
+
//# sourceMappingURL=get-ed25519-public-key-from-private-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ed25519-public-key-from-private-key.d.ts","sourceRoot":"","sources":["../../../src/crypto/private-public-keys/get-ed25519-public-key-from-private-key.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,GAAI,YAAY,MAAM,KAAG,MACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEd25519PublicKeyFromPrivateKey = void 0;
|
|
4
|
+
const ed25519_primitives_1 = require("../signature/ed25519-primitives");
|
|
5
|
+
/**
|
|
6
|
+
* Derives the 32-byte Ed25519 public key (hex) from a 32-byte Ed25519 secret
|
|
7
|
+
* seed (hex). The EdDSA counterpart to `getPublicKeyFromKeyPair` for the legacy
|
|
8
|
+
* path — useful when only the private seed is on hand (e.g. recovered from a
|
|
9
|
+
* mnemonic) and the matching public identity is needed.
|
|
10
|
+
*
|
|
11
|
+
* @param privateKey 32-byte Ed25519 secret seed as hex.
|
|
12
|
+
* @returns the 32-byte Ed25519 public key as hex (64 chars).
|
|
13
|
+
*/
|
|
14
|
+
const getEd25519PublicKeyFromPrivateKey = (privateKey) => ed25519_primitives_1.ed.etc.bytesToHex(ed25519_primitives_1.ed.getPublicKey(ed25519_primitives_1.ed.etc.hexToBytes(privateKey)));
|
|
15
|
+
exports.getEd25519PublicKeyFromPrivateKey = getEd25519PublicKeyFromPrivateKey;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signs a message with a true Ed25519 (EdDSA) secret seed.
|
|
3
|
+
*
|
|
4
|
+
* Unlike `createEllipticalCurveSignature`, this does NOT pre-hash the message.
|
|
5
|
+
* Ed25519 hashes the full message with SHA-512 internally (RFC 8032) and has no
|
|
6
|
+
* input-length truncation, so the SHA-256 pre-hash the ECDSA path needs to
|
|
7
|
+
* defend its 3-bit truncation would only discard information here. The UTF-8
|
|
8
|
+
* bytes of `message` are signed directly; `verifyEd25519Signature` mirrors this
|
|
9
|
+
* exactly.
|
|
10
|
+
*
|
|
11
|
+
* @param privateKey 32-byte Ed25519 secret seed as hex (e.g. SHA-256(mnemonic)).
|
|
12
|
+
* @param message the message string to sign.
|
|
13
|
+
* @returns the 64-byte EdDSA signature as hex (128 chars).
|
|
14
|
+
*/
|
|
15
|
+
export declare const createEd25519Signature: (privateKey: string, message: string) => string;
|
|
16
|
+
//# sourceMappingURL=create-ed25519-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-ed25519-signature.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/create-ed25519-signature.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GAAI,YAAY,MAAM,EAAE,SAAS,MAAM,KAAG,MAK5E,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEd25519Signature = void 0;
|
|
4
|
+
const ed25519_primitives_1 = require("./ed25519-primitives");
|
|
5
|
+
const cryptography_settings_1 = require("../../_settings/cryptography-settings");
|
|
6
|
+
/**
|
|
7
|
+
* Signs a message with a true Ed25519 (EdDSA) secret seed.
|
|
8
|
+
*
|
|
9
|
+
* Unlike `createEllipticalCurveSignature`, this does NOT pre-hash the message.
|
|
10
|
+
* Ed25519 hashes the full message with SHA-512 internally (RFC 8032) and has no
|
|
11
|
+
* input-length truncation, so the SHA-256 pre-hash the ECDSA path needs to
|
|
12
|
+
* defend its 3-bit truncation would only discard information here. The UTF-8
|
|
13
|
+
* bytes of `message` are signed directly; `verifyEd25519Signature` mirrors this
|
|
14
|
+
* exactly.
|
|
15
|
+
*
|
|
16
|
+
* @param privateKey 32-byte Ed25519 secret seed as hex (e.g. SHA-256(mnemonic)).
|
|
17
|
+
* @param message the message string to sign.
|
|
18
|
+
* @returns the 64-byte EdDSA signature as hex (128 chars).
|
|
19
|
+
*/
|
|
20
|
+
const createEd25519Signature = (privateKey, message) => {
|
|
21
|
+
const seed = ed25519_primitives_1.ed.etc.hexToBytes(privateKey);
|
|
22
|
+
const messageBytes = Buffer.from(message, cryptography_settings_1.CryptoSettings.TextEncoding);
|
|
23
|
+
const signature = ed25519_primitives_1.ed.sign(messageBytes, seed);
|
|
24
|
+
return ed25519_primitives_1.ed.etc.bytesToHex(signature);
|
|
25
|
+
};
|
|
26
|
+
exports.createEd25519Signature = createEd25519Signature;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared access point to the configured `@noble/ed25519` module.
|
|
3
|
+
*
|
|
4
|
+
* `@noble/ed25519` v3 ships ESM-only (`"type": "module"`, no CommonJS build).
|
|
5
|
+
* Our packages emit CommonJS (`module: "node16"`), where a static
|
|
6
|
+
* `import * as ed from '@noble/ed25519'` makes `tsc` emit a `require()` of an
|
|
7
|
+
* ESM module and reject it at compile time (TS1479). Node ≥22.12 can `require()`
|
|
8
|
+
* a synchronous ESM graph, and noble has no top-level await, so a runtime
|
|
9
|
+
* `require` resolves fine. `typeof import(...)` is a type-only query — fully
|
|
10
|
+
* erased, emits no import — so it gives full typings without re-triggering
|
|
11
|
+
* TS1479. Jest loads the same specifier via its `@noble/ed25519` → source-`.ts`
|
|
12
|
+
* moduleNameMapper + transformIgnorePatterns exception.
|
|
13
|
+
*
|
|
14
|
+
* v3's synchronous API (`getPublicKey` / `sign` / `verify`) refuses to run until
|
|
15
|
+
* a synchronous SHA-512 is wired into `ed.hashes.sha512`. We back it with Node's
|
|
16
|
+
* `crypto` so the rest of the codebase keeps its synchronous signing/verification
|
|
17
|
+
* call shape — the structural-proof verifier (`verifyShareDataProposalProof`) is
|
|
18
|
+
* synchronous on purpose and we don't want to cascade-async every caller.
|
|
19
|
+
*
|
|
20
|
+
* The hook receives the already-concatenated message bytes and must return a
|
|
21
|
+
* 64-byte digest. Guarded so re-importing this module does not re-assign it.
|
|
22
|
+
*/
|
|
23
|
+
declare const ed: typeof import('@noble/ed25519', { with: { 'resolution-mode': 'import' } });
|
|
24
|
+
export { ed };
|
|
25
|
+
//# sourceMappingURL=ed25519-primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519-primitives.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/ed25519-primitives.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,QAAA,MAAM,EAAE,EAAE,cAAc,gBAAgB,EAAU,UAAE,iBAAiB,EAAE,QAAQ,IAAE,CACpD,CAAC;AAM9B,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ed = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
/**
|
|
39
|
+
* Shared access point to the configured `@noble/ed25519` module.
|
|
40
|
+
*
|
|
41
|
+
* `@noble/ed25519` v3 ships ESM-only (`"type": "module"`, no CommonJS build).
|
|
42
|
+
* Our packages emit CommonJS (`module: "node16"`), where a static
|
|
43
|
+
* `import * as ed from '@noble/ed25519'` makes `tsc` emit a `require()` of an
|
|
44
|
+
* ESM module and reject it at compile time (TS1479). Node ≥22.12 can `require()`
|
|
45
|
+
* a synchronous ESM graph, and noble has no top-level await, so a runtime
|
|
46
|
+
* `require` resolves fine. `typeof import(...)` is a type-only query — fully
|
|
47
|
+
* erased, emits no import — so it gives full typings without re-triggering
|
|
48
|
+
* TS1479. Jest loads the same specifier via its `@noble/ed25519` → source-`.ts`
|
|
49
|
+
* moduleNameMapper + transformIgnorePatterns exception.
|
|
50
|
+
*
|
|
51
|
+
* v3's synchronous API (`getPublicKey` / `sign` / `verify`) refuses to run until
|
|
52
|
+
* a synchronous SHA-512 is wired into `ed.hashes.sha512`. We back it with Node's
|
|
53
|
+
* `crypto` so the rest of the codebase keeps its synchronous signing/verification
|
|
54
|
+
* call shape — the structural-proof verifier (`verifyShareDataProposalProof`) is
|
|
55
|
+
* synchronous on purpose and we don't want to cascade-async every caller.
|
|
56
|
+
*
|
|
57
|
+
* The hook receives the already-concatenated message bytes and must return a
|
|
58
|
+
* 64-byte digest. Guarded so re-importing this module does not re-assign it.
|
|
59
|
+
*/
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
61
|
+
const ed = require('@noble/ed25519');
|
|
62
|
+
exports.ed = ed;
|
|
63
|
+
if (!ed.hashes.sha512) {
|
|
64
|
+
ed.hashes.sha512 = (message) => Uint8Array.from(crypto.createHash('sha512').update(message).digest());
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies a true Ed25519 (EdDSA) signature over `message` for `publicKey`.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `createEd25519Signature`: the raw UTF-8 bytes of `message` are
|
|
5
|
+
* verified directly, with no SHA-256 pre-hash (Ed25519 hashes internally).
|
|
6
|
+
*
|
|
7
|
+
* @param publicKey 32-byte Ed25519 public key as hex (64 chars).
|
|
8
|
+
* @param message the message string that was signed.
|
|
9
|
+
* @param signature the 64-byte EdDSA signature as hex.
|
|
10
|
+
* @returns `true` when the signature is valid, `false` otherwise.
|
|
11
|
+
*/
|
|
12
|
+
export declare const verifyEd25519Signature: (publicKey: string, message: string, signature: string) => boolean;
|
|
13
|
+
//# sourceMappingURL=verify-ed25519-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-ed25519-signature.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/verify-ed25519-signature.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAC/B,WAAW,MAAM,EACjB,SAAS,MAAM,EACf,WAAW,MAAM,KAClB,OAYF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyEd25519Signature = void 0;
|
|
4
|
+
const ed25519_primitives_1 = require("./ed25519-primitives");
|
|
5
|
+
const cryptography_settings_1 = require("../../_settings/cryptography-settings");
|
|
6
|
+
/**
|
|
7
|
+
* Verifies a true Ed25519 (EdDSA) signature over `message` for `publicKey`.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors `createEd25519Signature`: the raw UTF-8 bytes of `message` are
|
|
10
|
+
* verified directly, with no SHA-256 pre-hash (Ed25519 hashes internally).
|
|
11
|
+
*
|
|
12
|
+
* @param publicKey 32-byte Ed25519 public key as hex (64 chars).
|
|
13
|
+
* @param message the message string that was signed.
|
|
14
|
+
* @param signature the 64-byte EdDSA signature as hex.
|
|
15
|
+
* @returns `true` when the signature is valid, `false` otherwise.
|
|
16
|
+
*/
|
|
17
|
+
const verifyEd25519Signature = (publicKey, message, signature) => {
|
|
18
|
+
try {
|
|
19
|
+
const publicKeyBytes = ed25519_primitives_1.ed.etc.hexToBytes(publicKey);
|
|
20
|
+
const signatureBytes = ed25519_primitives_1.ed.etc.hexToBytes(signature);
|
|
21
|
+
const messageBytes = Buffer.from(message, cryptography_settings_1.CryptoSettings.TextEncoding);
|
|
22
|
+
return ed25519_primitives_1.ed.verify(signatureBytes, messageBytes, publicKeyBytes);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// noble throws (TypeError/RangeError) on malformed hex or wrong byte
|
|
26
|
+
// lengths rather than returning false. Normalize to a single rejection
|
|
27
|
+
// mode so a tampered/garbage signature reads as "invalid", not an error.
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.verifyEd25519Signature = verifyEd25519Signature;
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './generic/generic-errors';
|
|
|
5
5
|
export * from './request/request-errors';
|
|
6
6
|
export * from './safe/safe-rules-errors';
|
|
7
7
|
export * from './scheduler/scheduler-errors';
|
|
8
|
+
export * from './settlement/settlement-errors';
|
|
8
9
|
export * from './share-data/share-data-errors';
|
|
9
10
|
export * from './shareblock/shareblock-errors';
|
|
10
11
|
export * from './validation/crypto-validation-errors';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AAGtD,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AAGtD,cAAc,cAAc,CAAC"}
|
package/dist/errors/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./generic/generic-errors"), exports);
|
|
|
21
21
|
__exportStar(require("./request/request-errors"), exports);
|
|
22
22
|
__exportStar(require("./safe/safe-rules-errors"), exports);
|
|
23
23
|
__exportStar(require("./scheduler/scheduler-errors"), exports);
|
|
24
|
+
__exportStar(require("./settlement/settlement-errors"), exports);
|
|
24
25
|
__exportStar(require("./share-data/share-data-errors"), exports);
|
|
25
26
|
__exportStar(require("./shareblock/shareblock-errors"), exports);
|
|
26
27
|
__exportStar(require("./validation/crypto-validation-errors"), exports);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { BaseError } from '../base-error';
|
|
2
|
+
import { SettlementPhase } from '../../models/settlement/settlement-models';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when a settlement leg's target block has advanced since the leg was
|
|
5
|
+
* signed. The leg's `againstHash` no longer matches the block's current-state
|
|
6
|
+
* hash, so reserving against it would bind a stale transition (D5 drift
|
|
7
|
+
* guard). The orchestrator treats this as a reserve failure and aborts the
|
|
8
|
+
* whole settlement.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SettlementLegDriftError extends BaseError {
|
|
11
|
+
readonly settlementId: string;
|
|
12
|
+
readonly blockId: string;
|
|
13
|
+
readonly expectedHash: string;
|
|
14
|
+
readonly actualHash: string;
|
|
15
|
+
constructor(settlementId: string, blockId: string, expectedHash: string, actualHash: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when a coordinator phase transition is illegal under the 2PC graph
|
|
19
|
+
* (e.g. `PREPARING → COMMITTED` skipping `COMMITTING`, or any move out of a
|
|
20
|
+
* terminal phase). Enforced by `buildSettlementPhaseRule`.
|
|
21
|
+
*/
|
|
22
|
+
export declare class SettlementPhaseError extends BaseError {
|
|
23
|
+
readonly settlementId: string;
|
|
24
|
+
readonly fromPhase: SettlementPhase;
|
|
25
|
+
readonly toPhase: SettlementPhase;
|
|
26
|
+
constructor(settlementId: string, fromPhase: SettlementPhase, toPhase: SettlementPhase);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Thrown when a settlement tries to reserve against a block that already holds
|
|
30
|
+
* a different, conflicting reservation under the same `settlementId`. (A
|
|
31
|
+
* re-drive with identical terms is idempotent and is not a conflict.)
|
|
32
|
+
*/
|
|
33
|
+
export declare class SettlementReservationConflictError extends BaseError {
|
|
34
|
+
readonly settlementId: string;
|
|
35
|
+
readonly blockId: string;
|
|
36
|
+
constructor(settlementId: string, blockId: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown when an operation references a leg (by `blockId`) that is not part of
|
|
40
|
+
* the settlement's plan.
|
|
41
|
+
*/
|
|
42
|
+
export declare class SettlementLegNotFoundError extends BaseError {
|
|
43
|
+
readonly settlementId: string;
|
|
44
|
+
readonly blockId: string;
|
|
45
|
+
constructor(settlementId: string, blockId: string);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Thrown when a mutating operation targets a settlement already in a terminal
|
|
49
|
+
* phase (`COMMITTED` or `ABORTED`). The journal says it finished; it cannot be
|
|
50
|
+
* reopened.
|
|
51
|
+
*/
|
|
52
|
+
export declare class SettlementAlreadyTerminalError extends BaseError {
|
|
53
|
+
readonly settlementId: string;
|
|
54
|
+
readonly phase: SettlementPhase;
|
|
55
|
+
constructor(settlementId: string, phase: SettlementPhase);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Thrown when a leg's block-side reserve does not take hold — the member block
|
|
59
|
+
* refused the PREPARE. The reserve function no-ops (returns `current`) on an
|
|
60
|
+
* overdraw, a closed block, a currency mismatch, or malformed input, and the
|
|
61
|
+
* rule engine can reject a crafted proposal; in every case the post-condition
|
|
62
|
+
* (`reservations[settlementId]` present and matching the leg) is unmet. The
|
|
63
|
+
* in-process executor surfaces that as this error, which the orchestrator
|
|
64
|
+
* treats as a reserve failure and aborts the whole settlement. `reason` carries
|
|
65
|
+
* human-readable context (the underlying cause cannot always be distinguished
|
|
66
|
+
* from a no-op flag alone).
|
|
67
|
+
*/
|
|
68
|
+
export declare class SettlementLegReserveFailedError extends BaseError {
|
|
69
|
+
readonly settlementId: string;
|
|
70
|
+
readonly blockId: string;
|
|
71
|
+
readonly reason: string;
|
|
72
|
+
constructor(settlementId: string, blockId: string, reason: string);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=settlement-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/settlement/settlement-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;IAClD,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAS9F;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IAC/C,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,SAAS,EAAE,eAAe,CAAC;IAC3C,SAAgB,OAAO,EAAE,eAAe,CAAC;gBAE7B,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe;CAQzF;AAED;;;;GAIG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;IAC7D,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAEpB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAOpD;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IACrD,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAEpB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAOpD;AAED;;;;GAIG;AACH,qBAAa,8BAA+B,SAAQ,SAAS;IACzD,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,KAAK,EAAE,eAAe,CAAC;gBAE3B,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe;CAO3D;AAED;;;;;;;;;;GAUG;AACH,qBAAa,+BAAgC,SAAQ,SAAS;IAC1D,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQpE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SettlementLegReserveFailedError = exports.SettlementAlreadyTerminalError = exports.SettlementLegNotFoundError = exports.SettlementReservationConflictError = exports.SettlementPhaseError = exports.SettlementLegDriftError = void 0;
|
|
4
|
+
const base_error_1 = require("../base-error");
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when a settlement leg's target block has advanced since the leg was
|
|
7
|
+
* signed. The leg's `againstHash` no longer matches the block's current-state
|
|
8
|
+
* hash, so reserving against it would bind a stale transition (D5 drift
|
|
9
|
+
* guard). The orchestrator treats this as a reserve failure and aborts the
|
|
10
|
+
* whole settlement.
|
|
11
|
+
*/
|
|
12
|
+
class SettlementLegDriftError extends base_error_1.BaseError {
|
|
13
|
+
constructor(settlementId, blockId, expectedHash, actualHash) {
|
|
14
|
+
super(`Settlement ${settlementId}: block ${blockId} drifted — leg signed against ${expectedHash}, block is now ${actualHash}.`);
|
|
15
|
+
this.settlementId = settlementId;
|
|
16
|
+
this.blockId = blockId;
|
|
17
|
+
this.expectedHash = expectedHash;
|
|
18
|
+
this.actualHash = actualHash;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.SettlementLegDriftError = SettlementLegDriftError;
|
|
22
|
+
/**
|
|
23
|
+
* Thrown when a coordinator phase transition is illegal under the 2PC graph
|
|
24
|
+
* (e.g. `PREPARING → COMMITTED` skipping `COMMITTING`, or any move out of a
|
|
25
|
+
* terminal phase). Enforced by `buildSettlementPhaseRule`.
|
|
26
|
+
*/
|
|
27
|
+
class SettlementPhaseError extends base_error_1.BaseError {
|
|
28
|
+
constructor(settlementId, fromPhase, toPhase) {
|
|
29
|
+
super(`Settlement ${settlementId}: illegal phase transition ${fromPhase} → ${toPhase}.`);
|
|
30
|
+
this.settlementId = settlementId;
|
|
31
|
+
this.fromPhase = fromPhase;
|
|
32
|
+
this.toPhase = toPhase;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.SettlementPhaseError = SettlementPhaseError;
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when a settlement tries to reserve against a block that already holds
|
|
38
|
+
* a different, conflicting reservation under the same `settlementId`. (A
|
|
39
|
+
* re-drive with identical terms is idempotent and is not a conflict.)
|
|
40
|
+
*/
|
|
41
|
+
class SettlementReservationConflictError extends base_error_1.BaseError {
|
|
42
|
+
constructor(settlementId, blockId) {
|
|
43
|
+
super(`Settlement ${settlementId}: block ${blockId} already has a conflicting reservation for this settlement.`);
|
|
44
|
+
this.settlementId = settlementId;
|
|
45
|
+
this.blockId = blockId;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.SettlementReservationConflictError = SettlementReservationConflictError;
|
|
49
|
+
/**
|
|
50
|
+
* Thrown when an operation references a leg (by `blockId`) that is not part of
|
|
51
|
+
* the settlement's plan.
|
|
52
|
+
*/
|
|
53
|
+
class SettlementLegNotFoundError extends base_error_1.BaseError {
|
|
54
|
+
constructor(settlementId, blockId) {
|
|
55
|
+
super(`Settlement ${settlementId}: no leg for block ${blockId} in the plan.`);
|
|
56
|
+
this.settlementId = settlementId;
|
|
57
|
+
this.blockId = blockId;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.SettlementLegNotFoundError = SettlementLegNotFoundError;
|
|
61
|
+
/**
|
|
62
|
+
* Thrown when a mutating operation targets a settlement already in a terminal
|
|
63
|
+
* phase (`COMMITTED` or `ABORTED`). The journal says it finished; it cannot be
|
|
64
|
+
* reopened.
|
|
65
|
+
*/
|
|
66
|
+
class SettlementAlreadyTerminalError extends base_error_1.BaseError {
|
|
67
|
+
constructor(settlementId, phase) {
|
|
68
|
+
super(`Settlement ${settlementId}: already terminal (${phase}); no further transitions allowed.`);
|
|
69
|
+
this.settlementId = settlementId;
|
|
70
|
+
this.phase = phase;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.SettlementAlreadyTerminalError = SettlementAlreadyTerminalError;
|
|
74
|
+
/**
|
|
75
|
+
* Thrown when a leg's block-side reserve does not take hold — the member block
|
|
76
|
+
* refused the PREPARE. The reserve function no-ops (returns `current`) on an
|
|
77
|
+
* overdraw, a closed block, a currency mismatch, or malformed input, and the
|
|
78
|
+
* rule engine can reject a crafted proposal; in every case the post-condition
|
|
79
|
+
* (`reservations[settlementId]` present and matching the leg) is unmet. The
|
|
80
|
+
* in-process executor surfaces that as this error, which the orchestrator
|
|
81
|
+
* treats as a reserve failure and aborts the whole settlement. `reason` carries
|
|
82
|
+
* human-readable context (the underlying cause cannot always be distinguished
|
|
83
|
+
* from a no-op flag alone).
|
|
84
|
+
*/
|
|
85
|
+
class SettlementLegReserveFailedError extends base_error_1.BaseError {
|
|
86
|
+
constructor(settlementId, blockId, reason) {
|
|
87
|
+
super(`Settlement ${settlementId}: reserve failed for block ${blockId} — ${reason}.`);
|
|
88
|
+
this.settlementId = settlementId;
|
|
89
|
+
this.blockId = blockId;
|
|
90
|
+
this.reason = reason;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.SettlementLegReserveFailedError = SettlementLegReserveFailedError;
|
package/dist/models/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export * from './safe/safe-transaction-models';
|
|
|
17
17
|
export * from './share-data/share-data-crypto-models';
|
|
18
18
|
export * from './share-data/share-data-models';
|
|
19
19
|
export * from './share-data/share-data-persistence-models';
|
|
20
|
+
export * from './settlement/settlement-models';
|
|
20
21
|
export * from './shareblock/shareblock-models';
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAEA,cAAc,sDAAsD,CAAC;AACrE,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAElD,cAAc,2BAA2B,CAAC;AAE1C,cAAc,qDAAqD,CAAC;AACpE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,gCAAgC,CAAC;AAG/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAEA,cAAc,sDAAsD,CAAC;AACrE,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAElD,cAAc,2BAA2B,CAAC;AAE1C,cAAc,qDAAqD,CAAC;AACpE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,gCAAgC,CAAC;AAG/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC"}
|
package/dist/models/index.js
CHANGED
|
@@ -38,4 +38,5 @@ __exportStar(require("./safe/safe-transaction-models"), exports);
|
|
|
38
38
|
__exportStar(require("./share-data/share-data-crypto-models"), exports);
|
|
39
39
|
__exportStar(require("./share-data/share-data-models"), exports);
|
|
40
40
|
__exportStar(require("./share-data/share-data-persistence-models"), exports);
|
|
41
|
+
__exportStar(require("./settlement/settlement-models"), exports);
|
|
41
42
|
__exportStar(require("./shareblock/shareblock-models"), exports);
|