@fangorn-network/sdk 2026.4.7 → 2026.4.15
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/README.md +137 -150
- package/lib/cli/cli.js +134 -226
- package/lib/cli/index.d.ts +170 -170
- package/lib/config.d.ts +260 -257
- package/lib/config.js +7 -5
- package/lib/fangorn.d.ts +3 -20
- package/lib/fangorn.js +15 -52
- package/lib/index.d.ts +3 -7
- package/lib/index.js +4 -7
- package/lib/modules/encryption/aes.d.ts +3 -3
- package/lib/modules/encryption/index.d.ts +1 -28
- package/lib/modules/encryption/index.js +1 -3
- package/lib/modules/encryption/types.d.ts +1 -48
- package/lib/providers/storage/index.d.ts +4 -21
- package/lib/providers/storage/index.js +3 -2
- package/lib/providers/storage/pinata.d.ts +14 -0
- package/lib/providers/storage/pinata.js +32 -0
- package/lib/providers/storage/types.d.ts +37 -0
- package/lib/providers/storage/utils.d.ts +12 -0
- package/lib/providers/storage/utils.js +50 -0
- package/lib/registries/datasource-registry/abi.d.ts +116 -43
- package/lib/registries/datasource-registry/abi.js +190 -12
- package/lib/registries/datasource-registry/index.d.ts +12 -6
- package/lib/registries/datasource-registry/index.js +96 -20
- package/lib/registries/index.js +1 -1
- package/lib/registries/schema-registry/abi.d.ts +157 -66
- package/lib/registries/schema-registry/abi.js +242 -15
- package/lib/registries/schema-registry/index.d.ts +8 -3
- package/lib/registries/schema-registry/index.js +82 -17
- package/lib/registries/settlement-registry/abi.d.ts +199 -145
- package/lib/registries/settlement-registry/abi.js +331 -25
- package/lib/registries/settlement-registry/index.d.ts +36 -39
- package/lib/registries/settlement-registry/index.js +125 -91
- package/lib/registries/settlement-registry/types.d.ts +6 -3
- package/lib/roles/consumer/index.d.ts +17 -42
- package/lib/roles/consumer/index.js +87 -58
- package/lib/roles/consumer/types.d.ts +15 -34
- package/lib/roles/publisher/index.d.ts +22 -40
- package/lib/roles/publisher/index.js +69 -113
- package/lib/roles/publisher/types.d.ts +40 -41
- package/lib/roles/schema/index.d.ts +4 -30
- package/lib/roles/schema/index.js +7 -60
- package/lib/roles/schema/types.d.ts +16 -2
- package/lib/test/testbed.d.ts +12 -36
- package/lib/test/testbed.js +35 -68
- package/lib/types/index.d.ts +14 -57
- package/package.json +1 -6
- package/lib/modules/encryption/lit.d.ts +0 -21
- package/lib/modules/encryption/lit.js +0 -127
- package/lib/modules/gadgets/index.d.ts +0 -2
- package/lib/modules/gadgets/index.js +0 -1
- package/lib/modules/gadgets/settledGadget.d.ts +0 -31
- package/lib/modules/gadgets/settledGadget.js +0 -75
- package/lib/modules/gadgets/types.d.ts +0 -27
- package/lib/providers/storage/pinata/index.d.ts +0 -13
- package/lib/providers/storage/pinata/index.js +0 -41
- package/lib/providers/storage/storacha/index.d.ts +0 -13
- package/lib/providers/storage/storacha/index.js +0 -49
- package/lib/providers/storage/storacha/readOnly.d.ts +0 -8
- package/lib/providers/storage/storacha/readOnly.js +0 -16
- /package/lib/{modules/gadgets → providers/storage}/types.js +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AppConfig } from "../../config.js";
|
|
2
|
-
import { Gadget, GadgetDescriptor } from "./types.js";
|
|
3
|
-
import { Address, Hex } from "viem";
|
|
4
|
-
import { UnifiedAccessControlCondition } from "@lit-protocol/access-control-conditions";
|
|
5
|
-
|
|
6
|
-
//#region src/modules/gadgets/settledGadget.d.ts
|
|
7
|
-
interface SettledGadgetParams {
|
|
8
|
-
/** keccak256(owner, schemaId, tag) — derived at upload time */
|
|
9
|
-
resourceId: Hex;
|
|
10
|
-
/** SettlementRegistry contract address */
|
|
11
|
-
settlementRegistryAddress: Address;
|
|
12
|
-
/** "arbitrumSepolia" | "baseSepolia" */
|
|
13
|
-
chainName: string;
|
|
14
|
-
}
|
|
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
|
-
declare class SettledGadget implements Gadget {
|
|
22
|
-
private readonly params;
|
|
23
|
-
readonly type = "settled";
|
|
24
|
-
constructor(params: SettledGadgetParams);
|
|
25
|
-
hookAddress(): Address;
|
|
26
|
-
hookParams(): Hex;
|
|
27
|
-
toAccessCondition(): UnifiedAccessControlCondition[];
|
|
28
|
-
toDescriptor(): GadgetDescriptor;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { SettledGadget, SettledGadgetParams, makeSettledGadgetFactory };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { zeroAddress } from "viem";
|
|
2
|
-
import { createAccBuilder } from "@lit-protocol/access-control-conditions";
|
|
3
|
-
|
|
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
|
-
var SettledGadget = class {
|
|
18
|
-
type = "settled";
|
|
19
|
-
constructor(params) {
|
|
20
|
-
this.params = params;
|
|
21
|
-
}
|
|
22
|
-
hookAddress() {
|
|
23
|
-
return zeroAddress;
|
|
24
|
-
}
|
|
25
|
-
hookParams() {
|
|
26
|
-
return "0x";
|
|
27
|
-
}
|
|
28
|
-
toAccessCondition() {
|
|
29
|
-
return createAccBuilder().custom({
|
|
30
|
-
conditionType: "evmContract",
|
|
31
|
-
contractAddress: this.params.settlementRegistryAddress,
|
|
32
|
-
chain: "arbitrumSepolia",
|
|
33
|
-
functionName: "isSettled",
|
|
34
|
-
functionParams: [":userAddress", this.params.resourceId],
|
|
35
|
-
functionAbi: {
|
|
36
|
-
name: "isSettled",
|
|
37
|
-
type: "function",
|
|
38
|
-
stateMutability: "view",
|
|
39
|
-
inputs: [{
|
|
40
|
-
name: "stealth_address",
|
|
41
|
-
type: "address"
|
|
42
|
-
}, {
|
|
43
|
-
name: "resource_id",
|
|
44
|
-
type: "bytes32"
|
|
45
|
-
}],
|
|
46
|
-
outputs: [{
|
|
47
|
-
name: "",
|
|
48
|
-
type: "bool"
|
|
49
|
-
}]
|
|
50
|
-
},
|
|
51
|
-
returnValueTest: {
|
|
52
|
-
key: "",
|
|
53
|
-
comparator: "=",
|
|
54
|
-
value: "true"
|
|
55
|
-
}
|
|
56
|
-
}).build();
|
|
57
|
-
}
|
|
58
|
-
toDescriptor() {
|
|
59
|
-
const acc = this.toAccessCondition();
|
|
60
|
-
return {
|
|
61
|
-
type: this.type,
|
|
62
|
-
description: "Settlement-gated: SettlementRegistry.isSettled(resourceId, caller)",
|
|
63
|
-
hookAddress: this.hookAddress(),
|
|
64
|
-
acc,
|
|
65
|
-
params: {
|
|
66
|
-
resourceId: this.params.resourceId,
|
|
67
|
-
settlementRegistryAddress: this.params.settlementRegistryAddress,
|
|
68
|
-
chainName: this.params.chainName
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
export { SettledGadget, makeSettledGadgetFactory };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Address, Hex } from "viem";
|
|
2
|
-
import { UnifiedAccessControlCondition } from "@lit-protocol/access-control-conditions";
|
|
3
|
-
|
|
4
|
-
//#region src/modules/gadgets/types.d.ts
|
|
5
|
-
interface Gadget {
|
|
6
|
-
readonly type: string;
|
|
7
|
-
/** Hook contract called by SettlementRegistry during settle(). Zero address = no hook. */
|
|
8
|
-
hookAddress(): Address;
|
|
9
|
-
/** ABI-encoded params forwarded to the hook. "0x" = no params. */
|
|
10
|
-
hookParams(): Hex;
|
|
11
|
-
/** The ACC baked into the ciphertext at encryption time. Must match what the hook produces. */
|
|
12
|
-
toAccessCondition(): UnifiedAccessControlCondition[];
|
|
13
|
-
/** Stored in the manifest so consumers/agents know what they're buying. */
|
|
14
|
-
toDescriptor(): GadgetDescriptor;
|
|
15
|
-
}
|
|
16
|
-
interface GadgetDescriptor {
|
|
17
|
-
type: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
/** Hook contract address — zero address for SettledGadget */
|
|
20
|
-
hookAddress: Address;
|
|
21
|
-
/** The ACC stored alongside the ciphertext */
|
|
22
|
-
acc?: UnifiedAccessControlCondition[];
|
|
23
|
-
/** Human-readable params for display and agent consumption */
|
|
24
|
-
params?: Record<string, unknown>;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { Gadget, GadgetDescriptor };
|
|
@@ -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 };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/providers/storage/storacha/readOnly.ts
|
|
2
|
-
var ReadOnlyStorachaStorage = class {
|
|
3
|
-
async retrieve(cid) {
|
|
4
|
-
const url = `https://${cid}.ipfs.w3s.link`;
|
|
5
|
-
const response = await fetch(url);
|
|
6
|
-
if (!response.ok) throw new Error(`Failed to retrieve ${cid}: ${response.statusText}`);
|
|
7
|
-
const text = await response.text();
|
|
8
|
-
return JSON.parse(text, (_key, value) => {
|
|
9
|
-
if (value !== null && typeof value === "object" && "__type" in value && "data" in value && value.__type === "Uint8Array") return new Uint8Array(Buffer.from(value.data, "base64"));
|
|
10
|
-
return value;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { ReadOnlyStorachaStorage };
|
|
File without changes
|