@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,34 +1,184 @@
1
1
  /**
2
- * Browser implementation of the Vana Platform Adapter using Uint8Array
2
+ * Provides browser-specific implementations of platform abstraction interfaces.
3
3
  *
4
- * This implementation uses browser-compatible libraries and native APIs
5
- * without requiring Buffer or other Node.js polyfills.
4
+ * @remarks
5
+ * This module implements all platform-specific operations for browser environments,
6
+ * using native Web APIs and browser-compatible libraries. It avoids Node.js-specific
7
+ * dependencies like Buffer, using Uint8Array and viem utilities instead. Supports
8
+ * both standard eccrypto and custom ECIES implementations based on feature flags.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Use the browser platform adapter
13
+ * import { BrowserPlatformAdapter } from '@vana-sdk/platform/browser';
14
+ *
15
+ * const adapter = new BrowserPlatformAdapter();
16
+ *
17
+ * // Encrypt data with public key
18
+ * const encrypted = await adapter.crypto.encryptWithPublicKey(
19
+ * 'sensitive data',
20
+ * '0x04...' // Public key hex
21
+ * );
22
+ *
23
+ * // Use sessionStorage-backed cache
24
+ * adapter.cache.set('temp_key', 'cached_value');
25
+ * ```
26
+ *
27
+ * @category Platform
28
+ * @module platform/browser
6
29
  */
7
30
  import type { VanaPlatformAdapter, VanaCryptoAdapter, VanaPGPAdapter, VanaHttpAdapter, VanaCacheAdapter } from "./interface";
8
31
  /**
9
- * Browser implementation of crypto operations using Uint8Array
10
- * Supports both eccrypto-js (default) and custom ECIES implementation
32
+ * Implements cryptographic operations for browser environments.
33
+ *
34
+ * @remarks
35
+ * Provides ECIES encryption/decryption, key generation, and password-based
36
+ * encryption using either eccrypto-js or a custom ECIES implementation.
37
+ * Uses Uint8Array and viem utilities for browser compatibility.
38
+ *
39
+ * @internal
11
40
  */
