@fangorn-network/sdk 2026.3.28 → 2026.4.0-8.dev

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 (38) hide show
  1. package/README.md +24 -31
  2. package/lib/cli/cli.d.ts +0 -0
  3. package/lib/cli/index.d.ts +170 -170
  4. package/lib/config.d.ts +257 -254
  5. package/lib/config.js +4 -2
  6. package/lib/fangorn.d.ts +0 -3
  7. package/lib/fangorn.js +12 -24
  8. package/lib/index.d.ts +3 -3
  9. package/lib/index.js +3 -3
  10. package/lib/modules/encryption/lit.d.ts +0 -1
  11. package/lib/modules/encryption/lit.js +1 -7
  12. package/lib/providers/storage/index.d.ts +12 -12
  13. package/lib/providers/storage/index.js +47 -2
  14. package/lib/providers/storage/pinata.d.ts +11 -0
  15. package/lib/providers/storage/pinata.js +24 -0
  16. package/lib/registries/datasource-registry/index.d.ts +4 -3
  17. package/lib/registries/datasource-registry/index.js +17 -2
  18. package/lib/registries/schema-registry/index.d.ts +2 -2
  19. package/lib/registries/settlement-registry/index.d.ts +2 -2
  20. package/lib/registries/settlement-registry/index.js +11 -13
  21. package/lib/registries/settlement-registry/types.d.ts +6 -3
  22. package/lib/roles/consumer/index.d.ts +2 -24
  23. package/lib/roles/consumer/index.js +5 -26
  24. package/lib/roles/publisher/index.d.ts +19 -17
  25. package/lib/roles/publisher/index.js +41 -29
  26. package/lib/roles/publisher/types.d.ts +5 -7
  27. package/lib/roles/schema/index.d.ts +3 -2
  28. package/lib/roles/schema/index.js +4 -2
  29. package/lib/test/testbed.d.ts +1 -1
  30. package/lib/test/testbed.js +15 -9
  31. package/lib/types/index.d.ts +10 -20
  32. package/package.json +72 -85
  33. package/lib/providers/storage/pinata/index.d.ts +0 -13
  34. package/lib/providers/storage/pinata/index.js +0 -41
  35. package/lib/providers/storage/storacha/index.d.ts +0 -13
  36. package/lib/providers/storage/storacha/index.js +0 -49
  37. package/lib/providers/storage/storacha/readOnly.d.ts +0 -8
  38. package/lib/providers/storage/storacha/readOnly.js +0 -16
@@ -1,5 +1,6 @@
1
1
  import { AppConfig } from "../../config.js";
2
- import { WritableStorage } from "../../providers/storage/index.js";
2
+ import { SchemaRegistry } from "../../registries/schema-registry/index.js";
3
+ import { PinningService } from "../../providers/storage/index.js";
3
4
  import { DataSourceRegistry } from "../../registries/datasource-registry/index.js";
4
5
  import { SettlementRegistry } from "../../registries/settlement-registry/index.js";
5
6
  import { EncryptionService } from "../../modules/encryption/index.js";
