@opendatalabs/vana-sdk 0.1.0-alpha.2e77fcc → 0.1.0-alpha.3041a59

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 (180) hide show
  1. package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
  2. package/dist/controllers/__tests__/operations.processQueue.test.d.ts +1 -0
  3. package/dist/controllers/data.cjs +255 -143
  4. package/dist/controllers/data.cjs.map +1 -1
  5. package/dist/controllers/data.d.ts +25 -10
  6. package/dist/controllers/data.js +268 -146
  7. package/dist/controllers/data.js.map +1 -1
  8. package/dist/controllers/operations.cjs +430 -0
  9. package/dist/controllers/operations.cjs.map +1 -0
  10. package/dist/controllers/operations.d.ts +229 -0
  11. package/dist/controllers/operations.js +406 -0
  12. package/dist/controllers/operations.js.map +1 -0
  13. package/dist/controllers/permissions.cjs +516 -183
  14. package/dist/controllers/permissions.cjs.map +1 -1
  15. package/dist/controllers/permissions.d.ts +126 -28
  16. package/dist/controllers/permissions.js +516 -183
  17. package/dist/controllers/permissions.js.map +1 -1
  18. package/dist/controllers/schemas.cjs +81 -4
  19. package/dist/controllers/schemas.cjs.map +1 -1
  20. package/dist/controllers/schemas.d.ts +41 -0
  21. package/dist/controllers/schemas.js +81 -4
  22. package/dist/controllers/schemas.js.map +1 -1
  23. package/dist/controllers/server.cjs +251 -42
  24. package/dist/controllers/server.cjs.map +1 -1
  25. package/dist/controllers/server.d.ts +111 -14
  26. package/dist/controllers/server.js +251 -42
  27. package/dist/controllers/server.js.map +1 -1
  28. package/dist/core/__tests__/health.test.d.ts +1 -0
  29. package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
  30. package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
  31. package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
  32. package/dist/core/health.cjs +289 -0
  33. package/dist/core/health.cjs.map +1 -0
  34. package/dist/core/health.d.ts +143 -0
  35. package/dist/core/health.js +265 -0
  36. package/dist/core/health.js.map +1 -0
  37. package/dist/core/inMemoryNonceManager.cjs +138 -0
  38. package/dist/core/inMemoryNonceManager.cjs.map +1 -0
  39. package/dist/core/inMemoryNonceManager.d.ts +69 -0
  40. package/dist/core/inMemoryNonceManager.js +114 -0
  41. package/dist/core/inMemoryNonceManager.js.map +1 -0
  42. package/dist/core/nonceManager.cjs +304 -0
  43. package/dist/core/nonceManager.cjs.map +1 -0
  44. package/dist/core/nonceManager.d.ts +116 -0
  45. package/dist/core/nonceManager.js +280 -0
  46. package/dist/core/nonceManager.js.map +1 -0
  47. package/dist/core/pollingManager.cjs +292 -0
  48. package/dist/core/pollingManager.cjs.map +1 -0
  49. package/dist/core/pollingManager.d.ts +120 -0
  50. package/dist/core/pollingManager.js +268 -0
  51. package/dist/core/pollingManager.js.map +1 -0
  52. package/dist/core.cjs +5 -0
  53. package/dist/core.cjs.map +1 -1
  54. package/dist/core.d.ts +11 -5
  55. package/dist/core.js +5 -0
  56. package/dist/core.js.map +1 -1
  57. package/dist/crypto/ecies/base.cjs +16 -3
  58. package/dist/crypto/ecies/base.cjs.map +1 -1
  59. package/dist/crypto/ecies/base.js +16 -3
  60. package/dist/crypto/ecies/base.js.map +1 -1
  61. package/dist/errors.cjs +29 -0
  62. package/dist/errors.cjs.map +1 -1
  63. package/dist/errors.d.ts +64 -0
  64. package/dist/errors.js +28 -0
  65. package/dist/errors.js.map +1 -1
  66. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +162 -0
  67. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -1
  68. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +123 -0
  69. package/dist/generated/abi/DataPortabilityGranteesImplementation.js +162 -0
  70. package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -1
  71. package/dist/generated/abi/index.d.ts +123 -0
  72. package/dist/generated/server/server-exports.cjs +22 -0
  73. package/dist/generated/server/server-exports.cjs.map +1 -1
  74. package/dist/generated/server/server-exports.d.ts +27 -10
  75. package/dist/generated/server/server-exports.js +17 -0
  76. package/dist/generated/server/server-exports.js.map +1 -1
  77. package/dist/generated/server/server.cjs.map +1 -1
  78. package/dist/generated/server/server.d.ts +771 -402
  79. package/dist/generated/subgraph.cjs +797 -32
  80. package/dist/generated/subgraph.cjs.map +1 -1
  81. package/dist/generated/subgraph.d.ts +135 -0
  82. package/dist/generated/subgraph.js +792 -32
  83. package/dist/generated/subgraph.js.map +1 -1
  84. package/dist/index.browser.d.ts +1 -0
  85. package/dist/index.browser.js +2 -0
  86. package/dist/index.browser.js.map +1 -1
  87. package/dist/index.node.cjs +17 -0
  88. package/dist/index.node.cjs.map +1 -1
  89. package/dist/index.node.d.ts +25 -5
  90. package/dist/index.node.js +15 -1
  91. package/dist/index.node.js.map +1 -1
  92. package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
  93. package/dist/lib/redisAtomicStore.cjs +201 -0
  94. package/dist/lib/redisAtomicStore.cjs.map +1 -0
  95. package/dist/lib/redisAtomicStore.d.ts +120 -0
  96. package/dist/lib/redisAtomicStore.js +177 -0
  97. package/dist/lib/redisAtomicStore.js.map +1 -0
  98. package/dist/server/relayerHandler.cjs +187 -25
  99. package/dist/server/relayerHandler.cjs.map +1 -1
  100. package/dist/server/relayerHandler.d.ts +35 -4
  101. package/dist/server/relayerHandler.js +187 -25
  102. package/dist/server/relayerHandler.js.map +1 -1
  103. package/dist/storage/index.cjs +3 -0
  104. package/dist/storage/index.cjs.map +1 -1
  105. package/dist/storage/index.d.ts +1 -0
  106. package/dist/storage/index.js +2 -0
  107. package/dist/storage/index.js.map +1 -1
  108. package/dist/storage/providers/dropbox.cjs +237 -0
  109. package/dist/storage/providers/dropbox.cjs.map +1 -0
  110. package/dist/storage/providers/dropbox.d.ts +39 -0
  111. package/dist/storage/providers/dropbox.js +215 -0
  112. package/dist/storage/providers/dropbox.js.map +1 -0
  113. package/dist/storage/providers/dropbox.test.d.ts +1 -0
  114. package/dist/tests/data-upload-owner-validation.test.d.ts +1 -0
  115. package/dist/types/atomicStore.cjs +31 -0
  116. package/dist/types/atomicStore.cjs.map +1 -0
  117. package/dist/types/atomicStore.d.ts +236 -0
  118. package/dist/types/atomicStore.js +7 -0
  119. package/dist/types/atomicStore.js.map +1 -0
  120. package/dist/types/config.cjs.map +1 -1
  121. package/dist/types/config.d.ts +3 -3
  122. package/dist/types/config.js.map +1 -1
  123. package/dist/types/controller-context.cjs.map +1 -1
  124. package/dist/types/controller-context.d.ts +4 -3
  125. package/dist/types/data.cjs.map +1 -1
  126. package/dist/types/data.d.ts +7 -4
  127. package/dist/types/index.cjs.map +1 -1
  128. package/dist/types/index.d.ts +4 -2
  129. package/dist/types/index.js.map +1 -1
  130. package/dist/types/operationStore.cjs +17 -0
  131. package/dist/types/operationStore.cjs.map +1 -0
  132. package/dist/types/operationStore.d.ts +171 -0
  133. package/dist/types/operationStore.js +1 -0
  134. package/dist/types/operationStore.js.map +1 -0
  135. package/dist/types/operations.cjs +3 -15
  136. package/dist/types/operations.cjs.map +1 -1
  137. package/dist/types/operations.d.ts +17 -88
  138. package/dist/types/operations.js +2 -13
  139. package/dist/types/operations.js.map +1 -1
  140. package/dist/types/options.cjs +17 -0
  141. package/dist/types/options.cjs.map +1 -0
  142. package/dist/types/options.d.ts +308 -0
  143. package/dist/types/options.js +1 -0
  144. package/dist/types/options.js.map +1 -0
  145. package/dist/types/permissions.cjs.map +1 -1
  146. package/dist/types/permissions.d.ts +4 -0
  147. package/dist/types/personal.cjs.map +1 -1
  148. package/dist/types/personal.d.ts +19 -0
  149. package/dist/types/relayer.cjs.map +1 -1
  150. package/dist/types/relayer.d.ts +10 -10
  151. package/dist/types/utils.cjs.map +1 -1
  152. package/dist/types/utils.d.ts +0 -49
  153. package/dist/utils/__tests__/chainQuery.test.d.ts +1 -0
  154. package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
  155. package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
  156. package/dist/utils/chainQuery.cjs +107 -0
  157. package/dist/utils/chainQuery.cjs.map +1 -0
  158. package/dist/utils/chainQuery.d.ts +31 -0
  159. package/dist/utils/chainQuery.js +82 -0
  160. package/dist/utils/chainQuery.js.map +1 -0
  161. package/dist/utils/grantFiles.cjs +4 -1
  162. package/dist/utils/grantFiles.cjs.map +1 -1
  163. package/dist/utils/grantFiles.js +4 -1
  164. package/dist/utils/grantFiles.js.map +1 -1
  165. package/dist/utils/subgraphConsistency.cjs +184 -0
  166. package/dist/utils/subgraphConsistency.cjs.map +1 -0
  167. package/dist/utils/subgraphConsistency.d.ts +65 -0
  168. package/dist/utils/subgraphConsistency.js +155 -0
  169. package/dist/utils/subgraphConsistency.js.map +1 -0
  170. package/dist/utils/subgraphMetaCache.cjs +101 -0
  171. package/dist/utils/subgraphMetaCache.cjs.map +1 -0
  172. package/dist/utils/subgraphMetaCache.d.ts +56 -0
  173. package/dist/utils/subgraphMetaCache.js +76 -0
  174. package/dist/utils/subgraphMetaCache.js.map +1 -0
  175. package/dist/utils/subgraphPagination.cjs +104 -0
  176. package/dist/utils/subgraphPagination.cjs.map +1 -0
  177. package/dist/utils/subgraphPagination.d.ts +78 -0
  178. package/dist/utils/subgraphPagination.js +78 -0
  179. package/dist/utils/subgraphPagination.js.map +1 -0
  180. package/package.json +1 -1
