@opendatalabs/vana-sdk 0.1.0-alpha.fd33fc9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (351) hide show
  1. package/dist/browser.cjs.map +1 -1
  2. package/dist/browser.d.ts +33 -1
  3. package/dist/browser.js.map +1 -1
  4. package/dist/chains/index.cjs.map +1 -1
  5. package/dist/chains/index.d.ts +30 -1
  6. package/dist/chains/index.js.map +1 -1
  7. package/dist/client/__tests__/enhancedResponse.test.d.ts +1 -0
  8. package/dist/client/enhancedResponse.cjs +164 -0
  9. package/dist/client/enhancedResponse.cjs.map +1 -0
  10. package/dist/client/enhancedResponse.d.ts +120 -0
  11. package/dist/client/enhancedResponse.js +138 -0
  12. package/dist/client/enhancedResponse.js.map +1 -0
  13. package/dist/config/chains.cjs.map +1 -1
  14. package/dist/config/chains.d.ts +99 -0
  15. package/dist/config/chains.js.map +1 -1
  16. package/dist/contracts/contractController.cjs.map +1 -1
  17. package/dist/contracts/contractController.d.ts +66 -10
  18. package/dist/contracts/contractController.js.map +1 -1
  19. package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
  20. package/dist/controllers/__tests__/operations.processQueue.test.d.ts +1 -0
  21. package/dist/controllers/base.cjs +33 -0
  22. package/dist/controllers/base.cjs.map +1 -1
  23. package/dist/controllers/base.d.ts +10 -0
  24. package/dist/controllers/base.js +33 -0
  25. package/dist/controllers/base.js.map +1 -1
  26. package/dist/controllers/data.cjs +417 -276
  27. package/dist/controllers/data.cjs.map +1 -1
  28. package/dist/controllers/data.d.ts +246 -193
  29. package/dist/controllers/data.js +430 -279
  30. package/dist/controllers/data.js.map +1 -1
  31. package/dist/controllers/operations.cjs +430 -0
  32. package/dist/controllers/operations.cjs.map +1 -0
  33. package/dist/controllers/operations.d.ts +229 -0
  34. package/dist/controllers/operations.js +406 -0
  35. package/dist/controllers/operations.js.map +1 -0
  36. package/dist/controllers/permissions.cjs +690 -209
  37. package/dist/controllers/permissions.cjs.map +1 -1
  38. package/dist/controllers/permissions.d.ts +196 -68
  39. package/dist/controllers/permissions.js +690 -209
  40. package/dist/controllers/permissions.js.map +1 -1
  41. package/dist/controllers/protocol.cjs.map +1 -1
  42. package/dist/controllers/protocol.d.ts +27 -28
  43. package/dist/controllers/protocol.js.map +1 -1
  44. package/dist/controllers/schemas.cjs +104 -25
  45. package/dist/controllers/schemas.cjs.map +1 -1
  46. package/dist/controllers/schemas.d.ts +88 -40
  47. package/dist/controllers/schemas.js +104 -25
  48. package/dist/controllers/schemas.js.map +1 -1
  49. package/dist/controllers/server.cjs +269 -58
  50. package/dist/controllers/server.cjs.map +1 -1
  51. package/dist/controllers/server.d.ts +157 -52
  52. package/dist/controllers/server.js +269 -58
  53. package/dist/controllers/server.js.map +1 -1
  54. package/dist/core/__tests__/health.test.d.ts +1 -0
  55. package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
  56. package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
  57. package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
  58. package/dist/core/apiClient.cjs +53 -3
  59. package/dist/core/apiClient.cjs.map +1 -1
  60. package/dist/core/apiClient.d.ts +132 -7
  61. package/dist/core/apiClient.js +53 -3
  62. package/dist/core/apiClient.js.map +1 -1
  63. package/dist/core/generics.cjs +30 -3
  64. package/dist/core/generics.cjs.map +1 -1
  65. package/dist/core/generics.d.ts +95 -6
  66. package/dist/core/generics.js +30 -3
  67. package/dist/core/generics.js.map +1 -1
  68. package/dist/core/health.cjs +289 -0
  69. package/dist/core/health.cjs.map +1 -0
  70. package/dist/core/health.d.ts +143 -0
  71. package/dist/core/health.js +265 -0
  72. package/dist/core/health.js.map +1 -0
  73. package/dist/core/inMemoryNonceManager.cjs +138 -0
  74. package/dist/core/inMemoryNonceManager.cjs.map +1 -0
  75. package/dist/core/inMemoryNonceManager.d.ts +69 -0
  76. package/dist/core/inMemoryNonceManager.js +114 -0
  77. package/dist/core/inMemoryNonceManager.js.map +1 -0
  78. package/dist/core/nonceManager.cjs +304 -0
  79. package/dist/core/nonceManager.cjs.map +1 -0
  80. package/dist/core/nonceManager.d.ts +116 -0
  81. package/dist/core/nonceManager.js +280 -0
  82. package/dist/core/nonceManager.js.map +1 -0
  83. package/dist/core/pollingManager.cjs +292 -0
  84. package/dist/core/pollingManager.cjs.map +1 -0
  85. package/dist/core/pollingManager.d.ts +120 -0
  86. package/dist/core/pollingManager.js +268 -0
  87. package/dist/core/pollingManager.js.map +1 -0
  88. package/dist/core.cjs +55 -1
  89. package/dist/core.cjs.map +1 -1
  90. package/dist/core.d.ts +54 -3
  91. package/dist/core.js +55 -1
  92. package/dist/core.js.map +1 -1
  93. package/dist/crypto/ecies/base.cjs +16 -3
  94. package/dist/crypto/ecies/base.cjs.map +1 -1
  95. package/dist/crypto/ecies/base.js +16 -3
  96. package/dist/crypto/ecies/base.js.map +1 -1
  97. package/dist/errors.cjs +29 -0
  98. package/dist/errors.cjs.map +1 -1
  99. package/dist/errors.d.ts +64 -0
  100. package/dist/errors.js +28 -0
  101. package/dist/errors.js.map +1 -1
  102. package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -1
  103. package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -1
  104. package/dist/generated/abi/DLPPerformanceImplementation.cjs +42 -0
  105. package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -1
  106. package/dist/generated/abi/DLPPerformanceImplementation.d.ts +32 -0
  107. package/dist/generated/abi/DLPPerformanceImplementation.js +42 -0
  108. package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -1
  109. package/dist/generated/abi/DLPRegistryImplementation.cjs +5 -5
  110. package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -1
  111. package/dist/generated/abi/DLPRegistryImplementation.d.ts +4 -4
  112. package/dist/generated/abi/DLPRegistryImplementation.js +5 -5
  113. package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -1
  114. package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +166 -2
  115. package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -1
  116. package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +129 -2
  117. package/dist/generated/abi/DLPRewardDeployerImplementation.js +166 -2
  118. package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -1
  119. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +167 -19
  120. package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -1
  121. package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +127 -14
  122. package/dist/generated/abi/DataPortabilityGranteesImplementation.js +167 -19
  123. package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -1
  124. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +0 -19
  125. package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -1
  126. package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +0 -14
  127. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +0 -19
  128. package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -1
  129. package/dist/generated/abi/DataPortabilityServersImplementation.cjs +0 -19
  130. package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -1
  131. package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +0 -14
  132. package/dist/generated/abi/DataPortabilityServersImplementation.js +0 -19
  133. package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -1
  134. package/dist/generated/abi/DataRegistryImplementation.cjs +0 -13
  135. package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
  136. package/dist/generated/abi/DataRegistryImplementation.d.ts +0 -10
  137. package/dist/generated/abi/DataRegistryImplementation.js +0 -13
  138. package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
  139. package/dist/generated/abi/SwapHelperImplementation.cjs +0 -43
  140. package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -1
  141. package/dist/generated/abi/SwapHelperImplementation.d.ts +0 -35
  142. package/dist/generated/abi/SwapHelperImplementation.js +0 -43
  143. package/dist/generated/abi/SwapHelperImplementation.js.map +1 -1
  144. package/dist/generated/abi/VanaEpochImplementation.cjs +195 -0
  145. package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -1
  146. package/dist/generated/abi/VanaEpochImplementation.d.ts +151 -0
  147. package/dist/generated/abi/VanaEpochImplementation.js +195 -0
  148. package/dist/generated/abi/VanaEpochImplementation.js.map +1 -1
  149. package/dist/generated/abi/VanaPoolEntityImplementation.cjs +22 -65
  150. package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -1
  151. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +17 -51
  152. package/dist/generated/abi/VanaPoolEntityImplementation.js +22 -65
  153. package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -1
  154. package/dist/generated/abi/VanaPoolStakingImplementation.cjs +113 -1
  155. package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -1
  156. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +85 -1
  157. package/dist/generated/abi/VanaPoolStakingImplementation.js +113 -1
  158. package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -1
  159. package/dist/generated/abi/index.d.ts +546 -146
  160. package/dist/generated/event-types.cjs.map +1 -1
  161. package/dist/generated/event-types.d.ts +14 -8
  162. package/dist/generated/eventRegistry.cjs +42 -18
  163. package/dist/generated/eventRegistry.cjs.map +1 -1
  164. package/dist/generated/eventRegistry.js +42 -18
  165. package/dist/generated/eventRegistry.js.map +1 -1
  166. package/dist/generated/server/server-exports.cjs +22 -0
  167. package/dist/generated/server/server-exports.cjs.map +1 -1
  168. package/dist/generated/server/server-exports.d.ts +27 -10
  169. package/dist/generated/server/server-exports.js +17 -0
  170. package/dist/generated/server/server-exports.js.map +1 -1
  171. package/dist/generated/server/server.cjs.map +1 -1
  172. package/dist/generated/server/server.d.ts +771 -402
  173. package/dist/generated/subgraph.cjs +797 -32
  174. package/dist/generated/subgraph.cjs.map +1 -1
  175. package/dist/generated/subgraph.d.ts +135 -0
  176. package/dist/generated/subgraph.js +792 -32
  177. package/dist/generated/subgraph.js.map +1 -1
  178. package/dist/index.browser.d.ts +2 -0
  179. package/dist/index.browser.js +10 -0
  180. package/dist/index.browser.js.map +1 -1
  181. package/dist/index.cjs.map +1 -1
  182. package/dist/index.js.map +1 -1
  183. package/dist/index.node.cjs +26 -0
  184. package/dist/index.node.cjs.map +1 -1
  185. package/dist/index.node.d.ts +49 -5
  186. package/dist/index.node.js +25 -1
  187. package/dist/index.node.js.map +1 -1
  188. package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
  189. package/dist/lib/redisAtomicStore.cjs +201 -0
  190. package/dist/lib/redisAtomicStore.cjs.map +1 -0
  191. package/dist/lib/redisAtomicStore.d.ts +120 -0
  192. package/dist/lib/redisAtomicStore.js +177 -0
  193. package/dist/lib/redisAtomicStore.js.map +1 -0
  194. package/dist/node.cjs.map +1 -1
  195. package/dist/node.d.ts +39 -1
  196. package/dist/node.js.map +1 -1
  197. package/dist/platform/browser.cjs +160 -2
  198. package/dist/platform/browser.cjs.map +1 -1
  199. package/dist/platform/browser.d.ts +232 -12
  200. package/dist/platform/browser.js +160 -2
  201. package/dist/platform/browser.js.map +1 -1
  202. package/dist/platform/interface.cjs.map +1 -1
  203. package/dist/platform/interface.d.ts +283 -90
  204. package/dist/platform/node.cjs +163 -2
  205. package/dist/platform/node.cjs.map +1 -1
  206. package/dist/platform/node.d.ts +69 -6
  207. package/dist/platform/node.js +163 -2
  208. package/dist/platform/node.js.map +1 -1
  209. package/dist/server/relayerHandler.cjs +315 -81
  210. package/dist/server/relayerHandler.cjs.map +1 -1
  211. package/dist/server/relayerHandler.d.ts +35 -2
  212. package/dist/server/relayerHandler.js +315 -81
  213. package/dist/server/relayerHandler.js.map +1 -1
  214. package/dist/storage/index.cjs +3 -0
  215. package/dist/storage/index.cjs.map +1 -1
  216. package/dist/storage/index.d.ts +1 -0
  217. package/dist/storage/index.js +2 -0
  218. package/dist/storage/index.js.map +1 -1
  219. package/dist/storage/manager.cjs +108 -25
  220. package/dist/storage/manager.cjs.map +1 -1
  221. package/dist/storage/manager.d.ts +119 -25
  222. package/dist/storage/manager.js +108 -25
  223. package/dist/storage/manager.js.map +1 -1
  224. package/dist/storage/providers/callback-storage.cjs +86 -15
  225. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  226. package/dist/storage/providers/callback-storage.d.ts +109 -20
  227. package/dist/storage/providers/callback-storage.js +86 -15
  228. package/dist/storage/providers/callback-storage.js.map +1 -1
  229. package/dist/storage/providers/dropbox.cjs +237 -0
  230. package/dist/storage/providers/dropbox.cjs.map +1 -0
  231. package/dist/storage/providers/dropbox.d.ts +39 -0
  232. package/dist/storage/providers/dropbox.js +215 -0
  233. package/dist/storage/providers/dropbox.js.map +1 -0
  234. package/dist/storage/providers/dropbox.test.d.ts +1 -0
  235. package/dist/storage/providers/pinata.cjs.map +1 -1
  236. package/dist/storage/providers/pinata.d.ts +12 -14
  237. package/dist/storage/providers/pinata.js.map +1 -1
  238. package/dist/tests/data-upload-owner-validation.test.d.ts +1 -0
  239. package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
  240. package/dist/types/atomicStore.cjs +31 -0
  241. package/dist/types/atomicStore.cjs.map +1 -0
  242. package/dist/types/atomicStore.d.ts +236 -0
  243. package/dist/types/atomicStore.js +7 -0
  244. package/dist/types/atomicStore.js.map +1 -0
  245. package/dist/types/blockchain.cjs.map +1 -1
  246. package/dist/types/blockchain.d.ts +39 -11
  247. package/dist/types/chains.cjs.map +1 -1
  248. package/dist/types/chains.d.ts +74 -7
  249. package/dist/types/chains.js.map +1 -1
  250. package/dist/types/config.cjs.map +1 -1
  251. package/dist/types/config.d.ts +38 -4
  252. package/dist/types/config.js.map +1 -1
  253. package/dist/types/contracts.cjs.map +1 -1
  254. package/dist/types/contracts.d.ts +71 -7
  255. package/dist/types/controller-context.cjs.map +1 -1
  256. package/dist/types/controller-context.d.ts +4 -1
  257. package/dist/types/data.cjs.map +1 -1
  258. package/dist/types/data.d.ts +11 -10
  259. package/dist/types/generics.cjs.map +1 -1
  260. package/dist/types/generics.d.ts +81 -10
  261. package/dist/types/index.cjs.map +1 -1
  262. package/dist/types/index.d.ts +31 -3
  263. package/dist/types/index.js.map +1 -1
  264. package/dist/types/operationStore.cjs +17 -0
  265. package/dist/types/operationStore.cjs.map +1 -0
  266. package/dist/types/operationStore.d.ts +171 -0
  267. package/dist/types/operationStore.js +1 -0
  268. package/dist/types/operationStore.js.map +1 -0
  269. package/dist/types/operations.cjs +3 -15
  270. package/dist/types/operations.cjs.map +1 -1
  271. package/dist/types/operations.d.ts +131 -39
  272. package/dist/types/operations.js +2 -13
  273. package/dist/types/operations.js.map +1 -1
  274. package/dist/types/options.cjs +17 -0
  275. package/dist/types/options.cjs.map +1 -0
  276. package/dist/types/options.d.ts +308 -0
  277. package/dist/types/options.js +1 -0
  278. package/dist/types/options.js.map +1 -0
  279. package/dist/types/permissions.cjs.map +1 -1
  280. package/dist/types/permissions.d.ts +19 -20
  281. package/dist/types/personal.cjs.map +1 -1
  282. package/dist/types/personal.d.ts +150 -14
  283. package/dist/types/relayer.cjs.map +1 -1
  284. package/dist/types/relayer.d.ts +145 -24
  285. package/dist/types/storage.cjs.map +1 -1
  286. package/dist/types/storage.d.ts +9 -21
  287. package/dist/types/storage.js.map +1 -1
  288. package/dist/types/utils.cjs.map +1 -1
  289. package/dist/types/utils.d.ts +0 -45
  290. package/dist/utils/__tests__/chainQuery.test.d.ts +1 -0
  291. package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
  292. package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
  293. package/dist/utils/chainQuery.cjs +107 -0
  294. package/dist/utils/chainQuery.cjs.map +1 -0
  295. package/dist/utils/chainQuery.d.ts +31 -0
  296. package/dist/utils/chainQuery.js +82 -0
  297. package/dist/utils/chainQuery.js.map +1 -0
  298. package/dist/utils/grantFiles.cjs +4 -1
  299. package/dist/utils/grantFiles.cjs.map +1 -1
  300. package/dist/utils/grantFiles.d.ts +10 -20
  301. package/dist/utils/grantFiles.js +4 -1
  302. package/dist/utils/grantFiles.js.map +1 -1
  303. package/dist/utils/grantValidation.cjs.map +1 -1
  304. package/dist/utils/grantValidation.d.ts +95 -16
  305. package/dist/utils/grantValidation.js.map +1 -1
  306. package/dist/utils/grants.cjs.map +1 -1
  307. package/dist/utils/grants.d.ts +93 -12
  308. package/dist/utils/grants.js.map +1 -1
  309. package/dist/utils/ipfs.cjs +2 -4
  310. package/dist/utils/ipfs.cjs.map +1 -1
  311. package/dist/utils/ipfs.d.ts +1 -1
  312. package/dist/utils/ipfs.js +2 -4
  313. package/dist/utils/ipfs.js.map +1 -1
  314. package/dist/utils/lazy-import.cjs.map +1 -1
  315. package/dist/utils/lazy-import.d.ts +32 -7
  316. package/dist/utils/lazy-import.js.map +1 -1
  317. package/dist/utils/signatureCache.cjs +8 -2
  318. package/dist/utils/signatureCache.cjs.map +1 -1
  319. package/dist/utils/signatureCache.d.ts +49 -8
  320. package/dist/utils/signatureCache.js +8 -2
  321. package/dist/utils/signatureCache.js.map +1 -1
  322. package/dist/utils/subgraphConsistency.cjs +184 -0
  323. package/dist/utils/subgraphConsistency.cjs.map +1 -0
  324. package/dist/utils/subgraphConsistency.d.ts +65 -0
  325. package/dist/utils/subgraphConsistency.js +155 -0
  326. package/dist/utils/subgraphConsistency.js.map +1 -0
  327. package/dist/utils/subgraphMetaCache.cjs +101 -0
  328. package/dist/utils/subgraphMetaCache.cjs.map +1 -0
  329. package/dist/utils/subgraphMetaCache.d.ts +56 -0
  330. package/dist/utils/subgraphMetaCache.js +76 -0
  331. package/dist/utils/subgraphMetaCache.js.map +1 -0
  332. package/dist/utils/subgraphPagination.cjs +104 -0
  333. package/dist/utils/subgraphPagination.cjs.map +1 -0
  334. package/dist/utils/subgraphPagination.d.ts +78 -0
  335. package/dist/utils/subgraphPagination.js +78 -0
  336. package/dist/utils/subgraphPagination.js.map +1 -0
  337. package/dist/utils/transactionHelpers.cjs.map +1 -1
  338. package/dist/utils/transactionHelpers.d.ts +12 -12
  339. package/dist/utils/transactionHelpers.js.map +1 -1
  340. package/dist/utils/typedDataConverter.cjs.map +1 -1
  341. package/dist/utils/typedDataConverter.d.ts +39 -3
  342. package/dist/utils/typedDataConverter.js.map +1 -1
  343. package/dist/utils/urlResolver.cjs +7 -0
  344. package/dist/utils/urlResolver.cjs.map +1 -1
  345. package/dist/utils/urlResolver.d.ts +22 -4
  346. package/dist/utils/urlResolver.js +7 -0
  347. package/dist/utils/urlResolver.js.map +1 -1
  348. package/dist/utils/wallet.cjs.map +1 -1
  349. package/dist/utils/wallet.d.ts +78 -16
  350. package/dist/utils/wallet.js.map +1 -1
  351. package/package.json +3 -1
