@totemsdk/proofgraph 0.1.1 → 1.0.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/canonical.d.ts +4 -4
- package/dist/canonical.js +11 -26
- package/dist/index.js +1 -1
- package/dist/io.d.ts +8 -5
- package/dist/io.js +132 -8
- package/package.json +21 -24
- package/rust/pkg/package.json +27 -0
- package/rust/pkg/proofgraph_wasm.d.ts +30 -0
- package/rust/pkg/proofgraph_wasm.js +9 -0
- package/rust/pkg/proofgraph_wasm_bg.js +690 -0
- package/rust/pkg/proofgraph_wasm_bg.wasm +0 -0
- package/rust/pkg/proofgraph_wasm_bg.wasm.d.ts +25 -0
- package/rust/pkg-node/package.json +21 -0
- package/rust/pkg-node/proofgraph_wasm.d.ts +30 -0
- package/rust/pkg-node/proofgraph_wasm.js +709 -0
- package/rust/pkg-node/proofgraph_wasm_bg.wasm +0 -0
- package/rust/pkg-node/proofgraph_wasm_bg.wasm.d.ts +25 -0
package/dist/canonical.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canonical JSON and ID rules for @totemsdk/proofgraph.
|
|
3
3
|
*
|
|
4
|
-
* canonicalJson
|
|
5
|
-
*
|
|
4
|
+
* canonicalJson and toHex are re-exported from @totemsdk/proof, which is the
|
|
5
|
+
* canonical implementation across the Totem SDK.
|
|
6
6
|
*
|
|
7
7
|
* ID rules:
|
|
8
8
|
* Node: type + ":" + refId (e.g. "proof:totem:proof:abc123")
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* Graph: sha3_256("totem-proofgraph" + canonicalJson(nodeHashes) + canonicalJson(sortedEdges))
|
|
11
11
|
* — node.createdAt and graph.metadata excluded from graphId (time-variant / mutable)
|
|
12
12
|
*/
|
|
13
|
+
import { canonicalJson, toHex } from '@totemsdk/proof';
|
|
13
14
|
import type { ProofGraphNode, ProofGraphEdge } from './types.js';
|
|
14
|
-
export
|
|
15
|
-
export declare function canonicalJson(value: unknown): string;
|
|
15
|
+
export { canonicalJson, toHex };
|
|
16
16
|
export declare function computeNodeId(type: string, refId: string): string;
|
|
17
17
|
export declare function computeEdgeId(type: string, from: string, to: string, proofId: string | undefined, data: Record<string, unknown> | undefined): string;
|
|
18
18
|
export declare function computeProofGraphId(nodes: ProofGraphNode[], edges: ProofGraphEdge[]): string;
|
package/dist/canonical.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Canonical JSON and ID rules for @totemsdk/proofgraph.
|
|
4
4
|
*
|
|
5
|
-
* canonicalJson
|
|
6
|
-
*
|
|
5
|
+
* canonicalJson and toHex are re-exported from @totemsdk/proof, which is the
|
|
6
|
+
* canonical implementation across the Totem SDK.
|
|
7
7
|
*
|
|
8
8
|
* ID rules:
|
|
9
9
|
* Node: type + ":" + refId (e.g. "proof:totem:proof:abc123")
|
|
@@ -12,37 +12,22 @@
|
|
|
12
12
|
* — node.createdAt and graph.metadata excluded from graphId (time-variant / mutable)
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.toHex =
|
|
16
|
-
exports.canonicalJson = canonicalJson;
|
|
15
|
+
exports.toHex = exports.canonicalJson = void 0;
|
|
17
16
|
exports.computeNodeId = computeNodeId;
|
|
18
17
|
exports.computeEdgeId = computeEdgeId;
|
|
19
18
|
exports.computeProofGraphId = computeProofGraphId;
|
|
20
19
|
exports.recomputeGraphId = recomputeGraphId;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.join('');
|
|
26
|
-
}
|
|
27
|
-
function canonicalJson(value) {
|
|
28
|
-
if (value === null || typeof value !== 'object') {
|
|
29
|
-
return JSON.stringify(value);
|
|
30
|
-
}
|
|
31
|
-
if (Array.isArray(value)) {
|
|
32
|
-
return '[' + value.map(canonicalJson).join(',') + ']';
|
|
33
|
-
}
|
|
34
|
-
const obj = value;
|
|
35
|
-
const keys = Object.keys(obj).sort();
|
|
36
|
-
const pairs = keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(obj[k])}`);
|
|
37
|
-
return '{' + pairs.join(',') + '}';
|
|
38
|
-
}
|
|
20
|
+
const core_1 = require("@totemsdk/core");
|
|
21
|
+
const proof_1 = require("@totemsdk/proof");
|
|
22
|
+
Object.defineProperty(exports, "canonicalJson", { enumerable: true, get: function () { return proof_1.canonicalJson; } });
|
|
23
|
+
Object.defineProperty(exports, "toHex", { enumerable: true, get: function () { return proof_1.toHex; } });
|
|
39
24
|
function computeNodeId(type, refId) {
|
|
40
25
|
return `${type}:${refId}`;
|
|
41
26
|
}
|
|
42
27
|
function computeEdgeId(type, from, to, proofId, data) {
|
|
43
|
-
const canonicalDataHash = toHex((0,
|
|
28
|
+
const canonicalDataHash = (0, proof_1.toHex)((0, core_1.sha3_256)(new TextEncoder().encode((0, proof_1.canonicalJson)(data ?? {}))));
|
|
44
29
|
const input = 'totem-proofgraph-edge' + type + from + to + (proofId ?? '') + canonicalDataHash;
|
|
45
|
-
return toHex((0,
|
|
30
|
+
return (0, proof_1.toHex)((0, core_1.sha3_256)(new TextEncoder().encode(input)));
|
|
46
31
|
}
|
|
47
32
|
/**
|
|
48
33
|
* Content-stable projection of a node for graphId computation.
|
|
@@ -58,8 +43,8 @@ function computeProofGraphId(nodes, edges) {
|
|
|
58
43
|
.sort((a, b) => a.id.localeCompare(b.id))
|
|
59
44
|
.map(nodeForHashing);
|
|
60
45
|
const sortedEdges = [...edges].sort((a, b) => a.id.localeCompare(b.id));
|
|
61
|
-
const input = 'totem-proofgraph' + canonicalJson(sortedNodes) + canonicalJson(sortedEdges);
|
|
62
|
-
return toHex((0,
|
|
46
|
+
const input = 'totem-proofgraph' + (0, proof_1.canonicalJson)(sortedNodes) + (0, proof_1.canonicalJson)(sortedEdges);
|
|
47
|
+
return (0, proof_1.toHex)((0, core_1.sha3_256)(new TextEncoder().encode(input)));
|
|
63
48
|
}
|
|
64
49
|
function recomputeGraphId(graph) {
|
|
65
50
|
return computeProofGraphId(graph.nodes, graph.edges);
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.importProofGraph = exports.exportProofGraph = exports.verifyGraphProofs = exports.verifyProofGraph = exports.reachableFrom = exports.getEdgesBetween = exports.getManifestsForAddress = exports.resolveCurrentProofSet = exports.getProofLineage = exports.getEvidenceTrail = exports.findConflicts = exports.findSupersessions = exports.findRevocations = exports.findAnchorsForProof = exports.findProofsByIssuer = exports.findProofsBySubject = exports.getProofNodes = exports.getEdgesByType = exports.getEdgesTo = exports.getEdgesFrom = exports.findNode = exports.addAnchor = exports.addReceiptLike = exports.addManifest = exports.addIdentityClaim = exports.addProof = exports.addIdentityDocument = exports.addEdge = exports.addNode = exports.buildEdge = exports.setGraphMetadata = exports.createProofGraph = exports.recomputeGraphId = exports.computeProofGraphId = exports.computeEdgeId = exports.computeNodeId = exports.canonicalJson = exports.toHex = void 0;
|
|
19
|
-
var canonical_js_1 = require("./canonical.js");
|
|
19
|
+
var canonical_js_1 = require("./canonical.js"); // canonicalJson / toHex re-exported from @totemsdk/proof
|
|
20
20
|
Object.defineProperty(exports, "toHex", { enumerable: true, get: function () { return canonical_js_1.toHex; } });
|
|
21
21
|
Object.defineProperty(exports, "canonicalJson", { enumerable: true, get: function () { return canonical_js_1.canonicalJson; } });
|
|
22
22
|
Object.defineProperty(exports, "computeNodeId", { enumerable: true, get: function () { return canonical_js_1.computeNodeId; } });
|
package/dist/io.d.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Serialization helpers for ProofGraph.
|
|
3
3
|
*
|
|
4
4
|
* exportProofGraph: JSON-stringify the graph for storage or transport.
|
|
5
|
-
* importProofGraph: parse JSON, recompute graphId,
|
|
5
|
+
* importProofGraph: parse JSON, validate every node/edge, recompute graphId,
|
|
6
|
+
* and throw if verification fails.
|
|
6
7
|
*
|
|
7
|
-
* The graphId guards against silent corruption in transit.
|
|
8
|
+
* The graphId guards against silent corruption in transit. Node/edge
|
|
9
|
+
* validation prevents hostile or malformed input from entering the system.
|
|
8
10
|
*/
|
|
9
11
|
import type { ProofGraph } from './types.js';
|
|
10
12
|
/**
|
|
@@ -15,9 +17,10 @@ export declare function exportProofGraph(graph: ProofGraph): string;
|
|
|
15
17
|
/**
|
|
16
18
|
* Deserialize a ProofGraph from a JSON string.
|
|
17
19
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
+
* Validates every node and edge against structural constraints, then
|
|
21
|
+
* recomputes the graphId from nodes + edges. Throws if any constraint
|
|
22
|
+
* is violated or if the recomputed graphId does not match the stored value.
|
|
20
23
|
*
|
|
21
|
-
* @throws Error if graphId verification fails.
|
|
24
|
+
* @throws Error if parsing, validation, or graphId verification fails.
|
|
22
25
|
*/
|
|
23
26
|
export declare function importProofGraph(json: string): ProofGraph;
|
package/dist/io.js
CHANGED
|
@@ -3,14 +3,120 @@
|
|
|
3
3
|
* Serialization helpers for ProofGraph.
|
|
4
4
|
*
|
|
5
5
|
* exportProofGraph: JSON-stringify the graph for storage or transport.
|
|
6
|
-
* importProofGraph: parse JSON, recompute graphId,
|
|
6
|
+
* importProofGraph: parse JSON, validate every node/edge, recompute graphId,
|
|
7
|
+
* and throw if verification fails.
|
|
7
8
|
*
|
|
8
|
-
* The graphId guards against silent corruption in transit.
|
|
9
|
+
* The graphId guards against silent corruption in transit. Node/edge
|
|
10
|
+
* validation prevents hostile or malformed input from entering the system.
|
|
9
11
|
*/
|
|
10
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
13
|
exports.exportProofGraph = exportProofGraph;
|
|
12
14
|
exports.importProofGraph = importProofGraph;
|
|
13
15
|
const canonical_js_1 = require("./canonical.js");
|
|
16
|
+
const VALID_NODE_TYPES = new Set([
|
|
17
|
+
'proof', 'identity', 'identity-claim', 'manifest', 'address',
|
|
18
|
+
'subject', 'evidence', 'anchor', 'receipt', 'payment', 'device',
|
|
19
|
+
'service', 'policy', 'custom',
|
|
20
|
+
]);
|
|
21
|
+
const VALID_EDGE_TYPES = new Set([
|
|
22
|
+
'proves', 'issued_by', 'signed_by', 'about', 'references',
|
|
23
|
+
'derived_from', 'supports', 'contradicts', 'supersedes', 'revokes',
|
|
24
|
+
'anchored_to', 'delegates_to', 'controls', 'depends_on',
|
|
25
|
+
'manifests_as', 'conflicts_with',
|
|
26
|
+
]);
|
|
27
|
+
const MAX_NODES = 10000;
|
|
28
|
+
const MAX_EDGES = 50000;
|
|
29
|
+
const MAX_STRING_LENGTH = 4096;
|
|
30
|
+
const MAX_DATA_DEPTH = 10;
|
|
31
|
+
const MAX_DATA_KEYS = 256;
|
|
32
|
+
/**
|
|
33
|
+
* Validate a single ProofGraphNode.
|
|
34
|
+
* Throws if the node violates structural constraints.
|
|
35
|
+
*/
|
|
36
|
+
function validateNode(node, index) {
|
|
37
|
+
if (!node || typeof node !== 'object') {
|
|
38
|
+
throw new Error(`importProofGraph: nodes[${index}] is not an object`);
|
|
39
|
+
}
|
|
40
|
+
const n = node;
|
|
41
|
+
if (typeof n.id !== 'string' || n.id.length === 0) {
|
|
42
|
+
throw new Error(`importProofGraph: nodes[${index}] missing or empty id`);
|
|
43
|
+
}
|
|
44
|
+
if (typeof n.refId !== 'string' || n.refId.length === 0) {
|
|
45
|
+
throw new Error(`importProofGraph: nodes[${index}] missing or empty refId`);
|
|
46
|
+
}
|
|
47
|
+
if (n.id.length > MAX_STRING_LENGTH) {
|
|
48
|
+
throw new Error(`importProofGraph: nodes[${index}].id exceeds ${MAX_STRING_LENGTH} chars`);
|
|
49
|
+
}
|
|
50
|
+
if (n.refId.length > MAX_STRING_LENGTH) {
|
|
51
|
+
throw new Error(`importProofGraph: nodes[${index}].refId exceeds ${MAX_STRING_LENGTH} chars`);
|
|
52
|
+
}
|
|
53
|
+
if (!VALID_NODE_TYPES.has(String(n.type))) {
|
|
54
|
+
throw new Error(`importProofGraph: nodes[${index}] invalid type "${String(n.type)}"`);
|
|
55
|
+
}
|
|
56
|
+
if (typeof n.createdAt !== 'number' || n.createdAt < 0 || !Number.isFinite(n.createdAt)) {
|
|
57
|
+
throw new Error(`importProofGraph: nodes[${index}] invalid or negative createdAt`);
|
|
58
|
+
}
|
|
59
|
+
if (n.data !== undefined && n.data !== null) {
|
|
60
|
+
if (typeof n.data !== 'object') {
|
|
61
|
+
throw new Error(`importProofGraph: nodes[${index}].data must be an object`);
|
|
62
|
+
}
|
|
63
|
+
const keys = Object.keys(n.data);
|
|
64
|
+
if (keys.length > MAX_DATA_KEYS) {
|
|
65
|
+
throw new Error(`importProofGraph: nodes[${index}].data exceeds ${MAX_DATA_KEYS} keys`);
|
|
66
|
+
}
|
|
67
|
+
checkDepth(n.data, 0, MAX_DATA_DEPTH, `nodes[${index}].data`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Validate a single ProofGraphEdge.
|
|
72
|
+
* Throws if the edge violates structural constraints.
|
|
73
|
+
*/
|
|
74
|
+
function validateEdge(edge, index) {
|
|
75
|
+
if (!edge || typeof edge !== 'object') {
|
|
76
|
+
throw new Error(`importProofGraph: edges[${index}] is not an object`);
|
|
77
|
+
}
|
|
78
|
+
const e = edge;
|
|
79
|
+
if (typeof e.id !== 'string' || e.id.length === 0) {
|
|
80
|
+
throw new Error(`importProofGraph: edges[${index}] missing or empty id`);
|
|
81
|
+
}
|
|
82
|
+
if (typeof e.from !== 'string' || e.from.length === 0) {
|
|
83
|
+
throw new Error(`importProofGraph: edges[${index}] missing or empty from`);
|
|
84
|
+
}
|
|
85
|
+
if (typeof e.to !== 'string' || e.to.length === 0) {
|
|
86
|
+
throw new Error(`importProofGraph: edges[${index}] missing or empty to`);
|
|
87
|
+
}
|
|
88
|
+
if (e.id.length > MAX_STRING_LENGTH || e.from.length > MAX_STRING_LENGTH || e.to.length > MAX_STRING_LENGTH) {
|
|
89
|
+
throw new Error(`importProofGraph: edges[${index}] string field exceeds ${MAX_STRING_LENGTH} chars`);
|
|
90
|
+
}
|
|
91
|
+
if (!VALID_EDGE_TYPES.has(String(e.type))) {
|
|
92
|
+
throw new Error(`importProofGraph: edges[${index}] invalid type "${String(e.type)}"`);
|
|
93
|
+
}
|
|
94
|
+
if (e.proofId !== undefined && typeof e.proofId !== 'string') {
|
|
95
|
+
throw new Error(`importProofGraph: edges[${index}].proofId must be a string`);
|
|
96
|
+
}
|
|
97
|
+
if (e.data !== undefined && e.data !== null) {
|
|
98
|
+
if (typeof e.data !== 'object') {
|
|
99
|
+
throw new Error(`importProofGraph: edges[${index}].data must be an object`);
|
|
100
|
+
}
|
|
101
|
+
checkDepth(e.data, 0, MAX_DATA_DEPTH, `edges[${index}].data`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Recursive depth check on nested data objects to prevent deep-object attacks.
|
|
106
|
+
*/
|
|
107
|
+
function checkDepth(obj, depth, maxDepth, path) {
|
|
108
|
+
if (depth > maxDepth) {
|
|
109
|
+
throw new Error(`importProofGraph: ${path} exceeds max nesting depth of ${maxDepth}`);
|
|
110
|
+
}
|
|
111
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
112
|
+
if (typeof key === 'string' && key.length > MAX_STRING_LENGTH) {
|
|
113
|
+
throw new Error(`importProofGraph: ${path} key exceeds ${MAX_STRING_LENGTH} chars`);
|
|
114
|
+
}
|
|
115
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Uint8Array)) {
|
|
116
|
+
checkDepth(value, depth + 1, maxDepth, `${path}.${key}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
14
120
|
/**
|
|
15
121
|
* Serialize a ProofGraph to a JSON string.
|
|
16
122
|
* The stored graphId was computed at mutation time and is included as-is.
|
|
@@ -21,10 +127,11 @@ function exportProofGraph(graph) {
|
|
|
21
127
|
/**
|
|
22
128
|
* Deserialize a ProofGraph from a JSON string.
|
|
23
129
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
130
|
+
* Validates every node and edge against structural constraints, then
|
|
131
|
+
* recomputes the graphId from nodes + edges. Throws if any constraint
|
|
132
|
+
* is violated or if the recomputed graphId does not match the stored value.
|
|
26
133
|
*
|
|
27
|
-
* @throws Error if graphId verification fails.
|
|
134
|
+
* @throws Error if parsing, validation, or graphId verification fails.
|
|
28
135
|
*/
|
|
29
136
|
function importProofGraph(json) {
|
|
30
137
|
let parsed;
|
|
@@ -41,9 +148,26 @@ function importProofGraph(json) {
|
|
|
41
148
|
if (!Array.isArray(graph.nodes) || !Array.isArray(graph.edges)) {
|
|
42
149
|
throw new Error('importProofGraph: missing nodes or edges arrays');
|
|
43
150
|
}
|
|
151
|
+
if (graph.nodes.length > MAX_NODES) {
|
|
152
|
+
throw new Error(`importProofGraph: node count ${graph.nodes.length} exceeds limit ${MAX_NODES}`);
|
|
153
|
+
}
|
|
154
|
+
if (graph.edges.length > MAX_EDGES) {
|
|
155
|
+
throw new Error(`importProofGraph: edge count ${graph.edges.length} exceeds limit ${MAX_EDGES}`);
|
|
156
|
+
}
|
|
157
|
+
// Validate every node and edge
|
|
158
|
+
for (let i = 0; i < graph.nodes.length; i++) {
|
|
159
|
+
validateNode(graph.nodes[i], i);
|
|
160
|
+
}
|
|
161
|
+
for (let i = 0; i < graph.edges.length; i++) {
|
|
162
|
+
validateEdge(graph.edges[i], i);
|
|
163
|
+
}
|
|
164
|
+
// Recompute and verify graphId
|
|
165
|
+
const originalId = typeof graph.graphId === 'string' ? graph.graphId : '';
|
|
44
166
|
const recomputed = (0, canonical_js_1.recomputeGraphId)(graph);
|
|
45
|
-
|
|
46
|
-
|
|
167
|
+
// If a stored graphId exists, verify it matches
|
|
168
|
+
if (originalId !== '' && recomputed !== originalId) {
|
|
169
|
+
throw new Error(`importProofGraph: graphId mismatch — stored="${originalId}" recomputed="${recomputed}"`);
|
|
47
170
|
}
|
|
48
|
-
|
|
171
|
+
// Return with graphId set to the recomputed value for consistency
|
|
172
|
+
return { ...graph, graphId: recomputed };
|
|
49
173
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/proofgraph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Local deterministic proof relationship graph for Totem Edge — indexes proofs, identities, manifests, and subjects into a queryable content-addressed DAG",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,30 +13,23 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
+
"rust/pkg/",
|
|
17
|
+
"rust/pkg-node/",
|
|
16
18
|
"README.md",
|
|
17
19
|
"LICENSE"
|
|
18
20
|
],
|
|
19
21
|
"dependencies": {
|
|
20
|
-
"@totemsdk/core": "1.
|
|
21
|
-
"@totemsdk/proof": "0.
|
|
22
|
-
"@totemsdk/manifest": "0.
|
|
23
|
-
"@totemsdk/identity": "0.
|
|
24
|
-
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@noble/hashes": "^2.0.0"
|
|
27
|
-
},
|
|
28
|
-
"peerDependenciesMeta": {
|
|
29
|
-
"@noble/hashes": {
|
|
30
|
-
"optional": false
|
|
31
|
-
}
|
|
22
|
+
"@totemsdk/core": "^1.2.9",
|
|
23
|
+
"@totemsdk/proof": "^1.0.0",
|
|
24
|
+
"@totemsdk/manifest": "^1.0.0",
|
|
25
|
+
"@totemsdk/identity": "^1.0.0"
|
|
32
26
|
},
|
|
33
27
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@types/jest": "^29.0.0",
|
|
28
|
+
"@types/jest": "^30.0.0",
|
|
36
29
|
"@types/node": "^20.0.0",
|
|
37
|
-
"jest": "^
|
|
30
|
+
"jest": "^30.4.2",
|
|
38
31
|
"ts-jest": "^29.0.0",
|
|
39
|
-
"typescript": "^
|
|
32
|
+
"typescript": "^7.0.2"
|
|
40
33
|
},
|
|
41
34
|
"engines": {
|
|
42
35
|
"node": ">=18.0.0"
|
|
@@ -46,20 +39,23 @@
|
|
|
46
39
|
},
|
|
47
40
|
"license": "MIT",
|
|
48
41
|
"author": "Totem SDK",
|
|
49
|
-
"homepage": "https://
|
|
42
|
+
"homepage": "https://totem.ing",
|
|
50
43
|
"bugs": {
|
|
51
|
-
"url": "https://github.com/
|
|
44
|
+
"url": "https://github.com/Totem-Edge/totem-sdk/issues"
|
|
52
45
|
},
|
|
53
46
|
"repository": {
|
|
54
47
|
"type": "git",
|
|
55
|
-
"url": "git+https://github.com/
|
|
56
|
-
"directory": "packages/
|
|
48
|
+
"url": "git+https://github.com/Totem-Edge/totem-sdk.git",
|
|
49
|
+
"directory": "packages/proofgraph"
|
|
57
50
|
},
|
|
58
51
|
"keywords": [
|
|
59
52
|
"totem",
|
|
60
53
|
"totemsdk",
|
|
61
54
|
"minima",
|
|
62
55
|
"blockchain",
|
|
56
|
+
"quantum-resistant",
|
|
57
|
+
"wots",
|
|
58
|
+
"utxo",
|
|
63
59
|
"proof",
|
|
64
60
|
"graph",
|
|
65
61
|
"dag",
|
|
@@ -69,8 +65,9 @@
|
|
|
69
65
|
"content-addressed"
|
|
70
66
|
],
|
|
71
67
|
"scripts": {
|
|
72
|
-
"build": "tsc",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
68
|
+
"build": "npm run build:wasm && tsc && node ../../scripts/clean-wasm-output-ignores.mjs",
|
|
69
|
+
"build:wasm": "cd rust && wasm-pack build --target bundler --out-dir pkg && wasm-pack build --target nodejs --out-dir pkg-node",
|
|
70
|
+
"clean": "rm -rf dist rust/pkg rust/pkg-node rust/target",
|
|
71
|
+
"test": "jest"
|
|
75
72
|
}
|
|
76
73
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "proofgraph-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Totem SDK Contributors"
|
|
6
|
+
],
|
|
7
|
+
"description": "Local deterministic proof relationship graph — content-addressed DAG, node/edge ID computation, graph ID hashing, import/export validation (Rust/WASM)",
|
|
8
|
+
"version": "0.1.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/Totem-Edge/totem-sdk"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"proofgraph_wasm_bg.wasm",
|
|
16
|
+
"proofgraph_wasm.js",
|
|
17
|
+
"proofgraph_wasm_bg.js",
|
|
18
|
+
"proofgraph_wasm.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"main": "proofgraph_wasm.js",
|
|
21
|
+
"homepage": "https://totem.ing",
|
|
22
|
+
"types": "proofgraph_wasm.d.ts",
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"./proofgraph_wasm.js",
|
|
25
|
+
"./snippets/*"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function add_edge_wasm(graph_js: any, edge_js: any): any;
|
|
5
|
+
|
|
6
|
+
export function add_node_wasm(graph_js: any, node_type: string, ref_id: string, data_js: any | null | undefined, created_at: bigint): any;
|
|
7
|
+
|
|
8
|
+
export function canonical_json_wasm(value_js: any): string;
|
|
9
|
+
|
|
10
|
+
export function compute_edge_id_wasm(edge_type: string, from: string, to: string, proof_id?: string | null, data_js?: any | null): string;
|
|
11
|
+
|
|
12
|
+
export function compute_node_id_wasm(node_type: string, ref_id: string): string;
|
|
13
|
+
|
|
14
|
+
export function compute_proof_graph_id_wasm(nodes_js: any, edges_js: any): string;
|
|
15
|
+
|
|
16
|
+
export function create_proof_graph_wasm(metadata_js: any | null | undefined, created_at: bigint): any;
|
|
17
|
+
|
|
18
|
+
export function find_node_wasm(graph_js: any, id: string): any;
|
|
19
|
+
|
|
20
|
+
export function find_proofs_by_subject_wasm(graph_js: any, subject_id: string): any;
|
|
21
|
+
|
|
22
|
+
export function get_edges_from_wasm(graph_js: any, node_id: string): any;
|
|
23
|
+
|
|
24
|
+
export function init(): void;
|
|
25
|
+
|
|
26
|
+
export function reachable_from_wasm(graph_js: any, start_ref_id: string): any;
|
|
27
|
+
|
|
28
|
+
export function resolve_current_proof_set_wasm(graph_js: any): any;
|
|
29
|
+
|
|
30
|
+
export function to_hex_wasm(bytes: Uint8Array): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./proofgraph_wasm.d.ts" */
|
|
2
|
+
import * as wasm from "./proofgraph_wasm_bg.wasm";
|
|
3
|
+
import { __wbg_set_wasm } from "./proofgraph_wasm_bg.js";
|
|
4
|
+
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
add_edge_wasm, add_node_wasm, canonical_json_wasm, compute_edge_id_wasm, compute_node_id_wasm, compute_proof_graph_id_wasm, create_proof_graph_wasm, find_node_wasm, find_proofs_by_subject_wasm, get_edges_from_wasm, init, reachable_from_wasm, resolve_current_proof_set_wasm, to_hex_wasm
|
|
9
|
+
} from "./proofgraph_wasm_bg.js";
|