@fangorn-network/sdk 2026.3.28 → 2026.3.29

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/lib/fangorn.js CHANGED
@@ -50,7 +50,7 @@ var Fangorn = class Fangorn {
50
50
  */
51
51
  get schema() {
52
52
  if (!isWritable(this.ctx.storage)) throw new Error("fangorn.schema requires writable storage. Use { storacha: { email } } or { pinata: { ... } }");
53
- return this._schema ??= new SchemaRole(this.ctx.schemaRegistry, this.ctx.storage, this.ctx.walletClient, this.ctx.schemaRoleConfig);
53
+ return this._schema ??= new SchemaRole(this.ctx.schemaRegistry, this.ctx.storage, this.ctx.walletClient);
54
54
  }
55
55
  /**
56
56
  * Publisher: encrypt, stage, and commit data under a schema.
@@ -1,4 +1,3 @@
1
- import { AppConfig } from "../../config.js";
2
1
  import { Gadget, GadgetDescriptor } from "./types.js";
3
2
  import { Address, Hex } from "viem";
4
3
  import { UnifiedAccessControlCondition } from "@lit-protocol/access-control-conditions";
@@ -12,12 +11,6 @@ interface SettledGadgetParams {
12
11
  /** "arbitrumSepolia" | "baseSepolia" */
13
12
  chainName: string;
14
13
  }
