@fangorn-network/sdk 2026.3.11 → 2026.3.27

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 (87) hide show
  1. package/README.md +311 -198
  2. package/lib/builders/a2aCardBuilder.js +1 -0
  3. package/lib/cli/cli.js +406 -379
  4. package/lib/cli/index.d.ts +170 -170
  5. package/lib/cli/index.js +1 -4
  6. package/lib/config.d.ts +543 -163
  7. package/lib/config.js +11 -8
  8. package/lib/fangorn.d.ts +28 -45
  9. package/lib/fangorn.js +98 -119
  10. package/lib/index.d.ts +8 -5
  11. package/lib/index.js +8 -7
  12. package/lib/modules/encryption/index.d.ts +4 -3
  13. package/lib/modules/encryption/lit.d.ts +3 -18
  14. package/lib/modules/encryption/lit.js +20 -49
  15. package/lib/modules/encryption/rand.js +2 -2
  16. package/lib/modules/encryption/types.d.ts +23 -8
  17. package/lib/modules/gadgets/settledGadget.d.ts +26 -0
  18. package/lib/modules/gadgets/settledGadget.js +63 -0
  19. package/lib/modules/gadgets/types.d.ts +16 -4
  20. package/lib/providers/storage/index.d.ts +15 -4
  21. package/lib/providers/storage/pinata/index.d.ts +5 -4
  22. package/lib/providers/storage/pinata/index.js +17 -2
  23. package/lib/providers/storage/storacha/index.d.ts +13 -0
  24. package/lib/providers/storage/storacha/index.js +49 -0
  25. package/lib/providers/storage/storacha/readOnly.d.ts +8 -0
  26. package/lib/providers/storage/storacha/readOnly.js +16 -0
  27. package/lib/{interface → registries}/datasource-registry/abi.d.ts +29 -43
  28. package/lib/registries/datasource-registry/abi.js +16 -0
  29. package/lib/{interface/datasource-registry/dataSourceRegistry.d.ts → registries/datasource-registry/index.d.ts} +9 -9
  30. package/lib/{interface/datasource-registry/dataSourceRegistry.js → registries/datasource-registry/index.js} +35 -34
  31. package/lib/registries/index.d.ts +3 -0
  32. package/lib/registries/index.js +4 -0
  33. package/lib/registries/schema-registry/abi.d.ts +127 -0
  34. package/lib/registries/schema-registry/abi.js +19 -0
  35. package/lib/registries/schema-registry/index.d.ts +29 -0
  36. package/lib/registries/schema-registry/index.js +114 -0
  37. package/lib/registries/settlement-registry/abi.d.ts +228 -0
  38. package/lib/registries/settlement-registry/abi.js +29 -0
  39. package/lib/registries/settlement-registry/index.d.ts +72 -0
  40. package/lib/registries/settlement-registry/index.js +316 -0
  41. package/lib/registries/settlement-registry/types.d.ts +51 -0
  42. package/lib/roles/consumer/index.d.ts +64 -0
  43. package/lib/roles/consumer/index.js +114 -0
  44. package/lib/roles/consumer/types.d.ts +66 -0
  45. package/lib/roles/index.js +1 -0
  46. package/lib/roles/publisher/index.d.ts +70 -0
  47. package/lib/roles/publisher/index.js +203 -0
  48. package/lib/roles/publisher/types.d.ts +93 -0
  49. package/lib/roles/publisher/types.js +1 -0
  50. package/lib/roles/schema/index.d.ts +44 -0
  51. package/lib/roles/schema/index.js +137 -0
  52. package/lib/roles/schema/types.d.ts +67 -0
  53. package/lib/roles/schema/types.js +1 -0
  54. package/lib/test/index.d.ts +5 -2
  55. package/lib/test/index.js +5 -3
  56. package/lib/test/testbed.d.ts +54 -32
  57. package/lib/test/testbed.js +149 -135
  58. package/lib/types/index.d.ts +65 -21
  59. package/lib/types/index.js +1 -12
  60. package/lib/utils/index.d.ts +2 -3
  61. package/lib/utils/index.js +4 -18
  62. package/package.json +9 -18
  63. package/lib/cli/registry.d.ts +0 -29
  64. package/lib/cli/registry.js +0 -53
  65. package/lib/deployContract.d.ts +0 -23
  66. package/lib/deployContract.js +0 -78
  67. package/lib/interface/datasource-registry/abi.js +0 -110
  68. package/lib/interface/index.d.ts +0 -3
  69. package/lib/interface/index.js +0 -4
  70. package/lib/interface/manifest.d.ts +0 -7
  71. package/lib/interface/manifest.js +0 -10
  72. package/lib/interface/settlement-tracker/abi.d.ts +0 -26
  73. package/lib/interface/settlement-tracker/abi.js +0 -88
  74. package/lib/interface/settlement-tracker/settlementTracker.d.ts +0 -32
  75. package/lib/interface/settlement-tracker/settlementTracker.js +0 -64
  76. package/lib/modules/gadgets/acc/gadgets.d.ts +0 -7
  77. package/lib/modules/gadgets/acc/gadgets.js +0 -10
  78. package/lib/modules/gadgets/acc.d.ts +0 -15
  79. package/lib/modules/gadgets/acc.js +0 -24
  80. package/lib/modules/gadgets/builder.d.ts +0 -1
  81. package/lib/modules/gadgets/payment.d.ts +0 -23
  82. package/lib/modules/gadgets/payment.js +0 -88
  83. package/lib/test/test-gadget.d.ts +0 -7
  84. package/lib/test/test-gadget.js +0 -10
  85. /package/lib/{modules/gadgets/builder.js → registries/settlement-registry/types.js} +0 -0
  86. /package/lib/{providers/storage/s3/index.js → roles/consumer/types.js} +0 -0
  87. /package/lib/{providers/storage/s3 → roles}/index.d.ts +0 -0
@@ -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