@degenerate/generic 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/library/library-errors.d.ts +101 -0
- package/dist/errors/library/library-errors.d.ts.map +1 -0
- package/dist/errors/library/library-errors.js +133 -0
- package/dist/errors/share-data/share-data-errors.d.ts +21 -0
- package/dist/errors/share-data/share-data-errors.d.ts.map +1 -1
- package/dist/errors/share-data/share-data-errors.js +30 -1
- package/dist/helpers/apply-share-function.d.ts +23 -0
- package/dist/helpers/apply-share-function.d.ts.map +1 -0
- package/dist/helpers/apply-share-function.js +32 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/library/authorize-library.d.ts +17 -0
- package/dist/library/authorize-library.d.ts.map +1 -0
- package/dist/library/authorize-library.js +39 -0
- package/dist/library/build-library.d.ts +49 -0
- package/dist/library/build-library.d.ts.map +1 -0
- package/dist/library/build-library.js +119 -0
- package/dist/library/caching-library-store.d.ts +19 -0
- package/dist/library/caching-library-store.d.ts.map +1 -0
- package/dist/library/caching-library-store.js +56 -0
- package/dist/library/canonical-json.d.ts +12 -0
- package/dist/library/canonical-json.d.ts.map +1 -0
- package/dist/library/canonical-json.js +30 -0
- package/dist/library/compile-rule-source.d.ts +21 -0
- package/dist/library/compile-rule-source.d.ts.map +1 -0
- package/dist/library/compile-rule-source.js +91 -0
- package/dist/library/evaluate-library-rules.d.ts +36 -0
- package/dist/library/evaluate-library-rules.d.ts.map +1 -0
- package/dist/library/evaluate-library-rules.js +47 -0
- package/dist/library/evaluate-library.d.ts +34 -0
- package/dist/library/evaluate-library.d.ts.map +1 -0
- package/dist/library/evaluate-library.js +66 -0
- package/dist/library/in-memory-library-store.d.ts +22 -0
- package/dist/library/in-memory-library-store.d.ts.map +1 -0
- package/dist/library/in-memory-library-store.js +92 -0
- package/dist/library/index.d.ts +18 -0
- package/dist/library/index.d.ts.map +1 -0
- package/dist/library/index.js +33 -0
- package/dist/library/library-hash.d.ts +9 -0
- package/dist/library/library-hash.d.ts.map +1 -0
- package/dist/library/library-hash.js +14 -0
- package/dist/library/library-models.d.ts +134 -0
- package/dist/library/library-models.d.ts.map +1 -0
- package/dist/library/library-models.js +84 -0
- package/dist/library/library-proof.d.ts +40 -0
- package/dist/library/library-proof.d.ts.map +1 -0
- package/dist/library/library-proof.js +44 -0
- package/dist/library/library-reference.d.ts +75 -0
- package/dist/library/library-reference.d.ts.map +1 -0
- package/dist/library/library-reference.js +98 -0
- package/dist/library/library-server.d.ts +17 -0
- package/dist/library/library-server.d.ts.map +1 -0
- package/dist/library/library-server.js +45 -0
- package/dist/library/library-store.d.ts +37 -0
- package/dist/library/library-store.d.ts.map +1 -0
- package/dist/library/library-store.js +2 -0
- package/dist/library/remote-library-models.d.ts +135 -0
- package/dist/library/remote-library-models.d.ts.map +1 -0
- package/dist/library/remote-library-models.js +26 -0
- package/dist/library/remote-library-store.d.ts +15 -0
- package/dist/library/remote-library-store.d.ts.map +1 -0
- package/dist/library/remote-library-store.js +59 -0
- package/dist/library/verify-library.d.ts +21 -0
- package/dist/library/verify-library.d.ts.map +1 -0
- package/dist/library/verify-library.js +86 -0
- package/dist/models/functions/share-data-function-models.d.ts +6 -74
- package/dist/models/functions/share-data-function-models.d.ts.map +1 -1
- package/dist/models/functions/share-data-function-models.js +7 -65
- package/dist/models/share-data/share-data-models.d.ts +12 -0
- package/dist/models/share-data/share-data-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.js +6 -6
- package/dist/sandbox/in-process-executor.d.ts +13 -0
- package/dist/sandbox/in-process-executor.d.ts.map +1 -0
- package/dist/sandbox/in-process-executor.js +31 -0
- package/dist/sandbox/index.d.ts +8 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +23 -0
- package/dist/sandbox/remote-sandbox-executor.d.ts +12 -0
- package/dist/sandbox/remote-sandbox-executor.d.ts.map +1 -0
- package/dist/sandbox/remote-sandbox-executor.js +49 -0
- package/dist/sandbox/remote-sandbox-models.d.ts +37 -0
- package/dist/sandbox/remote-sandbox-models.d.ts.map +1 -0
- package/dist/sandbox/remote-sandbox-models.js +2 -0
- package/dist/sandbox/rule-evaluator.d.ts +32 -0
- package/dist/sandbox/rule-evaluator.d.ts.map +1 -0
- package/dist/sandbox/rule-evaluator.js +23 -0
- package/dist/sandbox/run-sandboxed.d.ts +24 -0
- package/dist/sandbox/run-sandboxed.d.ts.map +1 -0
- package/dist/sandbox/run-sandboxed.js +88 -0
- package/dist/sandbox/sandbox-models.d.ts +40 -0
- package/dist/sandbox/sandbox-models.d.ts.map +1 -0
- package/dist/sandbox/sandbox-models.js +2 -0
- package/dist/sandbox/sandbox-server.d.ts +22 -0
- package/dist/sandbox/sandbox-server.d.ts.map +1 -0
- package/dist/sandbox/sandbox-server.js +62 -0
- package/package.json +2 -2
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateRuleReference = exports.executeFunctionReference = exports.resolveLibraryReference = exports.findPinnedVersion = exports.referenceForRule = exports.ruleLibrarySource = exports.referenceLibraryEntity = void 0;
|
|
4
|
+
const library_errors_1 = require("../errors/library/library-errors");
|
|
5
|
+
const evaluate_library_1 = require("./evaluate-library");
|
|
6
|
+
const library_hash_1 = require("./library-hash");
|
|
7
|
+
const library_models_1 = require("./library-models");
|
|
8
|
+
const pickVersion = (entity, versionHash) => {
|
|
9
|
+
if (versionHash === undefined) {
|
|
10
|
+
return entity.versions[entity.versions.length - 1]; // head
|
|
11
|
+
}
|
|
12
|
+
const version = entity.versions.find((candidate) => candidate.currentHash === versionHash);
|
|
13
|
+
if (!version) {
|
|
14
|
+
throw new library_errors_1.LibraryVersionNotFoundError(entity.id, versionHash);
|
|
15
|
+
}
|
|
16
|
+
return version;
|
|
17
|
+
};
|
|
18
|
+
/** Builds a reference pinning a specific version of `entity` (defaults to the head). */
|
|
19
|
+
const referenceLibraryEntity = (entity, versionHash) => {
|
|
20
|
+
const version = pickVersion(entity, versionHash);
|
|
21
|
+
return { kind: entity.kind, id: entity.id, currentHash: version.currentHash };
|
|
22
|
+
};
|
|
23
|
+
exports.referenceLibraryEntity = referenceLibraryEntity;
|
|
24
|
+
/**
|
|
25
|
+
* The canonical source string for a rule library entity: the stringified rule
|
|
26
|
+
* definition. A rule entity published with this source resolves to a reference
|
|
27
|
+
* built by {@link referenceForRule} (both hash the same bytes).
|
|
28
|
+
*/
|
|
29
|
+
const ruleLibrarySource = (rule) => JSON.stringify(rule);
|
|
30
|
+
exports.ruleLibrarySource = ruleLibrarySource;
|
|
31
|
+
/**
|
|
32
|
+
* Computes the content-addressed reference for a rule WITHOUT publishing it: the
|
|
33
|
+
* id is the hash of the rule's first (and, for a standard rule, only) version,
|
|
34
|
+
* exactly as `createLibraryEntity` would compute it. This lets a block reference
|
|
35
|
+
* a rule by hash and resolve it on demand from any store that has been seeded
|
|
36
|
+
* with the same rule definition (see `seedRuleLibrary` in `@degenerate/shareblock`).
|
|
37
|
+
*/
|
|
38
|
+
const referenceForRule = (rule) => {
|
|
39
|
+
const hash = (0, library_hash_1.computeVersionHash)((0, exports.ruleLibrarySource)(rule), '');
|
|
40
|
+
return { kind: library_models_1.LibraryEntityKind.RULE, id: hash, currentHash: hash };
|
|
41
|
+
};
|
|
42
|
+
exports.referenceForRule = referenceForRule;
|
|
43
|
+
/**
|
|
44
|
+
* Locates the pinned version within an already-in-hand entity (the
|
|
45
|
+
* self-contained path). Checks the reference's `id` and `kind` match the entity
|
|
46
|
+
* and that the pinned `currentHash` exists.
|
|
47
|
+
*/
|
|
48
|
+
const findPinnedVersion = (entity, reference) => {
|
|
49
|
+
if (entity.id !== reference.id) {
|
|
50
|
+
throw new library_errors_1.LibraryEntityInvalidError(`reference id ${reference.id} does not match entity ${entity.id}`);
|
|
51
|
+
}
|
|
52
|
+
if (entity.kind !== reference.kind) {
|
|
53
|
+
throw new library_errors_1.LibraryKindMismatchError(entity.id, reference.kind, entity.kind);
|
|
54
|
+
}
|
|
55
|
+
const version = entity.versions.find((candidate) => candidate.currentHash === reference.currentHash);
|
|
56
|
+
if (!version) {
|
|
57
|
+
throw new library_errors_1.LibraryVersionNotFoundError(entity.id, reference.currentHash);
|
|
58
|
+
}
|
|
59
|
+
return version;
|
|
60
|
+
};
|
|
61
|
+
exports.findPinnedVersion = findPinnedVersion;
|
|
62
|
+
/**
|
|
63
|
+
* Resolves a reference against the store (the limited-self-containment path):
|
|
64
|
+
* loads the entity by id (the store re-verifies it), then locates the pinned
|
|
65
|
+
* version. Throws {@link LibraryEntityNotFoundError} if the store lacks the id.
|
|
66
|
+
*/
|
|
67
|
+
const resolveLibraryReference = async (reference, store) => {
|
|
68
|
+
const entity = await store.get(reference.id); // re-verifies on read
|
|
69
|
+
if (!entity) {
|
|
70
|
+
throw new library_errors_1.LibraryEntityNotFoundError(reference.id);
|
|
71
|
+
}
|
|
72
|
+
return { entity, version: (0, exports.findPinnedVersion)(entity, reference) };
|
|
73
|
+
};
|
|
74
|
+
exports.resolveLibraryReference = resolveLibraryReference;
|
|
75
|
+
/** Resolves a FUNCTION reference from the store and runs its pinned version. */
|
|
76
|
+
const executeFunctionReference = async (reference, store, options) => {
|
|
77
|
+
const { entity } = await (0, exports.resolveLibraryReference)(reference, store);
|
|
78
|
+
return (0, evaluate_library_1.evaluateLibraryFunction)(entity, {
|
|
79
|
+
current: options.current,
|
|
80
|
+
input: options.input,
|
|
81
|
+
versionHash: reference.currentHash,
|
|
82
|
+
gasLimit: options.gasLimit,
|
|
83
|
+
executor: options.executor,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
exports.executeFunctionReference = executeFunctionReference;
|
|
87
|
+
/** Resolves a RULE reference from the store and evaluates its pinned version. */
|
|
88
|
+
const evaluateRuleReference = async (reference, store, options) => {
|
|
89
|
+
const { entity } = await (0, exports.resolveLibraryReference)(reference, store);
|
|
90
|
+
return (0, evaluate_library_1.evaluateLibraryRule)(entity, {
|
|
91
|
+
current: options.current,
|
|
92
|
+
proposed: options.proposed,
|
|
93
|
+
versionHash: reference.currentHash,
|
|
94
|
+
gasLimit: options.gasLimit,
|
|
95
|
+
evaluator: options.evaluator,
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
exports.evaluateRuleReference = evaluateRuleReference;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LibraryStore } from './library-store';
|
|
2
|
+
import { RemoteLibraryRequest, RemoteLibraryResponse } from './remote-library-models';
|
|
3
|
+
export interface LibraryServer {
|
|
4
|
+
handle(request: RemoteLibraryRequest): Promise<RemoteLibraryResponse>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The transport-agnostic rules-server handler: it receives a
|
|
8
|
+
* {@link RemoteLibraryRequest} and serves it from a backing {@link LibraryStore}
|
|
9
|
+
* (any DB). The CONSUMER wires this handler to their HTTP/RPC server — the server
|
|
10
|
+
* itself takes no transport dependency, the same discipline as the sandbox server.
|
|
11
|
+
*
|
|
12
|
+
* Operational failures are returned as `{ error }` rather than thrown, so the
|
|
13
|
+
* transport carries a normal response; the client's {@link createRemoteLibraryStore}
|
|
14
|
+
* turns `error` back into a thrown error on its side.
|
|
15
|
+
*/
|
|
16
|
+
export declare const createLibraryServer: (store: LibraryStore) => LibraryServer;
|
|
17
|
+
//# sourceMappingURL=library-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-server.d.ts","sourceRoot":"","sources":["../../src/library/library-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEtF,MAAM,WAAW,aAAa;IAC1B,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACzE;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,YAAY,KAAG,aA6BxD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLibraryServer = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The transport-agnostic rules-server handler: it receives a
|
|
6
|
+
* {@link RemoteLibraryRequest} and serves it from a backing {@link LibraryStore}
|
|
7
|
+
* (any DB). The CONSUMER wires this handler to their HTTP/RPC server — the server
|
|
8
|
+
* itself takes no transport dependency, the same discipline as the sandbox server.
|
|
9
|
+
*
|
|
10
|
+
* Operational failures are returned as `{ error }` rather than thrown, so the
|
|
11
|
+
* transport carries a normal response; the client's {@link createRemoteLibraryStore}
|
|
12
|
+
* turns `error` back into a thrown error on its side.
|
|
13
|
+
*/
|
|
14
|
+
const createLibraryServer = (store) => ({
|
|
15
|
+
async handle(request) {
|
|
16
|
+
try {
|
|
17
|
+
switch (request.op) {
|
|
18
|
+
case 'get': {
|
|
19
|
+
const entity = await store.get(request.id);
|
|
20
|
+
return { entity: entity ?? null };
|
|
21
|
+
}
|
|
22
|
+
case 'getVersion': {
|
|
23
|
+
const version = await store.getVersion(request.id, request.currentHash);
|
|
24
|
+
return { version: version ?? null };
|
|
25
|
+
}
|
|
26
|
+
case 'has':
|
|
27
|
+
return { exists: await store.has(request.id) };
|
|
28
|
+
case 'list':
|
|
29
|
+
return { entities: await store.list(request.filter) };
|
|
30
|
+
case 'search':
|
|
31
|
+
return { entities: await store.search(request.query) };
|
|
32
|
+
case 'save':
|
|
33
|
+
await store.save(request.entity);
|
|
34
|
+
return {};
|
|
35
|
+
case 'delete':
|
|
36
|
+
await store.delete(request.id);
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
exports.createLibraryServer = createLibraryServer;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ILibraryEntity, ILibraryVersion, LibraryEntityKind } from './library-models';
|
|
2
|
+
/** Filter for {@link LibraryStore.list}. */
|
|
3
|
+
export interface LibraryListFilter {
|
|
4
|
+
kind?: LibraryEntityKind;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Query for {@link LibraryStore.search} — discovering reusable functions/rules
|
|
8
|
+
* in the library. All supplied fields must match (AND). `text` is a
|
|
9
|
+
* case-insensitive substring match over `name` and `description`.
|
|
10
|
+
*/
|
|
11
|
+
export interface LibrarySearchQuery {
|
|
12
|
+
kind?: LibraryEntityKind;
|
|
13
|
+
text?: string;
|
|
14
|
+
ownerPublicKey?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Storage-agnostic persistence for library entities. The canonical record is
|
|
18
|
+
* portable JSON (the {@link ILibraryEntity} shape), so any backend works —
|
|
19
|
+
* in-memory, Firestore, Postgres, etc.
|
|
20
|
+
*
|
|
21
|
+
* Contract: the store is a cache of proofs, NEVER a trust anchor. `save`
|
|
22
|
+
* verifies before persisting and enforces append-only growth; every read
|
|
23
|
+
* (`get` / `getVersion` / `list`) RE-VERIFIES the entity before returning it, so
|
|
24
|
+
* a tampered backend surfaces as a thrown error rather than corrupt data.
|
|
25
|
+
*/
|
|
26
|
+
export interface LibraryStore {
|
|
27
|
+
get(id: string): Promise<ILibraryEntity | undefined>;
|
|
28
|
+
getVersion(id: string, currentHash: string): Promise<ILibraryVersion | undefined>;
|
|
29
|
+
has(id: string): Promise<boolean>;
|
|
30
|
+
list(filter?: LibraryListFilter): Promise<ILibraryEntity[]>;
|
|
31
|
+
/** Discover entities by kind, owner, and/or name/description text. */
|
|
32
|
+
search(query: LibrarySearchQuery): Promise<ILibraryEntity[]>;
|
|
33
|
+
/** Create a new entity or append-only-extend an existing one. */
|
|
34
|
+
save(entity: ILibraryEntity): Promise<void>;
|
|
35
|
+
delete(id: string): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=library-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-store.d.ts","sourceRoot":"","sources":["../../src/library/library-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEtF,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAC9B,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAC/B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IACzB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IACrD,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAClF,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC5D,sEAAsE;IACtE,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7D,iEAAiE;IACjE,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ILibraryEntity, ILibraryVersion } from './library-models';
|
|
3
|
+
import { LibraryListFilter, LibrarySearchQuery } from './library-store';
|
|
4
|
+
/**
|
|
5
|
+
* A portable-JSON request to a remote library ("rules server"), discriminated by
|
|
6
|
+
* `op`. Mirrors the {@link LibraryStore} surface so a remote store can proxy
|
|
7
|
+
* every operation across a transport.
|
|
8
|
+
*/
|
|
9
|
+
export type RemoteLibraryRequest = {
|
|
10
|
+
op: 'get';
|
|
11
|
+
id: string;
|
|
12
|
+
} | {
|
|
13
|
+
op: 'getVersion';
|
|
14
|
+
id: string;
|
|
15
|
+
currentHash: string;
|
|
16
|
+
} | {
|
|
17
|
+
op: 'has';
|
|
18
|
+
id: string;
|
|
19
|
+
} | {
|
|
20
|
+
op: 'list';
|
|
21
|
+
filter?: LibraryListFilter;
|
|
22
|
+
} | {
|
|
23
|
+
op: 'search';
|
|
24
|
+
query: LibrarySearchQuery;
|
|
25
|
+
} | {
|
|
26
|
+
op: 'save';
|
|
27
|
+
entity: ILibraryEntity;
|
|
28
|
+
} | {
|
|
29
|
+
op: 'delete';
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Runtime validator for a {@link RemoteLibraryRequest} — used by an HTTP/RPC
|
|
34
|
+
* server (e.g. the example endpoints route) to reject a malformed wire body
|
|
35
|
+
* before dispatching to the library server.
|
|
36
|
+
*/
|
|
37
|
+
export declare const RemoteLibraryRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
38
|
+
op: z.ZodLiteral<"get">;
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
41
|
+
op: z.ZodLiteral<"getVersion">;
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
currentHash: z.ZodString;
|
|
44
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
45
|
+
op: z.ZodLiteral<"has">;
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
op: z.ZodLiteral<"list">;
|
|
49
|
+
filter: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
51
|
+
function: "function";
|
|
52
|
+
rule: "rule";
|
|
53
|
+
}>>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
56
|
+
op: z.ZodLiteral<"search">;
|
|
57
|
+
query: z.ZodObject<{
|
|
58
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
function: "function";
|
|
60
|
+
rule: "rule";
|
|
61
|
+
}>>;
|
|
62
|
+
text: z.ZodOptional<z.ZodString>;
|
|
63
|
+
ownerPublicKey: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
op: z.ZodLiteral<"save">;
|
|
67
|
+
entity: z.ZodObject<{
|
|
68
|
+
kind: z.ZodEnum<{
|
|
69
|
+
function: "function";
|
|
70
|
+
rule: "rule";
|
|
71
|
+
}>;
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
name: z.ZodString;
|
|
74
|
+
description: z.ZodString;
|
|
75
|
+
gasLimit: z.ZodNumber;
|
|
76
|
+
owner: z.ZodObject<{
|
|
77
|
+
publicKey: z.ZodString;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
delegations: z.ZodArray<z.ZodObject<{
|
|
80
|
+
signerPublicKey: z.ZodString;
|
|
81
|
+
createdAt: z.ZodNumber;
|
|
82
|
+
proof: z.ZodObject<{
|
|
83
|
+
publicKey: z.ZodString;
|
|
84
|
+
signature: z.ZodString;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
}, z.core.$strip>>;
|
|
87
|
+
versions: z.ZodArray<z.ZodObject<{
|
|
88
|
+
createdAt: z.ZodNumber;
|
|
89
|
+
previousHash: z.ZodString;
|
|
90
|
+
source: z.ZodString;
|
|
91
|
+
currentHash: z.ZodString;
|
|
92
|
+
proof: z.ZodObject<{
|
|
93
|
+
publicKey: z.ZodString;
|
|
94
|
+
signature: z.ZodString;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
proofType: z.ZodEnum<{
|
|
97
|
+
CRYPTOGRAPHIC_SIGNATURE: "CRYPTOGRAPHIC_SIGNATURE";
|
|
98
|
+
}>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
head: z.ZodObject<{
|
|
101
|
+
currentHash: z.ZodString;
|
|
102
|
+
proof: z.ZodObject<{
|
|
103
|
+
publicKey: z.ZodString;
|
|
104
|
+
signature: z.ZodString;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
109
|
+
op: z.ZodLiteral<"delete">;
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
}, z.core.$strip>], "op">;
|
|
112
|
+
/**
|
|
113
|
+
* A portable-JSON response from a remote library. Only the field relevant to the
|
|
114
|
+
* request's `op` is populated; `error` carries a server-side failure message.
|
|
115
|
+
*/
|
|
116
|
+
export interface RemoteLibraryResponse {
|
|
117
|
+
entity?: ILibraryEntity | null;
|
|
118
|
+
version?: ILibraryVersion | null;
|
|
119
|
+
exists?: boolean;
|
|
120
|
+
entities?: ILibraryEntity[];
|
|
121
|
+
error?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The pluggable transport (a "port") carrying a request to a remote rules server
|
|
125
|
+
* and returning its response. The consumer wires this to their HTTP/RPC client,
|
|
126
|
+
* so `@degenerate/generic` stays dependency-free — the same discipline as
|
|
127
|
+
* {@link SandboxTransport} and the realtime Redis port.
|
|
128
|
+
*
|
|
129
|
+
* `send` may reject on a transport-level failure (network, timeout); that
|
|
130
|
+
* propagates to the caller rather than being mapped to a missing entity.
|
|
131
|
+
*/
|
|
132
|
+
export interface LibraryTransport {
|
|
133
|
+
send(request: RemoteLibraryRequest): Promise<RemoteLibraryResponse>;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=remote-library-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-library-models.d.ts","sourceRoot":"","sources":["../../src/library/remote-library-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAwB,eAAe,EAA2B,MAAM,kBAAkB,CAAC;AAClH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAC1B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,EAAE,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAC1C;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAC3C;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,GACtC;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAerC,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IAClC,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC7B,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACvE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RemoteLibraryRequestSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const library_models_1 = require("./library-models");
|
|
6
|
+
/**
|
|
7
|
+
* Runtime validator for a {@link RemoteLibraryRequest} — used by an HTTP/RPC
|
|
8
|
+
* server (e.g. the example endpoints route) to reject a malformed wire body
|
|
9
|
+
* before dispatching to the library server.
|
|
10
|
+
*/
|
|
11
|
+
exports.RemoteLibraryRequestSchema = zod_1.z.discriminatedUnion('op', [
|
|
12
|
+
zod_1.z.object({ op: zod_1.z.literal('get'), id: zod_1.z.string() }),
|
|
13
|
+
zod_1.z.object({ op: zod_1.z.literal('getVersion'), id: zod_1.z.string(), currentHash: zod_1.z.string() }),
|
|
14
|
+
zod_1.z.object({ op: zod_1.z.literal('has'), id: zod_1.z.string() }),
|
|
15
|
+
zod_1.z.object({ op: zod_1.z.literal('list'), filter: zod_1.z.object({ kind: library_models_1.LibraryEntityKindSchema.optional() }).optional() }),
|
|
16
|
+
zod_1.z.object({
|
|
17
|
+
op: zod_1.z.literal('search'),
|
|
18
|
+
query: zod_1.z.object({
|
|
19
|
+
kind: library_models_1.LibraryEntityKindSchema.optional(),
|
|
20
|
+
text: zod_1.z.string().optional(),
|
|
21
|
+
ownerPublicKey: zod_1.z.string().optional(),
|
|
22
|
+
}),
|
|
23
|
+
}),
|
|
24
|
+
zod_1.z.object({ op: zod_1.z.literal('save'), entity: library_models_1.ILibraryEntitySchema }),
|
|
25
|
+
zod_1.z.object({ op: zod_1.z.literal('delete'), id: zod_1.z.string() }),
|
|
26
|
+
]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LibraryStore } from './library-store';
|
|
2
|
+
import { LibraryTransport } from './remote-library-models';
|
|
3
|
+
/**
|
|
4
|
+
* A {@link LibraryStore} backed by a remote "rules server" reached over a
|
|
5
|
+
* {@link LibraryTransport}. Each operation is proxied across the transport, so a
|
|
6
|
+
* block can load (and only load) the exact rules it needs on demand.
|
|
7
|
+
*
|
|
8
|
+
* Trust discipline: the server is a cache of proofs, NEVER a trust anchor. Every
|
|
9
|
+
* entity that crosses the wire is re-verified here ({@link verifyLibraryEntity})
|
|
10
|
+
* before it is returned, so a tampered or malicious server surfaces as a thrown
|
|
11
|
+
* error rather than a corrupt entity. Compose with {@link createCachingLibraryStore}
|
|
12
|
+
* for "resolve once, retain in memory" on-demand loading.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createRemoteLibraryStore: (transport: LibraryTransport) => LibraryStore;
|
|
15
|
+
//# sourceMappingURL=remote-library-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-library-store.d.ts","sourceRoot":"","sources":["../../src/library/remote-library-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAyB,MAAM,yBAAyB,CAAC;AAUlF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,WAAW,gBAAgB,KAAG,YAoCtE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRemoteLibraryStore = void 0;
|
|
4
|
+
const verify_library_1 = require("./verify-library");
|
|
5
|
+
const unwrap = (response) => {
|
|
6
|
+
if (response.error) {
|
|
7
|
+
throw new Error(`remote library error: ${response.error}`);
|
|
8
|
+
}
|
|
9
|
+
return response;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A {@link LibraryStore} backed by a remote "rules server" reached over a
|
|
13
|
+
* {@link LibraryTransport}. Each operation is proxied across the transport, so a
|
|
14
|
+
* block can load (and only load) the exact rules it needs on demand.
|
|
15
|
+
*
|
|
16
|
+
* Trust discipline: the server is a cache of proofs, NEVER a trust anchor. Every
|
|
17
|
+
* entity that crosses the wire is re-verified here ({@link verifyLibraryEntity})
|
|
18
|
+
* before it is returned, so a tampered or malicious server surfaces as a thrown
|
|
19
|
+
* error rather than a corrupt entity. Compose with {@link createCachingLibraryStore}
|
|
20
|
+
* for "resolve once, retain in memory" on-demand loading.
|
|
21
|
+
*/
|
|
22
|
+
const createRemoteLibraryStore = (transport) => {
|
|
23
|
+
const verified = (entity) => {
|
|
24
|
+
(0, verify_library_1.verifyLibraryEntity)(entity); // throws on any tampering
|
|
25
|
+
return entity;
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
async get(id) {
|
|
29
|
+
const { entity } = unwrap(await transport.send({ op: 'get', id }));
|
|
30
|
+
return entity ? verified(entity) : undefined;
|
|
31
|
+
},
|
|
32
|
+
async getVersion(id, currentHash) {
|
|
33
|
+
// Resolve the whole entity so it is re-verified, then pick the version.
|
|
34
|
+
const { entity } = unwrap(await transport.send({ op: 'get', id }));
|
|
35
|
+
if (!entity)
|
|
36
|
+
return undefined;
|
|
37
|
+
return verified(entity).versions.find((version) => version.currentHash === currentHash);
|
|
38
|
+
},
|
|
39
|
+
async has(id) {
|
|
40
|
+
const { exists } = unwrap(await transport.send({ op: 'has', id }));
|
|
41
|
+
return exists === true;
|
|
42
|
+
},
|
|
43
|
+
async list(filter) {
|
|
44
|
+
const { entities } = unwrap(await transport.send({ op: 'list', filter }));
|
|
45
|
+
return (entities ?? []).map(verified);
|
|
46
|
+
},
|
|
47
|
+
async search(query) {
|
|
48
|
+
const { entities } = unwrap(await transport.send({ op: 'search', query }));
|
|
49
|
+
return (entities ?? []).map(verified);
|
|
50
|
+
},
|
|
51
|
+
async save(entity) {
|
|
52
|
+
unwrap(await transport.send({ op: 'save', entity }));
|
|
53
|
+
},
|
|
54
|
+
async delete(id) {
|
|
55
|
+
unwrap(await transport.send({ op: 'delete', id }));
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.createRemoteLibraryStore = createRemoteLibraryStore;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ILibraryEntity, ILibraryVersion, LibraryEntityKind } from './library-models';
|
|
2
|
+
/**
|
|
3
|
+
* Verifies a single library version against its expected chain position.
|
|
4
|
+
* Returns `true`; throws on any mismatch:
|
|
5
|
+
* 1. recompute `currentHash` from `source` + `previousHash` — must match;
|
|
6
|
+
* 2. `previousHash` must equal `expectedPreviousHash` (chain intact);
|
|
7
|
+
* 3. the Ed25519 signature must verify over the reconstructed canonical,
|
|
8
|
+
* purpose-bound payload (which also covers `createdAt`/`publicKey`).
|
|
9
|
+
*/
|
|
10
|
+
export declare const verifyLibraryVersion: (entityId: string, kind: LibraryEntityKind, version: ILibraryVersion, expectedPreviousHash: string) => true;
|
|
11
|
+
/**
|
|
12
|
+
* Verifies a whole library entity end-to-end. Returns `true`; throws on any
|
|
13
|
+
* failure. Checks: non-empty ledger; `id` equals the first version's hash
|
|
14
|
+
* (content-addressed identity); every version verifies and chains; the `head`
|
|
15
|
+
* matches the latest version and its proof verifies.
|
|
16
|
+
*
|
|
17
|
+
* This is the "quick verify" path — it re-checks recorded hashes and
|
|
18
|
+
* signatures without executing any source.
|
|
19
|
+
*/
|
|
20
|
+
export declare const verifyLibraryEntity: (entity: ILibraryEntity) => true;
|
|
21
|
+
//# sourceMappingURL=verify-library.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-library.d.ts","sourceRoot":"","sources":["../../src/library/verify-library.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQtF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAC7B,UAAU,MAAM,EAChB,MAAM,iBAAiB,EACvB,SAAS,eAAe,EACxB,sBAAsB,MAAM,KAC7B,IAoBF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,cAAc,KAAG,IA4C5D,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyLibraryEntity = exports.verifyLibraryVersion = void 0;
|
|
4
|
+
const verify_ed25519_signature_1 = require("../crypto/signature/verify-ed25519-signature");
|
|
5
|
+
const library_errors_1 = require("../errors/library/library-errors");
|
|
6
|
+
const authorize_library_1 = require("./authorize-library");
|
|
7
|
+
const library_hash_1 = require("./library-hash");
|
|
8
|
+
const library_proof_1 = require("./library-proof");
|
|
9
|
+
/**
|
|
10
|
+
* Verifies a single library version against its expected chain position.
|
|
11
|
+
* Returns `true`; throws on any mismatch:
|
|
12
|
+
* 1. recompute `currentHash` from `source` + `previousHash` — must match;
|
|
13
|
+
* 2. `previousHash` must equal `expectedPreviousHash` (chain intact);
|
|
14
|
+
* 3. the Ed25519 signature must verify over the reconstructed canonical,
|
|
15
|
+
* purpose-bound payload (which also covers `createdAt`/`publicKey`).
|
|
16
|
+
*/
|
|
17
|
+
const verifyLibraryVersion = (entityId, kind, version, expectedPreviousHash) => {
|
|
18
|
+
const recomputed = (0, library_hash_1.computeVersionHash)(version.source, version.previousHash);
|
|
19
|
+
if (recomputed !== version.currentHash) {
|
|
20
|
+
throw new library_errors_1.LibraryVersionHashMismatchError(entityId, version.currentHash, recomputed);
|
|
21
|
+
}
|
|
22
|
+
if (version.previousHash !== expectedPreviousHash) {
|
|
23
|
+
throw new library_errors_1.LibraryChainBrokenError(entityId, expectedPreviousHash, version.previousHash);
|
|
24
|
+
}
|
|
25
|
+
const payload = (0, library_proof_1.buildVersionProofPayload)({
|
|
26
|
+
id: entityId,
|
|
27
|
+
currentHash: version.currentHash,
|
|
28
|
+
previousHash: version.previousHash,
|
|
29
|
+
createdAt: version.createdAt,
|
|
30
|
+
purpose: (0, library_proof_1.versionPurpose)(kind),
|
|
31
|
+
publicKey: version.proof.publicKey,
|
|
32
|
+
});
|
|
33
|
+
if (!(0, verify_ed25519_signature_1.verifyEd25519Signature)(version.proof.publicKey, payload, version.proof.signature)) {
|
|
34
|
+
throw new library_errors_1.LibraryProofInvalidError(entityId, 'version');
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
38
|
+
exports.verifyLibraryVersion = verifyLibraryVersion;
|
|
39
|
+
/**
|
|
40
|
+
* Verifies a whole library entity end-to-end. Returns `true`; throws on any
|
|
41
|
+
* failure. Checks: non-empty ledger; `id` equals the first version's hash
|
|
42
|
+
* (content-addressed identity); every version verifies and chains; the `head`
|
|
43
|
+
* matches the latest version and its proof verifies.
|
|
44
|
+
*
|
|
45
|
+
* This is the "quick verify" path — it re-checks recorded hashes and
|
|
46
|
+
* signatures without executing any source.
|
|
47
|
+
*/
|
|
48
|
+
const verifyLibraryEntity = (entity) => {
|
|
49
|
+
if (entity.versions.length === 0) {
|
|
50
|
+
throw new library_errors_1.LibraryEntityInvalidError('entity has no versions');
|
|
51
|
+
}
|
|
52
|
+
if (entity.id !== entity.versions[0].currentHash) {
|
|
53
|
+
throw new library_errors_1.LibraryEntityInvalidError(`id ${entity.id} does not equal the first version hash ${entity.versions[0].currentHash}`);
|
|
54
|
+
}
|
|
55
|
+
// Every delegation must be a genuine owner-signed grant — catches a forged
|
|
56
|
+
// delegation entry even if no version relies on it.
|
|
57
|
+
for (const delegation of entity.delegations) {
|
|
58
|
+
if (!(0, authorize_library_1.isValidLibraryDelegation)(entity, delegation)) {
|
|
59
|
+
throw new library_errors_1.LibraryProofInvalidError(entity.id, 'delegation');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
let expectedPreviousHash = '';
|
|
63
|
+
for (const version of entity.versions) {
|
|
64
|
+
(0, exports.verifyLibraryVersion)(entity.id, entity.kind, version, expectedPreviousHash);
|
|
65
|
+
// The signature is valid; confirm the signer was actually authorized.
|
|
66
|
+
if (!(0, authorize_library_1.isLibraryAuthorizedSigner)(entity, version.proof.publicKey)) {
|
|
67
|
+
throw new library_errors_1.LibraryVersionNotAuthorizedError(entity.id, version.proof.publicKey);
|
|
68
|
+
}
|
|
69
|
+
expectedPreviousHash = version.currentHash;
|
|
70
|
+
}
|
|
71
|
+
// expectedPreviousHash now holds the latest version's currentHash.
|
|
72
|
+
if (entity.head.currentHash !== expectedPreviousHash) {
|
|
73
|
+
throw new library_errors_1.LibraryEntityInvalidError(`head ${entity.head.currentHash} does not match the latest version ${expectedPreviousHash}`);
|
|
74
|
+
}
|
|
75
|
+
const headPayload = (0, library_proof_1.buildHeadProofPayload)({
|
|
76
|
+
id: entity.id,
|
|
77
|
+
head: entity.head.currentHash,
|
|
78
|
+
purpose: (0, library_proof_1.headPurpose)(entity.kind),
|
|
79
|
+
publicKey: entity.head.proof.publicKey,
|
|
80
|
+
});
|
|
81
|
+
if (!(0, verify_ed25519_signature_1.verifyEd25519Signature)(entity.head.proof.publicKey, headPayload, entity.head.proof.signature)) {
|
|
82
|
+
throw new library_errors_1.LibraryProofInvalidError(entity.id, 'head');
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
exports.verifyLibraryEntity = verifyLibraryEntity;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Function record + proof types still referenced by the runtime (the rules
|
|
4
|
+
* engine's `ITargetObject` and the `IShareDataFunction` shape used by
|
|
5
|
+
* `share-data-errors`). The earlier network-function/rule "logic library"
|
|
6
|
+
* sketches (`IShareDataNetworkFunction` / `IShareDataNetworkRule` / …) were
|
|
7
|
+
* removed — the live, signed, versioned library entities in
|
|
8
|
+
* `@degenerate/generic`'s `library/` module supersede them.
|
|
4
9
|
*/
|
|
5
10
|
/**
|
|
6
11
|
* This contains all the proof types that exist for the network.
|
|
@@ -59,77 +64,4 @@ export declare const IShareDataFunctionSchema: z.ZodObject<{
|
|
|
59
64
|
currentHash: z.ZodString;
|
|
60
65
|
}, z.core.$strip>;
|
|
61
66
|
export type IShareDataFunction = z.infer<typeof IShareDataFunctionSchema>;
|
|
62
|
-
/**
|
|
63
|
-
* This contains a share data network function
|
|
64
|
-
*/
|
|
65
|
-
export declare const IShareDataNetworkFunctionSchema: z.ZodObject<{
|
|
66
|
-
id: z.ZodString;
|
|
67
|
-
name: z.ZodString;
|
|
68
|
-
description: z.ZodString;
|
|
69
|
-
shareDataFunctions: z.ZodArray<z.ZodObject<{
|
|
70
|
-
proof: z.ZodObject<{
|
|
71
|
-
publicKey: z.ZodString;
|
|
72
|
-
signature: z.ZodString;
|
|
73
|
-
}, z.core.$strip>;
|
|
74
|
-
proofType: z.ZodEnum<{
|
|
75
|
-
CRYPTOGRAPHIC_SIGNATURE: "CRYPTOGRAPHIC_SIGNATURE";
|
|
76
|
-
}>;
|
|
77
|
-
createdAt: z.ZodNumber;
|
|
78
|
-
previousHash: z.ZodString;
|
|
79
|
-
stringifiedFunction: z.ZodString;
|
|
80
|
-
currentHash: z.ZodString;
|
|
81
|
-
}, z.core.$strip>>;
|
|
82
|
-
proof: z.ZodObject<{
|
|
83
|
-
publicKey: z.ZodString;
|
|
84
|
-
signature: z.ZodString;
|
|
85
|
-
}, z.core.$strip>;
|
|
86
|
-
proofType: z.ZodEnum<{
|
|
87
|
-
CRYPTOGRAPHIC_SIGNATURE: "CRYPTOGRAPHIC_SIGNATURE";
|
|
88
|
-
}>;
|
|
89
|
-
}, z.core.$strip>;
|
|
90
|
-
export type IShareDataNetworkFunction = z.infer<typeof IShareDataNetworkFunctionSchema>;
|
|
91
|
-
/**
|
|
92
|
-
* This contains the data for a share data network function descriptor.
|
|
93
|
-
*/
|
|
94
|
-
export declare const IShareDataNetworkFunctionDescriptorSchema: z.ZodObject<{
|
|
95
|
-
functionNumber: z.ZodNumber;
|
|
96
|
-
name: z.ZodString;
|
|
97
|
-
description: z.ZodString;
|
|
98
|
-
}, z.core.$strip>;
|
|
99
|
-
export type IShareDataNetworkFunctionDescriptor = z.infer<typeof IShareDataNetworkFunctionDescriptorSchema>;
|
|
100
|
-
/**
|
|
101
|
-
* This contains the data for a share data network rule that is the basic shape.
|
|
102
|
-
*/
|
|
103
|
-
export declare const IShareDataRuleBasicSchema: z.ZodObject<{
|
|
104
|
-
createdAt: z.ZodNumber;
|
|
105
|
-
previousHash: z.ZodString;
|
|
106
|
-
stringifiedRule: z.ZodString;
|
|
107
|
-
currentHash: z.ZodString;
|
|
108
|
-
}, z.core.$strip>;
|
|
109
|
-
export type IShareDataRuleBasic = z.infer<typeof IShareDataRuleBasicSchema>;
|
|
110
|
-
/**
|
|
111
|
-
* This contains the interface for a share function record in the share data object
|
|
112
|
-
*/
|
|
113
|
-
export declare const IShareDataNetworkRuleSchema: z.ZodObject<{
|
|
114
|
-
id: z.ZodString;
|
|
115
|
-
shareDataRules: z.ZodArray<z.ZodObject<{
|
|
116
|
-
createdAt: z.ZodNumber;
|
|
117
|
-
previousHash: z.ZodString;
|
|
118
|
-
stringifiedRule: z.ZodString;
|
|
119
|
-
currentHash: z.ZodString;
|
|
120
|
-
}, z.core.$strip>>;
|
|
121
|
-
applicationId: z.ZodString;
|
|
122
|
-
applicationIdProof: z.ZodString;
|
|
123
|
-
}, z.core.$strip>;
|
|
124
|
-
export type IShareDataNetworkRule = z.infer<typeof IShareDataNetworkRuleSchema>;
|
|
125
|
-
/**
|
|
126
|
-
* This contains the data for a share data network rule.
|
|
127
|
-
*/
|
|
128
|
-
export declare const IShareDataRuleSchema: z.ZodObject<{
|
|
129
|
-
createdAt: z.ZodNumber;
|
|
130
|
-
previousHash: z.ZodString;
|
|
131
|
-
stringifiedRule: z.ZodString;
|
|
132
|
-
currentHash: z.ZodString;
|
|
133
|
-
}, z.core.$strip>;
|
|
134
|
-
export type IShareDataRule = z.infer<typeof IShareDataRuleSchema>;
|
|
135
67
|
//# sourceMappingURL=share-data-function-models.d.ts.map
|