@@ -123,6 +123,7 @@ export { DataController } from "./controllers/data";
123
123
  export { ServerController } from "./controllers/server";
124
124
  export { ProtocolController } from "./controllers/protocol";
125
125
  export { SchemaController } from "./controllers/schemas";
126
+ export { OperationsController } from "./controllers/operations";
126
127
  export * from "./contracts/contractController";
127
128
  export * from "./utils/encryption";
128
129
  export * from "./utils/formatters";
@@ -22,6 +22,7 @@ import { DataController } from "./controllers/data";
22
22
  import { ServerController } from "./controllers/server";
23
23
  import { ProtocolController } from "./controllers/protocol";
24
24
  import { SchemaController } from "./controllers/schemas";
25
+ import { OperationsController } from "./controllers/operations";
25
26
  export * from "./contracts/contractController";
26
27
  export * from "./utils/encryption";
27
28
  export * from "./utils/formatters";
@@ -82,6 +83,7 @@ export {
82
83
  EventEmitter,
83
84
  MemoryCache,
84
85
  MiddlewarePipeline,
86
+ OperationsController,
85
87
  PermissionsController,
86
88
  ProtocolController,
87
89
  RateLimiter,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.browser.ts"],"sourcesContent":["/**\n * @module Browser\n * Browser-specific implementation of the Vana SDK\n */\n\nimport { BrowserPlatformAdapter } from \"./platform/browser\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n} from \"./types\";\n\n/**\n * Internal implementation class for browser environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaBrowserImpl extends VanaCore {\n constructor(config: VanaConfig) {\n super(new BrowserPlatformAdapter(), config);\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for browser environments.\n *\n * @remarks\n * This is the primary entry point for browser applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The SDK supports multiple wallet configurations (direct WalletClient or chain config),\n * various storage providers (IPFS, Pinata, Google Drive), and gasless transactions via relayers.\n * All operations are optimized for browser environments with proper bundle size optimization.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for browser use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/browser';\n * import { createWalletClient, custom } from 'viem';\n * import { IPFSStorage } from '@opendatalabs/vana-sdk/browser';\n *\n * // Complete setup with storage and wallet\n * const walletClient = createWalletClient({\n * chain: mokshaTestnet,\n * transport: custom(window.ethereum)\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),\n * pinata: new PinataStorage({ apiKey: process.env.PINATA_KEY })\n * },\n * defaultProvider: 'ipfs'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * const response = await fetch('/api/relay/grant', {\n * method: 'POST',\n * body: JSON.stringify({ typedData, signature })\n * });\n * return (await response.json()).transactionHash;\n * }\n * }\n * });\n *\n * // All operations now available\n * const files = await vana.data.getUserFiles();\n * const permissions = await vana.permissions.getUserPermissions();\n * await vana.data.upload({ content: 'My data', filename: 'data.txt' });\n * ```\n *\n * @example\n * ```typescript\n * // Minimal setup without storage (read-only operations)\n * const vanaReadOnly = Vana({ walletClient });\n *\n * // These work without storage\n * const files = await vanaReadOnly.data.getUserFiles();\n * const permissions = await vanaReadOnly.permissions.getUserPermissions();\n *\n * // This would throw a runtime error\n * // await vanaReadOnly.data.upload(params); // ❌ InvalidConfigurationError\n *\n * // Safe runtime check\n * if (vanaReadOnly.isStorageEnabled()) {\n * await vanaReadOnly.data.upload(params); // ✅ TypeScript allows this\n * } else {\n * console.log('Storage not configured - upload unavailable');\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Using chain configuration instead of wallet client\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',\n * rpcUrl: 'https://rpc.moksha.vana.org',\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/getting-started | Getting Started Guide} for setup tutorials\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\nexport function Vana(\n config: VanaConfigWithStorage,\n): VanaBrowserImpl & StorageRequiredMarker;\nexport function Vana(config: VanaConfig): VanaBrowserImpl;\n/**\n * Creates a new Vana SDK instance.\n *\n * @param config - The configuration for the Vana SDK\n * @returns A new Vana SDK instance\n */\nexport function Vana(config: VanaConfig) {\n return new VanaBrowserImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in browser environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaBrowserImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress } from \"./config/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Platform adapters - browser-safe exports\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { BrowserECIESUint8Provider as BrowserECIESProvider } from \"./crypto/ecies/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Browser-only platform adapter utilities\nexport {\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-only\";\n\n// Note: createNodePlatformAdapter is not exported in browser bundle to avoid Node.js dependencies\n\n// NodePlatformAdapter is available through dynamic import to avoid bundling Node.js dependencies\n// Use createNodePlatformAdapter() for dynamic import\n\n// Platform utilities - browser-safe only\nexport {\n detectPlatform,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n\n// For testing purposes, we also export the implementation class\nexport { VanaBrowserImpl };\n"],"mappings":"AAKA,SAAS,8BAA8B;AACvC,SAAS,gBAAgB;AAWzB,MAAM,wBAAwB,SAAS;AAAA,EACrC,YAAY,QAAoB;AAC9B,UAAM,IAAI,uBAAuB,GAAG,MAAM;AAAA,EAC5C;AACF;AAwGO,SAAS,KAAK,QAAoB;AACvC,SAAO,IAAI,gBAAgB,MAAM;AACnC;AAWA,IAAO,wBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAM1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAGjC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAWd,cAAc;AAGd,SAAS,0BAA0B;AACnC,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,0BAAAC,+BAA8B;AACvC,SAAsC,iCAA4B;AAIlE;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","BrowserPlatformAdapter"]}