@@ -1,126 +1,246 @@
1
1
  /**
2
- * Platform Adapter interface for environment-specific implementations
2
+ * Defines platform abstraction interfaces for environment-specific implementations.
3
3
  *
4
- * This interface abstracts all environment-specific dependencies to ensure
5
- * the SDK works seamlessly across Node.js and browser/SSR environments.
4
+ * @remarks
5
+ * This module provides the contract for platform-specific operations, allowing
6
+ * the SDK to work seamlessly across Node.js and browser environments. Platform
7
+ * adapters handle all environment-specific dependencies including cryptography,
8
+ * HTTP requests, caching, and PGP operations.
9
+ *
10
+ * The SDK automatically selects the appropriate adapter based on the runtime
11
+ * environment. Custom implementations can be provided for specialized use cases.
6
12
  *
7
13
  * **Implementation Context:**
8
- * - Node.js: Uses native crypto modules and full OpenPGP support
9
- * - Browser: Uses Web Crypto API and browser-compatible libraries
10
- * - SSR: Automatically selects appropriate implementation based on runtime
14
+ * - Node.js: Uses native crypto modules, in-memory cache, and full OpenPGP support
15
+ * - Browser: Uses Web Crypto API, sessionStorage cache, and browser-compatible libraries
16
+ * - SSR: Automatically selects appropriate implementation based on runtime detection
11
17
  *
12
- * **Usage Notes:**
13
- * Platform adapters are automatically selected by the SDK. Direct usage is only
14
- * needed for custom implementations or testing.
18
+ * @example
19
+ * ```typescript
20
+ * // Custom platform adapter implementation
21
+ * class CustomPlatformAdapter implements VanaPlatformAdapter {
22
+ * crypto = new CustomCryptoAdapter();
23
+ * pgp = new CustomPGPAdapter();
24
+ * http = new CustomHttpAdapter();
25
+ * cache = new CustomCacheAdapter();
26
+ * platform = 'browser' as const;
27
+ * }
28
+ *
29
+ * // Use with SDK
30
+ * const client = createClient({
31
+ * platformAdapter: new CustomPlatformAdapter()
32
+ * });
33
+ * ```
34
+ *
35
+ * @category Platform
36
+ * @module platform/interface
15
37
  */
