@degenerate/generic 0.2.7 → 0.4.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/database-settings.d.ts +3 -0
- package/dist/_settings/database-settings.d.ts.map +1 -1
- package/dist/_settings/database-settings.js +3 -0
- package/dist/application/audit-log/additional-ids/create-audit-log-additional-ids-with-query.d.ts.map +1 -1
- package/dist/application/audit-log/additional-ids/create-multiple-path-alai.d.ts.map +1 -1
- package/dist/application/audit-log/additional-ids/create-query-audit-log-for-alai.d.ts.map +1 -1
- package/dist/application/audit-log/create-application-audit-log.d.ts.map +1 -1
- package/dist/application/audit-log/create-application-audit-log.js +1 -1
- package/dist/application/database/firestore/generics/add-items-to-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/add-items-to-database.js +2 -2
- package/dist/application/database/firestore/generics/add-or-update-items-to-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/add-or-update-items-to-database.js +3 -3
- package/dist/application/database/firestore/generics/create-database-change-information.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/delete-items-on-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/delete-items-on-database.js +2 -2
- package/dist/application/database/firestore/generics/get-item-from-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/get-item-from-database.js +2 -2
- package/dist/application/database/firestore/generics/get-items-different-path-on-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/get-items-different-path-on-database.js +2 -2
- package/dist/application/database/firestore/generics/get-items-from-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/get-items-from-database.js +1 -1
- package/dist/application/database/firestore/generics/update-items-on-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/update-items-on-database.js +2 -2
- package/dist/application/database/firestore/generics/update-items-properties-on-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/update-items-properties-on-database.js +2 -2
- package/dist/authorization/index.d.ts +1 -0
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +1 -0
- package/dist/authorization/jwt/keys/create-public-key-pem.d.ts.map +1 -1
- package/dist/authorization/jwt/keys/create-secret-key-pem.d.ts.map +1 -1
- package/dist/authorization/jwt/sign/create-authorization-issuer.d.ts.map +1 -1
- package/dist/authorization/jwt/sign/create-authorization-subject.d.ts.map +1 -1
- package/dist/authorization/jwt/sign/create-jwt-options.d.ts +7 -1
- package/dist/authorization/jwt/sign/create-jwt-options.d.ts.map +1 -1
- package/dist/authorization/jwt/sign/create-jwt-signed-token.d.ts.map +1 -1
- package/dist/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts.map +1 -1
- package/dist/authorization/jwt/verify/get-decoded-jwt-header.d.ts.map +1 -1
- package/dist/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts.map +1 -1
- package/dist/authorization/jwt/verify/verify-jwt-signed-token.d.ts.map +1 -1
- package/dist/authorization/safe/request/decode-bearer-token.d.ts.map +1 -1
- package/dist/authorization/safe/request/decode-safe-request.d.ts.map +1 -1
- package/dist/authorization/safe/request/determine-issuer-from-request.d.ts.map +1 -1
- package/dist/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts.map +1 -1
- package/dist/authorization/safe/request/verify-jwt-bearer-token-for-audience.d.ts +31 -0
- package/dist/authorization/safe/request/verify-jwt-bearer-token-for-audience.d.ts.map +1 -0
- package/dist/authorization/safe/request/verify-jwt-bearer-token-for-audience.js +50 -0
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts.map +1 -1
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts.map +1 -1
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts.map +1 -1
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts.map +1 -1
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts.map +1 -1
- package/dist/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts.map +1 -1
- package/dist/authorization/safe/validation/jwt/verify-token-header.d.ts.map +1 -1
- package/dist/authorization/safe/validation/jwt/verify-token-payload.d.ts.map +1 -1
- package/dist/crypto/calculate-combined-hash.d.ts.map +1 -1
- package/dist/crypto/calculate-hash.d.ts +1 -1
- package/dist/crypto/calculate-hash.d.ts.map +1 -1
- package/dist/crypto/calculate-hash.js +1 -1
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +1 -0
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +1 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +1 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +1 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts +11 -0
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.js +51 -0
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +1 -1
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +1 -1
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +1 -1
- package/dist/crypto/signature/create-crypto-signature.d.ts +11 -0
- package/dist/crypto/signature/create-crypto-signature.d.ts.map +1 -1
- package/dist/crypto/signature/create-crypto-signature.js +14 -1
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +4 -0
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +1 -1
- package/dist/crypto/signature/verify-crypto-signature-by-data.js +8 -2
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +4 -0
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +1 -1
- package/dist/crypto/signature/verify-crypto-signature-by-hash.js +7 -1
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -0
- package/dist/errors/share-data/share-data-errors.d.ts +105 -1
- package/dist/errors/share-data/share-data-errors.d.ts.map +1 -1
- package/dist/errors/share-data/share-data-errors.js +148 -1
- package/dist/errors/shareblock/shareblock-errors.d.ts +40 -0
- package/dist/errors/shareblock/shareblock-errors.d.ts.map +1 -0
- package/dist/errors/shareblock/shareblock-errors.js +50 -0
- package/dist/errors/validation/crypto-validation-errors.d.ts +8 -0
- package/dist/errors/validation/crypto-validation-errors.d.ts.map +1 -0
- package/dist/errors/validation/crypto-validation-errors.js +15 -0
- package/dist/helpers/array/array-helpers.d.ts.map +1 -1
- package/dist/helpers/crypto/cryptography-helpers.d.ts.map +1 -1
- package/dist/helpers/data/data-helpers.d.ts.map +1 -1
- package/dist/helpers/file/file-helpers.d.ts.map +1 -1
- package/dist/helpers/id-helpers.d.ts.map +1 -1
- package/dist/helpers/lodash/lodash-helpers.d.ts.map +1 -1
- package/dist/helpers/object-helpers.d.ts.map +1 -1
- package/dist/helpers/object-validation-helpers.d.ts.map +1 -1
- package/dist/helpers/request/params-object-helpers.d.ts +6 -13
- package/dist/helpers/request/params-object-helpers.d.ts.map +1 -1
- package/dist/helpers/request/params-object-helpers.js +11 -21
- package/dist/helpers/request/query-object-helpers.d.ts.map +1 -1
- package/dist/helpers/request/request-object-helpers.d.ts.map +1 -1
- package/dist/models/application/audit-log/application-audit-log-models.d.ts +82 -92
- package/dist/models/application/audit-log/application-audit-log-models.d.ts.map +1 -1
- package/dist/models/application/database/firestore-models.d.ts +158 -307
- package/dist/models/application/database/firestore-models.d.ts.map +1 -1
- package/dist/models/authorization/authorization-models.d.ts +34 -44
- package/dist/models/authorization/authorization-models.d.ts.map +1 -1
- package/dist/models/authorization/authorization-models.js +2 -2
- package/dist/models/crypto/crypto-models.d.ts +1 -7
- package/dist/models/crypto/crypto-models.d.ts.map +1 -1
- package/dist/models/data/data-models.d.ts +27 -13
- package/dist/models/data/data-models.d.ts.map +1 -1
- package/dist/models/data/data-models.js +23 -2
- package/dist/models/dynamic-execution/dynamic-execution-models.d.ts +1 -9
- package/dist/models/dynamic-execution/dynamic-execution-models.d.ts.map +1 -1
- package/dist/models/events/share-event-models.d.ts +91 -120
- package/dist/models/events/share-event-models.d.ts.map +1 -1
- package/dist/models/events/share-event-models.js +35 -4
- package/dist/models/functions/share-data-function-models.d.ts +23 -193
- package/dist/models/functions/share-data-function-models.d.ts.map +1 -1
- package/dist/models/functions/share-data-function-models.js +1 -1
- package/dist/models/generic/request-response-models.d.ts +1 -7
- package/dist/models/generic/request-response-models.d.ts.map +1 -1
- package/dist/models/index.d.ts +4 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +4 -1
- package/dist/models/rules/share-rule-models.d.ts +759 -1116
- package/dist/models/rules/share-rule-models.d.ts.map +1 -1
- package/dist/models/rules/share-rule-models.js +6 -6
- package/dist/models/safe/safe-transaction-models.d.ts +28 -30
- package/dist/models/safe/safe-transaction-models.d.ts.map +1 -1
- package/dist/models/safe/transactions/authorities-transactions-models.d.ts +77 -419
- package/dist/models/safe/transactions/authorities-transactions-models.d.ts.map +1 -1
- package/dist/models/safe/transactions/authorities-transactions-models.js +3 -3
- package/dist/models/safe/transactions/events-transactions-models.d.ts +22 -372
- package/dist/models/safe/transactions/events-transactions-models.d.ts.map +1 -1
- package/dist/models/safe/transactions/events-transactions-models.js +1 -1
- package/dist/models/safe/transactions/functions-transactions-models.d.ts +22 -372
- package/dist/models/safe/transactions/functions-transactions-models.d.ts.map +1 -1
- package/dist/models/safe/transactions/functions-transactions-models.js +1 -1
- package/dist/models/safe/transactions/rules-transactions-models.d.ts +59 -603
- package/dist/models/safe/transactions/rules-transactions-models.d.ts.map +1 -1
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts +256 -388
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts.map +1 -1
- package/dist/models/safe/transactions/sharedata-transactions-models.js +30 -4
- package/dist/models/share-data/share-data-crypto-models.d.ts +344 -0
- package/dist/models/share-data/share-data-crypto-models.d.ts.map +1 -0
- package/dist/models/share-data/share-data-crypto-models.js +131 -0
- package/dist/models/share-data/share-data-models.d.ts +114 -0
- package/dist/models/share-data/share-data-models.d.ts.map +1 -0
- package/dist/models/share-data/{share-data.js → share-data-models.js} +1 -1
- package/dist/models/share-data/share-data-persistence-models.d.ts +165 -0
- package/dist/models/share-data/share-data-persistence-models.d.ts.map +1 -0
- package/dist/models/share-data/share-data-persistence-models.js +101 -0
- package/dist/models/shareblock/shareblock-models.d.ts +489 -0
- package/dist/models/shareblock/shareblock-models.d.ts.map +1 -0
- package/dist/models/shareblock/shareblock-models.js +395 -0
- package/dist/transactions/authority/create-safe-transaction-authority-data.d.ts.map +1 -1
- package/dist/transactions/authority/create-safe-transaction-authority.d.ts.map +1 -1
- package/package.json +30 -22
- package/dist/models/share-data/share-data.d.ts +0 -181
- package/dist/models/share-data/share-data.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedata-transactions-models.d.ts","sourceRoot":"","sources":["../../../../src/models/safe/transactions/sharedata-transactions-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EAG5B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedata-transactions-models.d.ts","sourceRoot":"","sources":["../../../../src/models/safe/transactions/sharedata-transactions-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EAG5B,MAAM,4BAA4B,CAAC;AASpC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAO1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAIxF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE9F;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhD,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAEpG;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhD,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC"}
|
|
@@ -3,14 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ISAFETransactionShareDataDeleteSchema = exports.ISAFETransactionShareDataUpdateSchema = exports.ISAFETransactionShareDataAddSchema = exports.ISAFETransactionShareDataSchema = exports.ISAFETransactionShareDataDataSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const safe_transaction_models_1 = require("../safe-transaction-models");
|
|
6
|
+
const share_data_crypto_models_1 = require("../../share-data/share-data-crypto-models");
|
|
7
|
+
const shareblock_models_1 = require("../../shareblock/shareblock-models");
|
|
6
8
|
//#region ShareData Transaction
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
10
|
+
* Wire-format payload for creating a ShareData over the SAFE HTTP / SAFE
|
|
11
|
+
* transaction layer. Carries everything the receiving server needs to
|
|
12
|
+
* dispatch to the matching ShareBlock factory and reconstruct the
|
|
13
|
+
* client-signed trust chain:
|
|
14
|
+
*
|
|
15
|
+
* - `metadata` — variant tag + creation attribution (also identifies
|
|
16
|
+
* which factory to call).
|
|
17
|
+
* - `initialState` — caller-supplied initial state inputs. Validated
|
|
18
|
+
* loosely here (currency/participants/balance) — the factory layers
|
|
19
|
+
* the variant-specific defaults (`isOpen: true`, `committed: false`,
|
|
20
|
+
* etc.) on top.
|
|
21
|
+
* - `initialCrypto` — the client's pre-computed creation hash / sig.
|
|
22
|
+
* `creationPublicKey` is derived from this — *not* taken from a
|
|
23
|
+
* separate field — so there is one source of truth for "who created
|
|
24
|
+
* this block."
|
|
25
|
+
* - `proofs` — bundle keyed by purpose. Each entry signs over the
|
|
26
|
+
* in-construction share-data state at the moment the factory will
|
|
27
|
+
* register the matching function/rule. The server cross-checks the
|
|
28
|
+
* bundle covers every purpose the chosen factory requires (via
|
|
29
|
+
* `*_REQUIRED_PROOF_PURPOSES`) before invoking the factory.
|
|
30
|
+
*
|
|
31
|
+
* Replaces the legacy free-form `shareDataContent: Record<string, any>`
|
|
32
|
+
* shape — that was the attack surface that let the HTTP create route
|
|
33
|
+
* accept attacker-controlled JSON as canonical state.
|
|
9
34
|
*/
|
|
10
35
|
exports.ISAFETransactionShareDataDataSchema = zod_1.z.object({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
36
|
+
metadata: shareblock_models_1.IShareBlockMetadataSchema,
|
|
37
|
+
initialState: shareblock_models_1.IShareBlockInitialStateInputSchema,
|
|
38
|
+
initialCrypto: share_data_crypto_models_1.IShareDataInitialCryptoDataSchema,
|
|
39
|
+
proofs: share_data_crypto_models_1.ShareDataProofsSchema,
|
|
14
40
|
});
|
|
15
41
|
/**
|
|
16
42
|
* This is the transaction targeting a sharedata item in the SAFE Ecosystem.
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* This contains the interface for the share data initial crypto data schema
|
|
4
|
+
*/
|
|
5
|
+
export declare const IShareDataInitialCryptoDataSchema: z.ZodObject<{
|
|
6
|
+
publicKey: z.ZodString;
|
|
7
|
+
shareDataHash: z.ZodString;
|
|
8
|
+
shareDataSignature: z.ZodString;
|
|
9
|
+
timestamp: z.ZodNumber;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type IShareDataInitialCryptoData = z.infer<typeof IShareDataInitialCryptoDataSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* This contains the interface for the share data crypto proof schema.
|
|
14
|
+
*
|
|
15
|
+
* `purpose` identifies what this proof attests to (e.g. `'deposit'`,
|
|
16
|
+
* `'rule-balance'`, `'seed-function'`). It is folded into the canonical
|
|
17
|
+
* signed string so two proofs taken over the same share-data state at the
|
|
18
|
+
* same moment but tagged with different purposes produce different
|
|
19
|
+
* signatures. Verifiers consume `purpose` directly from the proof — the
|
|
20
|
+
* proof is self-describing, so the structural-add boundary
|
|
21
|
+
* (`addFunction` / `addRule`) does not need a separate purpose argument.
|
|
22
|
+
*/
|
|
23
|
+
export declare const IShareDataCryptoProofSchema: z.ZodObject<{
|
|
24
|
+
publicKey: z.ZodString;
|
|
25
|
+
shareDataHash: z.ZodString;
|
|
26
|
+
shareDataPreviousHash: z.ZodString;
|
|
27
|
+
shareDataSignature: z.ZodString;
|
|
28
|
+
timestamp: z.ZodNumber;
|
|
29
|
+
purpose: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type IShareDataCryptoProof = z.infer<typeof IShareDataCryptoProofSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* A bundle of structural proofs keyed by their `purpose`, used as the
|
|
34
|
+
* wire-format input to ShareBlock factories when the client (rather than
|
|
35
|
+
* the server) signs each registration. Matches how `_structuralProofs`
|
|
36
|
+
* end up shaped on a constructed ShareData — one proof per
|
|
37
|
+
* `addFunction` / `addRule` call.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ShareDataProofsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
40
|
+
publicKey: z.ZodString;
|
|
41
|
+
shareDataHash: z.ZodString;
|
|
42
|
+
shareDataPreviousHash: z.ZodString;
|
|
43
|
+
shareDataSignature: z.ZodString;
|
|
44
|
+
timestamp: z.ZodNumber;
|
|
45
|
+
purpose: z.ZodString;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
export type ShareDataProofs = z.infer<typeof ShareDataProofsSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* A single delegated-signer grant on a block: a public key the block owner has
|
|
50
|
+
* authorized to propose runtime transactions, scoped to a specific set of
|
|
51
|
+
* function ids (least privilege — a granted key can only drive the function(s)
|
|
52
|
+
* it was delegated, not arbitrary mutations).
|
|
53
|
+
*
|
|
54
|
+
* Field-declaration order is load-bearing, NOT cosmetic — same constraint as
|
|
55
|
+
* {@link IShareDataCryptoProofSchema}. The grant is folded into the canonical
|
|
56
|
+
* share-data string via order-sensitive `JSON.stringify` (see `getArrayString`
|
|
57
|
+
* / `calculateShareDataString`), so a grant that round-trips through `.parse()`
|
|
58
|
+
* (persistence reload) must come back with the SAME key order a freshly-built
|
|
59
|
+
* grant has, or the block's hash diverges and later proofs fail to verify.
|
|
60
|
+
* Keep `publicKey` before `functionIds`, matching the object literal pushed in
|
|
61
|
+
* `ShareData.addAuthorizedSigner`.
|
|
62
|
+
*/
|
|
63
|
+
export declare const IAuthorizedSignerSchema: z.ZodObject<{
|
|
64
|
+
publicKey: z.ZodString;
|
|
65
|
+
functionIds: z.ZodArray<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type IAuthorizedSigner = z.infer<typeof IAuthorizedSignerSchema>;
|
|
68
|
+
/** Prefix marking a structural proof's `purpose` as a delegate registration. */
|
|
69
|
+
export declare const DELEGATE_PURPOSE_PREFIX = "delegate:";
|
|
70
|
+
/**
|
|
71
|
+
* Builds the canonical `purpose` for a delegated-signer registration proof.
|
|
72
|
+
*
|
|
73
|
+
* The registration proof is signed over the block's PRE-append state (the grant
|
|
74
|
+
* is not yet folded into `_authorizedSigners` at signing time), so the proof's
|
|
75
|
+
* `purpose` is the only thing that cryptographically attests to the exact
|
|
76
|
+
* `(signerPublicKey, functionIds)` grant. Binding both into the purpose means a
|
|
77
|
+
* tampered snapshot cannot widen a delegate's scope (add function ids) or lift
|
|
78
|
+
* the signature to authorize a different key without invalidating the proof.
|
|
79
|
+
*
|
|
80
|
+
* `functionIds` are normalized (trimmed, de-duped, sorted) and JSON-encoded so
|
|
81
|
+
* the encoding is collision-free regardless of characters in the ids and
|
|
82
|
+
* order-independent across live-create and replay.
|
|
83
|
+
*/
|
|
84
|
+
export declare const buildDelegatePurpose: (signerPublicKey: string, functionIds: string[]) => string;
|
|
85
|
+
/**
|
|
86
|
+
* This contains the interface for the share data property config
|
|
87
|
+
* for creating strings from the object to ensure that signatures and
|
|
88
|
+
* hashes are consistent
|
|
89
|
+
*/
|
|
90
|
+
export declare const IShareDataPropertyConfigSchema: z.ZodObject<{
|
|
91
|
+
key: z.ZodString;
|
|
92
|
+
process: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodString>>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
export type IShareDataPropertyConfig = z.infer<typeof IShareDataPropertyConfigSchema>;
|
|
95
|
+
/**
|
|
96
|
+
* This contains the interface for the share data config array
|
|
97
|
+
* for creating strings from the object to ensure that signatures and
|
|
98
|
+
* hashes are consistent
|
|
99
|
+
*/
|
|
100
|
+
export declare const IShareDataConfigSchema: z.ZodArray<z.ZodObject<{
|
|
101
|
+
key: z.ZodString;
|
|
102
|
+
process: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodString>>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
export type IShareDataConfig = z.infer<typeof IShareDataConfigSchema>;
|
|
105
|
+
/**
|
|
106
|
+
* This contains the interface for additional data to include in the share data string.
|
|
107
|
+
*
|
|
108
|
+
* `purpose` is required and identifies what this signed snapshot is attesting to
|
|
109
|
+
* (e.g. `'deposit'`, `'rule-balance'`, `'seed-function'`). It is folded into the
|
|
110
|
+
* canonical string `calculateShareDataString` produces, so two proofs taken
|
|
111
|
+
* over the same share-data state at the same moment but tagged with different
|
|
112
|
+
* purposes produce different hashes and therefore different signatures. This
|
|
113
|
+
* structurally prevents replaying a proof signed for one purpose as a proof
|
|
114
|
+
* for another.
|
|
115
|
+
*/
|
|
116
|
+
export declare const IShareDataAdditionalValuesToIncludeSchema: z.ZodObject<{
|
|
117
|
+
purpose: z.ZodString;
|
|
118
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
119
|
+
ruleId: z.ZodString;
|
|
120
|
+
currentDataConditions: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
121
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
122
|
+
IS: "IS";
|
|
123
|
+
IS_NOT: "IS_NOT";
|
|
124
|
+
}>;
|
|
125
|
+
targettedProperty: z.ZodString;
|
|
126
|
+
conditionType: z.ZodLiteral<"TYPEOF">;
|
|
127
|
+
conditionValue: z.ZodEnum<{
|
|
128
|
+
NULL: "NULL";
|
|
129
|
+
STRING: "STRING";
|
|
130
|
+
NUMBER: "NUMBER";
|
|
131
|
+
INTEGER: "INTEGER";
|
|
132
|
+
BOOLEAN: "BOOLEAN";
|
|
133
|
+
OBJECT: "OBJECT";
|
|
134
|
+
ARRAY: "ARRAY";
|
|
135
|
+
UNDEFINED: "UNDEFINED";
|
|
136
|
+
FUNCTION: "FUNCTION";
|
|
137
|
+
BIGINT: "BIGINT";
|
|
138
|
+
}>;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
141
|
+
IS: "IS";
|
|
142
|
+
IS_NOT: "IS_NOT";
|
|
143
|
+
}>;
|
|
144
|
+
targettedProperty: z.ZodString;
|
|
145
|
+
conditionType: z.ZodLiteral<"EQUAL">;
|
|
146
|
+
conditionValue: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
147
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
148
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
149
|
+
IS: "IS";
|
|
150
|
+
IS_NOT: "IS_NOT";
|
|
151
|
+
}>;
|
|
152
|
+
targettedProperty: z.ZodString;
|
|
153
|
+
conditionType: z.ZodEnum<{
|
|
154
|
+
GREATER_THAN: "GREATER_THAN";
|
|
155
|
+
LESS_THAN: "LESS_THAN";
|
|
156
|
+
GREATER_THAN_OR_EQUAL: "GREATER_THAN_OR_EQUAL";
|
|
157
|
+
LESS_THAN_OR_EQUAL: "LESS_THAN_OR_EQUAL";
|
|
158
|
+
}>;
|
|
159
|
+
conditionValue: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
160
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
161
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
162
|
+
IS: "IS";
|
|
163
|
+
IS_NOT: "IS_NOT";
|
|
164
|
+
}>;
|
|
165
|
+
targettedProperty: z.ZodString;
|
|
166
|
+
conditionType: z.ZodLiteral<"CONTAINS">;
|
|
167
|
+
conditionValue: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodNumber>]>;
|
|
168
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
169
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
170
|
+
IS: "IS";
|
|
171
|
+
IS_NOT: "IS_NOT";
|
|
172
|
+
}>;
|
|
173
|
+
targettedProperty: z.ZodString;
|
|
174
|
+
conditionType: z.ZodEnum<{
|
|
175
|
+
STARTS_WITH: "STARTS_WITH";
|
|
176
|
+
ENDS_WITH: "ENDS_WITH";
|
|
177
|
+
}>;
|
|
178
|
+
conditionValue: z.ZodString;
|
|
179
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
180
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
181
|
+
IS: "IS";
|
|
182
|
+
IS_NOT: "IS_NOT";
|
|
183
|
+
}>;
|
|
184
|
+
targettedProperty: z.ZodString;
|
|
185
|
+
conditionType: z.ZodLiteral<"NULL">;
|
|
186
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
187
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
188
|
+
IS: "IS";
|
|
189
|
+
IS_NOT: "IS_NOT";
|
|
190
|
+
}>;
|
|
191
|
+
targettedProperty: z.ZodString;
|
|
192
|
+
conditionType: z.ZodEnum<{
|
|
193
|
+
TRUE: "TRUE";
|
|
194
|
+
FALSE: "FALSE";
|
|
195
|
+
}>;
|
|
196
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
197
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
198
|
+
IS: "IS";
|
|
199
|
+
IS_NOT: "IS_NOT";
|
|
200
|
+
}>;
|
|
201
|
+
targettedProperty: z.ZodString;
|
|
202
|
+
conditionType: z.ZodLiteral<"EMPTY">;
|
|
203
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
204
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
205
|
+
IS: "IS";
|
|
206
|
+
IS_NOT: "IS_NOT";
|
|
207
|
+
}>;
|
|
208
|
+
targettedProperty: z.ZodString;
|
|
209
|
+
conditionType: z.ZodEnum<{
|
|
210
|
+
PATTERN: "PATTERN";
|
|
211
|
+
}>;
|
|
212
|
+
conditionValue: z.ZodString;
|
|
213
|
+
}, z.core.$strip>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>>;
|
|
214
|
+
proposedDataConditions: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
215
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
216
|
+
IS: "IS";
|
|
217
|
+
IS_NOT: "IS_NOT";
|
|
218
|
+
}>;
|
|
219
|
+
targettedProperty: z.ZodString;
|
|
220
|
+
conditionType: z.ZodLiteral<"TYPEOF">;
|
|
221
|
+
conditionValue: z.ZodEnum<{
|
|
222
|
+
NULL: "NULL";
|
|
223
|
+
STRING: "STRING";
|
|
224
|
+
NUMBER: "NUMBER";
|
|
225
|
+
INTEGER: "INTEGER";
|
|
226
|
+
BOOLEAN: "BOOLEAN";
|
|
227
|
+
OBJECT: "OBJECT";
|
|
228
|
+
ARRAY: "ARRAY";
|
|
229
|
+
UNDEFINED: "UNDEFINED";
|
|
230
|
+
FUNCTION: "FUNCTION";
|
|
231
|
+
BIGINT: "BIGINT";
|
|
232
|
+
}>;
|
|
233
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
234
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
235
|
+
IS: "IS";
|
|
236
|
+
IS_NOT: "IS_NOT";
|
|
237
|
+
}>;
|
|
238
|
+
targettedProperty: z.ZodString;
|
|
239
|
+
conditionType: z.ZodLiteral<"EQUAL">;
|
|
240
|
+
conditionValue: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
241
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
242
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
243
|
+
IS: "IS";
|
|
244
|
+
IS_NOT: "IS_NOT";
|
|
245
|
+
}>;
|
|
246
|
+
targettedProperty: z.ZodString;
|
|
247
|
+
conditionType: z.ZodEnum<{
|
|
248
|
+
GREATER_THAN: "GREATER_THAN";
|
|
249
|
+
LESS_THAN: "LESS_THAN";
|
|
250
|
+
GREATER_THAN_OR_EQUAL: "GREATER_THAN_OR_EQUAL";
|
|
251
|
+
LESS_THAN_OR_EQUAL: "LESS_THAN_OR_EQUAL";
|
|
252
|
+
}>;
|
|
253
|
+
conditionValue: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
254
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
255
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
256
|
+
IS: "IS";
|
|
257
|
+
IS_NOT: "IS_NOT";
|
|
258
|
+
}>;
|
|
259
|
+
targettedProperty: z.ZodString;
|
|
260
|
+
conditionType: z.ZodLiteral<"CONTAINS">;
|
|
261
|
+
conditionValue: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodNumber>]>;
|
|
262
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
263
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
264
|
+
IS: "IS";
|
|
265
|
+
IS_NOT: "IS_NOT";
|
|
266
|
+
}>;
|
|
267
|
+
targettedProperty: z.ZodString;
|
|
268
|
+
conditionType: z.ZodEnum<{
|
|
269
|
+
STARTS_WITH: "STARTS_WITH";
|
|
270
|
+
ENDS_WITH: "ENDS_WITH";
|
|
271
|
+
}>;
|
|
272
|
+
conditionValue: z.ZodString;
|
|
273
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
274
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
275
|
+
IS: "IS";
|
|
276
|
+
IS_NOT: "IS_NOT";
|
|
277
|
+
}>;
|
|
278
|
+
targettedProperty: z.ZodString;
|
|
279
|
+
conditionType: z.ZodLiteral<"NULL">;
|
|
280
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
281
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
282
|
+
IS: "IS";
|
|
283
|
+
IS_NOT: "IS_NOT";
|
|
284
|
+
}>;
|
|
285
|
+
targettedProperty: z.ZodString;
|
|
286
|
+
conditionType: z.ZodEnum<{
|
|
287
|
+
TRUE: "TRUE";
|
|
288
|
+
FALSE: "FALSE";
|
|
289
|
+
}>;
|
|
290
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
291
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
292
|
+
IS: "IS";
|
|
293
|
+
IS_NOT: "IS_NOT";
|
|
294
|
+
}>;
|
|
295
|
+
targettedProperty: z.ZodString;
|
|
296
|
+
conditionType: z.ZodLiteral<"EMPTY">;
|
|
297
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
298
|
+
conditionTypeQualifier: z.ZodEnum<{
|
|
299
|
+
IS: "IS";
|
|
300
|
+
IS_NOT: "IS_NOT";
|
|
301
|
+
}>;
|
|
302
|
+
targettedProperty: z.ZodString;
|
|
303
|
+
conditionType: z.ZodEnum<{
|
|
304
|
+
PATTERN: "PATTERN";
|
|
305
|
+
}>;
|
|
306
|
+
conditionValue: z.ZodString;
|
|
307
|
+
}, z.core.$strip>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>>;
|
|
308
|
+
targettedProperty: z.ZodString;
|
|
309
|
+
}, z.core.$strip>>>;
|
|
310
|
+
functions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
311
|
+
id: z.ZodString;
|
|
312
|
+
groupingId: z.ZodString;
|
|
313
|
+
groupingName: z.ZodString;
|
|
314
|
+
name: z.ZodString;
|
|
315
|
+
description: z.ZodString;
|
|
316
|
+
hash: z.ZodString;
|
|
317
|
+
stringifiedFunction: z.ZodString;
|
|
318
|
+
}, z.core.$strip>>>;
|
|
319
|
+
transactionHistory: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
320
|
+
ruleOutcome: z.ZodBoolean;
|
|
321
|
+
ruleFailures: z.ZodArray<z.ZodObject<{
|
|
322
|
+
ruleId: z.ZodString;
|
|
323
|
+
}, z.core.$strip>>;
|
|
324
|
+
transactionFunction: z.ZodObject<{
|
|
325
|
+
input: z.ZodAny;
|
|
326
|
+
func: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
327
|
+
output: z.ZodAny;
|
|
328
|
+
}, z.core.$strip>;
|
|
329
|
+
}, z.core.$strip>>>;
|
|
330
|
+
events: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
331
|
+
shareData: z.ZodArray<z.ZodObject<{
|
|
332
|
+
shareDataId: z.ZodString;
|
|
333
|
+
functionId: z.ZodString;
|
|
334
|
+
shareDataInputs: z.ZodArray<z.ZodString>;
|
|
335
|
+
inputs: z.ZodAny;
|
|
336
|
+
}, z.core.$strip>>;
|
|
337
|
+
processingType: z.ZodEnum<{
|
|
338
|
+
parallel: "parallel";
|
|
339
|
+
linear: "linear";
|
|
340
|
+
}>;
|
|
341
|
+
}, z.core.$strip>>>;
|
|
342
|
+
}, z.core.$strip>;
|
|
343
|
+
export type IShareDataAdditionalValuesToInclude = z.infer<typeof IShareDataAdditionalValuesToIncludeSchema>;
|
|
344
|
+
//# sourceMappingURL=share-data-crypto-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-data-crypto-models.d.ts","sourceRoot":"","sources":["../../../src/models/share-data/share-data-crypto-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;GAEG;AACH,eAAO,MAAM,iCAAiC;;;;;iBAK5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F;;;;;;;;;;GAUG;AASH,eAAO,MAAM,2BAA2B;;;;;;;iBAOtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB;;;;;;;kBAAoD,CAAC;AAEvF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,gFAAgF;AAChF,eAAO,MAAM,uBAAuB,cAAc,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAC7B,iBAAiB,MAAM,EACvB,aAAa,MAAM,EAAE,KACtB,MAKF,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;;iBAGzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;kBAA0C,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAMtE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMpD,CAAC;AACH,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IShareDataAdditionalValuesToIncludeSchema = exports.IShareDataConfigSchema = exports.IShareDataPropertyConfigSchema = exports.buildDelegatePurpose = exports.DELEGATE_PURPOSE_PREFIX = exports.IAuthorizedSignerSchema = exports.ShareDataProofsSchema = exports.IShareDataCryptoProofSchema = exports.IShareDataInitialCryptoDataSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const share_rule_models_1 = require("../rules/share-rule-models");
|
|
6
|
+
const share_data_models_1 = require("./share-data-models");
|
|
7
|
+
const share_event_models_1 = require("../events/share-event-models");
|
|
8
|
+
// This contains models that are used in the share data specifically around crypto
|
|
9
|
+
//#region Share Data Crypto Schemas
|
|
10
|
+
/**
|
|
11
|
+
* This contains the interface for the share data initial crypto data schema
|
|
12
|
+
*/
|
|
13
|
+
exports.IShareDataInitialCryptoDataSchema = zod_1.z.object({
|
|
14
|
+
publicKey: zod_1.z.string(), // the public key of the share data
|
|
15
|
+
shareDataHash: zod_1.z.string(), // the share data hash
|
|
16
|
+
shareDataSignature: zod_1.z.string(), // the share data signature
|
|
17
|
+
timestamp: zod_1.z.number(), // the timestamp of the initial crypto data (in milliseconds)
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* This contains the interface for the share data crypto proof schema.
|
|
21
|
+
*
|
|
22
|
+
* `purpose` identifies what this proof attests to (e.g. `'deposit'`,
|
|
23
|
+
* `'rule-balance'`, `'seed-function'`). It is folded into the canonical
|
|
24
|
+
* signed string so two proofs taken over the same share-data state at the
|
|
25
|
+
* same moment but tagged with different purposes produce different
|
|
26
|
+
* signatures. Verifiers consume `purpose` directly from the proof — the
|
|
27
|
+
* proof is self-describing, so the structural-add boundary
|
|
28
|
+
* (`addFunction` / `addRule`) does not need a separate purpose argument.
|
|
29
|
+
*/
|
|
30
|
+
// Field declaration order here is load-bearing, NOT cosmetic. Zod
|
|
31
|
+
// reconstructs a parsed object in *schema-declaration* order, and the
|
|
32
|
+
// canonical share-data hash folds structural proofs in via order-sensitive
|
|
33
|
+
// `JSON.stringify` (see `getArrayString` / `calculateShareDataString`). So a
|
|
34
|
+
// proof that round-trips through `.parse()` (wire load, HTTP create) must come
|
|
35
|
+
// back with the SAME key order a freshly-minted proof has, or its hash
|
|
36
|
+
// diverges and structural-proof verification fails. This order must therefore
|
|
37
|
+
// mirror the object literal in `createShareDataProposalProof` exactly.
|
|
38
|
+
exports.IShareDataCryptoProofSchema = zod_1.z.object({
|
|
39
|
+
publicKey: zod_1.z.string(), // the public key of the share data
|
|
40
|
+
shareDataHash: zod_1.z.string(), // the share data hash
|
|
41
|
+
shareDataPreviousHash: zod_1.z.string(), // the previous share data hash
|
|
42
|
+
shareDataSignature: zod_1.z.string(), // the share data signature
|
|
43
|
+
timestamp: zod_1.z.number(), // the timestamp of the initial crypto data (in milliseconds)
|
|
44
|
+
purpose: zod_1.z.string().min(1), // what this proof attests to (e.g. 'deposit', 'rule-balance')
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* A bundle of structural proofs keyed by their `purpose`, used as the
|
|
48
|
+
* wire-format input to ShareBlock factories when the client (rather than
|
|
49
|
+
* the server) signs each registration. Matches how `_structuralProofs`
|
|
50
|
+
* end up shaped on a constructed ShareData — one proof per
|
|
51
|
+
* `addFunction` / `addRule` call.
|
|
52
|
+
*/
|
|
53
|
+
exports.ShareDataProofsSchema = zod_1.z.record(zod_1.z.string(), exports.IShareDataCryptoProofSchema);
|
|
54
|
+
/**
|
|
55
|
+
* A single delegated-signer grant on a block: a public key the block owner has
|
|
56
|
+
* authorized to propose runtime transactions, scoped to a specific set of
|
|
57
|
+
* function ids (least privilege — a granted key can only drive the function(s)
|
|
58
|
+
* it was delegated, not arbitrary mutations).
|
|
59
|
+
*
|
|
60
|
+
* Field-declaration order is load-bearing, NOT cosmetic — same constraint as
|
|
61
|
+
* {@link IShareDataCryptoProofSchema}. The grant is folded into the canonical
|
|
62
|
+
* share-data string via order-sensitive `JSON.stringify` (see `getArrayString`
|
|
63
|
+
* / `calculateShareDataString`), so a grant that round-trips through `.parse()`
|
|
64
|
+
* (persistence reload) must come back with the SAME key order a freshly-built
|
|
65
|
+
* grant has, or the block's hash diverges and later proofs fail to verify.
|
|
66
|
+
* Keep `publicKey` before `functionIds`, matching the object literal pushed in
|
|
67
|
+
* `ShareData.addAuthorizedSigner`.
|
|
68
|
+
*/
|
|
69
|
+
exports.IAuthorizedSignerSchema = zod_1.z.object({
|
|
70
|
+
publicKey: zod_1.z.string(), // the delegate's public key (hex)
|
|
71
|
+
functionIds: zod_1.z.array(zod_1.z.string()), // the function ids this key may drive (sorted)
|
|
72
|
+
});
|
|
73
|
+
/** Prefix marking a structural proof's `purpose` as a delegate registration. */
|
|
74
|
+
exports.DELEGATE_PURPOSE_PREFIX = 'delegate:';
|
|
75
|
+
/**
|
|
76
|
+
* Builds the canonical `purpose` for a delegated-signer registration proof.
|
|
77
|
+
*
|
|
78
|
+
* The registration proof is signed over the block's PRE-append state (the grant
|
|
79
|
+
* is not yet folded into `_authorizedSigners` at signing time), so the proof's
|
|
80
|
+
* `purpose` is the only thing that cryptographically attests to the exact
|
|
81
|
+
* `(signerPublicKey, functionIds)` grant. Binding both into the purpose means a
|
|
82
|
+
* tampered snapshot cannot widen a delegate's scope (add function ids) or lift
|
|
83
|
+
* the signature to authorize a different key without invalidating the proof.
|
|
84
|
+
*
|
|
85
|
+
* `functionIds` are normalized (trimmed, de-duped, sorted) and JSON-encoded so
|
|
86
|
+
* the encoding is collision-free regardless of characters in the ids and
|
|
87
|
+
* order-independent across live-create and replay.
|
|
88
|
+
*/
|
|
89
|
+
const buildDelegatePurpose = (signerPublicKey, functionIds) => {
|
|
90
|
+
const normalized = Array.from(new Set(functionIds.map((id) => id.trim()).filter((id) => id.length > 0))).sort();
|
|
91
|
+
return `${exports.DELEGATE_PURPOSE_PREFIX}${signerPublicKey}:${JSON.stringify(normalized)}`;
|
|
92
|
+
};
|
|
93
|
+
exports.buildDelegatePurpose = buildDelegatePurpose;
|
|
94
|
+
//#endregion Share Data Crypto Schemas
|
|
95
|
+
//#region Stringify Configurations
|
|
96
|
+
/**
|
|
97
|
+
* This contains the interface for the share data property config
|
|
98
|
+
* for creating strings from the object to ensure that signatures and
|
|
99
|
+
* hashes are consistent
|
|
100
|
+
*/
|
|
101
|
+
exports.IShareDataPropertyConfigSchema = zod_1.z.object({
|
|
102
|
+
key: zod_1.z.string(),
|
|
103
|
+
process: zod_1.z.function({ input: zod_1.z.tuple([zod_1.z.any()]), output: zod_1.z.string() }).optional(), // Simplified process type
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* This contains the interface for the share data config array
|
|
107
|
+
* for creating strings from the object to ensure that signatures and
|
|
108
|
+
* hashes are consistent
|
|
109
|
+
*/
|
|
110
|
+
exports.IShareDataConfigSchema = zod_1.z.array(exports.IShareDataPropertyConfigSchema);
|
|
111
|
+
//#endregion Stringify Configurations
|
|
112
|
+
//#region Additional Data to include
|
|
113
|
+
/**
|
|
114
|
+
* This contains the interface for additional data to include in the share data string.
|
|
115
|
+
*
|
|
116
|
+
* `purpose` is required and identifies what this signed snapshot is attesting to
|
|
117
|
+
* (e.g. `'deposit'`, `'rule-balance'`, `'seed-function'`). It is folded into the
|
|
118
|
+
* canonical string `calculateShareDataString` produces, so two proofs taken
|
|
119
|
+
* over the same share-data state at the same moment but tagged with different
|
|
120
|
+
* purposes produce different hashes and therefore different signatures. This
|
|
121
|
+
* structurally prevents replaying a proof signed for one purpose as a proof
|
|
122
|
+
* for another.
|
|
123
|
+
*/
|
|
124
|
+
exports.IShareDataAdditionalValuesToIncludeSchema = zod_1.z.object({
|
|
125
|
+
purpose: zod_1.z.string().min(1),
|
|
126
|
+
rules: zod_1.z.array(share_rule_models_1.IShareRuleAppliedSchema).optional(),
|
|
127
|
+
functions: zod_1.z.array(share_data_models_1.IShareFunctionRecordSchema).optional(),
|
|
128
|
+
transactionHistory: zod_1.z.array(share_data_models_1.IShareDataTransactionBaseSchema).optional(),
|
|
129
|
+
events: zod_1.z.array(share_event_models_1.IShareDataEventSchema).optional(),
|
|
130
|
+
});
|
|
131
|
+
//#endregion Additional Data to include
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import type { IShareDataCryptoProof } from './share-data-crypto-models';
|
|
3
|
+
/**
|
|
4
|
+
* This contains the data for the share data object
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ShareDataTypes {
|
|
7
|
+
AUTHORIZATION = "AUTHORIZATION",
|
|
8
|
+
RULE = "RULE",
|
|
9
|
+
FUNCTION = "FUNCTION",
|
|
10
|
+
TRANSACTION_HISTORY = "TRANSACTION_HISTORY",
|
|
11
|
+
DATA = "DATA"
|
|
12
|
+
}
|
|
13
|
+
export declare const ShareDataTypesSchema: z.ZodEnum<{
|
|
14
|
+
FUNCTION: "FUNCTION";
|
|
15
|
+
AUTHORIZATION: "AUTHORIZATION";
|
|
16
|
+
RULE: "RULE";
|
|
17
|
+
TRANSACTION_HISTORY: "TRANSACTION_HISTORY";
|
|
18
|
+
DATA: "DATA";
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* This contains the interface for a data in a share data object
|
|
22
|
+
*/
|
|
23
|
+
export declare const IShareDataSchema: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
24
|
+
export type IShareData = z.infer<typeof IShareDataSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* This contains the interface for a share function record in the share data object
|
|
27
|
+
*/
|
|
28
|
+
export declare const IShareFunctionRecordSchema: z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
groupingId: z.ZodString;
|
|
31
|
+
groupingName: z.ZodString;
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
description: z.ZodString;
|
|
34
|
+
hash: z.ZodString;
|
|
35
|
+
stringifiedFunction: z.ZodString;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export type IShareFunctionRecord = z.infer<typeof IShareFunctionRecordSchema>;
|
|
38
|
+
/**
|
|
39
|
+
* This contains the interface for a share function in the share data object
|
|
40
|
+
*/
|
|
41
|
+
export declare const IShareFunctionSchema: z.ZodObject<{
|
|
42
|
+
input: z.ZodAny;
|
|
43
|
+
func: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
44
|
+
output: z.ZodAny;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export interface IShareFunction<TInput, TFunction extends (...args: any[]) => any, TOutput> {
|
|
47
|
+
/**
|
|
48
|
+
* Stable identifier the host application can use to refer to this
|
|
49
|
+
* function from outside the runtime — e.g., when a client submits a
|
|
50
|
+
* `propose` over the realtime transport and needs to name which
|
|
51
|
+
* registered function should evaluate the proposal.
|
|
52
|
+
*
|
|
53
|
+
* Optional today for backwards compatibility with existing
|
|
54
|
+
* constructions that don't set it. Functions without an id are
|
|
55
|
+
* invisible to id-based lookup (see `createIdBasedFunctionResolver`
|
|
56
|
+
* in `@degenerate/realtime`); the host can still resolve them via a
|
|
57
|
+
* custom `FunctionResolver`.
|
|
58
|
+
*/
|
|
59
|
+
id?: string;
|
|
60
|
+
input: TInput;
|
|
61
|
+
func: TFunction;
|
|
62
|
+
output: TOutput;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* This contains the interface for the rule failures in the share data object
|
|
66
|
+
*/
|
|
67
|
+
export declare const IShareDataRuleFailuresSchema: z.ZodObject<{
|
|
68
|
+
ruleId: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export type IShareDataRuleFailures = z.infer<typeof IShareDataRuleFailuresSchema>;
|
|
71
|
+
/**
|
|
72
|
+
* This contains the interface for the share transaction history in the share data object
|
|
73
|
+
*/
|
|
74
|
+
export declare const IShareDataTransactionBaseSchema: z.ZodObject<{
|
|
75
|
+
ruleOutcome: z.ZodBoolean;
|
|
76
|
+
ruleFailures: z.ZodArray<z.ZodObject<{
|
|
77
|
+
ruleId: z.ZodString;
|
|
78
|
+
}, z.core.$strip>>;
|
|
79
|
+
transactionFunction: z.ZodObject<{
|
|
80
|
+
input: z.ZodAny;
|
|
81
|
+
func: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
82
|
+
output: z.ZodAny;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export type IShareDataTransactionBase = z.infer<typeof IShareDataTransactionBaseSchema>;
|
|
86
|
+
/**
|
|
87
|
+
* This contains the interface for the share transaction history in the share data object
|
|
88
|
+
* This is done for storage
|
|
89
|
+
*/
|
|
90
|
+
export declare const IShareDataTransactionHistorySchema: z.ZodObject<{
|
|
91
|
+
ruleOutcome: z.ZodBoolean;
|
|
92
|
+
ruleFailures: z.ZodArray<z.ZodObject<{
|
|
93
|
+
ruleId: z.ZodString;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
transactionFunction: z.ZodObject<{
|
|
96
|
+
input: z.ZodAny;
|
|
97
|
+
func: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
98
|
+
output: z.ZodAny;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
transactionId: z.ZodString;
|
|
101
|
+
transactionTime: z.ZodNumber;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
/**
|
|
104
|
+
* `proof` is the transaction proposal proof that authorized this state change
|
|
105
|
+
* (present for transactions applied through the signed `addTransaction` path;
|
|
106
|
+
* absent for legacy/internal applies). It makes the audit log itself carry the
|
|
107
|
+
* signature, not just the function + rule outcome. Typed here rather than in
|
|
108
|
+
* the Zod schema to avoid a module load-time cycle — see the `import type` note
|
|
109
|
+
* at the top of this file.
|
|
110
|
+
*/
|
|
111
|
+
export type IShareDataTransactionHistory = z.infer<typeof IShareDataTransactionHistorySchema> & {
|
|
112
|
+
proof?: IShareDataCryptoProof;
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=share-data-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-data-models.d.ts","sourceRoot":"","sources":["../../../src/models/share-data/share-data-models.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAOpB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE;;GAEG;AACH,oBAAY,cAAc;IACtB,aAAa,kBAAkB;IAC/B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,mBAAmB,wBAAwB;IAC3C,IAAI,SAAS;CAChB;AAED,eAAO,MAAM,oBAAoB;;;;;;EAM/B,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,gBAAgB,oCAAgC,CAAC;AAC9D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;iBAQrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;iBAI/B,CAAC;AAGH,MAAM,WAAW,cAAc,CAAC,MAAM,EAAE,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,OAAO;IACtF;;;;;;;;;;;OAWG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CACnB;AAGD;;GAEG;AACH,eAAO,MAAM,4BAA4B;;iBAEvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;iBAI1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF;;;GAGG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;iBAG7C,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,GAAG;IAC5F,KAAK,CAAC,EAAE,qBAAqB,CAAC;CACjC,CAAC"}
|
|
@@ -29,7 +29,7 @@ exports.ShareDataTypesSchema = zod_1.default.enum([
|
|
|
29
29
|
/**
|
|
30
30
|
* This contains the interface for a data in a share data object
|
|
31
31
|
*/
|
|
32
|
-
exports.IShareDataSchema = zod_1.default.record(zod_1.default.any());
|
|
32
|
+
exports.IShareDataSchema = zod_1.default.record(zod_1.default.string(), zod_1.default.any());
|
|
33
33
|
/**
|
|
34
34
|
* This contains the interface for a share function record in the share data object
|
|
35
35
|
*/
|