1
+ {"version":3,"sources":["../src/index.browser.ts"],"sourcesContent":["/**\n * @module Browser\n * Browser-specific implementation of the Vana SDK\n */\n\nimport { BrowserPlatformAdapter } from \"./platform/browser\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n} from \"./types\";\n\n/**\n * Internal implementation class for browser environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaBrowserImpl extends VanaCore {\n constructor(config: VanaConfig) {\n super(new BrowserPlatformAdapter(), config);\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for browser environments.\n *\n * @remarks\n * This is the primary entry point for browser applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The SDK supports multiple wallet configurations (direct WalletClient or chain config),\n * various storage providers (IPFS, Pinata, Google Drive), and gasless transactions via relayers.\n * All operations are optimized for browser environments with proper bundle size optimization.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for browser use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/browser';\n * import { createWalletClient, custom } from 'viem';\n * import { IPFSStorage } from '@opendatalabs/vana-sdk/browser';\n *\n * // Complete setup with storage and wallet\n * const walletClient = createWalletClient({\n * chain: mokshaTestnet,\n * transport: custom(window.ethereum)\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),\n * pinata: new PinataStorage({ apiKey: process.env.PINATA_KEY })\n * },\n * defaultProvider: 'ipfs'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * const response = await fetch('/api/relay/grant', {\n * method: 'POST',\n * body: JSON.stringify({ typedData, signature })\n * });\n * return (await response.json()).transactionHash;\n * }\n * }\n * });\n *\n * // All operations now available\n * const files = await vana.data.getUserFiles();\n * const permissions = await vana.permissions.getUserPermissions();\n * await vana.data.upload({ content: 'My data', filename: 'data.txt' });\n * ```\n *\n * @example\n * ```typescript\n * // Minimal setup without storage (read-only operations)\n * const vanaReadOnly = Vana({ walletClient });\n *\n * // These work without storage\n * const files = await vanaReadOnly.data.getUserFiles();\n * const permissions = await vanaReadOnly.permissions.getUserPermissions();\n *\n * // This would throw a runtime error\n * // await vanaReadOnly.data.upload(params); // ❌ InvalidConfigurationError\n *\n * // Safe runtime check\n * if (vanaReadOnly.isStorageEnabled()) {\n * await vanaReadOnly.data.upload(params); // ✅ TypeScript allows this\n * } else {\n * console.log('Storage not configured - upload unavailable');\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Using chain configuration instead of wallet client\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',\n * rpcUrl: 'https://rpc.moksha.vana.org',\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/getting-started | Getting Started Guide} for setup tutorials\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\nexport function Vana(\n config: VanaConfigWithStorage,\n): VanaBrowserImpl & StorageRequiredMarker;\nexport function Vana(config: VanaConfig): VanaBrowserImpl;\n/**\n * Creates a new Vana SDK instance.\n *\n * @param config - The configuration for the Vana SDK\n * @returns A new Vana SDK instance\n */\nexport function Vana(config: VanaConfig) {\n return new VanaBrowserImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in browser environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaBrowserImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress } from \"./config/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Platform adapters - browser-safe exports\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { BrowserECIESUint8Provider as BrowserECIESProvider } from \"./crypto/ecies/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Browser-only platform adapter utilities\nexport {\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-only\";\n\n// Note: createNodePlatformAdapter is not exported in browser bundle to avoid Node.js dependencies\n\n// NodePlatformAdapter is available through dynamic import to avoid bundling Node.js dependencies\n// Use createNodePlatformAdapter() for dynamic import\n\n// Platform utilities - browser-safe only\nexport {\n detectPlatform,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n\n// For testing purposes, we also export the implementation class\nexport { VanaBrowserImpl };\n"],"mappings":"AAKA,SAAS,8BAA8B;AACvC,SAAS,gBAAgB;AAWzB,MAAM,wBAAwB,SAAS;AAAA,EACrC,YAAY,QAAoB;AAC9B,UAAM,IAAI,uBAAuB,GAAG,MAAM;AAAA,EAC5C;AACF;AAwGO,SAAS,KAAK,QAAoB;AACvC,SAAO,IAAI,gBAAgB,MAAM;AACnC;AAWA,IAAO,wBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAM1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAWd,cAAc;AAGd,SAAS,0BAA0B;AACnC,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,0BAAAC,+BAA8B;AACvC,SAAsC,iCAA4B;AAIlE;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","BrowserPlatformAdapter"]}
@@ -25,16 +25,21 @@ __export(index_node_exports, {
25
25
  BrowserPlatformAdapter: () => import_browser.BrowserPlatformAdapter,
26
26
  CircuitBreaker: () => import_generics.CircuitBreaker,
27
27
  DataController: () => import_data.DataController,
28
+ DistributedNonceManager: () => import_nonceManager.DistributedNonceManager,
28
29
  EventEmitter: () => import_generics.EventEmitter,
30
+ InMemoryNonceManager: () => import_inMemoryNonceManager.InMemoryNonceManager,
29
31
  MemoryCache: () => import_generics.MemoryCache,
30
32
  MiddlewarePipeline: () => import_generics.MiddlewarePipeline,
31
33
  NodePlatformAdapter: () => import_node2.NodePlatformAdapter,
34
+ OperationsController: () => import_operations.OperationsController,
32
35
  PermissionsController: () => import_permissions.PermissionsController,
33
36
  ProtocolController: () => import_protocol.ProtocolController,
34
37
  RateLimiter: () => import_generics.RateLimiter,
38
+ RedisAtomicStore: () => import_redisAtomicStore.RedisAtomicStore,
35
39
  RetryUtility: () => import_generics.RetryUtility,
36
40
  SchemaController: () => import_schemas.SchemaController,
37
41
  ServerController: () => import_server.ServerController,
42
+ SystemHealthChecker: () => import_health.SystemHealthChecker,
38
43
  Vana: () => Vana,
39
44
  VanaCore: () => import_core2.VanaCore,
40
45
  VanaCoreFactory: () => import_core2.VanaCoreFactory,
@@ -70,6 +75,10 @@ module.exports = __toCommonJS(index_node_exports);
70
75
  var import_node = require("./platform/node");
71
76
  var import_core = require("./core");
72
77
  var import_core2 = require("./core");
78
+ var import_nonceManager = require("./core/nonceManager");
79
+ var import_inMemoryNonceManager = require("./core/inMemoryNonceManager");
80
+ var import_health = require("./core/health");
81
+ var import_redisAtomicStore = require("./lib/redisAtomicStore");
73
82
  var import_external_apis = require("./types/external-apis");
74
83
  __reExport(index_node_exports, require("./errors"), module.exports);
75
84
  var import_permissions = require("./controllers/permissions");
@@ -77,6 +86,7 @@ var import_data = require("./controllers/data");
77
86
  var import_server = require("./controllers/server");
78
87
  var import_protocol = require("./controllers/protocol");
79
88
  var import_schemas = require("./controllers/schemas");
89
+ var import_operations = require("./controllers/operations");
80
90
  __reExport(index_node_exports, require("./contracts/contractController"), module.exports);
81
91
  __reExport(index_node_exports, require("./utils/encryption"), module.exports);
82
92
  __reExport(index_node_exports, require("./utils/formatters"), module.exports);
@@ -102,9 +112,11 @@ var import_browser_safe = require("./platform/browser-safe");
102
112
  var import_apiClient = require("./core/apiClient");
103
113
  class VanaNodeImpl extends import_core.VanaCore {
104
114
  operationStore;
115
+ atomicStore;
105
116
  constructor(config) {
106
117
  super(new import_node.NodePlatformAdapter(), config);
107
118
  this.operationStore = config.operationStore;
119
+ this.atomicStore = config.atomicStore;
108
120
  }
109
121
  }
110
122
  function Vana(config) {
@@ -119,16 +131,21 @@ var index_node_default = Vana;
119
131
  BrowserPlatformAdapter,
120
132
  CircuitBreaker,
121
133
  DataController,
134
+ DistributedNonceManager,
122
135
  EventEmitter,
136
+ InMemoryNonceManager,
123
137
  MemoryCache,
124
138
  MiddlewarePipeline,
125
139
  NodePlatformAdapter,
140
+ OperationsController,
126
141
  PermissionsController,
127
142
  ProtocolController,
128
143
  RateLimiter,
144
+ RedisAtomicStore,
129
145
  RetryUtility,
130
146
  SchemaController,
131
147
  ServerController,
148
+ SystemHealthChecker,
132
149
  Vana,
133
150
  VanaCore,
134
151
  VanaCoreFactory,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n IOperationStore,\n} from \"./types\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress } from \"./config/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport { handleRelayerOperation } from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,kBAAoC;AACpC,kBAAyB;AAkMzB,IAAAA,eAA0C;AAM1C,2BAKO;AAMP,+BAAc,qBAzNd;AA4NA,yBAAsC;AACtC,kBAA+B;AAC/B,oBAAiC;AACjC,sBAAmC;AACnC,qBAAiC;AAGjC,+BAAc,2CAnOd;AAsOA,+BAAc,+BAtOd;AAuOA,+BAAc,+BAvOd;AAwOA,+BAAc,+BAxOd;AAyOA,+BAAc,oCAzOd;AA0OA,+BAAc,2BA1Od;AA2OA,+BAAc,yBA3Od;AA4OA,+BAAc,qCA5Od;AA6OA,+BAAc,mCA7Od;AAgPA,+BAAc,sBAhPd;AAmPA,uBAAmC;AACnC,oBAAuB;AACvB,8BAMO;AAGP,IAAAC,iBAOO;AACP,+BAAc,qBAtQd;AAyQA,iBAAuB;AAIvB,sBASO;AAGP,4BAAuC;AAevC,IAAAC,eAAoC;AACpC,qBAAuC;AAIvC,mBAMO;AAGP,0BAIO;AAEP,uBAA0B;AAvR1B,MAAM,qBAAqB,qBAAS;AAAA,EAChB;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,gCAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAAA,EAC/B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;","names":["import_core","import_chains","import_node"]}
1
+ {"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress } from \"./config/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,kBAAoC;AACpC,kBAAyB;AA2MzB,IAAAA,eAA0C;AAC1C,0BAAwC;AACxC,kCAAqC;AACrC,oBAAoC;AAUpC,8BAAiC;AAcjC,2BAKO;AAMP,+BAAc,qBAvPd;AA0PA,yBAAsC;AACtC,kBAA+B;AAC/B,oBAAiC;AACjC,sBAAmC;AACnC,qBAAiC;AACjC,wBAAqC;AAGrC,+BAAc,2CAlQd;AAqQA,+BAAc,+BArQd;AAsQA,+BAAc,+BAtQd;AAuQA,+BAAc,+BAvQd;AAwQA,+BAAc,oCAxQd;AAyQA,+BAAc,2BAzQd;AA0QA,+BAAc,yBA1Qd;AA2QA,+BAAc,qCA3Qd;AA4QA,+BAAc,mCA5Qd;AA+QA,+BAAc,sBA/Qd;AAkRA,uBAAmC;AACnC,oBAAuB;AACvB,8BAMO;AAGP,IAAAC,iBAOO;AACP,+BAAc,qBArSd;AAwSA,iBAAuB;AAIvB,sBASO;AAGP,4BAGO;AAeP,IAAAC,eAAoC;AACpC,qBAAuC;AAIvC,mBAMO;AAGP,0BAIO;AAEP,uBAA0B;AAlT1B,MAAM,qBAAqB,qBAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,gCAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;","names":["import_core","import_chains","import_node"]}
@@ -3,14 +3,18 @@
3
3
  * Node.js-specific implementation of the Vana SDK
4
4
  */
5
5
  import { VanaCore } from "./core";
6
- import type { VanaConfig, VanaConfigWithStorage, StorageRequiredMarker, RelayerRequiredMarker, IOperationStore } from "./types";
6
+ import type { VanaConfig, VanaConfigWithStorage, StorageRequiredMarker, RelayerRequiredMarker } from "./types";
7
+ import type { IOperationStore, IRelayerStateStore } from "./types/operationStore";
8
+ import type { IAtomicStore } from "./types/atomicStore";
9
+ import type { PublicClient } from "viem";
7
10
  /**
8
11
  * Node.js-specific configuration interface with operation store support
9
12
  *
10
13
  * @category Configuration
11
14
  */
12
15
  export type VanaNodeConfig = VanaConfig & {
13
- operationStore?: IOperationStore;
16
+ operationStore?: IOperationStore | IRelayerStateStore;
17
+ atomicStore?: IAtomicStore;
14
18
  };
15
19
  /**
16
20
  * Node.js configuration with storage requirements
@@ -18,14 +22,16 @@ export type VanaNodeConfig = VanaConfig & {
18
22
  * @category Configuration
19
23
  */
20
24
  export type VanaNodeConfigWithStorage = VanaConfigWithStorage & {
21
- operationStore?: IOperationStore;
25
+ operationStore?: IOperationStore | IRelayerStateStore;
26
+ atomicStore?: IAtomicStore;
22
27
  };
23
28
  /**
24
29
  * Internal implementation class for Node.js environments.
25
30
  * This class is not exported directly - use the Vana factory function instead.
26
31
  */
27
32
  declare class VanaNodeImpl extends VanaCore {
28
- readonly operationStore?: IOperationStore;
33
+ readonly operationStore?: IOperationStore | IRelayerStateStore;
34
+ readonly atomicStore?: IAtomicStore;
29
35
  constructor(config: VanaNodeConfig);
30
36
  }
31
37
  /**
@@ -163,7 +169,15 @@ export declare function Vana(config: VanaNodeConfig): VanaNodeImpl;
163
169
  export type VanaInstance = InstanceType<typeof VanaNodeImpl>;
164
170
  export default Vana;
165
171
  export { VanaCore, VanaCoreFactory } from "./core";
172
+ export { DistributedNonceManager } from "./core/nonceManager";
173
+ export { InMemoryNonceManager } from "./core/inMemoryNonceManager";
174
+ export { SystemHealthChecker } from "./core/health";
175
+ export type { SystemHealthCheckerConfig, HealthStatus, ComponentHealth, NonceHealth, QueueHealth, } from "./core/health";
176
+ export { RedisAtomicStore } from "./lib/redisAtomicStore";
177
+ export type { RedisAtomicStoreConfig } from "./lib/redisAtomicStore";
166
178
  export type * from "./types";
179
+ export type { IAtomicStore } from "./types/atomicStore";
180
+ export type { IOperationStore, StoredOperation, IRelayerStateStore, OperationState, } from "./types/operationStore";
167
181
  export { isReplicateAPIResponse, isAPIResponse, safeParseJSON, parseReplicateOutput, } from "./types/external-apis";
168
182
  export type { VanaContract } from "./generated/abi";
169
183
  export * from "./errors";
@@ -172,6 +186,7 @@ export { DataController } from "./controllers/data";
172
186
  export { ServerController } from "./controllers/server";
173
187
  export { ProtocolController } from "./controllers/protocol";
174
188
  export { SchemaController } from "./controllers/schemas";
189
+ export { OperationsController } from "./controllers/operations";
175
190
  export * from "./contracts/contractController";
176
191
  export * from "./utils/encryption";
177
192
  export * from "./utils/formatters";
@@ -190,7 +205,7 @@ export * from "./chains";
190
205
  export { getAbi } from "./generated/abi";
191
206
  export type { VanaContract as VanaContractAbi } from "./generated/abi";
192
207
  export { BaseController, RetryUtility, RateLimiter, MemoryCache, EventEmitter, MiddlewarePipeline, AsyncQueue, CircuitBreaker, } from "./core/generics";
193
- export { handleRelayerOperation } from "./server/relayerHandler";
208
+ export { handleRelayerOperation, type RelayerOperationOptions, } from "./server/relayerHandler";
194
209
  export type { UnifiedRelayerRequest, UnifiedRelayerResponse, } from "./types/relayer";
195
210
  export type { Operation, TransactionResult, TransactionReceipt, PollingOptions, TransactionWaitOptions, } from "./types/operations";
196
211
  export { NodePlatformAdapter } from "./platform/node";
@@ -201,3 +216,8 @@ export { createNodePlatformAdapter, createBrowserPlatformAdapter, createPlatform
201
216
  export { ApiClient } from "./core/apiClient";
202
217
  export type { ApiClientConfig, HttpMethod, RequestOptions, } from "./core/apiClient";
203
218
  export { VanaNodeImpl };
219
+ export interface VanaWithStores {
220
+ readonly operationStore?: IOperationStore | IRelayerStateStore;
221
+ readonly atomicStore?: IAtomicStore;
222
+ readonly publicClient: PublicClient;
223
+ }
@@ -2,9 +2,11 @@ import { NodePlatformAdapter } from "./platform/node";
2
2
  import { VanaCore } from "./core";
3
3
  class VanaNodeImpl extends VanaCore {
4
4
  operationStore;
5
+ atomicStore;
5
6
  constructor(config) {
6
7
  super(new NodePlatformAdapter(), config);
7
8
  this.operationStore = config.operationStore;
9
+ this.atomicStore = config.atomicStore;
8
10
  }
9
11
  }
10
12
  function Vana(config) {
@@ -12,6 +14,10 @@ function Vana(config) {
12
14
  }
13
15
  var index_node_default = Vana;
14
16
  import { VanaCore as VanaCore2, VanaCoreFactory } from "./core";
17
+ import { DistributedNonceManager } from "./core/nonceManager";
18
+ import { InMemoryNonceManager } from "./core/inMemoryNonceManager";
19
+ import { SystemHealthChecker } from "./core/health";
20
+ import { RedisAtomicStore } from "./lib/redisAtomicStore";
15
21
  import {
16
22
  isReplicateAPIResponse,
17
23
  isAPIResponse,
@@ -24,6 +30,7 @@ import { DataController } from "./controllers/data";
24
30
  import { ServerController } from "./controllers/server";
25
31
  import { ProtocolController } from "./controllers/protocol";
26
32
  import { SchemaController } from "./controllers/schemas";
33
+ import { OperationsController } from "./controllers/operations";
27
34
  export * from "./contracts/contractController";
28
35
  export * from "./utils/encryption";
29
36
  export * from "./utils/formatters";
@@ -61,7 +68,9 @@ import {
61
68
  AsyncQueue,
62
69
  CircuitBreaker
63
70
  } from "./core/generics";
64
- import { handleRelayerOperation } from "./server/relayerHandler";
71
+ import {
72
+ handleRelayerOperation
73
+ } from "./server/relayerHandler";
65
74
  import { NodePlatformAdapter as NodePlatformAdapter2 } from "./platform/node";
66
75
  import { BrowserPlatformAdapter } from "./platform/browser";
67
76
  import {
@@ -84,16 +93,21 @@ export {
84
93
  BrowserPlatformAdapter,
85
94
  CircuitBreaker,
86
95
  DataController,
96
+ DistributedNonceManager,
87
97
  EventEmitter,
98
+ InMemoryNonceManager,
88
99
  MemoryCache,
89
100
  MiddlewarePipeline,
90
101
  NodePlatformAdapter2 as NodePlatformAdapter,
102
+ OperationsController,
91
103
  PermissionsController,
92
104
  ProtocolController,
93
105
  RateLimiter,
106
+ RedisAtomicStore,
94
107
  RetryUtility,
95
108
  SchemaController,
96
109
  ServerController,
110
+ SystemHealthChecker,
97
111
  Vana,
98
112
  VanaCore2 as VanaCore,
99
113
  VanaCoreFactory,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n IOperationStore,\n} from \"./types\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress } from \"./config/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport { handleRelayerOperation } from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n"],"mappings":"AAKA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AA+BzB,MAAM,qBAAqB,SAAS;AAAA,EAChB;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,oBAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAAA,EAC/B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAM1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAGjC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,0BAA0B;AACnC,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,8BAA8B;AAevC,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,8BAA8B;AAIvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","NodePlatformAdapter"]}
1
+ {"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress } from \"./config/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":"AAKA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAsCzB,MAAM,qBAAqB,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,oBAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAC1C,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AAUpC,SAAS,wBAAwB;AAcjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,0BAA0B;AACnC,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,OAEK;AAeP,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,8BAA8B;AAIvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","NodePlatformAdapter"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var redisAtomicStore_exports = {};
20
+ __export(redisAtomicStore_exports, {
21
+ RedisAtomicStore: () => RedisAtomicStore
22
+ });
23
+ module.exports = __toCommonJS(redisAtomicStore_exports);
24
+ class RedisAtomicStore {
25
+ redis;
26
+ // ioredis instance
27
+ keyPrefix;
28
+ /**
29
+ * Lua script for safe lock release.
30
+ * This ensures we only delete a lock if the value matches our lock ID.
31
+ */
32
+ UNLOCK_SCRIPT = `
33
+ if redis.call("GET", KEYS[1]) == ARGV[1] then
34
+ return redis.call("DEL", KEYS[1])
35
+ else
36
+ return 0
37
+ end
38
+ `;
39
+ constructor(config) {
40
+ if (typeof config.redis === "string") {
41
+ throw new Error(
42
+ "RedisAtomicStore requires an initialized Redis client instance. Please create the Redis client in your application and pass it to the constructor."
43
+ );
44
+ }
45
+ this.redis = config.redis;
46
+ this.keyPrefix = config.keyPrefix ?? "vana-sdk:atomic";
47
+ if (!this.redis || typeof this.redis.incr !== "function" || typeof this.redis.set !== "function" || typeof this.redis.get !== "function" || typeof this.redis.eval !== "function") {
48
+ throw new Error(
49
+ "Invalid Redis client instance provided to RedisAtomicStore"
50
+ );
51
+ }
52
+ }
53
+ /**
54
+ * Atomically increments a counter.
55
+ */
56
+ async incr(key) {
57
+ const fullKey = `${this.keyPrefix}:${key}`;
58
+ return await this.redis.incr(fullKey);
59
+ }
60
+ /**
61
+ * Acquires a distributed lock using SET NX EX.
62
+ */
63
+ async acquireLock(key, ttlSeconds) {
64
+ const fullKey = `${this.keyPrefix}:${key}`;
65
+ const lockId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
66
+ const result = await this.redis.set(
67
+ fullKey,
68
+ lockId,
69
+ "EX",
70
+ ttlSeconds,
71
+ "NX"
72
+ );
73
+ if (result === "OK") {
74
+ console.log(`[RedisAtomicStore] Lock acquired: ${key} with ID ${lockId}`);
75
+ return lockId;
76
+ }
77
+ return null;
78
+ }
79
+ /**
80
+ * Releases a lock using a Lua script for atomicity.
81
+ */
82
+ async releaseLock(key, lockId) {
83
+ const fullKey = `${this.keyPrefix}:${key}`;
84
+ const result = await this.redis.eval(
85
+ this.UNLOCK_SCRIPT,
86
+ 1,
87
+ // Number of keys
88
+ fullKey,
89
+ // KEYS[1]
90
+ lockId
91
+ // ARGV[1]
92
+ );
93
+ if (result === 1) {
94
+ console.log(`[RedisAtomicStore] Lock released: ${key}`);
95
+ } else {
96
+ console.warn(
97
+ `[RedisAtomicStore] Lock release failed: ${key} (lock not held or expired)`
98
+ );
99
+ }
100
+ }
101
+ /**
102
+ * Gets a value from Redis.
103
+ */
104
+ async get(key) {
105
+ const fullKey = `${this.keyPrefix}:${key}`;
106
+ return await this.redis.get(fullKey);
107
+ }
108
+ /**
109
+ * Sets a value in Redis.
110
+ */
111
+ async set(key, value) {
112
+ const fullKey = `${this.keyPrefix}:${key}`;
113
+ await this.redis.set(fullKey, value);
114
+ }
115
+ /**
116
+ * Sets a value with TTL for automatic expiration.
117
+ */
118
+ async setWithTTL(key, value, ttlSeconds) {
119
+ const fullKey = `${this.keyPrefix}:${key}`;
120
+ await this.redis.setex(fullKey, ttlSeconds, value);
121
+ }
122
+ /**
123
+ * Deletes a key from Redis.
124
+ */
125
+ async delete(key) {
126
+ const fullKey = `${this.keyPrefix}:${key}`;
127
+ await this.redis.del(fullKey);
128
+ }
129
+ /**
130
+ * Executes a Lua script atomically.
131
+ *
132
+ * @remarks
133
+ * This provides generic script execution for complex atomic operations.
134
+ * Keys passed to the script will be automatically prefixed.
135
+ *
136
+ * @param script - The Lua script to execute
137
+ * @param keys - Array of keys (will be prefixed)
138
+ * @param args - Array of arguments
139
+ * @returns The script's return value
140
+ */
141
+ async eval(script, keys, args) {
142
+ const prefixedKeys = keys.map((key) => `${this.keyPrefix}:${key}`);
143
+ const result = await this.redis.eval(
144
+ script,
145
+ keys.length,
146
+ ...prefixedKeys,
147
+ ...args
148
+ );
149
+ return result;
150
+ }
151
+ /**
152
+ * Atomically assigns a nonce using Vana App's battle-tested logic.
153
+ *
154
+ * @remarks
155
+ * This is a Redis-specific optimization that uses a Lua script for
156
+ * atomic nonce assignment with gap prevention. This method is called
157
+ * by DistributedNonceManager when it detects a Redis store.
158
+ *
159
+ * Ported from apps/web/app/api/relay/route.ts (Vana App production code)
160
+ * DO NOT MODIFY without thorough testing in production environment.
161
+ *
162
+ * @param key - The key for storing the last used nonce
163
+ * @param pendingCount - The current pending transaction count from blockchain
164
+ * @returns The assigned nonce
165
+ */
166
+ async atomicAssignNonce(key, pendingCount) {
167
+ const LUA_ASSIGN_NONCE = `
168
+ -- KEYS[1] = lastUsedKey
169
+ -- ARGV[1] = pendingCount (integer)
170
+
171
+ local last = tonumber(redis.call("GET", KEYS[1]) or "-1")
172
+ local pending = tonumber(ARGV[1])
173
+ local candidate = last + 1
174
+ if pending > candidate or (candidate - pending > 500) then
175
+ -- If pending is ahead OR if candidate is too far ahead (>500 nonces), reset to pending
176
+ candidate = pending
177
+ end
178
+
179
+ -- IMPORTANT: Atomically update the last used nonce
180
+ redis.call("SET", KEYS[1], candidate)
181
+
182
+ return candidate
183
+ `;
184
+ const fullKey = `${this.keyPrefix}:${key}`;
185
+ const nonce = await this.redis.eval(
186
+ LUA_ASSIGN_NONCE,
187
+ 1,
188
+ // Number of keys
189
+ fullKey,
190
+ // KEYS[1]
191
+ pendingCount.toString()
192
+ // ARGV[1]
193
+ );
194
+ return nonce;
195
+ }
196
+ }
197
+ // Annotate the CommonJS export names for ESM import in node:
198
+ 0 && (module.exports = {
199
+ RedisAtomicStore
200
+ });
201
+ //# sourceMappingURL=redisAtomicStore.cjs.map