16
38
  /**
17
- * Platform type identifier
39
+ * Identifies the runtime platform for adapter selection.
40
+ *
41
+ * @remarks
42
+ * Used for debugging, telemetry, and conditional logic based on
43
+ * the execution environment.
44
+ *
45
+ * @category Platform
18
46
  */
19
47
  export type PlatformType = "node" | "browser";
20
48
  /**
21
- * Encryption operations that require different implementations per platform
49
+ * Provides platform-specific cryptographic operations.
50
+ *
51
+ * @remarks
52
+ * Implements ECIES encryption/decryption, key generation, and password-based
53
+ * encryption using platform-appropriate libraries. Node.js uses Buffer-based
54
+ * libraries while browser uses Uint8Array and Web Crypto where possible.
55
+ *
56
+ * @category Platform
22
57
  */
23
58
  export interface VanaCryptoAdapter {
24
59
  /**
25
- * Encrypt data with a public key using asymmetric cryptography
60
+ * Encrypts data with a public key using ECIES.
61
+ *
62
+ * @remarks
63
+ * Uses Elliptic Curve Integrated Encryption Scheme (ECIES) for
64
+ * asymmetric encryption. The implementation varies by platform but
65
+ * maintains compatible output format.
26
66
  *
27
- * **Usage Context:**
28
- * - Used internally for file encryption before storage
29
- * - Public key format: Armored PGP public key string
30
- * - Returns base64-encoded encrypted data
67
+ * @param data - The plaintext data to encrypt.
68
+ * Typically user data or encryption keys.
69
+ * @param publicKey - The recipient's public key in hex format.
70
+ * Can be compressed or uncompressed secp256k1 key.
71
+ * @returns Hex-encoded encrypted data containing IV, ephemeral key, ciphertext, and MAC
31
72
  *
32
- * @param data The data to encrypt
33
- * @param publicKey The public key for encryption
34
- * @returns Promise resolving to encrypted data
73
+ * @example
74
+ * ```typescript
75
+ * const encrypted = await adapter.crypto.encryptWithPublicKey(
76
+ * 'sensitive data',
77
+ * '04abcd...' // 65-byte uncompressed public key
78
+ * );
79
+ * ```
35
80
  */
36
81
  encryptWithPublicKey(data: string, publicKey: string): Promise<string>;
37
82
  /**
38
- * Decrypt data with a private key using asymmetric cryptography
83
+ * Decrypts ECIES-encrypted data with a private key.
39
84
  *
40
- * @param encryptedData The encrypted data
41
- * @param privateKey The private key for decryption
42
- * @returns Promise resolving to decrypted data
85
+ * @param encryptedData - Hex-encoded encrypted data.
86
+ * Must contain IV, ephemeral key, ciphertext, and MAC.
87
+ * @param privateKey - The private key in hex format.
88
+ * Must correspond to the public key used for encryption.
89
+ * @returns The decrypted plaintext string
90
+ *
91
+ * @throws {Error} If decryption or MAC verification fails
43
92
  */
44
93
  decryptWithPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
45
94
  /**
46
- * Generate a new key pair for asymmetric cryptography
95
+ * Generates a new secp256k1 key pair.
96
+ *
97
+ * @returns Object with hex-encoded keys
98
+ * @returns returns.publicKey - Compressed public key in hex
99
+ * @returns returns.privateKey - Private key in hex
47
100
  *
48
- * @returns Promise resolving to public and private key pair
101
+ * @example
102
+ * ```typescript
103
+ * const { publicKey, privateKey } = await adapter.crypto.generateKeyPair();
104
+ * console.log('Public key:', publicKey); // 33 bytes compressed
105
+ * ```
49
106
  */
50
107
  generateKeyPair(): Promise<{
51
108
  publicKey: string;
52
109
  privateKey: string;
53
110
  }>;
54
111
  /**
55
- * Encrypt data with a wallet's public key using ECDH cryptography
56
- * Uses platform-appropriate ECDH implementation (eccrypto vs eccrypto-js)
112
+ * Encrypts data with an Ethereum wallet's public key.
113
+ *
114
+ * @remarks
115
+ * Specifically designed for wallet-based encryption where the public
116
+ * key comes from an Ethereum wallet. Handles key format conversion
117
+ * and uses ECIES for encryption.
57
118
  *
58
- * **Usage Context:**
59
- * - Used for sharing encryption keys with permission recipients
60
- * - Public key format: Compressed or uncompressed secp256k1 hex string
61
- * - Compatible with Ethereum wallet public keys
119
+ * @param data - The plaintext data to encrypt.
120
+ * Typically permission grants or metadata.
121
+ * @param publicKey - The wallet's public key.
122
+ * Accepts compressed/uncompressed, with/without 0x prefix.
123
+ * @returns Hex-encoded encrypted data
62
124
  *
63
- * @param data The data to encrypt (string)
64
- * @param publicKey The wallet's public key (secp256k1)
65
- * @returns Promise resolving to encrypted data as hex string
125
+ * @example
126
+ * ```typescript
127
+ * const encrypted = await adapter.crypto.encryptWithWalletPublicKey(
128
+ * JSON.stringify({ permission: 'read' }),
129
+ * walletPublicKey
130
+ * );
131
+ * ```
66
132
  */
67
133
  encryptWithWalletPublicKey(data: string, publicKey: string): Promise<string>;
68
134
  /**
69
- * Decrypt data with a wallet's private key using ECDH cryptography
70
- * Uses platform-appropriate ECDH implementation (eccrypto vs eccrypto-js)
135
+ * Decrypts data with an Ethereum wallet's private key.
71
136
  *
72
- * @param encryptedData The encrypted data as hex string
73
- * @param privateKey The wallet's private key (secp256k1)
74
- * @returns Promise resolving to decrypted data as string
137
+ * @param encryptedData - Hex-encoded encrypted data.
138
+ * Must be encrypted with corresponding wallet public key.
139
+ * @param privateKey - The wallet's private key.
140
+ * Handle with extreme care - never log or store.
141
+ * @returns The decrypted plaintext string
142
+ *
143
+ * @throws {Error} If decryption fails or key is invalid
75
144
  */
76
145
  decryptWithWalletPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
77
146
  /**
78
- * Encrypt data with a password using PGP password-based encryption
79
- * Uses platform-appropriate OpenPGP implementation with consistent format
147
+ * Encrypts binary data with password-based encryption.
148
+ *
149
+ * @remarks
150
+ * Uses OpenPGP password-based encryption with automatic salt
151
+ * generation. Often used with wallet signatures as passwords for
152
+ * deterministic key derivation.
153
+ *
154
+ * @param data - Binary data to encrypt.
155
+ * Typically file contents or serialized data.
156
+ * @param password - Password for encryption.
157
+ * Often derived from wallet signatures.
158
+ * @returns Encrypted data as Uint8Array
80
159
  *
81
- * @param data The data to encrypt as Uint8Array
82
- * @param password The password for encryption (typically wallet signature)
83
- * @returns Promise resolving to encrypted data as Uint8Array
160
+ * @example
161
+ * ```typescript
162
+ * const fileData = new Uint8Array([1, 2, 3, 4]);
163
+ * const encrypted = await adapter.crypto.encryptWithPassword(
164
+ * fileData,
165
+ * walletSignature
166
+ * );
167
+ * ```
84
168
  */
85
169
  encryptWithPassword(data: Uint8Array, password: string): Promise<Uint8Array>;
86
170
  /**
87
- * Decrypt data with a password using PGP password-based decryption
88
- * Uses platform-appropriate OpenPGP implementation with consistent format
171
+ * Decrypts password-encrypted binary data.
89
172
  *
90
- * @param encryptedData The encrypted data as Uint8Array
91
- * @param password The password for decryption (typically wallet signature)
92
- * @returns Promise resolving to decrypted data as Uint8Array
173
+ * @param encryptedData - Password-encrypted data.
174
+ * Must be encrypted with the same password.
175
+ * @param password - Password for decryption.
176
+ * Must match the encryption password exactly.
177
+ * @returns Decrypted data as Uint8Array
178
+ *
179
+ * @throws {Error} If decryption fails or password is incorrect
93
180
  */
94
181
  decryptWithPassword(encryptedData: Uint8Array, password: string): Promise<Uint8Array>;
95
182
  }
