@fangorn-network/sdk 2026.7.13 → 2026.7.14

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.
Files changed (61) hide show
  1. package/README.md +23 -2
  2. package/lib/cli/cli.js +18 -11
  3. package/lib/cli/index.d.ts +13 -13
  4. package/lib/config.d.ts +93 -92
  5. package/lib/contracts/data-registry/abi.d.ts +207 -35
  6. package/lib/contracts/data-registry/index.js +4 -4
  7. package/lib/contracts/index.d.ts +3 -1
  8. package/lib/contracts/index.js +3 -1
  9. package/lib/contracts/settlement-registry/abi.d.ts +47 -0
  10. package/lib/contracts/settlement-registry/abi.js +48 -0
  11. package/lib/contracts/settlement-registry/index.d.ts +25 -0
  12. package/lib/contracts/settlement-registry/index.js +40 -0
  13. package/lib/crypto/aes.d.ts +1 -8
  14. package/lib/crypto/aes.js +2 -34
  15. package/lib/crypto/encryption.d.ts +112 -26
  16. package/lib/crypto/encryption.js +105 -21
  17. package/lib/engine/index.js +5 -2
  18. package/lib/fangorn.d.ts +3 -3
  19. package/lib/fangorn.js +19 -13
  20. package/lib/harness/index.d.ts +4 -3
  21. package/lib/harness/index.js +9 -3
  22. package/lib/index.d.ts +2 -3
  23. package/lib/index.js +2 -3
  24. package/lib/node_modules/{.pnpm/@noble_ciphers@1.3.0/node_modules/@noble → @noble}/ciphers/esm/_polyval.js +1 -1
  25. package/lib/node_modules/{.pnpm/@noble_ciphers@1.3.0/node_modules/@noble → @noble}/ciphers/esm/aes.js +1 -1
  26. package/lib/node_modules/{.pnpm/@noble_ciphers@1.3.0/node_modules/@noble → @noble}/ciphers/esm/utils.js +1 -1
  27. package/lib/node_modules/{.pnpm/@noble_curves@1.9.7/node_modules/@noble → @noble}/curves/esm/abstract/curve.js +1 -1
  28. package/lib/node_modules/{.pnpm/@noble_curves@1.9.7/node_modules/@noble → @noble}/curves/esm/abstract/edwards.js +1 -1
  29. package/lib/node_modules/{.pnpm/@noble_curves@1.9.7/node_modules/@noble → @noble}/curves/esm/abstract/modular.js +1 -1
  30. package/lib/node_modules/{.pnpm/@noble_curves@1.9.7/node_modules/@noble → @noble}/curves/esm/abstract/montgomery.js +1 -1
  31. package/lib/node_modules/{.pnpm/@noble_curves@1.9.7/node_modules/@noble → @noble}/curves/esm/ed25519.js +1 -1
  32. package/lib/node_modules/{.pnpm/@noble_curves@1.9.7/node_modules/@noble → @noble}/curves/esm/utils.js +1 -1
  33. package/lib/providers/storage/car.js +2 -1
  34. package/lib/providers/storage/pinata.js +5 -4
  35. package/lib/{roles/repo → repo}/index.d.ts +1 -1
  36. package/lib/{roles/repo → repo}/index.js +1 -1
  37. package/lib/test/testbed.d.ts +2 -2
  38. package/lib/test/testbed.js +1 -1
  39. package/package.json +2 -2
  40. package/lib/ crypto/constants.d.ts +0 -4
  41. package/lib/ crypto/constants.js +0 -5
  42. package/lib/ crypto/merkle.d.ts +0 -10
  43. package/lib/ crypto/merkle.js +0 -34
  44. package/lib/ crypto/utils.d.ts +0 -1
  45. package/lib/ crypto/utils.js +0 -1
  46. package/lib/builders/a2aCardBuilder.d.ts +0 -28
  47. package/lib/builders/a2aCardBuilder.js +0 -105
  48. package/lib/roles/index.d.ts +0 -1
  49. package/lib/roles/index.js +0 -1
  50. package/lib/test/car_smoke.d.ts +0 -1
  51. package/lib/test/car_smoke.js +0 -81
  52. package/lib/test/cleanup-embeddings-testdata.d.ts +0 -1
  53. package/lib/test/cleanup-embeddings-testdata.js +0 -75
  54. package/lib/test/index.d.ts +0 -10
  55. package/lib/test/index.js +0 -27
  56. package/lib/test/setup-embeddings-testdata.d.ts +0 -11
  57. package/lib/test/setup-embeddings-testdata.js +0 -155
  58. package/lib/utils/index.d.ts +0 -11
  59. package/lib/utils/index.js +0 -29
  60. package/lib/utils/manifest.d.ts +0 -23
  61. package/lib/utils/manifest.js +0 -77