12
41
  declare class BrowserCryptoAdapter implements VanaCryptoAdapter {
13
42
  private customEciesProvider;
14
43
  private customWalletService;
44
+ /**
45
+ * Encrypts data using ECIES with a public key.
46
+ *
47
+ * @param data - The plaintext string to encrypt.
48
+ * Typically user data or sensitive information.
49
+ * @param publicKeyHex - The recipient's public key in hex format.
50
+ * Can include or omit the '0x' prefix.
51
+ * @returns Encrypted data as a hex string without '0x' prefix
52
+ *
53
+ * @throws {Error} If encryption fails or public key is invalid
54
+ */
15
55
  encryptWithPublicKey(data: string, publicKeyHex: string): Promise<string>;
56
+ /**
57
+ * Decrypts ECIES-encrypted data using a private key.
58
+ *
59
+ * @param encryptedData - Hex string containing encrypted data.
60
+ * Can include or omit the '0x' prefix.
61
+ * @param privateKeyHex - The private key in hex format.
62
+ * Must correspond to the public key used for encryption.
63
+ * @returns The decrypted plaintext string
64
+ *
65
+ * @throws {Error} If decryption fails or MAC verification fails
66
+ */
16
67
  decryptWithPrivateKey(encryptedData: string, privateKeyHex: string): Promise<string>;
68
+ /**
69
+ * Encrypts data using a wallet's public key.
70
+ *
71
+ * @param data - The plaintext string to encrypt.
72
+ * Typically permission data or DLP metadata.
73
+ * @param publicKey - The wallet's public key.
74
+ * Automatically handles compressed/uncompressed formats.
75
+ * @returns Encrypted data as a hex string
76
+ *
77
+ * @throws {Error} If encryption fails or key processing fails
78
+ */
17
79
  encryptWithWalletPublicKey(data: string, publicKey: string): Promise<string>;
80
+ /**
81
+ * Decrypts data using a wallet's private key.
82
+ *
83
+ * @param encryptedData - Hex string containing encrypted data.
84
+ * Must be encrypted with corresponding wallet public key.
85
+ * @param privateKey - The wallet's private key.
86
+ * Obtain from wallet connection (handle with care).
87
+ * @returns The decrypted plaintext string
88
+ *
89
+ * @throws {Error} If decryption fails or key is invalid
90
+ */
18
91
  decryptWithWalletPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
92
+ /**
93
+ * Generates a new secp256k1 key pair for ECIES operations.
94
+ *
95
+ * @returns Object containing hex-encoded public and private keys
96
+ * @returns returns.privateKey - Private key in hex format without '0x'
97
+ * @returns returns.publicKey - Compressed public key in hex format without '0x'
98
+ *
99
+ * @throws {Error} If key generation fails
100
+ */
19
101
  generateKeyPair(): Promise<{
20
102
  privateKey: string;
21
103
  publicKey: string;
22
104
  }>;
105
+ /**
106
+ * Encrypts binary data using password-based encryption.
107
+ *
108
+ * @param data - Binary data to encrypt.
109
+ * Typically file contents or serialized objects.
110
+ * @param password - Password for encryption.
111
+ * Often derived from wallet signatures.
112
+ * @returns Encrypted data as Uint8Array
113
+ *
114
+ * @remarks
115
+ * Uses OpenPGP for password-based encryption with automatic
116
+ * salt generation for security.
117
+ *
118
+ * @throws {Error} If encryption fails
119
+ */
23
120
  encryptWithPassword(data: Uint8Array, password: string): Promise<Uint8Array>;
121
+ /**
122
+ * Decrypts password-encrypted binary data.
123
+ *
124
+ * @param encryptedData - Password-encrypted data as Uint8Array.
125
+ * Must be encrypted with the same password.
126
+ * @param password - Password for decryption.
127
+ * Must match the encryption password.
128
+ * @returns Decrypted data as Uint8Array
129
+ *
130
+ * @throws {Error} If decryption fails or password is incorrect
131
+ */
24
132
  decryptWithPassword(encryptedData: Uint8Array, password: string): Promise<Uint8Array>;
25
133
  }
26
134
  /**
27
- * Browser implementation of PGP operations
135
+ * Implements PGP operations for browser environments.
136
+ *
137
+ * @remarks
138
+ * Provides PGP encryption, decryption, and key generation using the OpenPGP.js
139
+ * library with browser-optimized configuration.
140
+ *
141
+ * @internal
28
142
  */