96
183
  /**
97
- * PGP operations that require different configurations per platform
184
+ * Provides platform-specific PGP operations.
185
+ *
186
+ * @remarks
187
+ * Implements PGP encryption, decryption, and key generation using
188
+ * OpenPGP.js with platform-appropriate configuration. Node.js uses
189
+ * optimizations like zlib compression.
190
+ *
191
+ * @category Platform
98
192
  */
99
193
  export interface VanaPGPAdapter {
100
194
  /**
101
- * Encrypt data using PGP with proper platform configuration
195
+ * Encrypts data using PGP public key encryption.
102
196
  *
103
- * @param data The data to encrypt
104
- * @param publicKey The PGP public key
105
- * @returns Promise resolving to encrypted data
197
+ * @param data - The plaintext data to encrypt.
198
+ * Typically messages or structured data.
199
+ * @param publicKey - ASCII-armored PGP public key.
200
+ * Obtain from generateKeyPair or key servers.
201
+ * @returns ASCII-armored encrypted message
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * const encrypted = await adapter.pgp.encrypt(
206
+ * 'secret message',
207
+ * armoredPublicKey
208
+ * );
209
+ * ```
106
210
  */
107
211
  encrypt(data: string, publicKey: string): Promise<string>;
108
212
  /**
109
- * Decrypt data using PGP with proper platform configuration
213
+ * Decrypts PGP-encrypted data.
214
+ *
215
+ * @param encryptedData - ASCII-armored encrypted message.
216
+ * Must be encrypted with corresponding public key.
217
+ * @param privateKey - ASCII-armored PGP private key.
218
+ * May be passphrase-protected.
219
+ * @returns The decrypted plaintext string
110
220
  *
111
- * @param encryptedData The encrypted data
112
- * @param privateKey The PGP private key
113
- * @returns Promise resolving to decrypted data
221
+ * @throws {Error} If decryption fails or key is invalid
114
222
  */
115
223
  decrypt(encryptedData: string, privateKey: string): Promise<string>;
116
224
  /**
117
- * Generate a new PGP key pair with platform-appropriate configuration
225
+ * Generates a new PGP key pair.
226
+ *
227
+ * @param options - Key generation configuration
228
+ * @param options.name - Identity name.
229
+ * Defaults to 'Vana User'.
230
+ * @param options.email - Identity email.
231
+ * Defaults to 'user@vana.com'.
232
+ * @param options.passphrase - Private key passphrase.
233
+ * If omitted, private key is unprotected.
234
+ * @returns ASCII-armored public and private keys
118
235
  *
119
- * @param options - Key generation options
120
- * @param options.name - The name for the PGP key
121
- * @param options.email - The email for the PGP key
122
- * @param options.passphrase - Optional passphrase to protect the private key
123
- * @returns Promise resolving to public and private key pair
236
+ * @example
237
+ * ```typescript
238
+ * const { publicKey, privateKey } = await adapter.pgp.generateKeyPair({
239
+ * name: 'Alice Smith',
240
+ * email: 'alice@example.com',
241
+ * passphrase: 'secure-passphrase'
242
+ * });
243
+ * ```
124
244
  */
125
245
  generateKeyPair(options?: {
126
246
  name?: string;
@@ -132,49 +252,97 @@ export interface VanaPGPAdapter {
132
252
  }>;
133
253
  }
134
254
  /**
135
- * HTTP operations that need consistent API across platforms
255
+ * Provides platform-specific HTTP operations.
256
+ *
257
+ * @remarks
258
+ * Wraps the fetch API to ensure consistent behavior across
259
+ * Node.js and browser environments.
260
+ *
261
+ * @category Platform
136
262
  */
137
263
  export interface VanaHttpAdapter {
138
264
  /**
139
- * Perform HTTP request with platform-appropriate fetch implementation
265
+ * Performs an HTTP request.
266
+ *
267
+ * @param url - The URL to request.
268
+ * Must be a valid HTTP/HTTPS URL.
269
+ * @param options - Standard fetch RequestInit options.
270
+ * See MDN documentation for details.
271
+ * @returns Standard fetch Response object
140
272
  *
141
- * @param url The URL to request
142
- * @param options Request options
143
- * @returns Promise resolving to response
273
+ * @example
274
+ * ```typescript
275
+ * const response = await adapter.http.fetch(
276
+ * 'https://api.vana.com/data',
277
+ * { method: 'GET', headers: { 'Authorization': 'Bearer token' } }
278
+ * );
279
+ * ```
144
280
  */
145
281
  fetch(url: string, options?: RequestInit): Promise<Response>;
146
282
  }
147
283
  /**
148
- * Simple cache operations that work across platforms
284
+ * Provides platform-specific caching operations.
285
+ *
286
+ * @remarks
287
+ * Implements simple key-value caching with platform-appropriate storage.
288
+ * Node.js uses in-memory Map with TTL, browser uses sessionStorage for
289
+ * security (cleared on tab close).
290
+ *
291
+ * @category Platform
149
292
  */
150
293
  export interface VanaCacheAdapter {
151
294
  /**
152
- * Get a value from the cache
295
+ * Retrieves a cached value.
153
296
  *
154
- * @param key The cache key
297
+ * @param key - The cache key.
298
+ * Should be unique per operation.
155
299
  * @returns The cached value or null if not found/expired
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * const cachedSignature = adapter.cache.get('sig_0x123...');
304
+ * if (cachedSignature) {
305
+ * return cachedSignature;
306
+ * }
307
+ * ```
156
308
  */
157
309
  get(key: string): string | null;
158
310
  /**
159
- * Set a value in the cache
311
+ * Stores a value in the cache.
160
312
  *
161
- * @param key The cache key
162
- * @param value The value to cache
313
+ * @param key - The cache key.
314
+ * Should be unique and descriptive.
315
+ * @param value - The value to cache.
316
+ * Typically signatures or computed results.
317
+ *
318
+ * @remarks
319
+ * Node.js: Cached for 2 hours with TTL
320
+ * Browser: Cached until tab closes (sessionStorage)
163
321
  */
164
322
  set(key: string, value: string): void;
165
323
  /**
166
- * Delete a value from the cache
324
+ * Removes a cached value.
167
325
  *
168
- * @param key The cache key
326
+ * @param key - The cache key to remove.
327
+ * Use when cached data becomes invalid.
169
328
  */
170
329
  delete(key: string): void;
171
330
  /**
172
- * Clear all values from the cache
331
+ * Clears all cached values.
332
+ *
333
+ * @remarks
334
+ * Use with caution as this removes all performance optimizations.
335
+ * Browser implementation only clears Vana-prefixed keys.
173
336
  */
174
337
  clear(): void;
175
338
  }
176
339
  /**
177
- * Main platform adapter interface that combines all platform-specific functionality
340
+ * Aggregates all platform-specific adapters into a single interface.
341
+ *
342
+ * @remarks
343
+ * This is the main interface for platform abstraction. Implementations
344
+ * must provide all required adapters while maintaining consistent behavior
345
+ * and data formats across platforms.
178
346
  *
179
347
  * **Implementation Guidelines:**
180
348
  * 1. All methods must maintain consistent behavior across platforms
@@ -182,35 +350,60 @@ export interface VanaCacheAdapter {
182
350
  * 3. Data formats (encoding, serialization) must be identical
183
351
  * 4. Performance characteristics can vary but API must be consistent
184
352
  *
185
- * **Custom Implementation Example:**
353
+ * @example
186
354
  * ```typescript
187
- * class CustomPlatformAdapter implements VanaPlatformAdapter {
188
- * crypto = new CustomCryptoAdapter();
189
- * pgp = new CustomPGPAdapter();
190
- * http = new CustomHttpAdapter();
191
- * platform = 'browser' as const;
355
+ * // Custom implementation for specialized environment
356
+ * class EdgePlatformAdapter implements VanaPlatformAdapter {
357
+ * crypto = new EdgeCryptoAdapter();
358
+ * pgp = new EdgePGPAdapter();
359
+ * http = new EdgeHttpAdapter();
360
+ * cache = new EdgeCacheAdapter();
361
+ * platform = 'browser' as const; // Edge is browser-like
192
362
  * }
363
+ *
364
+ * // Use with SDK
365
+ * const client = createClient({
366
+ * platformAdapter: new EdgePlatformAdapter()
367
+ * });
193
368
  * ```
369
+ *
370
+ * @category Platform
194
371
  */
195
372
  export interface VanaPlatformAdapter {
196
373
  /**
197
- * Crypto operations adapter
374
+ * Provides cryptographic operations.
375
+ *
376
+ * @remarks
377
+ * Handles ECIES, wallet encryption, and password-based encryption.
198
378
  */
199
379
  crypto: VanaCryptoAdapter;
200
380
  /**
201
- * PGP operations adapter
381
+ * Provides PGP operations.
382
+ *
383
+ * @remarks
384
+ * Handles PGP encryption, decryption, and key generation.
202
385
  */
203
386
  pgp: VanaPGPAdapter;
204
387
  /**
205
- * HTTP operations adapter
388
+ * Provides HTTP operations.
389
+ *
390
+ * @remarks
391
+ * Wraps fetch API for consistent cross-platform behavior.
206
392
  */
207
393
  http: VanaHttpAdapter;
208
394
  /**
209
- * Cache operations adapter
395
+ * Provides caching operations.
396
+ *
397
+ * @remarks
398
+ * Platform-appropriate storage for temporary data.
210
399
  */
211
400
  cache: VanaCacheAdapter;
212
401
  /**
213
- * Platform identifier for debugging/telemetry
402
+ * Identifies the platform type.
403
+ *
404
+ * @remarks
405
+ * Used for debugging, telemetry, and conditional logic.
406
+ * Must be 'node' or 'browser'.
214
407
  */
215
408
  readonly platform: PlatformType;
216
409
  }