@fangorn-network/sdk 2026.3.11 → 2026.3.28

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 (89) hide show
  1. package/README.md +311 -198
  2. package/lib/builders/a2aCardBuilder.js +1 -0
  3. package/lib/cli/cli.d.ts +0 -0
  4. package/lib/cli/cli.js +399 -380
  5. package/lib/cli/index.d.ts +170 -170
  6. package/lib/cli/index.js +1 -4
  7. package/lib/config.d.ts +543 -163
  8. package/lib/config.js +11 -8
  9. package/lib/fangorn.d.ts +31 -43
  10. package/lib/fangorn.js +101 -117
  11. package/lib/index.d.ts +8 -5
  12. package/lib/index.js +8 -7
  13. package/lib/modules/encryption/index.d.ts +4 -3
  14. package/lib/modules/encryption/lit.d.ts +3 -18
  15. package/lib/modules/encryption/lit.js +20 -49
  16. package/lib/modules/encryption/rand.js +2 -2
  17. package/lib/modules/encryption/types.d.ts +23 -8
  18. package/lib/modules/gadgets/settledGadget.d.ts +31 -0
  19. package/lib/modules/gadgets/settledGadget.js +75 -0
  20. package/lib/modules/gadgets/types.d.ts +16 -4
  21. package/lib/providers/storage/index.d.ts +15 -4
  22. package/lib/providers/storage/pinata/index.d.ts +5 -4
  23. package/lib/providers/storage/pinata/index.js +17 -2
  24. package/lib/providers/storage/storacha/index.d.ts +13 -0
  25. package/lib/providers/storage/storacha/index.js +49 -0
  26. package/lib/providers/storage/storacha/readOnly.d.ts +8 -0
  27. package/lib/providers/storage/storacha/readOnly.js +16 -0
  28. package/lib/{interface → registries}/datasource-registry/abi.d.ts +29 -43
  29. package/lib/registries/datasource-registry/abi.js +16 -0
  30. package/lib/registries/datasource-registry/index.d.ts +24 -0
  31. package/lib/{interface/datasource-registry/dataSourceRegistry.js → registries/datasource-registry/index.js} +35 -34
  32. package/lib/registries/index.d.ts +3 -0
  33. package/lib/registries/index.js +4 -0
  34. package/lib/registries/schema-registry/abi.d.ts +127 -0
  35. package/lib/registries/schema-registry/abi.js +19 -0
  36. package/lib/registries/schema-registry/index.d.ts +29 -0
  37. package/lib/registries/schema-registry/index.js +114 -0
  38. package/lib/registries/settlement-registry/abi.d.ts +228 -0
  39. package/lib/registries/settlement-registry/abi.js +29 -0
  40. package/lib/registries/settlement-registry/index.d.ts +72 -0
  41. package/lib/registries/settlement-registry/index.js +316 -0
  42. package/lib/registries/settlement-registry/types.d.ts +51 -0
  43. package/lib/roles/consumer/index.d.ts +64 -0
  44. package/lib/roles/consumer/index.js +114 -0
  45. package/lib/roles/consumer/types.d.ts +66 -0
  46. package/lib/roles/index.js +1 -0
  47. package/lib/roles/publisher/index.d.ts +68 -0
  48. package/lib/roles/publisher/index.js +205 -0
  49. package/lib/roles/publisher/types.d.ts +93 -0
  50. package/lib/roles/publisher/types.js +1 -0
  51. package/lib/roles/schema/index.d.ts +44 -0
  52. package/lib/roles/schema/index.js +137 -0
  53. package/lib/roles/schema/types.d.ts +67 -0
  54. package/lib/roles/schema/types.js +1 -0
  55. package/lib/test/index.d.ts +5 -2
  56. package/lib/test/index.js +5 -3
  57. package/lib/test/testbed.d.ts +52 -32
  58. package/lib/test/testbed.js +138 -137
  59. package/lib/types/index.d.ts +65 -21
  60. package/lib/types/index.js +1 -12
  61. package/lib/utils/index.d.ts +2 -3
  62. package/lib/utils/index.js +4 -18
  63. package/package.json +85 -81
  64. package/lib/cli/registry.d.ts +0 -29
  65. package/lib/cli/registry.js +0 -53
  66. package/lib/deployContract.d.ts +0 -23
  67. package/lib/deployContract.js +0 -78
  68. package/lib/interface/datasource-registry/abi.js +0 -110
  69. package/lib/interface/datasource-registry/dataSourceRegistry.d.ts +0 -24
  70. package/lib/interface/index.d.ts +0 -3
  71. package/lib/interface/index.js +0 -4
  72. package/lib/interface/manifest.d.ts +0 -7
  73. package/lib/interface/manifest.js +0 -10
  74. package/lib/interface/settlement-tracker/abi.d.ts +0 -26
  75. package/lib/interface/settlement-tracker/abi.js +0 -88
  76. package/lib/interface/settlement-tracker/settlementTracker.d.ts +0 -32
  77. package/lib/interface/settlement-tracker/settlementTracker.js +0 -64
  78. package/lib/modules/gadgets/acc/gadgets.d.ts +0 -7
  79. package/lib/modules/gadgets/acc/gadgets.js +0 -10
  80. package/lib/modules/gadgets/acc.d.ts +0 -15
  81. package/lib/modules/gadgets/acc.js +0 -24
  82. package/lib/modules/gadgets/builder.d.ts +0 -1
  83. package/lib/modules/gadgets/payment.d.ts +0 -23
  84. package/lib/modules/gadgets/payment.js +0 -88
  85. package/lib/test/test-gadget.d.ts +0 -7
  86. package/lib/test/test-gadget.js +0 -10
  87. /package/lib/{modules/gadgets/builder.js → registries/settlement-registry/types.js} +0 -0
  88. /package/lib/{providers/storage/s3/index.js → roles/consumer/types.js} +0 -0
  89. /package/lib/{providers/storage/s3 → roles}/index.d.ts +0 -0