29
143
  declare class BrowserPGPAdapter implements VanaPGPAdapter {
144
+ /**
145
+ * Encrypts data using PGP public key encryption.
146
+ *
147
+ * @param data - The plaintext string to encrypt.
148
+ * Typically messages or structured data.
149
+ * @param publicKeyArmored - ASCII-armored PGP public key.
150
+ * Obtain from PGP key generation or key servers.
151
+ * @returns ASCII-armored encrypted message
152
+ *
153
+ * @throws {Error} If encryption fails or public key is invalid
154
+ */
30
155
  encrypt(data: string, publicKeyArmored: string): Promise<string>;
156
+ /**
157
+ * Decrypts PGP-encrypted data using a private key.
158
+ *
159
+ * @param encryptedData - ASCII-armored encrypted message.
160
+ * Must be encrypted with corresponding public key.
161
+ * @param privateKeyArmored - ASCII-armored PGP private key.
162
+ * Must correspond to the public key used for encryption.
163
+ * @returns The decrypted plaintext string
164
+ *
165
+ * @throws {Error} If decryption fails or private key is invalid
166
+ */
31
167
  decrypt(encryptedData: string, privateKeyArmored: string): Promise<string>;
168
+ /**
169
+ * Generates a new PGP key pair.
170
+ *
171
+ * @param options - Key generation options
172
+ * @param options.name - Name for the key identity.
173
+ * Defaults to 'Vana User'.
174
+ * @param options.email - Email for the key identity.
175
+ * Defaults to 'user@vana.com'.
176
+ * @param options.passphrase - Passphrase to protect the private key.
177
+ * If not provided, key is unprotected.
178
+ * @returns ASCII-armored public and private keys
179
+ *
180
+ * @throws {Error} If key generation fails
181
+ */
32
182
  generateKeyPair(options?: {
33
183
  name?: string;
34
184
  email?: string;
@@ -39,27 +189,97 @@ declare class BrowserPGPAdapter implements VanaPGPAdapter {
39
189
  }>;
40
190
  }
41
191
  /**
42
- * Browser implementation of HTTP operations using Fetch API
192
+ * Implements HTTP operations for browser environments.
193
+ *
194
+ * @remarks
195
+ * Uses the native Fetch API available in all modern browsers.
196
+ *
197
+ * @internal
43
198
  */
44
199
  declare class BrowserHttpAdapter implements VanaHttpAdapter {
200
+ /**
201
+ * Performs an HTTP request using the Fetch API.
202
+ *
203
+ * @param url - The URL to fetch.
204
+ * Must be a valid HTTP/HTTPS URL.
205
+ * @param options - Standard fetch options.
206
+ * See MDN fetch documentation for details.
207
+ * @returns Standard fetch Response object
208
+ */
45
209
  fetch(url: string, options?: RequestInit): Promise<Response>;
46
210
  }
47
211
  /**
48
- * Browser implementation of caching using sessionStorage for security
49
- * SessionStorage is cleared when the tab closes, making it more secure for signature caching
212
+ * Implements secure caching for browser environments.
213
+ *
214
+ * @remarks
215
+ * Uses sessionStorage for temporary caching that's automatically cleared
216
+ * when the browser tab closes. This provides better security for sensitive
217
+ * data like signatures compared to localStorage. All keys are prefixed to
218
+ * avoid conflicts with other applications.
219
+ *
220
+ * @internal
50
221
  */
51
222
  declare class BrowserCacheAdapter implements VanaCacheAdapter {
52
223
  private readonly prefix;
224
+ /**
225
+ * Retrieves a cached value by key.
226
+ *
227
+ * @param key - The cache key to look up.
228
+ * Automatically prefixed to avoid conflicts.
229
+ * @returns The cached value or null if not found
230
+ */
53
231
  get(key: string): string | null;
232
+ /**
233
+ * Stores a value in sessionStorage.
234
+ *
235
+ * @param key - The cache key.
236
+ * Automatically prefixed with 'vana_cache_'.
237
+ * @param value - The value to cache.
238
+ * Will be cleared when tab closes.
239
+ */
54
240
  set(key: string, value: string): void;
241
+ /**
242
+ * Removes a specific key from the cache.
243
+ *
244
+ * @param key - The cache key to remove.
245
+ * Only removes the prefixed key.
246
+ */
55
247
  delete(key: string): void;
248
+ /**
249
+ * Clears all Vana-prefixed cache entries.
250
+ *
251
+ * @remarks
252
+ * Only removes entries with the 'vana_cache_' prefix,
253
+ * preserving other sessionStorage data.
254
+ */
56
255
  clear(): void;
57
256
  }
58
257
  /**
59
- * Browser implementation of the Vana Platform Adapter
258
+ * Provides complete platform abstraction for browser environments.
259
+ *
260
+ * @remarks
261
+ * This adapter aggregates all browser-specific implementations of platform
262
+ * operations. It uses native Web APIs where possible and browser-compatible
263
+ * libraries for crypto and PGP operations. The adapter automatically selects
264
+ * appropriate cryptographic implementations based on feature flags.
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * // Create a browser adapter instance
269
+ * const adapter = new BrowserPlatformAdapter();
270
+ *
271
+ * // All platform operations are available
272
+ * const encrypted = await adapter.crypto.encryptWithPublicKey(
273
+ * 'secret',
274
+ * publicKey
275
+ * );
276
+ *
277
+ * const response = await adapter.http.fetch('/api/data');
278
+ *
279
+ * adapter.cache.set('key', 'value'); // Uses sessionStorage
280
+ * ```
60
281
  *
61
- * This adapter provides all platform-specific functionality for browser environments
62
- * without requiring any Node.js polyfills.
282
+ * @category Platform
63
283
  */
64
284
  export declare class BrowserPlatformAdapter implements VanaPlatformAdapter {
65
285
  readonly crypto: BrowserCryptoAdapter;
@@ -15,6 +15,17 @@ class BrowserCryptoAdapter {
15
15
  customWalletService = new WalletKeyEncryptionService({
16
16
  eciesProvider: this.customEciesProvider
17
17
  });
18
+ /**
19
+ * Encrypts data using ECIES with a public key.
20
+ *
21
+ * @param data - The plaintext string to encrypt.
22
+ * Typically user data or sensitive information.
23
+ * @param publicKeyHex - The recipient's public key in hex format.
24
+ * Can include or omit the '0x' prefix.
25
+ * @returns Encrypted data as a hex string without '0x' prefix
26
+ *
27
+ * @throws {Error} If encryption fails or public key is invalid
28
+ */
18
29
  async encryptWithPublicKey(data, publicKeyHex) {
19
30
  try {
20
31
  if (features.useCustomECIES) {
@@ -35,7 +46,10 @@ class BrowserCryptoAdapter {
35
46
  const eccryptojs = await getEccryptoJS();
36
47
  const cleanKey = publicKeyHex.startsWith("0x") ? publicKeyHex.slice(2) : publicKeyHex;
37
48
  const publicKeyBytes = Buffer.from(cleanKey, "hex");
38
- const publicKeyBuffer = publicKeyBytes.length === 64 ? Buffer.concat([Buffer.from([4]), publicKeyBytes]) : publicKeyBytes;
49
+ const uncompressed = this.customEciesProvider.normalizeToUncompressed(
50
+ new Uint8Array(publicKeyBytes)
51
+ );
52
+ const publicKeyBuffer = Buffer.from(uncompressed);
39
53
  const message = Buffer.from(data, "utf8");
40
54
  const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);
41
55
  const result = Buffer.concat([
@@ -50,6 +64,17 @@ class BrowserCryptoAdapter {
50
64
  throw wrapCryptoError("encryptWithPublicKey", error);
51
65
  }
52
66
  }
67
+ /**
68
+ * Decrypts ECIES-encrypted data using a private key.
69
+ *
70
+ * @param encryptedData - Hex string containing encrypted data.
71
+ * Can include or omit the '0x' prefix.
72
+ * @param privateKeyHex - The private key in hex format.
73
+ * Must correspond to the public key used for encryption.
74
+ * @returns The decrypted plaintext string
75
+ *
76
+ * @throws {Error} If decryption fails or MAC verification fails
77
+ */
53
78
  async decryptWithPrivateKey(encryptedData, privateKeyHex) {
54
79
  try {
55
80
  if (features.useCustomECIES) {
@@ -80,6 +105,17 @@ class BrowserCryptoAdapter {
80
105
  throw wrapCryptoError("decryptWithPrivateKey", error);
81
106
  }
82
107
  }
108
+ /**
109
+ * Encrypts data using a wallet's public key.
110
+ *
111
+ * @param data - The plaintext string to encrypt.
112
+ * Typically permission data or DLP metadata.
113
+ * @param publicKey - The wallet's public key.
114
+ * Automatically handles compressed/uncompressed formats.
115
+ * @returns Encrypted data as a hex string
116
+ *
117
+ * @throws {Error} If encryption fails or key processing fails
118
+ */
83
119
  async encryptWithWalletPublicKey(data, publicKey) {
84
120
  try {
85
121
  if (features.useCustomECIES) {
@@ -91,7 +127,10 @@ class BrowserCryptoAdapter {
91
127
  const eccryptojs = await getEccryptoJS();
92
128
  const cleanKey = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
93
129
  const publicKeyBytes = Buffer.from(cleanKey, "hex");
94
- const publicKeyBuffer = publicKeyBytes.length === 64 ? Buffer.concat([Buffer.from([4]), publicKeyBytes]) : publicKeyBytes;
130
+ const uncompressed = this.customEciesProvider.normalizeToUncompressed(
131
+ new Uint8Array(publicKeyBytes)
132
+ );
133
+ const publicKeyBuffer = Buffer.from(uncompressed);
95
134
  const message = Buffer.from(data, "utf8");
96
135
  const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);
97
136
  const result = Buffer.concat([
@@ -106,6 +145,17 @@ class BrowserCryptoAdapter {
106
145
  throw wrapCryptoError("encryptWithWalletPublicKey", error);
107
146
  }
108
147
  }
148
+ /**
149
+ * Decrypts data using a wallet's private key.
150
+ *
151
+ * @param encryptedData - Hex string containing encrypted data.
152
+ * Must be encrypted with corresponding wallet public key.
153
+ * @param privateKey - The wallet's private key.
154
+ * Obtain from wallet connection (handle with care).
155
+ * @returns The decrypted plaintext string
156
+ *
157
+ * @throws {Error} If decryption fails or key is invalid
158
+ */
109
159
  async decryptWithWalletPrivateKey(encryptedData, privateKey) {
110
160
  try {
111
161
  if (features.useCustomECIES) {
@@ -130,6 +180,15 @@ class BrowserCryptoAdapter {
130
180
  throw wrapCryptoError("decryptWithWalletPrivateKey", error);
131
181
  }
132
182
  }
183
+ /**
184
+ * Generates a new secp256k1 key pair for ECIES operations.
185
+ *
186
+ * @returns Object containing hex-encoded public and private keys
187
+ * @returns returns.privateKey - Private key in hex format without '0x'
188
+ * @returns returns.publicKey - Compressed public key in hex format without '0x'
189
+ *
190
+ * @throws {Error} If key generation fails
191
+ */
133
192
  async generateKeyPair() {
134
193
  try {
135
194
  if (features.useCustomECIES) {
@@ -152,6 +211,21 @@ class BrowserCryptoAdapter {
152
211
  throw wrapCryptoError("generateKeyPair", error);
153
212
  }
154
213
  }
214
+ /**
215
+ * Encrypts binary data using password-based encryption.
216
+ *
217
+ * @param data - Binary data to encrypt.
218
+ * Typically file contents or serialized objects.
219
+ * @param password - Password for encryption.
220
+ * Often derived from wallet signatures.
221
+ * @returns Encrypted data as Uint8Array
222
+ *
223
+ * @remarks
224
+ * Uses OpenPGP for password-based encryption with automatic
225
+ * salt generation for security.
226
+ *
227
+ * @throws {Error} If encryption fails
228
+ */
155
229
  async encryptWithPassword(data, password) {
156
230
  try {
157
231
  const openpgp = await getOpenPGP();
@@ -166,6 +240,17 @@ class BrowserCryptoAdapter {
166
240
  throw wrapCryptoError("encryptWithPassword", error);
167
241
  }
168
242
  }
243
+ /**
244
+ * Decrypts password-encrypted binary data.
245
+ *
246
+ * @param encryptedData - Password-encrypted data as Uint8Array.
247
+ * Must be encrypted with the same password.
248
+ * @param password - Password for decryption.
249
+ * Must match the encryption password.
250
+ * @returns Decrypted data as Uint8Array
251
+ *
252
+ * @throws {Error} If decryption fails or password is incorrect
253
+ */
169
254
  async decryptWithPassword(encryptedData, password) {
170
255
  try {
171
256
  const openpgp = await getOpenPGP();
@@ -184,6 +269,17 @@ class BrowserCryptoAdapter {
184
269
  }
185
270
  }
186
271
  class BrowserPGPAdapter {
272
+ /**
273
+ * Encrypts data using PGP public key encryption.
274
+ *
275
+ * @param data - The plaintext string to encrypt.
276
+ * Typically messages or structured data.
277
+ * @param publicKeyArmored - ASCII-armored PGP public key.
278
+ * Obtain from PGP key generation or key servers.
279
+ * @returns ASCII-armored encrypted message
280
+ *
281
+ * @throws {Error} If encryption fails or public key is invalid
282
+ */
187
283
  async encrypt(data, publicKeyArmored) {
188
284
  try {
189
285
  const openpgp = await getOpenPGP();
@@ -200,6 +296,17 @@ class BrowserPGPAdapter {
200
296
  throw new Error(`PGP encryption failed: ${String(error)}`);
201
297
  }
202
298
  }
299
+ /**
300
+ * Decrypts PGP-encrypted data using a private key.
301
+ *
302
+ * @param encryptedData - ASCII-armored encrypted message.
303
+ * Must be encrypted with corresponding public key.
304
+ * @param privateKeyArmored - ASCII-armored PGP private key.
305
+ * Must correspond to the public key used for encryption.
306
+ * @returns The decrypted plaintext string
307
+ *
308
+ * @throws {Error} If decryption fails or private key is invalid
309
+ */
203
310
  async decrypt(encryptedData, privateKeyArmored) {
204
311
  try {
205
312
  const openpgp = await getOpenPGP();
@@ -218,6 +325,20 @@ class BrowserPGPAdapter {
218
325
  throw new Error(`PGP decryption failed: ${String(error)}`);
219
326
  }
220
327
  }
328
+ /**
329
+ * Generates a new PGP key pair.
330
+ *
331
+ * @param options - Key generation options
332
+ * @param options.name - Name for the key identity.
333
+ * Defaults to 'Vana User'.
334
+ * @param options.email - Email for the key identity.
335
+ * Defaults to 'user@vana.com'.
336
+ * @param options.passphrase - Passphrase to protect the private key.
337
+ * If not provided, key is unprotected.
338
+ * @returns ASCII-armored public and private keys
339
+ *
340
+ * @throws {Error} If key generation fails
341
+ */
221
342
  async generateKeyPair(options) {
222
343
  try {
223
344
  const openpgp = await getOpenPGP();
@@ -230,12 +351,28 @@ class BrowserPGPAdapter {
230
351
  }
231
352
  }
232
353
  class BrowserHttpAdapter {
354
+ /**
355
+ * Performs an HTTP request using the Fetch API.
356
+ *
357
+ * @param url - The URL to fetch.
358
+ * Must be a valid HTTP/HTTPS URL.
359
+ * @param options - Standard fetch options.
360
+ * See MDN fetch documentation for details.
361
+ * @returns Standard fetch Response object
362
+ */
233
363
  async fetch(url, options) {
234
364
  return fetch(url, options);
235
365
  }
236
366
  }
237
367
  class BrowserCacheAdapter {
238
368
  prefix = "vana_cache_";
369
+ /**
370
+ * Retrieves a cached value by key.
371
+ *
372
+ * @param key - The cache key to look up.
373
+ * Automatically prefixed to avoid conflicts.
374
+ * @returns The cached value or null if not found
375
+ */
239
376
  get(key) {
240
377
  try {
241
378
  if (typeof sessionStorage === "undefined") {
@@ -246,6 +383,14 @@ class BrowserCacheAdapter {
246
383
  return null;
247
384
  }
248
385
  }
386
+ /**
387
+ * Stores a value in sessionStorage.
388
+ *
389
+ * @param key - The cache key.
390
+ * Automatically prefixed with 'vana_cache_'.
391
+ * @param value - The value to cache.
392
+ * Will be cleared when tab closes.
393
+ */
249
394
  set(key, value) {
250
395
  try {
251
396
  if (typeof sessionStorage === "undefined") {
@@ -255,6 +400,12 @@ class BrowserCacheAdapter {
255
400
  } catch {
256
401
  }
257
402
  }
403
+ /**
404
+ * Removes a specific key from the cache.
405
+ *
406
+ * @param key - The cache key to remove.
407
+ * Only removes the prefixed key.
408
+ */
258
409
  delete(key) {
259
410
  try {
260
411
  if (typeof sessionStorage === "undefined") {
@@ -264,6 +415,13 @@ class BrowserCacheAdapter {
264
415
  } catch {
265
416
  }
266
417
  }
418
+ /**
419
+ * Clears all Vana-prefixed cache entries.
420
+ *
421
+ * @remarks
422
+ * Only removes entries with the 'vana_cache_' prefix,
423
+ * preserving other sessionStorage data.
424
+ */
267
425
  clear() {
268
426
  try {
269
427
  if (typeof sessionStorage === "undefined") {