@@ -1,29 +0,0 @@
1
- import { encodeAbiParameters, keccak256, parseAbiParameters } from "viem";
2
-
3
- //#region src/utils/index.ts
4
- function stringToBytes32Array(str) {
5
- const padded = str.padEnd(32, "\0");
6
- return Array.from(new TextEncoder().encode(padded)).slice(0, 32);
7
- }
8
- function hexToBytes32Array(hex) {
9
- const padded = hex.slice(2).padStart(64, "0");
10
- return Array.from(Buffer.from(padded, "hex"));
11
- }
12
- function addressToBytes32Array(address) {
13
- const clean = address.slice(2).toLowerCase();
14
- const bytes20 = Array.from(Buffer.from(clean, "hex"));
15
- return [...new Array(12).fill(0), ...bytes20];
16
- }
17
- function fieldToHex(field) {
18
- return `0x${field.toString(16).padStart(64, "0")}`;
19
- }
20
- function hexToField(hex) {
21
- const cleanHex = hex.startsWith("0x") ? hex : `0x${hex}`;
22
- return BigInt(cleanHex);
23
- }
24
- function computeSchemaId(name) {
25
- return keccak256(encodeAbiParameters(parseAbiParameters("string"), [name]));
26
- }
27
-
28
- //#endregion
29
- export { addressToBytes32Array, computeSchemaId, fieldToHex, hexToBytes32Array, hexToField, stringToBytes32Array };
@@ -1,23 +0,0 @@
1
- import { Address, Hex } from "viem";
2
-
3
- //#region src/utils/manifest.d.ts
4
- declare function poseidonHash(inputs: bigint[]): bigint;
5
- declare function hashString(value: string): bigint;
6
- interface ManifestLeaf {
7
- index: bigint;
8
- name: string;
9
- }
10
- declare class MerkleTree {
11
- protected constructor();
12
- static leafHash(leaf: ManifestLeaf): bigint;
13
- static buildTree(leaves: ManifestLeaf[]): {
14
- root: bigint;
15
- layers: bigint[][];
16
- };
17
- static buildProof(layers: bigint[][], index: number): bigint[];
18
- static rootToHex(root: bigint): Hex;
19
- }
20
- /** Off-chain datasource resourceId: keccak(owner ‖ schemaId ‖ keccak(name)). */
21
- declare function resourceId(owner: Address, schemaId: Hex, name: string): Hex;
22
- //#endregion
23
- export { ManifestLeaf, MerkleTree, hashString, poseidonHash, resourceId };
@@ -1,77 +0,0 @@
1
- import { encodePacked, keccak256 } from "viem";
2
- import { poseidon2 } from "poseidon-lite";
3
-
4
- //#region src/utils/manifest.ts
5
- const MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
6
- function normalize(v) {
7
- return (v % MODULUS + MODULUS) % MODULUS;
8
- }
9
- function poseidonHash(inputs) {
10
- return poseidon2(inputs.map(normalize));
11
- }
12
- function bytesToField(chunk) {
13
- let acc = 0n;
14
- for (const b of chunk) acc = acc << 8n | BigInt(b);
15
- return acc;
16
- }
17
- function hashString(value) {
18
- const bytes = new TextEncoder().encode(value);
19
- let h = 0n;
20
- for (let i = 0; i < bytes.length; i += 31) h = poseidonHash([h, bytesToField(bytes.subarray(i, i + 31))]);
21
- return h;
22
- }
23
- var MerkleTree = class MerkleTree {
24
- constructor() {
25
- throw new Error("MerkleTree is a static utility class and cannot be instantiated.");
26
- }
27
- static leafHash(leaf) {
28
- return poseidonHash([leaf.index, hashString(leaf.name)]);
29
- }
30
- static buildTree(leaves) {
31
- if (leaves.length === 0) throw new Error("Empty tree");
32
- let current = [...leaves].sort((a, b) => Number(a.index - b.index)).map((leaf) => MerkleTree.leafHash(leaf));
33
- const layers = [current];
34
- while (current.length > 1) {
35
- const next = [];
36
- for (let i = 0; i < current.length; i += 2) {
37
- const left = current[i];
38
- const right = current[i + 1] ?? left;
39
- next.push(poseidonHash([left, right]));
40
- }
41
- current = next;
42
- layers.push(next);
43
- }
44
- return {
45
- root: current[0],
46
- layers
47
- };
48
- }
49
- static buildProof(layers, index) {
50
- const proof = [];
51
- for (let d = 0; d < layers.length - 1; d++) {
52
- const layer = layers[d];
53
- const sibling = index % 2 === 0 ? layer[index + 1] ?? layer[index] : layer[index - 1];
54
- proof.push(sibling);
55
- index = Math.floor(index / 2);
56
- }
57
- return proof;
58
- }
59
- static rootToHex(root) {
60
- return `0x${root.toString(16).padStart(64, "0")}`;
61
- }
62
- };
63
- /** Off-chain datasource resourceId: keccak(owner ‖ schemaId ‖ keccak(name)). */
64
- function resourceId(owner, schemaId, name) {
65
- return keccak256(encodePacked([
66
- "address",
67
- "bytes32",
68
- "bytes32"
69
- ], [
70
- owner,
71
- schemaId,
72
- keccak256(new TextEncoder().encode(name))
73
- ]));
74
- }
75
-
76
- //#endregion
77
- export { MerkleTree, hashString, poseidonHash, resourceId };