15
- /**
16
- * Build a new default gadget from the given config
17
- * @param config : AppConfig
18
- * @returns the configured gadget
19
- */
20
- declare function makeSettledGadgetFactory(config: AppConfig): (resourceId: Hex) => SettledGadget;
21
14
  declare class SettledGadget implements Gadget {
22
15
  private readonly params;
23
16
  readonly type = "settled";
@@ -28,4 +21,4 @@ declare class SettledGadget implements Gadget {
28
21
  toDescriptor(): GadgetDescriptor;
29
22
  }
30
23
  //#endregion
31
- export { SettledGadget, SettledGadgetParams, makeSettledGadgetFactory };
24
+ export { SettledGadget, SettledGadgetParams };
@@ -2,18 +2,6 @@ import { zeroAddress } from "viem";
2
2
  import { createAccBuilder } from "@lit-protocol/access-control-conditions";
3
3
 
4
4
  //#region src/modules/gadgets/settledGadget.ts
5
- /**
6
- * Build a new default gadget from the given config
7
- * @param config : AppConfig
8
- * @returns the configured gadget
9
- */
10
- function makeSettledGadgetFactory(config) {
11
- return (resourceId) => new SettledGadget({
12
- resourceId,
13
- settlementRegistryAddress: config.settlementRegistryContractAddress,
14
- chainName: config.chainName
15
- });
16
- }
17
5
  var SettledGadget = class {
18
6
  type = "settled";
19
7
  constructor(params) {
@@ -72,4 +60,4 @@ var SettledGadget = class {
72
60
  };
73
61
 
74
62
  //#endregion
75
- export { SettledGadget, makeSettledGadgetFactory };
63
+ export { SettledGadget };
@@ -1,4 +1,4 @@
1
- import * as viem431 from "viem";
1
+ import * as viem429 from "viem";
2
2
  import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
3
3
 
4
4
  //#region src/registries/datasource-registry/index.d.ts
@@ -18,7 +18,7 @@ declare class DataSourceRegistry {
18
18
  publishManifest(manifestCid: string, schemaId: Hex): Promise<Hash>;
19
19
  getManifest(owner: Address, schemaId: Hex): Promise<DataSource>;
20
20
  getVersion(owner: Address, schemaId: Hex): Promise<bigint>;
21
- waitForTransaction(hash: Hash): Promise<viem431.TransactionReceipt>;
21
+ waitForTransaction(hash: Hash): Promise<viem429.TransactionReceipt>;
22
22
  }
23
23
  //#endregion
24
24
  export { DataSource, DataSourceRegistry };
@@ -1,4 +1,4 @@
1
- import * as viem429 from "viem";
1
+ import * as viem430 from "viem";
2
2
  import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
3
3
 
4
4
  //#region src/registries/schema-registry/index.d.ts
@@ -22,7 +22,7 @@ declare class SchemaRegistry {
22
22
  updateSchema(nameOrId: string, newSpecCid: string, newAgentId: string): Promise<Hash>;
23
23
  getSchema(nameOrId: string): Promise<Schema>;
24
24
  schemaExists(nameOrId: string): Promise<boolean>;
25
- waitForTransaction(hash: Hash): Promise<viem429.TransactionReceipt>;
25
+ waitForTransaction(hash: Hash): Promise<viem430.TransactionReceipt>;
26
26
  private resolveId;
27
27
  }
28
28
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { PrepareSettleParams, PrepareSettleResult, RegisterParams, SettleParams, TransferWithAuthParams, TransferWithAuthPayload } from "./types.js";
2
- import * as viem430 from "viem";
2
+ import * as viem431 from "viem";
3
3
  import { Address, Hex, PublicClient, WalletClient } from "viem";
4
4
 
5
5
  //#region src/registries/settlement-registry/index.d.ts
@@ -66,7 +66,7 @@ declare class SettlementRegistry {
66
66
  * viem topic-encoding edge cases with indexed params.
67
67
  */
68
68
  private fetchGroup;
69
- waitForTransaction(hash: Hex): Promise<viem430.TransactionReceipt>;
69
+ waitForTransaction(hash: Hex): Promise<viem431.TransactionReceipt>;
70
70
  }
71
71
  //#endregion
72
72
  export { SettlementRegistry };
@@ -1,5 +1,5 @@
1
1
  import { SettlementRegistry } from "../../registries/settlement-registry/index.js";
2
- import { makeSettledGadgetFactory } from "../../modules/gadgets/settledGadget.js";
2
+ import { SettledGadget } from "../../modules/gadgets/settledGadget.js";
3
3
 
4
4
  //#region src/roles/publisher/index.ts
5
5
  var PublisherRole = class {
@@ -25,13 +25,18 @@ var PublisherRole = class {
25
25
  async upload(params, price) {
26
26
  const { records, schema, schemaId, gateway, options } = params;
27
27
  const address = this.requireAccount();
28
- const gadgetFactory = params.gadgetFactory ?? ((tag) => {
29
- const resourceId = SettlementRegistry.deriveResourceId(address, schemaId, tag);
30
- return makeSettledGadgetFactory(this.config)(resourceId);
31
- });
28
+ const gadgetFactory = (tag) => {
29
+ return new SettledGadget({
30
+ resourceId: SettlementRegistry.deriveResourceId(address, schemaId, tag),
31
+ settlementRegistryAddress: this.config.settlementRegistryContractAddress,
32
+ chainName: this.config.chainName
33
+ });
34
+ };
32
35
  for (const record of records) {
33
36
  this.validateRecord(record, schema);
34
- const gadget = await gadgetFactory(SettlementRegistry.deriveResourceId(address, schemaId, record.tag));
37
+ const resourceId = SettlementRegistry.deriveResourceId(address, schemaId, record.tag);
38
+ console.log("using resource Id" + resourceId);
39
+ const gadget = gadgetFactory(record.tag);
35
40
  const entry = await this.resolveRecord(record, schema, gadget, gateway);
36
41
  this.pendingEntries.set(record.tag, entry);
37
42
  }
@@ -8,12 +8,7 @@ declare class SchemaRole {
8
8
  private readonly schemaRegistry;
9
9
  private readonly storage;
10
10
  private readonly walletClient;
11
- private readonly agent0;
12
- constructor(schemaRegistry: SchemaRegistry, storage: WritableStorage<unknown>, walletClient: WalletClient, config?: SchemaRoleConfig);
13
- /**
14
- * Register an agent identity via the agent0-sdk / ERC-8004.
15
- */
16
- registerAgent(params: RegisterAgentParams): Promise<RegisteredAgent>;
11
+ constructor(schemaRegistry: SchemaRegistry, storage: WritableStorage<unknown>, walletClient: WalletClient);
17
12
  /**
18
13
  * Register a schema on-chain, tied to an existing agent identity.
19
14
  *
@@ -38,7 +33,6 @@ declare class SchemaRole {
38
33
  */
39
34
  validate(data: Record<string, unknown>, definition: SchemaDefinition): string[];
40
35
  private requireAccount;
41
- private requireAgent0;
42
36
  }
43
37
  //#endregion
44
38
  export { EncryptedField, FieldDefinition, PlainField, RegisterAgentParams, RegisterSchemaParams, RegisteredAgent, RegisteredSchema, SchemaBlobV1, SchemaDefinition, SchemaRole, SchemaRoleConfig };
@@ -1,36 +1,9 @@
1
- import { SDK } from "agent0-sdk";
2
-
3
1
  //#region src/roles/schema/index.ts
4
2
  var SchemaRole = class {
5
- agent0;
6
- constructor(schemaRegistry, storage, walletClient, config) {
3
+ constructor(schemaRegistry, storage, walletClient) {
7
4
  this.schemaRegistry = schemaRegistry;
8
5
  this.storage = storage;
9
6
  this.walletClient = walletClient;
10
- this.agent0 = config ? new SDK({
11
- chainId: config.chainId,
12
- rpcUrl: config.rpcUrl,
13
- privateKey: config.privateKey,
14
- ipfs: "pinata",
15
- pinataJwt: config.pinataJwt,
16
- ...config.registryOverrides && { registryOverrides: config.registryOverrides },
17
- ...config.subgraphOverrides && { subgraphOverrides: config.subgraphOverrides }
18
- }) : null;
19
- }
20
- /**
21
- * Register an agent identity via the agent0-sdk / ERC-8004.
22
- */
23
- async registerAgent(params) {
24
- const agent = this.requireAgent0().createAgent(params.name, params.description);
25
- if (params.a2aUrl) await agent.setA2A(params.a2aUrl);
26
- if (params.mcpEndpoint) await agent.setMCP(params.mcpEndpoint);
27
- if (params.ens) agent.setENS(params.ens);
28
- agent.setActive(true);
29
- agent.setX402Support(true);
30
- const { result: registrationFile } = await (await agent.registerIPFS()).waitConfirmed();
31
- const agentId = registrationFile.agentId;
32
- if (!agentId) throw new Error("ERC-8004 registration did not return an agentId");
33
- return { agentId };
34
7
  }
35
8
  /**
36
9
  * Register a schema on-chain, tied to an existing agent identity.
@@ -127,10 +100,6 @@ var SchemaRole = class {
127
100
  if (!address) throw new Error("No account connected to wallet client");
128
101
  return address;
129
102
  }
130
- requireAgent0() {
131
- if (!this.agent0) throw new Error("registerAgent() requires AgentConfig (privateKey + pinataJwt). Pass agentConfig to Fangorn.init() to enable ERC-8004 registration.");
132
- return this.agent0;
133
- }
134
103
  };
135
104
 
136
105
  //#endregion
@@ -1,4 +1,4 @@
1
- import { RegisterAgentParams, RegisteredAgent, SchemaDefinition } from "../roles/schema/types.js";
1
+ import { SchemaDefinition } from "../roles/schema/types.js";
2
2
  import "../roles/schema/index.js";
3
3
  import { PrepareSettleResult, TransferWithAuthPayload } from "../registries/settlement-registry/types.js";
4
4
  import { SettlementRegistry } from "../registries/settlement-registry/index.js";
@@ -34,7 +34,6 @@ declare class TestBed {
34
34
  * @returns The testbed client
35
35
  */
36
36
  static init(delegatorWalletClient: WalletClient, dataSourceRegistryContractAddress: Hex, schemaRegistryContractAddress: Hex, settlementRegistryContractAddress: Hex, usdcContractAddress: Hex, usdcDomainName: string, rpcUrl: string, chain: string, caip2: number): Promise<TestBed>;
37
- registerAgent(params: RegisterAgentParams): Promise<RegisteredAgent>;
38
37
  registerSchema(name: string, definition: SchemaDefinition, agentId: string): Promise<Hex>;
39
38
  /**
40
39
  * Upload files encrypted under SettledGadget.
@@ -61,9 +61,6 @@ var TestBed = class TestBed {
61
61
  if (!delegatorWalletClient.account) throw new Error("Delegator account not found");
62
62
  return new TestBed(delegatorWalletClient.account.address, delegatorFangorn, delegateeFangorn, usdcContractAddress, usdcDomainName);
63
63
  }
64
- async registerAgent(params) {
65
- return this.delegatorFangorn.schema.registerAgent(params);
66
- }
67
64
  async registerSchema(name, definition, agentId) {
68
65
  const { schemaId } = await this.delegatorFangorn.schema.register({
69
66
  name,
package/package.json CHANGED
@@ -1,87 +1,74 @@
1
1
  {
2
- "name": "@fangorn-network/sdk",
3
- "version": "2026.03.28",
4
- "description": "A zero-knowledge conditional access control framework",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/fangorn-network/fangorn.git"
8
- },
9
- "bin": {
10
- "fangorn": "lib/cli/cli.js"
11
- },
12
- "license": "MIT",
13
- "type": "module",
14
- "main": "lib/index.js",
15
- "files": [
16
- "lib/"
17
- ],
18
- "scripts": {
19
- "build": "tsdown",
20
- "format": "prettier . --write",
21
- "lint": "eslint . --max-warnings 0",
22
- "prepare": "husky",
23
- "test": "dotenvx run -f .env -- vitest run",
24
- "test:e2e": "dotenvx run -f .env -- vitest run --config vitest.e2e.config.ts",
25
- "tsc": "tsc",
26
- "deploy": "dotenvx run -f .env -- tsx deploy.ts",
27
- "prepare:cli": "npm run build",
28
- "fangorn": "dotenvx run -f .env -- node dist/src/cli/cli.js"
29
- },
30
- "lint-staged": {
31
- "*": "prettier --ignore-unknown --write"
32
- },
33
- "devDependencies": {
34
- "@dotenvx/dotenvx": "^1.51.1",
35
- "@eslint/js": "9.39.1",
36
- "@types/node": "24.10.1",
37
- "@vitest/coverage-v8": "4.0.15",
38
- "@vitest/eslint-plugin": "1.5.1",
39
- "eslint": "9.39.1",
40
- "husky": "9.1.7",
41
- "lint-staged": "16.2.7",
42
- "prettier": "3.7.3",
43
- "tsdown": "0.16.8",
44
- "tsx": "^4.21.0",
45
- "typescript": "5.8.3",
46
- "typescript-eslint": "8.48.1",
47
- "vitest": "^4.0.18"
48
- },
49
- "packageManager": "pnpm@10.4.0",
50
- "engines": {
51
- "node": ">=20.19.0"
52
- },
53
- "dependencies": {
54
- "@a2a-js/sdk": "^0.3.10",
55
- "@clack/prompts": "^1.0.1",
56
- "@lit-protocol/access-control-conditions": "^8.0.2",
57
- "@lit-protocol/auth": "^8.2.2",
58
- "@lit-protocol/auth-helpers": "^8.2.1",
59
- "@lit-protocol/lit-client": "^8.3.1",
60
- "@lit-protocol/networks": "^8.4.1",
61
- "@semaphore-protocol/group": "^4.14.2",
62
- "@semaphore-protocol/identity": "^4.14.2",
63
- "@semaphore-protocol/proof": "^4.14.2",
64
- "@storacha/client": "^2.1.3",
65
- "agent0-sdk": "^1.5.3",
66
- "commander": "^14.0.3",
67
- "dotenv": "^17.2.3",
68
- "ethers": "^6.16.0",
69
- "pinata": "^2.5.2",
70
- "solc": "^0.8.28",
71
- "viem": "^2.47.1"
72
- },
73
- "overrides": {
74
- "viem": "$viem"
75
- },
76
- "pnpm": {
77
- "overrides": {
78
- "write-file-atomic": "7.0.0"
79
- },
80
- "peerDependencyRules": {
81
- "allowedVersions": {
82
- "viem": ">=2.38.3",
83
- "ethers": ">=5.7.2"
84
- }
85
- }
86
- }
2
+ "name": "@fangorn-network/sdk",
3
+ "version": "2026.03.29",
4
+ "description": "A zero-knowledge conditional access control framework",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/fangorn-network/fangorn.git"
8
+ },
9
+ "bin": {
10
+ "fangorn": "lib/cli/cli.js"
11
+ },
12
+ "license": "MIT",
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "files": [
16
+ "lib/"
17
+ ],
18
+ "lint-staged": {
19
+ "*": "prettier --ignore-unknown --write"
20
+ },
21
+ "devDependencies": {
22
+ "@dotenvx/dotenvx": "^1.51.1",
23
+ "@eslint/js": "9.39.1",
24
+ "@types/node": "24.10.1",
25
+ "@vitest/coverage-v8": "4.0.15",
26
+ "@vitest/eslint-plugin": "1.5.1",
27
+ "eslint": "9.39.1",
28
+ "husky": "9.1.7",
29
+ "lint-staged": "16.2.7",
30
+ "prettier": "3.7.3",
31
+ "tsdown": "0.16.8",
32
+ "tsx": "^4.21.0",
33
+ "typescript": "5.8.3",
34
+ "typescript-eslint": "8.48.1",
35
+ "vitest": "^4.0.18"
36
+ },
37
+ "engines": {
38
+ "node": ">=20.19.0"
39
+ },
40
+ "dependencies": {
41
+ "@a2a-js/sdk": "^0.3.10",
42
+ "@clack/prompts": "^1.0.1",
43
+ "@lit-protocol/access-control-conditions": "^8.0.2",
44
+ "@lit-protocol/auth": "^8.2.2",
45
+ "@lit-protocol/auth-helpers": "^8.2.1",
46
+ "@lit-protocol/lit-client": "^8.3.1",
47
+ "@lit-protocol/networks": "^8.4.1",
48
+ "@semaphore-protocol/group": "^4.14.2",
49
+ "@semaphore-protocol/identity": "^4.14.2",
50
+ "@semaphore-protocol/proof": "^4.14.2",
51
+ "@storacha/client": "^2.1.3",
52
+ "agent0-sdk": "^1.5.3",
53
+ "commander": "^14.0.3",
54
+ "dotenv": "^17.2.3",
55
+ "ethers": "^6.16.0",
56
+ "pinata": "^2.5.2",
57
+ "solc": "^0.8.28",
58
+ "viem": "^2.47.1"
59
+ },
60
+ "overrides": {
61
+ "viem": "$viem"
62
+ },
63
+ "scripts": {
64
+ "build": "tsdown",
65
+ "format": "prettier . --write",
66
+ "lint": "eslint . --max-warnings 0",
67
+ "test": "dotenvx run -f .env -- vitest run",
68
+ "test:e2e": "dotenvx run -f .env -- vitest run --config vitest.e2e.config.ts",
69
+ "tsc": "tsc",
70
+ "deploy": "dotenvx run -f .env -- tsx deploy.ts",
71
+ "prepare:cli": "npm run build",
72
+ "fangorn": "dotenvx run -f .env -- node dist/src/cli/cli.js"
73
+ }
87
74
  }