@@ -1,64 +0,0 @@
1
- import { SETTLEMENT_TRACKER_ABI } from "./abi.js";
2
-
3
- //#region src/interface/settlement-tracker/settlementTracker.ts
4
- var SettlementTracker = class {
5
- publicClient;
6
- walletClient;
7
- contractAddress;
8
- constructor(contractAddress, publicClient, walletClient) {
9
- this.publicClient = publicClient;
10
- this.contractAddress = contractAddress;
11
- this.walletClient = walletClient;
12
- }
13
- getWriteConfig() {
14
- if (!this.walletClient.chain) throw new Error("Chain required");
15
- if (!this.walletClient.account) throw new Error("Account required");
16
- return {
17
- chain: this.walletClient.chain,
18
- account: this.walletClient.account
19
- };
20
- }
21
- getContractAddress() {
22
- return this.contractAddress;
23
- }
24
- async checkSettlement(commitment, user) {
25
- return await this.publicClient.readContract({
26
- address: this.contractAddress,
27
- abi: SETTLEMENT_TRACKER_ABI,
28
- functionName: "checkSettlement",
29
- args: [commitment, user]
30
- });
31
- }
32
- /**
33
- * Settles the payment on-chain using the EIP-3009 authorization
34
- * This is usually called by the Facilitator.
35
- */
36
- async pay(args) {
37
- const { chain, account } = this.getWriteConfig();
38
- return this.walletClient.writeContract({
39
- address: this.contractAddress,
40
- abi: SETTLEMENT_TRACKER_ABI,
41
- functionName: "pay",
42
- args: [
43
- args.commitment,
44
- args.from,
45
- args.to,
46
- args.value,
47
- args.validAfter,
48
- args.validBefore,
49
- args.nonce,
50
- args.v,
51
- args.r,
52
- args.s
53
- ],
54
- chain,
55
- account
56
- });
57
- }
58
- async waitForTransaction(hash) {
59
- return this.publicClient.waitForTransactionReceipt({ hash });
60
- }
61
- };
62
-
63
- //#endregion
64
- export { SettlementTracker };
@@ -1,7 +0,0 @@
1
- import { AccGadget } from "../acc.js";
2
- import { EvmChain } from "@lit-protocol/access-control-conditions";
3
-
4
- //#region src/modules/gadgets/acc/gadgets.d.ts
5
- declare function identity(chain: EvmChain, who: string): AccGadget;
6
- //#endregion
7
- export { identity };
@@ -1,10 +0,0 @@
1
- import { AccGadget } from "../acc.js";
2
- import { createAccBuilder } from "@lit-protocol/access-control-conditions";
3
-
4
- //#region src/modules/gadgets/acc/gadgets.ts
5
- function identity(chain, who) {
6
- return new AccGadget(createAccBuilder().requireWalletOwnership(who).on(chain).build(), "Caller must match the specified wallet.");
7
- }
8
-
9
- //#endregion
10
- export { identity };
@@ -1,15 +0,0 @@
1
- import { Gadget, GadgetDescriptor } from "./types.js";
2
- import { AccessControlConditions } from "@lit-protocol/access-control-conditions";
3
-
4
- //#region src/modules/gadgets/acc.d.ts
5
- declare class AccGadget implements Gadget {
6
- private acc;
7
- private description?;
8
- readonly type = "acc";
9
- constructor(acc: AccessControlConditions, description?: string);
10
- toLitAction(): string;
11
- toAccessCondition(): Promise<AccessControlConditions>;
12
- toDescriptor(): GadgetDescriptor;
13
- }
14
- //#endregion
15
- export { AccGadget };
@@ -1,24 +0,0 @@
1
- //#region src/modules/gadgets/acc.ts
2
- var AccGadget = class {
3
- type = "acc";
4
- constructor(acc, description) {
5
- this.acc = acc;
6
- this.description = description;
7
- }
8
- toLitAction() {
9
- return ``;
10
- }
11
- async toAccessCondition() {
12
- return this.acc;
13
- }
14
- toDescriptor() {
15
- return {
16
- type: this.type,
17
- description: this.description,
18
- acc: this.acc
19
- };
20
- }
21
- };
22
-
23
- //#endregion
24
- export { AccGadget };
@@ -1 +0,0 @@
1
- export { };
@@ -1,23 +0,0 @@
1
- import { Gadget, GadgetDescriptor } from "./types.js";
2
- import { Address, Hex } from "viem";
3
-
4
- //#region src/modules/gadgets/payment.d.ts
5
- interface PaymentGadgetParams {
6
- usdcPrice: string;
7
- commitment: Hex;
8
- chainName: string;
9
- settlementTrackerContractAddress: Address;
10
- pinataJwt: String;
11
- }
12
- declare class PaymentGadget implements Gadget {
13
- private params;
14
- readonly type = "payment";
15
- private litActionCid;
16
- constructor(params: PaymentGadgetParams);
17
- toLitAction(): string;
18
- toAccessCondition(): Promise<any>;
19
- toDescriptor(): GadgetDescriptor;
20
- private toLitActionIpfsHash;
21
- }
22
- //#endregion
23
- export { PaymentGadget, PaymentGadgetParams };
@@ -1,88 +0,0 @@
1
- import { createAccBuilder } from "@lit-protocol/access-control-conditions";
2
-
3
- //#region src/modules/gadgets/payment.ts
4
- var PaymentGadget = class {
5
- type = "payment";
6
- litActionCid = null;
7
- constructor(params) {
8
- this.params = params;
9
- }
10
- toLitAction() {
11
- return `
12
- const arbitrumSepolia = "https://sepolia-rollup.arbitrum.io/rpc";
13
- const baseSepolia = "https://sepolia.base.org";
14
-
15
- const go = async (supportedNetwork, paywallAddress, commitment, price) => {
16
- let rpcUrl = baseSepolia;
17
- if (supportedNetwork == "arbitrumSepolia") rpcUrl = arbitrumSepolia;
18
- else if (supportedNetwork == "baseSepolia") rpcUrl = baseSepolia;
19
- else {
20
- throw new Error(
21
- 'Unsupported network.Choose a supported network in the list ["arbitrumSepolia", "baseSepolia"].'
22
- );
23
- }
24
-
25
- const callerAddress = Lit.Auth.authSigAddress;
26
- const provider = new ethers.providers.JsonRpcProvider(rpcUrl);
27
-
28
- const paywallAbi = [
29
- "function checkSettlement(bytes32 commitment, address user) external view returns (uint256)",
30
- ];
31
-
32
- const paywall = new ethers.Contract(paywallAddress, paywallAbi, provider);
33
-
34
- const paidAmount = await paywall.checkSettlement(commitment, callerAddress);
35
-
36
- if (paidAmount < price) {
37
- Lit.Actions.setResponse({ success: false, response: "goodbye" });
38
- throw new Error("x402: Payment Required. " + paidAmount + " < " + price + " with commitment " + commitment );
39
- }
40
-
41
- Lit.Actions.setResponse({ response: true.toString() });
42
-
43
- return true.toString()
44
- };
45
- `;
46
- }
47
- async toAccessCondition() {
48
- return createAccBuilder().requireLitAction(await this.toLitActionIpfsHash(), "go", [
49
- this.params.chainName,
50
- this.params.settlementTrackerContractAddress,
51
- this.params.commitment,
52
- this.params.usdcPrice
53
- ], "true").build();
54
- }
55
- toDescriptor() {
56
- return {
57
- type: this.type,
58
- description: "x402: Payment Required",
59
- acc: this.toAccessCondition(),
60
- params: {
61
- price: this.params.usdcPrice,
62
- token: "USDC"
63
- }
64
- };
65
- }
66
- async toLitActionIpfsHash() {
67
- const content = this.toLitAction();
68
- const name = "lit-action-payment-gadget-v1";
69
- const form = new FormData();
70
- form.append("file", new Blob([content], { type: "text/plain" }), name);
71
- form.append("pinataOptions", JSON.stringify({ cidVersion: 0 }));
72
- form.append("pinataMetadata", JSON.stringify({ name }));
73
- const res = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", {
74
- method: "POST",
75
- headers: { Authorization: `Bearer ${this.params.pinataJwt}` },
76
- body: form
77
- });
78
- if (!res.ok) {
79
- const text = await res.text();
80
- throw new Error(`Pinata upload failed: ${res.status} - ${text}`);
81
- }
82
- this.litActionCid = (await res.json()).IpfsHash;
83
- return this.litActionCid;
84
- }
85
- };
86
-
87
- //#endregion
88
- export { PaymentGadget };
@@ -1,7 +0,0 @@
1
- import { AccGadget } from "../modules/gadgets/acc.js";
2
- import { EvmChain } from "@lit-protocol/access-control-conditions";
3
-
4
- //#region src/test/test-gadget.d.ts
5
- declare function emptyWallet(chain: EvmChain): AccGadget;
6
- //#endregion
7
- export { emptyWallet };
@@ -1,10 +0,0 @@
1
- import { AccGadget } from "../modules/gadgets/acc.js";
2
- import { createAccBuilder } from "@lit-protocol/access-control-conditions";
3
-
4
- //#region src/test/test-gadget.ts
5
- function emptyWallet(chain) {
6
- return new AccGadget(createAccBuilder().requireEthBalance("0", "=").on(chain).build(), "Caller must have zero ETH balance");
7
- }
8
-
9
- //#endregion
10
- export { emptyWallet };
File without changes