@@ -10,21 +11,23 @@ import { Hex, WalletClient } from "viem";
10
11
  declare class PublisherRole {
11
12
  private readonly dataSourceRegistry;
12
13
  private readonly settlementRegistry;
14
+ private readonly schemaRegistry;
13
15
  private readonly storage;
14
16
  private readonly encryptionService;
15
17
  private readonly walletClient;
16
18
  private readonly config;
17
19
  private pendingEntries;
18
- constructor(dataSourceRegistry: DataSourceRegistry, settlementRegistry: SettlementRegistry, storage: WritableStorage<unknown>, encryptionService: EncryptionService, walletClient: WalletClient, config: AppConfig);
20
+ private readonly schemaCache;
21
+ constructor(dataSourceRegistry: DataSourceRegistry, settlementRegistry: SettlementRegistry, schemaRegistry: SchemaRegistry, storage: PinningService, encryptionService: EncryptionService, walletClient: WalletClient, config: AppConfig);
19
22
  /**
20
- * Encrypt and Upload data with Fangorn
21
- * Validate records against the schema, encrypt encrypted
22
- * fields, stage all resolved entries, then commit to IPFS + on-chain.
23
+ * Encrypt and upload schema-conformant data
24
+ * Validates records against the schema, encrypts fields as required,
25
+ * stages all resolved entries, then commits to IPFS and publishes onchain.
23
26
  *
24
27
  * Each encrypted field within a record is stored as a separate IPFS object
25
- * (the ciphertext). The manifest entry stores the handle (CID + gateway)
26
- * alongside the plain fields. Consumers can read plain fields freely and
27
- * only need to purchase + decrypt for encrypted fields.
28
+ * (the ciphertext). The manifest entry stores the handle (CID and gateway)
29
+ * alongside plain fields. Consumers can read plain fields freely and
30
+ * only need to purchase and decrypt for encrypted fields.
28
31
  */
29
32
  upload(params: UploadParams, price: bigint): Promise<CommitResult>;
30
33
  stage(entry: ManifestEntry): void;
@@ -34,33 +37,32 @@ declare class PublisherRole {
34
37
  /**
35
38
  * Serialize all staged entries into a manifest, create SettlementRegistry
36
39
  * resources for each entry, pin the manifest to IPFS, and publish on-chain.
37
- *
38
- * @param schemaId: The unique id of the schema
39
- * @param price: The USDC price required to register with the sempaphore group
40
- * @param overwrite: If true, overwrite manifest data, else append (default: false)
41
- *
42
40
  */
43
41
  commit(schemaId: Hex, price: bigint, overwrite: boolean): Promise<CommitResult>;
44
42
  getManifest(schemaId: Hex): Promise<Manifest | undefined>;
45
43
  getEntry(schemaId: Hex, tag: string): Promise<ManifestEntry>;
46
44
  private requireAccount;
45
+ /**
46
+ * Resolve the schema definition and id by name, with in-memory caching.
47
+ * Schema resolution is concurrent-safe — parallel calls for the same name
48
+ * share a single in-flight promise.
49
+ */
50
+ private resolveSchema;
47
51
  /**
48
52
  * Resolve a PublishRecord into a ManifestEntry by processing each field
49
53
  * according to the schema definition:
50
54
  * - plain fields are stored as-is
51
- * - encrypted fields are AES+Lit encrypted, pinned to IPFS, and replaced
55
+ * - encrypted fields are encrypted, pinned to IPFS, and replaced
52
56
  * with a handle + gadgetDescriptor
53
57
  */
54
58
  private resolveRecord;
55
59
  /**
56
60
  * Validate that a record's fields match the schema before touching IPFS.
57
- * Catches type mismatches and missing required fields early.
58
61
  */
59
62
  private validateRecord;
60
63
  private validateField;
61
64
  /**
62
- * Load the existing manifest into pending entries for merge behaviour.
63
- * Unpins the old manifest CID
65
+ * Load the existing manifest for merge behaviour and unpin the old CID.
64
66
  */
65
67
  private loadExistingManifest;
66
68
  }
@@ -1,32 +1,35 @@
1
+ import { retrieveByCid } from "../../providers/storage/index.js";
1
2
  import { SettlementRegistry } from "../../registries/settlement-registry/index.js";
2
3
  import { makeSettledGadgetFactory } from "../../modules/gadgets/settledGadget.js";
3
4
 
4
5
  //#region src/roles/publisher/index.ts
5
6
  var PublisherRole = class {
6
7
  pendingEntries = /* @__PURE__ */ new Map();
7
- constructor(dataSourceRegistry, settlementRegistry, storage, encryptionService, walletClient, config) {
8
+ schemaCache = /* @__PURE__ */ new Map();
9
+ constructor(dataSourceRegistry, settlementRegistry, schemaRegistry, storage, encryptionService, walletClient, config) {
8
10
  this.dataSourceRegistry = dataSourceRegistry;
9
11
  this.settlementRegistry = settlementRegistry;
12
+ this.schemaRegistry = schemaRegistry;
10
13
  this.storage = storage;
11
14
  this.encryptionService = encryptionService;
12
15
  this.walletClient = walletClient;
13
16
  this.config = config;
14
17
  }
15
18
  /**
16
- * Encrypt and Upload data with Fangorn
17
- * Validate records against the schema, encrypt encrypted
18
- * fields, stage all resolved entries, then commit to IPFS + on-chain.
19
+ * Encrypt and upload schema-conformant data
20
+ * Validates records against the schema, encrypts fields as required,
21
+ * stages all resolved entries, then commits to IPFS and publishes onchain.
19
22
  *
20
23
  * Each encrypted field within a record is stored as a separate IPFS object
21
- * (the ciphertext). The manifest entry stores the handle (CID + gateway)
22
- * alongside the plain fields. Consumers can read plain fields freely and
23
- * only need to purchase + decrypt for encrypted fields.
24
+ * (the ciphertext). The manifest entry stores the handle (CID and gateway)
25
+ * alongside plain fields. Consumers can read plain fields freely and
26
+ * only need to purchase and decrypt for encrypted fields.
24
27
  */
25
28
  async upload(params, price) {
26
- const { records, schema, schemaId, gateway, options } = params;
29
+ const { records, schemaName, gateway, options } = params;
27
30
  const address = this.requireAccount();
28
- const gadgetFactory = params.gadgetFactory ?? ((tag) => {
29
- const resourceId = SettlementRegistry.deriveResourceId(address, schemaId, tag);
31
+ const { schema, schemaId } = await this.resolveSchema(schemaName);
32
+ const gadgetFactory = params.gadgetFactory ?? ((resourceId) => {
30
33
  return makeSettledGadgetFactory(this.config)(resourceId);
31
34
  });
32
35
  for (const record of records) {
@@ -52,11 +55,6 @@ var PublisherRole = class {
52
55
  /**
53
56
  * Serialize all staged entries into a manifest, create SettlementRegistry
54
57
  * resources for each entry, pin the manifest to IPFS, and publish on-chain.
55
- *
56
- * @param schemaId: The unique id of the schema
57
- * @param price: The USDC price required to register with the sempaphore group
58
- * @param overwrite: If true, overwrite manifest data, else append (default: false)
59
- *
60
58
  */
61
59
  async commit(schemaId, price, overwrite) {
62
60
  const owner = this.requireAccount();
@@ -72,8 +70,8 @@ var PublisherRole = class {
72
70
  }
73
71
  }
74
72
  if (!overwrite) {
75
- const vals = (await this.loadExistingManifest(owner, schemaId)).values();
76
- entries = [...Array.from(vals), ...entries];
73
+ const existingEntriesMap = await this.loadExistingManifest(owner, schemaId);
74
+ entries = [...Array.from(existingEntriesMap.values()), ...entries];
77
75
  }
78
76
  const manifest = {
79
77
  version: 1,
@@ -95,7 +93,7 @@ var PublisherRole = class {
95
93
  try {
96
94
  const ds = await this.dataSourceRegistry.getManifest(owner, schemaId);
97
95
  if (!ds.manifestCid || ds.manifestCid === "") return void 0;
98
- return await this.storage.retrieve(ds.manifestCid);
96
+ return retrieveByCid(ds.manifestCid, this.config.ipfsGateway);
99
97
  } catch {
100
98
  return;
101
99
  }
@@ -113,10 +111,30 @@ var PublisherRole = class {
113
111
  return address;
114
112
  }
115
113
  /**
114
+ * Resolve the schema definition and id by name, with in-memory caching.
115
+ * Schema resolution is concurrent-safe — parallel calls for the same name
116
+ * share a single in-flight promise.
117
+ */
118
+ resolveSchema(name) {
119
+ if (!this.schemaCache.has(name)) {
120
+ const p = Promise.all([this.schemaRegistry.getSchema(name), this.schemaRegistry.schemaId(name)]).then(async ([{ cid }, schemaId]) => {
121
+ return {
122
+ schema: (await retrieveByCid(cid, this.config.ipfsGateway)).definition,
123
+ schemaId
124
+ };
125
+ }).catch((err) => {
126
+ this.schemaCache.delete(name);
127
+ throw err;
128
+ });
129
+ this.schemaCache.set(name, p);
130
+ }
131
+ return this.schemaCache.get(name);
132
+ }
133
+ /**
116
134
  * Resolve a PublishRecord into a ManifestEntry by processing each field
117
135
  * according to the schema definition:
118
136
  * - plain fields are stored as-is
119
- * - encrypted fields are AES+Lit encrypted, pinned to IPFS, and replaced
137
+ * - encrypted fields are encrypted, pinned to IPFS, and replaced
120
138
  * with a handle + gadgetDescriptor
121
139
  */
122
140
  async resolveRecord(record, schema, gadget, gateway) {
@@ -132,14 +150,13 @@ var PublisherRole = class {
132
150
  fileType: input.fileType ?? "application/octet-stream"
133
151
  }, gadget);
134
152
  const cid = await this.storage.store(encrypted, { metadata: { name: `${record.tag}:${fieldName}` } });
135
- const gadgetDescriptor = gadget.toDescriptor();
136
153
  resolvedFields[fieldName] = {
137
154
  "@type": "encrypted",
138
155
  handle: {
139
156
  cid,
140
157
  gateway
141
158
  },
142
- gadgetDescriptor
159
+ gadgetDescriptor: gadget.toDescriptor()
143
160
  };
144
161
  } else resolvedFields[fieldName] = value;
145
162
  }
@@ -150,14 +167,10 @@ var PublisherRole = class {
150
167
  }
151
168
  /**
152
169
  * Validate that a record's fields match the schema before touching IPFS.
153
- * Catches type mismatches and missing required fields early.
154
170
  */
155
171
  validateRecord(record, schema) {
156
172
  const errors = [];
157
- for (const [fieldName, fieldDef] of Object.entries(schema)) {
158
- const value = record.fields[fieldName];
159
- this.validateField(record.tag, fieldName, fieldDef, value, errors);
160
- }
173
+ for (const [fieldName, fieldDef] of Object.entries(schema)) this.validateField(record.tag, fieldName, fieldDef, record.fields[fieldName], errors);
161
174
  for (const fieldName of Object.keys(record.fields)) if (!(fieldName in schema)) console.warn(`Record "${record.tag}": field "${fieldName}" is not in the schema and will be ignored`);
162
175
  if (errors.length > 0) throw new Error(`Validation failed for record "${record.tag}":\n` + errors.map((e) => ` • ${e}`).join("\n"));
163
176
  }
@@ -181,15 +194,14 @@ var PublisherRole = class {
181
194
  }
182
195
  }
183
196
  /**
184
- * Load the existing manifest into pending entries for merge behaviour.
185
- * Unpins the old manifest CID
197
+ * Load the existing manifest for merge behaviour and unpin the old CID.
186
198
  */
187
199
  async loadExistingManifest(owner, schemaId) {
188
200
  const entries = /* @__PURE__ */ new Map();
189
201
  try {
190
202
  const ds = await this.dataSourceRegistry.getManifest(owner, schemaId);
191
203
  if (!ds.manifestCid) return entries;
192
- const manifest = await this.storage.retrieve(ds.manifestCid);
204
+ const manifest = await retrieveByCid(ds.manifestCid, this.config.ipfsGateway);
193
205
  for (const entry of manifest.entries) entries.set(entry.tag, entry);
194
206
  try {
195
207
  await this.storage.delete(ds.manifestCid);
@@ -1,4 +1,3 @@
1
- import { SchemaDefinition } from "../schema/types.js";
2
1
  import { Gadget, GadgetDescriptor } from "../../modules/gadgets/types.js";
3
2
  import "../../modules/gadgets/index.js";
4
3
  import { Address, Hex } from "viem";
@@ -57,18 +56,17 @@ interface Manifest {
57
56
  }
58
57
  interface UploadParams {
59
58
  records: PublishRecord[];
60
- /**
61
- * The schema the records must conform to. Required — field-level encryption
62
- * decisions are driven by the schema definition.
63
- */
64
- schema: SchemaDefinition;
65
- schemaId: Hex;
59
+ schemaName: string;
66
60
  /**
67
61
  * Called once per record to produce the gadget for that record's encrypted
68
62
  * fields. All encrypted fields within a record share the same gadget —
69
63
  * and therefore the same resourceId and access condition.
70
64
  */
71
65
  gadgetFactory?: (tag: string) => Gadget | Promise<Gadget>;
66
+ /**
67
+ * Configurable gas for sending the call
68
+ */
69
+ gas?: bigint;
72
70
  /**
73
71
  * IPFS gateway URL written into each encrypted field handle so consumers
74
72
  * can retrieve ciphertexts without knowing the storage provider.
@@ -1,5 +1,5 @@
1
1
  import { SchemaRegistry } from "../../registries/schema-registry/index.js";
2
- import { WritableStorage } from "../../providers/storage/index.js";
2
+ import { PinningService } from "../../providers/storage/index.js";
3
3
  import { EncryptedField, FieldDefinition, PlainField, RegisterAgentParams, RegisterSchemaParams, RegisteredAgent, RegisteredSchema, SchemaBlobV1, SchemaDefinition, SchemaRoleConfig } from "./types.js";
4
4
  import { WalletClient } from "viem";
5
5
 
@@ -8,8 +8,9 @@ declare class SchemaRole {
8
8
  private readonly schemaRegistry;
9
9
  private readonly storage;
10
10
  private readonly walletClient;
11
+ private readonly ipfsGateway;
11
12
  private readonly agent0;
12
- constructor(schemaRegistry: SchemaRegistry, storage: WritableStorage<unknown>, walletClient: WalletClient, config?: SchemaRoleConfig);
13
+ constructor(schemaRegistry: SchemaRegistry, storage: PinningService, walletClient: WalletClient, ipfsGateway: string, config?: SchemaRoleConfig);
13
14
  /**
14
15
  * Register an agent identity via the agent0-sdk / ERC-8004.
15
16
  */
@@ -1,12 +1,14 @@
1
+ import { retrieveByCid } from "../../providers/storage/index.js";
1
2
  import { SDK } from "agent0-sdk";
2
3
 
3
4
  //#region src/roles/schema/index.ts
4
5
  var SchemaRole = class {
5
6
  agent0;
6
- constructor(schemaRegistry, storage, walletClient, config) {
7
+ constructor(schemaRegistry, storage, walletClient, ipfsGateway, config) {
7
8
  this.schemaRegistry = schemaRegistry;
8
9
  this.storage = storage;
9
10
  this.walletClient = walletClient;
11
+ this.ipfsGateway = ipfsGateway;
10
12
  this.agent0 = config ? new SDK({
11
13
  chainId: config.chainId,
12
14
  rpcUrl: config.rpcUrl,
@@ -68,7 +70,7 @@ var SchemaRole = class {
68
70
  const schemaId = await this.schemaRegistry.schemaId(typeof nameOrId === "string" && !/^0x[0-9a-fA-F]{64}$/.test(nameOrId) ? nameOrId : nameOrId);
69
71
  const record = await this.schemaRegistry.getSchema(nameOrId);
70
72
  if (!record.cid) return void 0;
71
- const blob = await this.storage.retrieve(record.cid);
73
+ const blob = await retrieveByCid(record.cid, this.ipfsGateway);
72
74
  return {
73
75
  schemaId,
74
76
  schemaCid: record.cid,
@@ -43,7 +43,7 @@ declare class TestBed {
43
43
  * which is baked into the ACC at encryption time. A buyer must complete the
44
44
  * full purchase → claim flow for each specific tag before decrypting.
45
45
  */
46
- fileUpload(records: PublishRecord[], schema: SchemaDefinition, schemaId: Hex, gateway: string, price: bigint): Promise<string>;
46
+ fileUpload(records: PublishRecord[], schemaName: string, gateway: string, price: bigint): Promise<string>;
47
47
  prepareRegister(burnerPrivateKey: Hex, paymentRecipient: Address, amount: bigint): Promise<TransferWithAuthPayload>;
48
48
  register(owner: Address, schemaId: Hex, tag: string, identityCommitment: bigint, relayerPrivateKey: Hex, preparedRegister: TransferWithAuthPayload): Promise<Hex>;
49
49
  prepareSettle(owner: Address, schemaId: Hex, tag: string, identity: Identity, stealthAddress: Address): Promise<PrepareSettleResult>;
@@ -40,20 +40,22 @@ var TestBed = class TestBed {
40
40
  chainName: chain,
41
41
  chain: chainImpl,
42
42
  rpcUrl,
43
- caip2
43
+ caip2,
44
+ ipfsGateway: "https://gateway.pinata.cloud"
44
45
  };
45
- const agentConfig = void 0;
46
46
  const delegatorFangorn = await Fangorn.create({
47
47
  privateKey: process.env.DELEGATOR_ETH_PRIVATE_KEY ?? "0x0",
48
- storage: { storacha: { "email": process.env.TEST_EMAIL_ADDR ?? "" } },
48
+ storage: { pinata: {
49
+ jwt: process.env.PINATA_JWT ?? "",
50
+ gateway: process.env.PINATA_GATEWAY ?? ""
51
+ } },
49
52
  encryption: { lit: true },
50
53
  config,
51
54
  domain: "localhost",
52
- agentConfig
55
+ agentConfig: void 0
53
56
  });
54
57
  const delegateeFangorn = await Fangorn.create({
55
58
  privateKey: process.env.DELEGATEE_ETH_PRIVATE_KEY ?? "0x0",
56
- storage: { storacha: { "readOnly": true } },
57
59
  encryption: { lit: true },
58
60
  config,
59
61
  domain: "localhost"
@@ -79,18 +81,22 @@ var TestBed = class TestBed {
79
81
  * which is baked into the ACC at encryption time. A buyer must complete the
80
82
  * full purchase → claim flow for each specific tag before decrypting.
81
83
  */
82
- async fileUpload(records, schema, schemaId, gateway, price) {
84
+ async fileUpload(records, schemaName, gateway, price) {
83
85
  const { manifestCid } = await this.delegatorFangorn.publisher.upload({
84
86
  records,
85
- schema,
86
- schemaId,
87
+ schemaName,
87
88
  gateway
88
89
  }, price);
89
90
  return manifestCid;
90
91
  }
91
92
  async prepareRegister(burnerPrivateKey, paymentRecipient, amount) {
93
+ const walletClient = createWalletClient({
94
+ account: privateKeyToAccount(burnerPrivateKey),
95
+ chain: arbitrumSepolia,
96
+ transport: http(process.env.RPC_URL ?? "")
97
+ });
92
98
  return this.delegateeFangorn.consumer.prepareRegister({
93
- burnerPrivateKey,
99
+ walletClient,
94
100
  paymentRecipient,
95
101
  amount,
96
102
  usdcAddress: this.usdcContractAddress,
@@ -1,6 +1,6 @@
1
1
  import { AppConfig } from "../config.js";
2
2
  import { SchemaRegistry } from "../registries/schema-registry/index.js";
3
- import { ReadableStorage, WritableStorage } from "../providers/storage/index.js";
3
+ import { PinningService } from "../providers/storage/index.js";
4
4
  import { SchemaRoleConfig } from "../roles/schema/types.js";
5
5
  import "../roles/schema/index.js";
6
6
  import { DataSourceRegistry } from "../registries/datasource-registry/index.js";
@@ -29,29 +29,22 @@ interface EncryptedData {
29
29
  authTag: Uint8Array<ArrayBuffer>;
30
30
  salt: Uint8Array<ArrayBuffer>;
31
31
  }
32
- /**
33
- * Credentials required to enable ERC-8004 agent registration via agent0-sdk.
34
- * Optional: omit if thewill throw. caller only needs publisher or consumer functionality.
35
- * When omitted, fangorn.schema.register() and fangorn.schema.get() still work;
36
- * only fangorn.schema.registerAgent()
37
- */
38
32
  interface AgentConfig {
39
33
  privateKey: Hex;
40
34
  pinataJwt: string;
41
- /** Override ERC-8004 registry addresses per chainId (e.g. for Arbitrum Sepolia) */
42
35
  registryOverrides?: Record<number, {
43
36
  IDENTITY: string;
44
37
  REPUTATION: string;
45
38
  }>;
46
- /** Override subgraph URLs per chainId */
47
39
  subgraphOverrides?: Record<number, string>;
48
40
  }
49
41
  interface FangornContext {
50
42
  config: AppConfig;
51
43
  walletClient: WalletClient;
52
- storage: ReadableStorage<unknown> | WritableStorage<unknown>;
44
+ storage: PinningService | undefined;
53
45
  encryption: EncryptionService;
54
46
  domain: string;
47
+ ipfsGateway: string;
55
48
  schemaRegistry: SchemaRegistry;
56
49
  dataSourceRegistry: DataSourceRegistry;
57
50
  settlementRegistry: SettlementRegistry;
@@ -62,21 +55,18 @@ type StorageConfig = {
62
55
  jwt: string;
63
56
  gateway: string;
64
57
  };
65
- } | {
66
- storacha: {
67
- email: string;
68
- };
69
- } | {
70
- storacha: {
71
- readOnly: true;
72
- };
73
- } | ReadableStorage<unknown>;
58
+ };
74
59
  type EncryptionConfig = {
75
60
  lit: true;
76
61
  } | EncryptionService;
77
62
  interface FangornCreateOptions {
78
- storage: StorageConfig;
63
+ /**
64
+ * Pinning service config. Required for publisher and schema roles.
65
+ * Omit for consumer-only usage — reads always go through the public IPFS gateway.
66
+ */
67
+ storage?: StorageConfig;
79
68
  encryption: EncryptionConfig;
69
+ ipfsGateway?: string;
80
70
  config?: AppConfig;
81
71
  domain?: string;
82
72
  agentConfig?: AgentConfig;
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.04.08.dev",
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
  }
@@ -1,13 +0,0 @@
1
- import { WritableStorage } from "../index.js";
2
-
3
- //#region src/providers/storage/pinata/index.d.ts
4
- declare class PinataStorage implements WritableStorage<unknown> {
5
- private pinata;
6
- private gateway;
7
- constructor(pinataJwt: string, pinataGateway: string);
8
- store(data: unknown, metadata?: Record<string, string>): Promise<string>;
9
- retrieve(cid: string): Promise<unknown>;
10
- delete(cid: string): Promise<void>;
11
- }
12
- //#endregion
13
- export { PinataStorage };