@fangorn-network/sdk 2026.3.28 → 2026.4.7-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.
Files changed (34) 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 -8
  7. package/lib/fangorn.js +12 -29
  8. package/lib/index.d.ts +3 -3
  9. package/lib/index.js +3 -3
  10. package/lib/providers/storage/index.d.ts +12 -12
  11. package/lib/providers/storage/index.js +47 -2
  12. package/lib/providers/storage/pinata.d.ts +11 -0
  13. package/lib/providers/storage/pinata.js +24 -0
  14. package/lib/registries/datasource-registry/index.d.ts +2 -1
  15. package/lib/registries/datasource-registry/index.js +14 -2
  16. package/lib/registries/schema-registry/index.d.ts +2 -2
  17. package/lib/registries/settlement-registry/index.d.ts +2 -2
  18. package/lib/roles/consumer/index.d.ts +2 -24
  19. package/lib/roles/consumer/index.js +5 -26
  20. package/lib/roles/publisher/index.d.ts +17 -15
  21. package/lib/roles/publisher/index.js +39 -27
  22. package/lib/roles/publisher/types.d.ts +5 -7
  23. package/lib/roles/schema/index.d.ts +3 -2
  24. package/lib/roles/schema/index.js +4 -2
  25. package/lib/test/testbed.d.ts +1 -1
  26. package/lib/test/testbed.js +9 -8
  27. package/lib/types/index.d.ts +10 -20
  28. package/package.json +72 -85
  29. package/lib/providers/storage/pinata/index.d.ts +0 -13
  30. package/lib/providers/storage/pinata/index.js +0 -41
  31. package/lib/providers/storage/storacha/index.d.ts +0 -13
  32. package/lib/providers/storage/storacha/index.js +0 -49
  33. package/lib/providers/storage/storacha/readOnly.d.ts +0 -8
  34. package/lib/providers/storage/storacha/readOnly.js +0 -16
@@ -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 data with Fangorn.
20
+ * Validates records against the schema, encrypts encrypted fields,
21
+ * stages all resolved entries, then commits to IPFS + on-chain.
19
22
  *
20
23
  * Each encrypted field within a record is stored as a separate IPFS object
21
24
  * (the ciphertext). The manifest entry stores the handle (CID + gateway)
22
- * alongside the plain fields. Consumers can read plain fields freely and
25
+ * alongside plain fields. Consumers can read plain fields freely and
23
26
  * only need to purchase + 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,11 +81,10 @@ 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;
@@ -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.07-0",
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 };
@@ -1,41 +0,0 @@
1
- import { PinataSDK } from "pinata";
2
-
3
- //#region src/providers/storage/pinata/index.ts
4
- var PinataStorage = class {
5
- pinata;
6
- gateway;
7
- constructor(pinataJwt, pinataGateway) {
8
- this.pinata = new PinataSDK({
9
- pinataJwt,
10
- pinataGateway
11
- });
12
- this.gateway = pinataGateway.replace(/\/$/, "");
13
- }
14
- async store(data, metadata) {
15
- const content = typeof data === "string" ? data : JSON.stringify(data, (_key, value) => {
16
- if (value instanceof Uint8Array) return {
17
- __type: "Uint8Array",
18
- data: Buffer.from(value).toString("base64")
19
- };
20
- return value;
21
- });
22
- const file = new File([content], metadata?.name ?? "file", { type: "text/plain" });
23
- return (await this.pinata.upload.public.file(file, { metadata })).cid;
24
- }
25
- async retrieve(cid) {
26
- const url = `https://${this.gateway}/ipfs/${cid}`;
27
- const response = await fetch(url);
28
- const text = await response.text();
29
- if (!response.ok) throw new Error(`Failed to retrieve ${cid}: ${response.statusText}`);
30
- return JSON.parse(text, (_key, value) => {
31
- if (value !== null && typeof value === "object" && "__type" in value && "data" in value && value.__type === "Uint8Array") return new Uint8Array(Buffer.from(value.data, "base64"));
32
- return value;
33
- });
34
- }
35
- async delete(cid) {
36
- await this.pinata.files.public.delete([cid]);
37
- }
38
- };
39
-
40
- //#endregion
41
- export { PinataStorage };
@@ -1,13 +0,0 @@
1
- import { WritableStorage } from "../index.js";
2
-
3
- //#region src/providers/storage/storacha/index.d.ts
4
- declare class StorachaStorage implements WritableStorage<unknown> {
5
- private client;
6
- private constructor();
7
- static create(email: string): Promise<StorachaStorage>;
8
- store(data: unknown, metadata?: Record<string, unknown>): Promise<string>;
9
- retrieve(cid: string): Promise<unknown>;
10
- delete(cid: string): Promise<void>;
11
- }
12
- //#endregion
13
- export { StorachaStorage };
@@ -1,49 +0,0 @@
1
- import { create } from "@storacha/client";
2
-
3
- //#region src/providers/storage/storacha/index.ts
4
- var StorachaStorage = class StorachaStorage {
5
- client;
6
- constructor(client) {
7
- this.client = client;
8
- }
9
- static async create(email) {
10
- const client = await create();
11
- const account = await client.login(email);
12
- if (!(await account.plan.get()).ok) await account.plan.wait();
13
- const spaces = client.spaces();
14
- if (spaces.length > 0) await client.setCurrentSpace(spaces[0].did());
15
- else {
16
- const space = await client.createSpace("fangorn", { account });
17
- await client.setCurrentSpace(space.did());
18
- }
19
- return new StorachaStorage(client);
20
- }
21
- async store(data, metadata) {
22
- const content = typeof data === "string" ? data : JSON.stringify(data, (_key, value) => {
23
- if (value instanceof Uint8Array) return {
24
- __type: "Uint8Array",
25
- data: Buffer.from(value).toString("base64")
26
- };
27
- return value;
28
- });
29
- const name = typeof metadata?.name === "string" ? metadata.name : "file";
30
- const file = new File([content], name, { type: "text/plain" });
31
- return (await this.client.uploadFile(file)).toString();
32
- }
33
- async retrieve(cid) {
34
- const url = `https://${cid}.ipfs.w3s.link`;
35
- const response = await fetch(url);
36
- if (!response.ok) throw new Error(`Failed to retrieve ${cid}: ${response.statusText}`);
37
- const text = await response.text();
38
- return JSON.parse(text, (_key, value) => {
39
- if (value !== null && typeof value === "object" && "__type" in value && "data" in value && value.__type === "Uint8Array") return new Uint8Array(Buffer.from(value.data, "base64"));
40
- return value;
41
- });
42
- }
43
- async delete(cid) {
44
- await this.client.remove(cid);
45
- }
46
- };
47
-
48
- //#endregion
49
- export { StorachaStorage };
@@ -1,8 +0,0 @@
1
- import { ReadableStorage } from "../index.js";
2
-
3
- //#region src/providers/storage/storacha/readOnly.d.ts
4
- declare class ReadOnlyStorachaStorage implements ReadableStorage<unknown> {
5
- retrieve(cid: string): Promise<unknown>;
6
- }
7
- //#endregion
8
- export { ReadOnlyStorachaStorage };