cilantro-sdk 0.0.31 → 0.0.33

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 (537) hide show
  1. package/README.md +2824 -136
  2. package/dist/admin.cjs +4 -1
  3. package/dist/admin.cjs.map +2 -2
  4. package/dist/admin.d.ts +30 -30
  5. package/dist/admin.d.ts.map +1 -1
  6. package/dist/admin.mjs +4 -1
  7. package/dist/admin.mjs.map +2 -2
  8. package/dist/api/admin/admin.d.ts +31 -31
  9. package/dist/api/admin/admin.d.ts.map +1 -1
  10. package/dist/api/auth/auth.d.ts +6 -6
  11. package/dist/api/auth/auth.d.ts.map +1 -1
  12. package/dist/api/delegated-keys/delegated-keys.d.ts +6 -6
  13. package/dist/api/delegated-keys/delegated-keys.d.ts.map +1 -1
  14. package/dist/api/health/health.d.ts +5 -5
  15. package/dist/api/health/health.d.ts.map +1 -1
  16. package/dist/api/plans/plans.d.ts +8 -8
  17. package/dist/api/plans/plans.d.ts.map +1 -1
  18. package/dist/api/platforms/platforms.d.ts +25 -25
  19. package/dist/api/platforms/platforms.d.ts.map +1 -1
  20. package/dist/api/public/public.d.ts +3 -2
  21. package/dist/api/public/public.d.ts.map +1 -1
  22. package/dist/api/subscriptions/subscriptions.d.ts +10 -10
  23. package/dist/api/subscriptions/subscriptions.d.ts.map +1 -1
  24. package/dist/api/transactions/transactions.d.ts +4 -4
  25. package/dist/api/transactions/transactions.d.ts.map +1 -1
  26. package/dist/api/users/users.d.ts +5 -5
  27. package/dist/api/users/users.d.ts.map +1 -1
  28. package/dist/api/wallets/wallets.d.ts +47 -47
  29. package/dist/api/wallets/wallets.d.ts.map +1 -1
  30. package/dist/api/webhooks/webhooks.d.ts +6 -6
  31. package/dist/api/webhooks/webhooks.d.ts.map +1 -1
  32. package/dist/auth.cjs.map +2 -2
  33. package/dist/auth.d.ts +11 -3
  34. package/dist/auth.d.ts.map +1 -1
  35. package/dist/auth.mjs.map +2 -2
  36. package/dist/delegated-keys.cjs.map +2 -2
  37. package/dist/delegated-keys.d.ts +5 -5
  38. package/dist/delegated-keys.d.ts.map +1 -1
  39. package/dist/delegated-keys.mjs.map +2 -2
  40. package/dist/helpers.cjs +642 -42
  41. package/dist/helpers.cjs.map +4 -4
  42. package/dist/helpers.mjs +642 -42
  43. package/dist/helpers.mjs.map +4 -4
  44. package/dist/index.cjs +650 -44
  45. package/dist/index.cjs.map +4 -4
  46. package/dist/index.mjs +650 -44
  47. package/dist/index.mjs.map +4 -4
  48. package/dist/models/adminCurrentResponseDto.d.ts +14 -0
  49. package/dist/models/adminCurrentResponseDto.d.ts.map +1 -0
  50. package/dist/models/adminDataDto.d.ts +16 -0
  51. package/dist/models/adminDataDto.d.ts.map +1 -0
  52. package/dist/models/adminResponseDto.d.ts +13 -0
  53. package/dist/models/adminResponseDto.d.ts.map +1 -0
  54. package/dist/models/adminsListResponseDto.d.ts +15 -0
  55. package/dist/models/adminsListResponseDto.d.ts.map +1 -0
  56. package/dist/models/adminsListResponseDtoMeta.d.ts +11 -0
  57. package/dist/models/adminsListResponseDtoMeta.d.ts.map +1 -0
  58. package/dist/models/analyticsOverviewDataDto.d.ts +15 -0
  59. package/dist/models/analyticsOverviewDataDto.d.ts.map +1 -0
  60. package/dist/models/analyticsOverviewResponseDto.d.ts +13 -0
  61. package/dist/models/analyticsOverviewResponseDto.d.ts.map +1 -0
  62. package/dist/models/authSuccessResponseDto.d.ts +12 -0
  63. package/dist/models/authSuccessResponseDto.d.ts.map +1 -0
  64. package/dist/models/currentPaymentDataDto.d.ts +22 -0
  65. package/dist/models/currentPaymentDataDto.d.ts.map +1 -0
  66. package/dist/models/currentPaymentDataDtoLastPaymentTransactionId.d.ts +14 -0
  67. package/dist/models/currentPaymentDataDtoLastPaymentTransactionId.d.ts.map +1 -0
  68. package/dist/models/currentPaymentDataDtoPaymentDate.d.ts +14 -0
  69. package/dist/models/currentPaymentDataDtoPaymentDate.d.ts.map +1 -0
  70. package/dist/models/currentPaymentDataDtoPaymentMethod.d.ts +14 -0
  71. package/dist/models/currentPaymentDataDtoPaymentMethod.d.ts.map +1 -0
  72. package/dist/models/currentPaymentDataDtoPaymentTransactionId.d.ts +14 -0
  73. package/dist/models/currentPaymentDataDtoPaymentTransactionId.d.ts.map +1 -0
  74. package/dist/models/delegatedKeyDataDto.d.ts +21 -0
  75. package/dist/models/delegatedKeyDataDto.d.ts.map +1 -0
  76. package/dist/models/delegatedKeyDataDtoExpiresAt.d.ts +14 -0
  77. package/dist/models/delegatedKeyDataDtoExpiresAt.d.ts.map +1 -0
  78. package/dist/models/delegatedKeyDeletedResponseDto.d.ts +13 -0
  79. package/dist/models/delegatedKeyDeletedResponseDto.d.ts.map +1 -0
  80. package/dist/models/delegatedKeyResponseDto.d.ts +13 -0
  81. package/dist/models/delegatedKeyResponseDto.d.ts.map +1 -0
  82. package/dist/models/delegatedKeysListResponseDto.d.ts +13 -0
  83. package/dist/models/delegatedKeysListResponseDto.d.ts.map +1 -0
  84. package/dist/models/deviceEncryptedSecretResponseDto.d.ts +13 -0
  85. package/dist/models/deviceEncryptedSecretResponseDto.d.ts.map +1 -0
  86. package/dist/models/deviceIdentityDataDto.d.ts +26 -0
  87. package/dist/models/deviceIdentityDataDto.d.ts.map +1 -0
  88. package/dist/models/deviceIdentityDataDtoDeviceFingerprint.d.ts +15 -0
  89. package/dist/models/deviceIdentityDataDtoDeviceFingerprint.d.ts.map +1 -0
  90. package/dist/models/deviceIdentityDataDtoLastUsedAt.d.ts +14 -0
  91. package/dist/models/deviceIdentityDataDtoLastUsedAt.d.ts.map +1 -0
  92. package/dist/models/deviceIdentityResponseDto.d.ts +14 -0
  93. package/dist/models/deviceIdentityResponseDto.d.ts.map +1 -0
  94. package/dist/models/healthCheckResultDto.d.ts +15 -0
  95. package/dist/models/healthCheckResultDto.d.ts.map +1 -0
  96. package/dist/models/healthCheckResultDtoStatus.d.ts +13 -0
  97. package/dist/models/healthCheckResultDtoStatus.d.ts.map +1 -0
  98. package/dist/models/healthChecksDto.d.ts +14 -0
  99. package/dist/models/healthChecksDto.d.ts.map +1 -0
  100. package/dist/models/healthStatusDto.d.ts +16 -0
  101. package/dist/models/healthStatusDto.d.ts.map +1 -0
  102. package/dist/models/healthStatusDtoStatus.d.ts +14 -0
  103. package/dist/models/healthStatusDtoStatus.d.ts.map +1 -0
  104. package/dist/models/index.d.ts +220 -0
  105. package/dist/models/index.d.ts.map +1 -1
  106. package/dist/models/livenessResponseDto.d.ts +12 -0
  107. package/dist/models/livenessResponseDto.d.ts.map +1 -0
  108. package/dist/models/loginResponseDataDto.d.ts +17 -0
  109. package/dist/models/loginResponseDataDto.d.ts.map +1 -0
  110. package/dist/models/loginResponseDataDtoUser.d.ts +11 -0
  111. package/dist/models/loginResponseDataDtoUser.d.ts.map +1 -0
  112. package/dist/models/loginResponseDataDtoUserType.d.ts +14 -0
  113. package/dist/models/loginResponseDataDtoUserType.d.ts.map +1 -0
  114. package/dist/models/loginResponseDto.d.ts +14 -0
  115. package/dist/models/loginResponseDto.d.ts.map +1 -0
  116. package/dist/models/paginationMetaDto.d.ts +16 -0
  117. package/dist/models/paginationMetaDto.d.ts.map +1 -0
  118. package/dist/models/passkeyAuthenticationOptionsDto.d.ts +20 -0
  119. package/dist/models/passkeyAuthenticationOptionsDto.d.ts.map +1 -0
  120. package/dist/models/passkeyAuthenticationResponseDto.d.ts +13 -0
  121. package/dist/models/passkeyAuthenticationResponseDto.d.ts.map +1 -0
  122. package/dist/models/passkeyRegistrationOptionsDto.d.ts +26 -0
  123. package/dist/models/passkeyRegistrationOptionsDto.d.ts.map +1 -0
  124. package/dist/models/passkeyRegistrationOptionsDtoRp.d.ts +14 -0
  125. package/dist/models/passkeyRegistrationOptionsDtoRp.d.ts.map +1 -0
  126. package/dist/models/passkeyRegistrationOptionsDtoUser.d.ts +14 -0
  127. package/dist/models/passkeyRegistrationOptionsDtoUser.d.ts.map +1 -0
  128. package/dist/models/passkeyRegistrationResponseDto.d.ts +13 -0
  129. package/dist/models/passkeyRegistrationResponseDto.d.ts.map +1 -0
  130. package/dist/models/passkeyVerifyAuthDataDto.d.ts +11 -0
  131. package/dist/models/passkeyVerifyAuthDataDto.d.ts.map +1 -0
  132. package/dist/models/passkeyVerifyAuthResponseDto.d.ts +13 -0
  133. package/dist/models/passkeyVerifyAuthResponseDto.d.ts.map +1 -0
  134. package/dist/models/paymentHistoryDataDto.d.ts +15 -0
  135. package/dist/models/paymentHistoryDataDto.d.ts.map +1 -0
  136. package/dist/models/paymentHistoryEntryDto.d.ts +16 -0
  137. package/dist/models/paymentHistoryEntryDto.d.ts.map +1 -0
  138. package/dist/models/paymentHistoryEntryDtoAction.d.ts +22 -0
  139. package/dist/models/paymentHistoryEntryDtoAction.d.ts.map +1 -0
  140. package/dist/models/paymentHistoryEntryDtoMetadata.d.ts +14 -0
  141. package/dist/models/paymentHistoryEntryDtoMetadata.d.ts.map +1 -0
  142. package/dist/models/paymentHistoryResponseDto.d.ts +13 -0
  143. package/dist/models/paymentHistoryResponseDto.d.ts.map +1 -0
  144. package/dist/models/planDataDto.d.ts +32 -0
  145. package/dist/models/planDataDto.d.ts.map +1 -0
  146. package/dist/models/planDataDtoDescription.d.ts +14 -0
  147. package/dist/models/planDataDtoDescription.d.ts.map +1 -0
  148. package/dist/models/planDataDtoEnforcementType.d.ts +14 -0
  149. package/dist/models/planDataDtoEnforcementType.d.ts.map +1 -0
  150. package/dist/models/planDataDtoFeatures.d.ts +14 -0
  151. package/dist/models/planDataDtoFeatures.d.ts.map +1 -0
  152. package/dist/models/planDataDtoMetadata.d.ts +14 -0
  153. package/dist/models/planDataDtoMetadata.d.ts.map +1 -0
  154. package/dist/models/planResponseDto.d.ts +13 -0
  155. package/dist/models/planResponseDto.d.ts.map +1 -0
  156. package/dist/models/plansListResponseDto.d.ts +13 -0
  157. package/dist/models/plansListResponseDto.d.ts.map +1 -0
  158. package/dist/models/platformActivityTimelineDataDto.d.ts +12 -0
  159. package/dist/models/platformActivityTimelineDataDto.d.ts.map +1 -0
  160. package/dist/models/platformActivityTimelineDataDtoTimelineItem.d.ts +11 -0
  161. package/dist/models/platformActivityTimelineDataDtoTimelineItem.d.ts.map +1 -0
  162. package/dist/models/platformActivityTimelineResponseDto.d.ts +13 -0
  163. package/dist/models/platformActivityTimelineResponseDto.d.ts.map +1 -0
  164. package/dist/models/platformAnalyticsDataDto.d.ts +14 -0
  165. package/dist/models/platformAnalyticsDataDto.d.ts.map +1 -0
  166. package/dist/models/platformAnalyticsResponseDto.d.ts +13 -0
  167. package/dist/models/platformAnalyticsResponseDto.d.ts.map +1 -0
  168. package/dist/models/platformApiKeyDataDto.d.ts +12 -0
  169. package/dist/models/platformApiKeyDataDto.d.ts.map +1 -0
  170. package/dist/models/platformApiKeyResponseDto.d.ts +13 -0
  171. package/dist/models/platformApiKeyResponseDto.d.ts.map +1 -0
  172. package/dist/models/platformApiKeysListResponseDto.d.ts +13 -0
  173. package/dist/models/platformApiKeysListResponseDto.d.ts.map +1 -0
  174. package/dist/models/platformCreatedDataDto.d.ts +47 -0
  175. package/dist/models/platformCreatedDataDto.d.ts.map +1 -0
  176. package/dist/models/platformCreatedDataDtoBrandLogoUri.d.ts +14 -0
  177. package/dist/models/platformCreatedDataDtoBrandLogoUri.d.ts.map +1 -0
  178. package/dist/models/platformCreatedDataDtoBrandName.d.ts +14 -0
  179. package/dist/models/platformCreatedDataDtoBrandName.d.ts.map +1 -0
  180. package/dist/models/platformCreatedDataDtoCurrentSubscriptionId.d.ts +14 -0
  181. package/dist/models/platformCreatedDataDtoCurrentSubscriptionId.d.ts.map +1 -0
  182. package/dist/models/platformCreatedDataDtoFeePayerPublicKey.d.ts +14 -0
  183. package/dist/models/platformCreatedDataDtoFeePayerPublicKey.d.ts.map +1 -0
  184. package/dist/models/platformCreatedDataDtoPlanEnforcementType.d.ts +17 -0
  185. package/dist/models/platformCreatedDataDtoPlanEnforcementType.d.ts.map +1 -0
  186. package/dist/models/platformCreatedDataDtoPlanId.d.ts +14 -0
  187. package/dist/models/platformCreatedDataDtoPlanId.d.ts.map +1 -0
  188. package/dist/models/platformCreatedDataDtoWebauthnOrigin.d.ts +14 -0
  189. package/dist/models/platformCreatedDataDtoWebauthnOrigin.d.ts.map +1 -0
  190. package/dist/models/platformCreatedDataDtoWebauthnRpId.d.ts +14 -0
  191. package/dist/models/platformCreatedDataDtoWebauthnRpId.d.ts.map +1 -0
  192. package/dist/models/platformCreatedDataDtoWebauthnRpName.d.ts +14 -0
  193. package/dist/models/platformCreatedDataDtoWebauthnRpName.d.ts.map +1 -0
  194. package/dist/models/platformCreatedResponseDto.d.ts +13 -0
  195. package/dist/models/platformCreatedResponseDto.d.ts.map +1 -0
  196. package/dist/models/platformDataDto.d.ts +46 -0
  197. package/dist/models/platformDataDto.d.ts.map +1 -0
  198. package/dist/models/platformDataDtoBrandLogoUri.d.ts +14 -0
  199. package/dist/models/platformDataDtoBrandLogoUri.d.ts.map +1 -0
  200. package/dist/models/platformDataDtoBrandName.d.ts +14 -0
  201. package/dist/models/platformDataDtoBrandName.d.ts.map +1 -0
  202. package/dist/models/platformDataDtoCurrentSubscriptionId.d.ts +14 -0
  203. package/dist/models/platformDataDtoCurrentSubscriptionId.d.ts.map +1 -0
  204. package/dist/models/platformDataDtoFeePayerPublicKey.d.ts +14 -0
  205. package/dist/models/platformDataDtoFeePayerPublicKey.d.ts.map +1 -0
  206. package/dist/models/platformDataDtoPlanEnforcementType.d.ts +17 -0
  207. package/dist/models/platformDataDtoPlanEnforcementType.d.ts.map +1 -0
  208. package/dist/models/platformDataDtoPlanId.d.ts +14 -0
  209. package/dist/models/platformDataDtoPlanId.d.ts.map +1 -0
  210. package/dist/models/platformDataDtoWebauthnOrigin.d.ts +14 -0
  211. package/dist/models/platformDataDtoWebauthnOrigin.d.ts.map +1 -0
  212. package/dist/models/platformDataDtoWebauthnRpId.d.ts +14 -0
  213. package/dist/models/platformDataDtoWebauthnRpId.d.ts.map +1 -0
  214. package/dist/models/platformDataDtoWebauthnRpName.d.ts +14 -0
  215. package/dist/models/platformDataDtoWebauthnRpName.d.ts.map +1 -0
  216. package/dist/models/platformGrowthTrendsDataDto.d.ts +12 -0
  217. package/dist/models/platformGrowthTrendsDataDto.d.ts.map +1 -0
  218. package/dist/models/platformGrowthTrendsDataDtoTrendsItem.d.ts +11 -0
  219. package/dist/models/platformGrowthTrendsDataDtoTrendsItem.d.ts.map +1 -0
  220. package/dist/models/platformGrowthTrendsResponseDto.d.ts +13 -0
  221. package/dist/models/platformGrowthTrendsResponseDto.d.ts.map +1 -0
  222. package/dist/models/platformPaginatedResponseDto.d.ts +15 -0
  223. package/dist/models/platformPaginatedResponseDto.d.ts.map +1 -0
  224. package/dist/models/platformPaginatedResponseDtoMeta.d.ts +11 -0
  225. package/dist/models/platformPaginatedResponseDtoMeta.d.ts.map +1 -0
  226. package/dist/models/platformResponseDto.d.ts +13 -0
  227. package/dist/models/platformResponseDto.d.ts.map +1 -0
  228. package/dist/models/platformUsageMetricsDataDto.d.ts +12 -0
  229. package/dist/models/platformUsageMetricsDataDto.d.ts.map +1 -0
  230. package/dist/models/platformUsageMetricsDataDtoMetricsItem.d.ts +11 -0
  231. package/dist/models/platformUsageMetricsDataDtoMetricsItem.d.ts.map +1 -0
  232. package/dist/models/platformUsageMetricsResponseDto.d.ts +13 -0
  233. package/dist/models/platformUsageMetricsResponseDto.d.ts.map +1 -0
  234. package/dist/models/platformWithUsersDataDto.d.ts +47 -0
  235. package/dist/models/platformWithUsersDataDto.d.ts.map +1 -0
  236. package/dist/models/platformWithUsersDataDtoBrandLogoUri.d.ts +14 -0
  237. package/dist/models/platformWithUsersDataDtoBrandLogoUri.d.ts.map +1 -0
  238. package/dist/models/platformWithUsersDataDtoBrandName.d.ts +14 -0
  239. package/dist/models/platformWithUsersDataDtoBrandName.d.ts.map +1 -0
  240. package/dist/models/platformWithUsersDataDtoCurrentSubscriptionId.d.ts +14 -0
  241. package/dist/models/platformWithUsersDataDtoCurrentSubscriptionId.d.ts.map +1 -0
  242. package/dist/models/platformWithUsersDataDtoFeePayerPublicKey.d.ts +14 -0
  243. package/dist/models/platformWithUsersDataDtoFeePayerPublicKey.d.ts.map +1 -0
  244. package/dist/models/platformWithUsersDataDtoPlanEnforcementType.d.ts +17 -0
  245. package/dist/models/platformWithUsersDataDtoPlanEnforcementType.d.ts.map +1 -0
  246. package/dist/models/platformWithUsersDataDtoPlanId.d.ts +14 -0
  247. package/dist/models/platformWithUsersDataDtoPlanId.d.ts.map +1 -0
  248. package/dist/models/platformWithUsersDataDtoWebauthnOrigin.d.ts +14 -0
  249. package/dist/models/platformWithUsersDataDtoWebauthnOrigin.d.ts.map +1 -0
  250. package/dist/models/platformWithUsersDataDtoWebauthnRpId.d.ts +14 -0
  251. package/dist/models/platformWithUsersDataDtoWebauthnRpId.d.ts.map +1 -0
  252. package/dist/models/platformWithUsersDataDtoWebauthnRpName.d.ts +14 -0
  253. package/dist/models/platformWithUsersDataDtoWebauthnRpName.d.ts.map +1 -0
  254. package/dist/models/platformWithUsersResponseDto.d.ts +15 -0
  255. package/dist/models/platformWithUsersResponseDto.d.ts.map +1 -0
  256. package/dist/models/platformWithUsersResponseDtoMeta.d.ts +11 -0
  257. package/dist/models/platformWithUsersResponseDtoMeta.d.ts.map +1 -0
  258. package/dist/models/platformsListResponseDto.d.ts +13 -0
  259. package/dist/models/platformsListResponseDto.d.ts.map +1 -0
  260. package/dist/models/prepareTransactionDataDto.d.ts +16 -0
  261. package/dist/models/prepareTransactionDataDto.d.ts.map +1 -0
  262. package/dist/models/prepareTransactionResponseDto.d.ts +13 -0
  263. package/dist/models/prepareTransactionResponseDto.d.ts.map +1 -0
  264. package/dist/models/publicStatsDataDto.d.ts +13 -0
  265. package/dist/models/publicStatsDataDto.d.ts.map +1 -0
  266. package/dist/models/publicStatsResponseDto.d.ts +13 -0
  267. package/dist/models/publicStatsResponseDto.d.ts.map +1 -0
  268. package/dist/models/publicStatsTotalsDto.d.ts +15 -0
  269. package/dist/models/publicStatsTotalsDto.d.ts.map +1 -0
  270. package/dist/models/readinessResponseDto.d.ts +15 -0
  271. package/dist/models/readinessResponseDto.d.ts.map +1 -0
  272. package/dist/models/readinessResponseDtoStatus.d.ts +13 -0
  273. package/dist/models/readinessResponseDtoStatus.d.ts.map +1 -0
  274. package/dist/models/recentActivityDataDto.d.ts +12 -0
  275. package/dist/models/recentActivityDataDto.d.ts.map +1 -0
  276. package/dist/models/recentActivityDataDtoActivitiesItem.d.ts +11 -0
  277. package/dist/models/recentActivityDataDtoActivitiesItem.d.ts.map +1 -0
  278. package/dist/models/recentActivityResponseDto.d.ts +13 -0
  279. package/dist/models/recentActivityResponseDto.d.ts.map +1 -0
  280. package/dist/models/sendTransactionDataDto.d.ts +13 -0
  281. package/dist/models/sendTransactionDataDto.d.ts.map +1 -0
  282. package/dist/models/sendTransactionDataDtoStatus.d.ts +14 -0
  283. package/dist/models/sendTransactionDataDtoStatus.d.ts.map +1 -0
  284. package/dist/models/sendTransactionResponseDto.d.ts +13 -0
  285. package/dist/models/sendTransactionResponseDto.d.ts.map +1 -0
  286. package/dist/models/signMessageDataDto.d.ts +14 -0
  287. package/dist/models/signMessageDataDto.d.ts.map +1 -0
  288. package/dist/models/signMessageResponseDto.d.ts +13 -0
  289. package/dist/models/signMessageResponseDto.d.ts.map +1 -0
  290. package/dist/models/signerCreatedDataDto.d.ts +16 -0
  291. package/dist/models/signerCreatedDataDto.d.ts.map +1 -0
  292. package/dist/models/signerCreatedResponseDto.d.ts +13 -0
  293. package/dist/models/signerCreatedResponseDto.d.ts.map +1 -0
  294. package/dist/models/signerDataDto.d.ts +23 -0
  295. package/dist/models/signerDataDto.d.ts.map +1 -0
  296. package/dist/models/signerDataDtoCustodyType.d.ts +13 -0
  297. package/dist/models/signerDataDtoCustodyType.d.ts.map +1 -0
  298. package/dist/models/signerDataDtoSignerConfig.d.ts +14 -0
  299. package/dist/models/signerDataDtoSignerConfig.d.ts.map +1 -0
  300. package/dist/models/signerDataDtoSignerType.d.ts +16 -0
  301. package/dist/models/signerDataDtoSignerType.d.ts.map +1 -0
  302. package/dist/models/signerDeletedResponseDto.d.ts +13 -0
  303. package/dist/models/signerDeletedResponseDto.d.ts.map +1 -0
  304. package/dist/models/signerResponseDto.d.ts +17 -0
  305. package/dist/models/signerResponseDto.d.ts.map +1 -0
  306. package/dist/models/signerResponseDtoData.d.ts +14 -0
  307. package/dist/models/signerResponseDtoData.d.ts.map +1 -0
  308. package/dist/models/signerResponseDtoType.d.ts +16 -0
  309. package/dist/models/signerResponseDtoType.d.ts.map +1 -0
  310. package/dist/models/signerSummaryDto.d.ts +18 -0
  311. package/dist/models/signerSummaryDto.d.ts.map +1 -0
  312. package/dist/models/signerSummaryDtoCustodyType.d.ts +13 -0
  313. package/dist/models/signerSummaryDtoCustodyType.d.ts.map +1 -0
  314. package/dist/models/signerSummaryDtoSignerType.d.ts +16 -0
  315. package/dist/models/signerSummaryDtoSignerType.d.ts.map +1 -0
  316. package/dist/models/signerUpdatedResponseDto.d.ts +13 -0
  317. package/dist/models/signerUpdatedResponseDto.d.ts.map +1 -0
  318. package/dist/models/signersListDataDto.d.ts +14 -0
  319. package/dist/models/signersListDataDto.d.ts.map +1 -0
  320. package/dist/models/signersListResponseDto.d.ts +13 -0
  321. package/dist/models/signersListResponseDto.d.ts.map +1 -0
  322. package/dist/models/simulateTransactionDataDto.d.ts +14 -0
  323. package/dist/models/simulateTransactionDataDto.d.ts.map +1 -0
  324. package/dist/models/simulateTransactionResponseDto.d.ts +13 -0
  325. package/dist/models/simulateTransactionResponseDto.d.ts.map +1 -0
  326. package/dist/models/submitTransactionDataDto.d.ts +15 -0
  327. package/dist/models/submitTransactionDataDto.d.ts.map +1 -0
  328. package/dist/models/submitTransactionDataDtoStatus.d.ts +17 -0
  329. package/dist/models/submitTransactionDataDtoStatus.d.ts.map +1 -0
  330. package/dist/models/submitTransactionResponseDto.d.ts +13 -0
  331. package/dist/models/submitTransactionResponseDto.d.ts.map +1 -0
  332. package/dist/models/subscriptionDataDto.d.ts +53 -0
  333. package/dist/models/subscriptionDataDto.d.ts.map +1 -0
  334. package/dist/models/subscriptionDataDtoBillingCycle.d.ts +13 -0
  335. package/dist/models/subscriptionDataDtoBillingCycle.d.ts.map +1 -0
  336. package/dist/models/subscriptionDataDtoCancellationReason.d.ts +14 -0
  337. package/dist/models/subscriptionDataDtoCancellationReason.d.ts.map +1 -0
  338. package/dist/models/subscriptionDataDtoCancelledAt.d.ts +14 -0
  339. package/dist/models/subscriptionDataDtoCancelledAt.d.ts.map +1 -0
  340. package/dist/models/subscriptionDataDtoEndDate.d.ts +14 -0
  341. package/dist/models/subscriptionDataDtoEndDate.d.ts.map +1 -0
  342. package/dist/models/subscriptionDataDtoGracePeriodEndDate.d.ts +14 -0
  343. package/dist/models/subscriptionDataDtoGracePeriodEndDate.d.ts.map +1 -0
  344. package/dist/models/subscriptionDataDtoLastPaymentTransactionId.d.ts +14 -0
  345. package/dist/models/subscriptionDataDtoLastPaymentTransactionId.d.ts.map +1 -0
  346. package/dist/models/subscriptionDataDtoMetadata.d.ts +14 -0
  347. package/dist/models/subscriptionDataDtoMetadata.d.ts.map +1 -0
  348. package/dist/models/subscriptionDataDtoNextBillingDate.d.ts +14 -0
  349. package/dist/models/subscriptionDataDtoNextBillingDate.d.ts.map +1 -0
  350. package/dist/models/subscriptionDataDtoPaymentDate.d.ts +14 -0
  351. package/dist/models/subscriptionDataDtoPaymentDate.d.ts.map +1 -0
  352. package/dist/models/subscriptionDataDtoPaymentMethod.d.ts +14 -0
  353. package/dist/models/subscriptionDataDtoPaymentMethod.d.ts.map +1 -0
  354. package/dist/models/subscriptionDataDtoPaymentTransactionId.d.ts +14 -0
  355. package/dist/models/subscriptionDataDtoPaymentTransactionId.d.ts.map +1 -0
  356. package/dist/models/subscriptionDataDtoStatus.d.ts +16 -0
  357. package/dist/models/subscriptionDataDtoStatus.d.ts.map +1 -0
  358. package/dist/models/subscriptionDataDtoTrialEndDate.d.ts +14 -0
  359. package/dist/models/subscriptionDataDtoTrialEndDate.d.ts.map +1 -0
  360. package/dist/models/subscriptionHistoryDataDto.d.ts +30 -0
  361. package/dist/models/subscriptionHistoryDataDto.d.ts.map +1 -0
  362. package/dist/models/subscriptionHistoryDataDtoAction.d.ts +22 -0
  363. package/dist/models/subscriptionHistoryDataDtoAction.d.ts.map +1 -0
  364. package/dist/models/subscriptionHistoryDataDtoMetadata.d.ts +14 -0
  365. package/dist/models/subscriptionHistoryDataDtoMetadata.d.ts.map +1 -0
  366. package/dist/models/subscriptionHistoryDataDtoNewPlanId.d.ts +14 -0
  367. package/dist/models/subscriptionHistoryDataDtoNewPlanId.d.ts.map +1 -0
  368. package/dist/models/subscriptionHistoryDataDtoNewStatus.d.ts +14 -0
  369. package/dist/models/subscriptionHistoryDataDtoNewStatus.d.ts.map +1 -0
  370. package/dist/models/subscriptionHistoryDataDtoOldPlanId.d.ts +14 -0
  371. package/dist/models/subscriptionHistoryDataDtoOldPlanId.d.ts.map +1 -0
  372. package/dist/models/subscriptionHistoryDataDtoOldStatus.d.ts +14 -0
  373. package/dist/models/subscriptionHistoryDataDtoOldStatus.d.ts.map +1 -0
  374. package/dist/models/subscriptionHistoryResponseDto.d.ts +13 -0
  375. package/dist/models/subscriptionHistoryResponseDto.d.ts.map +1 -0
  376. package/dist/models/subscriptionResponseDto.d.ts +13 -0
  377. package/dist/models/subscriptionResponseDto.d.ts.map +1 -0
  378. package/dist/models/subscriptionsListResponseDto.d.ts +13 -0
  379. package/dist/models/subscriptionsListResponseDto.d.ts.map +1 -0
  380. package/dist/models/subscriptionsPaginatedResponseDto.d.ts +15 -0
  381. package/dist/models/subscriptionsPaginatedResponseDto.d.ts.map +1 -0
  382. package/dist/models/topPlatformsDataDto.d.ts +12 -0
  383. package/dist/models/topPlatformsDataDto.d.ts.map +1 -0
  384. package/dist/models/topPlatformsDataDtoPlatformsItem.d.ts +11 -0
  385. package/dist/models/topPlatformsDataDtoPlatformsItem.d.ts.map +1 -0
  386. package/dist/models/topPlatformsResponseDto.d.ts +13 -0
  387. package/dist/models/topPlatformsResponseDto.d.ts.map +1 -0
  388. package/dist/models/totalBalanceResponseDto.d.ts +12 -0
  389. package/dist/models/totalBalanceResponseDto.d.ts.map +1 -0
  390. package/dist/models/transactionDataDto.d.ts +43 -0
  391. package/dist/models/transactionDataDto.d.ts.map +1 -0
  392. package/dist/models/transactionDataDtoError.d.ts +14 -0
  393. package/dist/models/transactionDataDtoError.d.ts.map +1 -0
  394. package/dist/models/transactionDataDtoFromAddress.d.ts +14 -0
  395. package/dist/models/transactionDataDtoFromAddress.d.ts.map +1 -0
  396. package/dist/models/transactionDataDtoMetadata.d.ts +14 -0
  397. package/dist/models/transactionDataDtoMetadata.d.ts.map +1 -0
  398. package/dist/models/transactionDataDtoSignature.d.ts +14 -0
  399. package/dist/models/transactionDataDtoSignature.d.ts.map +1 -0
  400. package/dist/models/transactionDataDtoStatus.d.ts +14 -0
  401. package/dist/models/transactionDataDtoStatus.d.ts.map +1 -0
  402. package/dist/models/transactionDataDtoToAddress.d.ts +14 -0
  403. package/dist/models/transactionDataDtoToAddress.d.ts.map +1 -0
  404. package/dist/models/transactionDataDtoTokenMint.d.ts +14 -0
  405. package/dist/models/transactionDataDtoTokenMint.d.ts.map +1 -0
  406. package/dist/models/transactionDataDtoType.d.ts +19 -0
  407. package/dist/models/transactionDataDtoType.d.ts.map +1 -0
  408. package/dist/models/transactionHashDataDto.d.ts +13 -0
  409. package/dist/models/transactionHashDataDto.d.ts.map +1 -0
  410. package/dist/models/transactionListDataDto.d.ts +14 -0
  411. package/dist/models/transactionListDataDto.d.ts.map +1 -0
  412. package/dist/models/transactionListResponseDto.d.ts +13 -0
  413. package/dist/models/transactionListResponseDto.d.ts.map +1 -0
  414. package/dist/models/transactionResponseDto.d.ts +13 -0
  415. package/dist/models/transactionResponseDto.d.ts.map +1 -0
  416. package/dist/models/transactionStatusDataDto.d.ts +24 -0
  417. package/dist/models/transactionStatusDataDto.d.ts.map +1 -0
  418. package/dist/models/transactionStatusDataDtoError.d.ts +14 -0
  419. package/dist/models/transactionStatusDataDtoError.d.ts.map +1 -0
  420. package/dist/models/transactionStatusDataDtoStatus.d.ts +14 -0
  421. package/dist/models/transactionStatusDataDtoStatus.d.ts.map +1 -0
  422. package/dist/models/transactionStatusResponseDto.d.ts +13 -0
  423. package/dist/models/transactionStatusResponseDto.d.ts.map +1 -0
  424. package/dist/models/userDataDto.d.ts +21 -0
  425. package/dist/models/userDataDto.d.ts.map +1 -0
  426. package/dist/models/userDataDtoPlanId.d.ts +14 -0
  427. package/dist/models/userDataDtoPlanId.d.ts.map +1 -0
  428. package/dist/models/userResponseDto.d.ts +13 -0
  429. package/dist/models/userResponseDto.d.ts.map +1 -0
  430. package/dist/models/userWithWalletsDataDto.d.ts +23 -0
  431. package/dist/models/userWithWalletsDataDto.d.ts.map +1 -0
  432. package/dist/models/userWithWalletsDataDtoPlanId.d.ts +14 -0
  433. package/dist/models/userWithWalletsDataDtoPlanId.d.ts.map +1 -0
  434. package/dist/models/userWithWalletsResponseDto.d.ts +15 -0
  435. package/dist/models/userWithWalletsResponseDto.d.ts.map +1 -0
  436. package/dist/models/userWithWalletsResponseDtoMeta.d.ts +11 -0
  437. package/dist/models/userWithWalletsResponseDtoMeta.d.ts.map +1 -0
  438. package/dist/models/usersListResponseDto.d.ts +13 -0
  439. package/dist/models/usersListResponseDto.d.ts.map +1 -0
  440. package/dist/models/walletAnalyticsDataDto.d.ts +15 -0
  441. package/dist/models/walletAnalyticsDataDto.d.ts.map +1 -0
  442. package/dist/models/walletAnalyticsResponseDto.d.ts +13 -0
  443. package/dist/models/walletAnalyticsResponseDto.d.ts.map +1 -0
  444. package/dist/models/walletAssetWithInfoDataDto.d.ts +25 -0
  445. package/dist/models/walletAssetWithInfoDataDto.d.ts.map +1 -0
  446. package/dist/models/walletAssetWithInfoDataDtoAssetType.d.ts +14 -0
  447. package/dist/models/walletAssetWithInfoDataDtoAssetType.d.ts.map +1 -0
  448. package/dist/models/walletAssetWithInfoDataDtoMetadata.d.ts +11 -0
  449. package/dist/models/walletAssetWithInfoDataDtoMetadata.d.ts.map +1 -0
  450. package/dist/models/walletAssetsListDataDto.d.ts +14 -0
  451. package/dist/models/walletAssetsListDataDto.d.ts.map +1 -0
  452. package/dist/models/walletAssetsListDataDtoMeta.d.ts +11 -0
  453. package/dist/models/walletAssetsListDataDtoMeta.d.ts.map +1 -0
  454. package/dist/models/walletAssetsListResponseDto.d.ts +13 -0
  455. package/dist/models/walletAssetsListResponseDto.d.ts.map +1 -0
  456. package/dist/models/walletAssetsResponseDto.d.ts +13 -0
  457. package/dist/models/walletAssetsResponseDto.d.ts.map +1 -0
  458. package/dist/models/walletCustodyInfoDataDto.d.ts +20 -0
  459. package/dist/models/walletCustodyInfoDataDto.d.ts.map +1 -0
  460. package/dist/models/walletCustodyInfoDataDtoWalletMode.d.ts +13 -0
  461. package/dist/models/walletCustodyInfoDataDtoWalletMode.d.ts.map +1 -0
  462. package/dist/models/walletCustodyInfoResponseDto.d.ts +13 -0
  463. package/dist/models/walletCustodyInfoResponseDto.d.ts.map +1 -0
  464. package/dist/models/walletDataDto.d.ts +29 -0
  465. package/dist/models/walletDataDto.d.ts.map +1 -0
  466. package/dist/models/walletDataDtoMetadata.d.ts +14 -0
  467. package/dist/models/walletDataDtoMetadata.d.ts.map +1 -0
  468. package/dist/models/walletDataDtoWalletMode.d.ts +13 -0
  469. package/dist/models/walletDataDtoWalletMode.d.ts.map +1 -0
  470. package/dist/models/walletDataDtoWalletType.d.ts +12 -0
  471. package/dist/models/walletDataDtoWalletType.d.ts.map +1 -0
  472. package/dist/models/walletSignerDataDto.d.ts +24 -0
  473. package/dist/models/walletSignerDataDto.d.ts.map +1 -0
  474. package/dist/models/walletSignerDataDtoPermissions.d.ts +11 -0
  475. package/dist/models/walletSignerDataDtoPermissions.d.ts.map +1 -0
  476. package/dist/models/walletSignerDataDtoSignerType.d.ts +15 -0
  477. package/dist/models/walletSignerDataDtoSignerType.d.ts.map +1 -0
  478. package/dist/models/walletSuccessResponseDto.d.ts +13 -0
  479. package/dist/models/walletSuccessResponseDto.d.ts.map +1 -0
  480. package/dist/models/walletsListResponseDto.d.ts +13 -0
  481. package/dist/models/walletsListResponseDto.d.ts.map +1 -0
  482. package/dist/models/webhookDataDto.d.ts +22 -0
  483. package/dist/models/webhookDataDto.d.ts.map +1 -0
  484. package/dist/models/webhookDataDtoLastTriggeredAt.d.ts +14 -0
  485. package/dist/models/webhookDataDtoLastTriggeredAt.d.ts.map +1 -0
  486. package/dist/models/webhookResponseDto.d.ts +13 -0
  487. package/dist/models/webhookResponseDto.d.ts.map +1 -0
  488. package/dist/models/webhooksListResponseDto.d.ts +13 -0
  489. package/dist/models/webhooksListResponseDto.d.ts.map +1 -0
  490. package/dist/plans.cjs +4 -1
  491. package/dist/plans.cjs.map +2 -2
  492. package/dist/plans.d.ts +6 -6
  493. package/dist/plans.d.ts.map +1 -1
  494. package/dist/plans.mjs +4 -1
  495. package/dist/plans.mjs.map +2 -2
  496. package/dist/platform.cjs +4 -1
  497. package/dist/platform.cjs.map +2 -2
  498. package/dist/platform.d.ts +24 -24
  499. package/dist/platform.d.ts.map +1 -1
  500. package/dist/platform.mjs +4 -1
  501. package/dist/platform.mjs.map +2 -2
  502. package/dist/signers/deviceIdentityHelpers.d.ts.map +1 -1
  503. package/dist/signers/emailSigner.d.ts.map +1 -1
  504. package/dist/signers/passkeyHelpers.d.ts.map +1 -1
  505. package/dist/signers/phoneSigner.d.ts.map +1 -1
  506. package/dist/signers/signerLifecycle.d.ts.map +1 -1
  507. package/dist/signers/walletTransactionHelpers.d.ts.map +1 -1
  508. package/dist/subscriptions.cjs.map +2 -2
  509. package/dist/subscriptions.d.ts +9 -9
  510. package/dist/subscriptions.d.ts.map +1 -1
  511. package/dist/subscriptions.mjs.map +2 -2
  512. package/dist/transactions.cjs.map +2 -2
  513. package/dist/transactions.d.ts +18 -6
  514. package/dist/transactions.d.ts.map +1 -1
  515. package/dist/transactions.mjs.map +2 -2
  516. package/dist/types.cjs.map +1 -1
  517. package/dist/types.d.ts +3 -1
  518. package/dist/types.d.ts.map +1 -1
  519. package/dist/user.cjs.map +2 -2
  520. package/dist/user.d.ts +4 -4
  521. package/dist/user.d.ts.map +1 -1
  522. package/dist/user.mjs.map +2 -2
  523. package/dist/utils/storage/adapters.d.ts +5 -1
  524. package/dist/utils/storage/adapters.d.ts.map +1 -1
  525. package/dist/utils/storage/encryption.d.ts +41 -0
  526. package/dist/utils/storage/encryption.d.ts.map +1 -0
  527. package/dist/utils/storage/index.d.ts +1 -1
  528. package/dist/utils/storage/index.d.ts.map +1 -1
  529. package/dist/wallet.cjs.map +2 -2
  530. package/dist/wallet.d.ts +46 -46
  531. package/dist/wallet.d.ts.map +1 -1
  532. package/dist/wallet.mjs.map +2 -2
  533. package/dist/webhooks.cjs.map +2 -2
  534. package/dist/webhooks.d.ts +5 -5
  535. package/dist/webhooks.d.ts.map +1 -1
  536. package/dist/webhooks.mjs.map +2 -2
  537. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,31 @@
1
1
  # Cilantro Smart SDK
2
2
 
3
- A TypeScript/JavaScript SDK for interacting with the Cilantro Smart API - A Solana wallet management system.
3
+ A TypeScript/JavaScript SDK for interacting with the Cilantro Smart API - A Solana wallet management system with comprehensive signer management, passkey support, and multi-device capabilities.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Quick Start](#quick-start)
9
+ - [Configuration](#configuration)
10
+ - [Complete API Reference](#complete-api-reference)
11
+ - [SDK Configuration](#sdk-configuration-cilantro-sdk)
12
+ - [Platform Module](#platform-module-cilantro-sdkplatform)
13
+ - [User Module](#user-module-cilantro-sdkuser)
14
+ - [Wallet Module](#wallet-module-cilantro-sdkwallet)
15
+ - [Auth Module](#auth-module-cilantro-sdkauth)
16
+ - [Subscriptions Module](#subscriptions-module-cilantro-sdksubscriptions)
17
+ - [Plans Module](#plans-module-cilantro-sdkplans)
18
+ - [Transactions Module](#transactions-module-cilantro-sdktransactions)
19
+ - [Delegated Keys Module](#delegated-keys-module-cilantro-sdkdelegated-keys)
20
+ - [Webhooks Module](#webhooks-module-cilantro-sdkwebhooks)
21
+ - [Helpers Module](#helpers-module-cilantro-sdkhelpers)
22
+ - [Utils Module](#utils-module-cilantro-sdkutils)
23
+ - [Examples & Use Cases](#examples--use-cases)
24
+ - [Error Handling](#error-handling)
25
+ - [TypeScript Support](#typescript-support)
26
+ - [Cross-Platform Support](#cross-platform-support)
27
+ - [Best Practices](#best-practices)
28
+ - [License](#license)
4
29
 
5
30
  ## Installation
6
31
 
@@ -133,189 +158,2656 @@ const keypair = await getEmailSignerKeypair(
133
158
  ### Available Helpers
134
159
 
135
160
  **Device Key Management:**
136
- - `getDevicePublicKey()` - Get or create device key with caching
137
161
  - `generateDeviceKeyPair()` - Generate new device key pair
138
- - `rotateDeviceKey()` - Rotate device keys
139
- - `clearDeviceKeyCache()` - Clear cache
140
- - `findDeviceKeyByPublicKey()` - Find device key by public key
141
- - `listAllDeviceKeys()` - List all device keys with metadata
162
+ - `getOrCreateDeviceKeyPair(storage, keyId?)` - Get or create device key pair with caching
163
+ - `getDevicePublicKey(storage, keyId)` - Get device public key
164
+ - `getDevicePrivateKey(storage, keyId)` - Get device private key
165
+ - `rotateDeviceKey(storage, keyId)` - Rotate device keys
166
+ - `clearDeviceKeyCache(keyId?)` - Clear device key cache
167
+ - `deleteDeviceKey(storage, keyId)` - Delete device key
168
+ - `listDeviceKeys(storage)` - List all device key IDs
169
+ - `findDeviceKeyByPublicKey(storage, publicKey)` - Find device key by public key
170
+ - `listAllDeviceKeys(storage)` - List all device keys with metadata
142
171
 
143
172
  **Email Signer Helpers:**
144
- - `createEmailSignerHelper()` - Create email signer with automatic device key generation
145
- - `getEmailSignerKeypair()` - Get keypair with automatic device key resolution
146
- - `signWithEmailSigner()` - Sign messages with email signer
147
- - `getEmailSignerByEmail()` - Find email signer by email address
173
+ - `createEmailSignerHelper(walletId, options)` - Create email signer with automatic device key generation
174
+ - `getEmailSignerKeypair(walletId, signerId, options)` - Get keypair with automatic device key resolution
175
+ - `signWithEmailSigner(walletId, signerId, message, options)` - Sign messages with email signer
176
+ - `clearEmailSignerCache(walletId, signerId?)` - Clear email signer cache
177
+ - `getEmailSignerByEmail(walletId, email)` - Find email signer by email address
148
178
 
149
179
  **Phone Signer Helpers:**
150
- - `createPhoneSignerHelper()` - Create phone signer with automatic device key generation
151
- - `getPhoneSignerKeypair()` - Get keypair with automatic device key resolution
152
- - `signWithPhoneSigner()` - Sign messages with phone signer
153
- - `getPhoneSignerByPhone()` - Find phone signer by phone number
180
+ - `createPhoneSignerHelper(walletId, options)` - Create phone signer with automatic device key generation
181
+ - `getPhoneSignerKeypair(walletId, signerId, options)` - Get keypair with automatic device key resolution
182
+ - `signWithPhoneSigner(walletId, signerId, message, options)` - Sign messages with phone signer
183
+ - `clearPhoneSignerCache(walletId, signerId?)` - Clear phone signer cache
184
+ - `getPhoneSignerByPhone(walletId, phone)` - Find phone signer by phone number
185
+
186
+ **Passkey (WebAuthn) Helpers:**
187
+ - `isWebAuthnSupported()` - Check if WebAuthn is supported
188
+ - `isPlatformAuthenticatorAvailable()` - Check if platform authenticator is available
189
+ - `registerPasskey(walletId, options?)` - Register a new passkey
190
+ - `authenticateWithPasskey(walletId, options?)` - Authenticate with existing passkey
191
+ - `formatRegistrationResponse(response)` - Format passkey registration response
192
+ - `formatAuthenticationResponse(response)` - Format passkey authentication response
193
+ - `formatAuthenticationForVerification(response)` - Format authentication for verification
194
+ - `findExistingPasskeySigner(walletId, credentialId?)` - Find existing passkey signer
195
+ - `registerPasskeyComplete(walletId, registrationData, verificationData)` - Complete passkey registration
196
+ - `signWithPasskeySigner(walletId, signerId, message, options)` - Sign with passkey signer
154
197
 
155
198
  **Device Key Validation & Resolution:**
156
- - `getSignerDeviceKeys()` - Get all device keys for a signer from API
157
- - `validateDeviceKey()` - Validate device key matches API
158
- - `resolveDeviceKey()` - Automatically find matching device key
159
- - `getBestDeviceIdentity()` - Get most recently used device identity
199
+ - `getSignerDeviceKeys(walletId, signerId)` - Get all device keys for a signer from API
200
+ - `validateDeviceKey(storage, keyId, expectedPublicKey)` - Validate device key matches API
201
+ - `resolveDeviceKey(storage, walletId, signerId)` - Automatically find matching device key
202
+ - `findAndValidateDeviceKey(storage, walletId, signerId, devicePublicKey)` - Find and validate device key
203
+ - `getBestDeviceIdentity(walletId, signerId)` - Get most recently used device identity
160
204
 
161
205
  **Device Identity Management:**
162
- - `addDeviceIdentityToSigner()` - Add new device to existing signer
163
- - `replaceDeviceIdentity()` - Replace existing device identity
164
- - `addNewDeviceToSigner()` - Convenience function for adding new device
165
- - `canAddDeviceToSigner()` - Check if device can be added
206
+ - `addDeviceIdentityToSigner(walletId, signerId, options)` - Add new device to existing signer
207
+ - `replaceDeviceIdentity(walletId, signerId, options)` - Replace existing device identity
208
+ - `addNewDeviceToSigner(walletId, signerId, options)` - Convenience function for adding new device
209
+ - `canAddDeviceToSigner(walletId, signerId)` - Check if device can be added to signer
210
+
211
+ **Signer Lifecycle:**
212
+ - `createSigner(walletId, signerType, config)` - Create a new signer
213
+ - `revokeSigner(walletId, signerId)` - Revoke a signer
214
+ - `getSigners(walletId)` - Get all signers for a wallet
215
+
216
+ **Multi-Device Management:**
217
+ - `addDevice(walletId, signerId, devicePublicKey)` - Add device to signer
218
+ - `replaceDevice(walletId, signerId, oldDeviceId, newDevicePublicKey)` - Replace device
219
+ - `getDevices(walletId, signerId)` - Get all devices for a signer
220
+ - `updateDevice(walletId, signerId, deviceId, data)` - Update device information
221
+
222
+ **Core Signer Helpers:**
223
+ - `deriveSignerKeypair(walletId, signerId, options)` - Derive signer keypair from encrypted secret
224
+ - `signWithSigner(walletId, signerId, message, options)` - Sign message with signer
225
+ - `parseSignerResponse(response)` - Parse signer API response to SignerInfo
226
+ - `clearSignerCache(walletId?, signerId?)` - Clear signer keypair cache
227
+ - `getCacheStats()` - Get cache statistics
228
+
229
+ **Validation:**
230
+ - `isValidEmail(email)` - Validate email format
231
+ - `isValidPhone(phone)` - Validate phone number format
232
+ - `isBrowserCompatible()` - Check if browser is compatible
233
+
234
+ **External Wallet Adapter:**
235
+ - `detectWallets()` - Detect available Solana wallets
236
+ - `getWallet(name)` - Get wallet by name
237
+ - `connectWallet(wallet)` - Connect to external wallet
238
+ - `signTransaction(wallet, transaction)` - Sign transaction with external wallet
239
+ - `signMessage(wallet, message)` - Sign message with external wallet
240
+
241
+ **Wallet Transaction Helpers:**
242
+ - `signTransactionWithEmailSigner(walletId, signerId, transaction, options)` - Sign transaction with email signer
243
+ - `signTransactionWithPhoneSigner(walletId, signerId, transaction, options)` - Sign transaction with phone signer
244
+ - `signTransactionWithPasskeySigner(walletId, signerId, transaction, options)` - Sign transaction with passkey signer
245
+ - `signTransactionWithExternalWallet(wallet, transaction)` - Sign transaction with external wallet
246
+ - `prepareSignAndSubmitTransaction(walletId, transaction, signerConfig)` - Prepare, sign, and submit transaction
247
+ - `sendSOLWithSigner(walletId, recipientAddress, amountLamports, signerConfig)` - Send SOL using signer
248
+ - `sendSPLWithSigner(walletId, recipientAddress, mintAddress, amount, signerConfig)` - Send SPL token using signer
166
249
 
167
250
  **Storage Adapters:**
168
- - `createLocalStorageAdapter()` - Browser localStorage adapter
169
- - `createFileSystemAdapter()` - Node.js filesystem adapter
170
- - `createMemoryAdapter()` - In-memory adapter (for testing)
171
- - `getDefaultStorageAdapter()` - Get platform-appropriate adapter
251
+ - `createMemoryAdapter()` - Create in-memory storage adapter (for testing)
252
+ - `createLocalStorageAdapter()` - Create browser localStorage adapter
253
+ - `createFileSystemAdapter(basePath)` - Create Node.js filesystem adapter
254
+ - `getDefaultStorageAdapter()` - Get platform-appropriate storage adapter
255
+
256
+ **Key Format Utilities:**
257
+ - `normalizeSPKI(spkiKey)` - Normalize SPKI key format
258
+ - `base64ToPEM(base64Key, keyType)` - Convert base64 to PEM format
259
+ - `pemToBase64(pemKey)` - Convert PEM to base64
260
+ - `base64ToArrayBuffer(base64)` - Convert base64 to ArrayBuffer
261
+ - `arrayBufferToBase64(buffer)` - Convert ArrayBuffer to base64
262
+ - `importSPKIPublicKey(spkiBase64)` - Import SPKI public key
263
+ - `exportToSPKI(key)` - Export key to SPKI format
264
+ - `isValidBase64(str)` - Validate base64 string
172
265
 
173
266
  For detailed documentation on device key management, see [DEVICE_KEY_MANAGEMENT.md](./DEVICE_KEY_MANAGEMENT.md).
174
267
 
175
268
  ## Configuration
176
269
 
177
- ### `configure(config)`
270
+ ### `configure(config: SDKConfig): void`
271
+
272
+ Initialize the SDK with configuration options. This should be called once at the start of your application.
273
+
274
+ **Parameters:**
275
+ - `config` (`SDKConfig`): Configuration object
276
+ - `apiKey?` (`string`): API key for authentication (recommended for server-side)
277
+ - `jwt?` (`string`): JWT token for authentication (obtained from login)
278
+ - `baseURL?` (`string`): Custom API base URL (defaults to `https://api.cilantro.gg`)
279
+
280
+ **Returns:** `void`
281
+
282
+ **Example:**
283
+ ```typescript
284
+ import { configure } from 'cilantro-sdk';
285
+
286
+ // Configure with API key (server-side)
287
+ configure({
288
+ apiKey: 'your-api-key',
289
+ baseURL: 'https://api.cilantro.gg'
290
+ });
291
+
292
+ // Configure with JWT (after login)
293
+ configure({
294
+ jwt: 'your-jwt-token'
295
+ });
296
+
297
+ // Configure with both
298
+ configure({
299
+ apiKey: 'your-api-key',
300
+ jwt: 'your-jwt-token'
301
+ });
302
+ ```
303
+
304
+ ### `setAuth(auth: { jwt?: string; apiKey?: string }): void`
305
+
306
+ Update authentication credentials after initialization. Useful when credentials change (e.g., after login or token refresh).
307
+
308
+ **Parameters:**
309
+ - `auth` (`object`): Authentication credentials
310
+ - `jwt?` (`string`): JWT token to set
311
+ - `apiKey?` (`string`): API key to set
312
+
313
+ **Returns:** `void`
314
+
315
+ **Example:**
316
+ ```typescript
317
+ import { setAuth } from 'cilantro-sdk';
318
+ import { login } from 'cilantro-sdk/auth';
319
+
320
+ // Login and update auth
321
+ const result = await login({
322
+ usernameOrEmail: 'user@example.com',
323
+ password: 'password123'
324
+ });
325
+
326
+ setAuth({ jwt: result.data.jwt });
327
+ ```
328
+
329
+ ### `clearAuth(): void`
330
+
331
+ Clear all authentication credentials. Useful for logout or resetting authentication state.
332
+
333
+ **Parameters:** None
334
+
335
+ **Returns:** `void`
336
+
337
+ **Example:**
338
+ ```typescript
339
+ import { clearAuth } from 'cilantro-sdk';
340
+
341
+ // Clear all authentication
342
+ clearAuth();
343
+ ```
344
+
345
+ ### Authentication Types
346
+
347
+ The SDK supports two types of authentication:
348
+
349
+ 1. **API Key Authentication**: For server-side applications and platform-level access
350
+ - Use when you have a platform API key
351
+ - Best for server-side operations
352
+ - Set via `configure({ apiKey: '...' })` or `setAuth({ apiKey: '...' })`
353
+
354
+ 2. **JWT Token Authentication**: For user-specific operations after login
355
+ - Use after user/platform login
356
+ - Best for user-scoped operations
357
+ - Set via `configure({ jwt: '...' })` or `setAuth({ jwt: '...' })`
358
+
359
+ You can use either or both simultaneously. The SDK will automatically include the appropriate headers in all requests.
360
+
361
+ ## Documentation
362
+
363
+ ### Getting Started Guides
364
+
365
+ - **[Complete Wallet & Transaction Flow Guide](./WALLET_TRANSACTION_FLOW.md)** - Comprehensive step-by-step guide covering:
366
+ - Wallet creation (platform-controlled vs user-controlled)
367
+ - Understanding and creating signers (email, phone, passkey, external, API key)
368
+ - Device key management and ECDH encryption
369
+ - Complete transaction flows (server-side and client-side signing)
370
+ - Real-world examples and best practices
371
+
372
+ - **[Device Key Management Guide](./DEVICE_KEY_MANAGEMENT.md)** - Deep dive into device key architecture
373
+
374
+ ### Quick Links
375
+
376
+ - [Examples](./examples/) - Code examples
377
+ - [API Documentation](https://api.cilantro.gg/docs) - Complete API reference
378
+
379
+ ## Module Structure
380
+
381
+ The SDK is organized into modules for better code organization:
382
+
383
+ - **Platform** (`cilantro-sdk/platform`) - Platform management and user operations
384
+ - **User** (`cilantro-sdk/user`) - User account operations
385
+ - **Wallet** (`cilantro-sdk/wallet`) - Wallet and blockchain operations
386
+ - **Auth** (`cilantro-sdk/auth`) - Universal authentication
387
+ - **Subscriptions** (`cilantro-sdk/subscriptions`) - Subscription management operations
388
+ - **Plans** (`cilantro-sdk/plans`) - Subscription plan management operations
389
+ - **Transactions** (`cilantro-sdk/transactions`) - Transaction history and status queries
390
+ - **Delegated Keys** (`cilantro-sdk/delegated-keys`) - Temporary key management for session-based signing
391
+ - **Webhooks** (`cilantro-sdk/webhooks`) - Webhook endpoint management for event notifications
392
+ - **Utils** (`cilantro-sdk/utils`) - Utility functions
393
+ - **Helpers** (`cilantro-sdk/helpers`) - Device key management and signer helpers
394
+
395
+ ## Complete API Reference
396
+
397
+ ### SDK Configuration (`cilantro-sdk`)
398
+
399
+ #### `configure(config: SDKConfig): void`
178
400
 
179
401
  Initialize the SDK with configuration options.
180
402
 
403
+ **Parameters:**
404
+ - `config` (`SDKConfig`): Configuration object
405
+ - `apiKey?` (`string`): API key for server-side authentication
406
+ - `jwt?` (`string`): JWT token for user authentication
407
+ - `baseURL?` (`string`): Custom API base URL (default: `https://api.cilantro.gg`)
408
+
409
+ **Returns:** `void`
410
+
411
+ **Example:**
412
+ ```typescript
413
+ import { configure } from 'cilantro-sdk';
414
+
415
+ configure({
416
+ apiKey: 'your-api-key',
417
+ baseURL: 'https://api.cilantro.gg'
418
+ });
419
+ ```
420
+
421
+ #### `setAuth(auth: { jwt?: string; apiKey?: string }): void`
422
+
423
+ Update authentication credentials after initialization.
424
+
425
+ **Parameters:**
426
+ - `auth` (`object`): Authentication credentials
427
+ - `jwt?` (`string`): JWT token
428
+ - `apiKey?` (`string`): API key
429
+
430
+ **Returns:** `void`
431
+
432
+ **Example:**
433
+ ```typescript
434
+ import { setAuth } from 'cilantro-sdk';
435
+
436
+ setAuth({ jwt: 'your-jwt-token' });
437
+ ```
438
+
439
+ #### `clearAuth(): void`
440
+
441
+ Clear all authentication credentials.
442
+
443
+ **Parameters:** None
444
+
445
+ **Returns:** `void`
446
+
447
+ **Example:**
448
+ ```typescript
449
+ import { clearAuth } from 'cilantro-sdk';
450
+
451
+ clearAuth();
452
+ ```
453
+
454
+ #### `generateDevicePublicKey(): Promise<string>`
455
+
456
+ Generate a device public key for ECDH (P-256) encryption. Works in both browser and Node.js environments.
457
+
458
+ **Parameters:** None
459
+
460
+ **Returns:** `Promise<string>` - Base64-encoded P-256 ECDH public key (65 bytes, uncompressed format)
461
+
462
+ **Example:**
463
+ ```typescript
464
+ import { generateDevicePublicKey } from 'cilantro-sdk';
465
+
466
+ const devicePublicKey = await generateDevicePublicKey();
467
+ // Use with createEmailSigner or createPhoneSigner
468
+ ```
469
+
470
+ #### `updateDeviceIdentity(walletId: string, signerId: string, data: UpdateDeviceIdentityDto): Promise<WalletControllerUpdateDeviceIdentityResult>`
471
+
472
+ Update device identity for a signer. Used to add or replace device keys associated with email/phone signers.
473
+
474
+ **Parameters:**
475
+ - `walletId` (`string`): Wallet ID
476
+ - `signerId` (`string`): Signer ID
477
+ - `data` (`UpdateDeviceIdentityDto`): Device identity data
478
+ - `devicePublicKey` (`string`): Base64-encoded device public key
479
+ - `deviceId?` (`string`): Optional device ID (for replacing existing device)
480
+ - `replace?` (`boolean`): Whether to replace existing device
481
+
482
+ **Returns:** `Promise<WalletControllerUpdateDeviceIdentityResult>` - Updated device identity information
483
+
484
+ **Example:**
485
+ ```typescript
486
+ import { updateDeviceIdentity, generateDevicePublicKey } from 'cilantro-sdk';
487
+
488
+ const devicePublicKey = await generateDevicePublicKey();
489
+ await updateDeviceIdentity('wallet-id', 'signer-id', {
490
+ devicePublicKey,
491
+ replace: false
492
+ });
493
+ ```
494
+
495
+ ### Platform Module (`cilantro-sdk/platform`)
496
+
497
+ #### Platform Management
498
+
499
+ ##### `create(data: CreatePlatformDto): Promise<PlatformControllerCreateResult>`
500
+
501
+ Create a new platform account.
502
+
503
+ **Parameters:**
504
+ - `data` (`CreatePlatformDto`): Platform creation data
505
+ - `platformName` (`string`): Platform name
506
+ - `email` (`string`): Platform email
507
+ - `password` (`string`): Platform password
508
+ - `billingCycle?` (`'monthly' | 'yearly'`): Billing cycle preference
509
+
510
+ **Returns:** `Promise<PlatformControllerCreateResult>` - Created platform information
511
+
512
+ **Example:**
513
+ ```typescript
514
+ import { platform } from 'cilantro-sdk';
515
+
516
+ const newPlatform = await platform.create({
517
+ platformName: 'My Platform',
518
+ email: 'platform@example.com',
519
+ password: 'SecurePass123!',
520
+ billingCycle: 'monthly'
521
+ });
522
+ ```
523
+
524
+ ##### `findAll(params?: PlatformControllerFindAllParams): Promise<PlatformControllerFindAllResult>`
525
+
526
+ Get all platforms with optional filters.
527
+
528
+ **Parameters:**
529
+ - `params?` (`PlatformControllerFindAllParams`): Optional query parameters
530
+ - `page?` (`number`): Page number for pagination
531
+ - `limit?` (`number`): Items per page
532
+ - `search?` (`string`): Search term
533
+
534
+ **Returns:** `Promise<PlatformControllerFindAllResult>` - Paginated list of platforms
535
+
536
+ **Example:**
537
+ ```typescript
538
+ const platforms = await platform.findAll({
539
+ page: 1,
540
+ limit: 20,
541
+ search: 'example'
542
+ });
543
+ ```
544
+
545
+ ##### `findOne(platformId: string): Promise<PlatformControllerFindOneResult>`
546
+
547
+ Get platform by ID.
548
+
549
+ **Parameters:**
550
+ - `platformId` (`string`): Platform ID
551
+
552
+ **Returns:** `Promise<PlatformControllerFindOneResult>` - Platform details
553
+
554
+ **Example:**
555
+ ```typescript
556
+ const platformData = await platform.findOne('platform-id');
557
+ ```
558
+
559
+ ##### `update(platformId: string, data: UpdatePlatformDto): Promise<PlatformControllerUpdateResult>`
560
+
561
+ Update platform information.
562
+
563
+ **Parameters:**
564
+ - `platformId` (`string`): Platform ID
565
+ - `data` (`UpdatePlatformDto`): Update data
566
+ - `platformName?` (`string`): New platform name
567
+ - `email?` (`string`): New email
568
+ - `isActive?` (`boolean`): Active status
569
+
570
+ **Returns:** `Promise<PlatformControllerUpdateResult>` - Updated platform information
571
+
572
+ **Example:**
573
+ ```typescript
574
+ await platform.update('platform-id', {
575
+ platformName: 'Updated Name'
576
+ });
577
+ ```
578
+
579
+ ##### `remove(platformId: string): Promise<PlatformControllerRemoveResult>`
580
+
581
+ Remove (delete) a platform.
582
+
583
+ **Parameters:**
584
+ - `platformId` (`string`): Platform ID
585
+
586
+ **Returns:** `Promise<PlatformControllerRemoveResult>` - Removal confirmation
587
+
588
+ **Example:**
589
+ ```typescript
590
+ await platform.remove('platform-id');
591
+ ```
592
+
593
+ ##### `getOwnProfile(): Promise<PlatformControllerGetOwnProfileResult>`
594
+
595
+ Get current platform's profile (authenticated platform).
596
+
597
+ **Parameters:** None
598
+
599
+ **Returns:** `Promise<PlatformControllerGetOwnProfileResult>` - Current platform profile
600
+
601
+ **Example:**
602
+ ```typescript
603
+ const profile = await platform.getOwnProfile();
604
+ ```
605
+
606
+ ##### `updateOwnProfile(data: UpdatePlatformDto): Promise<PlatformControllerUpdateOwnProfileResult>`
607
+
608
+ Update current platform's profile.
609
+
610
+ **Parameters:**
611
+ - `data` (`UpdatePlatformDto`): Update data
612
+
613
+ **Returns:** `Promise<PlatformControllerUpdateOwnProfileResult>` - Updated profile
614
+
615
+ **Example:**
616
+ ```typescript
617
+ await platform.updateOwnProfile({
618
+ platformName: 'New Name'
619
+ });
620
+ ```
621
+
622
+ ##### `changePassword(data: ChangePasswordDto): Promise<PlatformControllerChangePasswordResult>`
623
+
624
+ Change platform password.
625
+
626
+ **Parameters:**
627
+ - `data` (`ChangePasswordDto`): Password change data
628
+ - `currentPassword` (`string`): Current password
629
+ - `newPassword` (`string`): New password
630
+
631
+ **Returns:** `Promise<PlatformControllerChangePasswordResult>` - Password change confirmation
632
+
633
+ **Example:**
634
+ ```typescript
635
+ await platform.changePassword({
636
+ currentPassword: 'old-password',
637
+ newPassword: 'new-secure-password'
638
+ });
639
+ ```
640
+
641
+ #### User Management
642
+
643
+ ##### `getUsers(platformId: string, params?: PlatformControllerGetUsersForPlatformParams): Promise<PlatformControllerGetUsersForPlatformResult>`
644
+
645
+ Get all users for a platform.
646
+
647
+ **Parameters:**
648
+ - `platformId` (`string`): Platform ID
649
+ - `params?` (`object`): Optional query parameters
650
+ - `page?` (`number`): Page number
651
+ - `limit?` (`number`): Items per page
652
+ - `search?` (`string`): Search term
653
+ - `isActive?` (`boolean`): Filter by active status
654
+
655
+ **Returns:** `Promise<PlatformControllerGetUsersForPlatformResult>` - Paginated list of users
656
+
657
+ **Example:**
658
+ ```typescript
659
+ const users = await platform.getUsers('platform-id', {
660
+ page: 1,
661
+ limit: 20,
662
+ isActive: true
663
+ });
664
+ ```
665
+
666
+ ##### `createUser(platformId: string, data: CreateUserDto): Promise<PlatformControllerCreateUserForPlatformResult>`
667
+
668
+ Create a new user for the platform.
669
+
670
+ **Parameters:**
671
+ - `platformId` (`string`): Platform ID
672
+ - `data` (`CreateUserDto`): User creation data
673
+ - `username` (`string`): Username
674
+ - `email` (`string`): Email address
675
+ - `password` (`string`): Password
676
+
677
+ **Returns:** `Promise<PlatformControllerCreateUserForPlatformResult>` - Created user information
678
+
679
+ **Example:**
680
+ ```typescript
681
+ const user = await platform.createUser('platform-id', {
682
+ username: 'johndoe',
683
+ email: 'john@example.com',
684
+ password: 'SecurePass123!'
685
+ });
686
+ ```
687
+
688
+ ##### `updateUser(platformId: string, userId: string, data: UpdateUserDto): Promise<PlatformControllerUpdateUserForPlatformResult>`
689
+
690
+ Update user information.
691
+
692
+ **Parameters:**
693
+ - `platformId` (`string`): Platform ID
694
+ - `userId` (`string`): User ID
695
+ - `data` (`UpdateUserDto`): Update data
696
+ - `username?` (`string`): New username
697
+ - `email?` (`string`): New email
698
+ - `isActive?` (`boolean`): Active status
699
+
700
+ **Returns:** `Promise<PlatformControllerUpdateUserForPlatformResult>` - Updated user information
701
+
702
+ **Example:**
703
+ ```typescript
704
+ await platform.updateUser('platform-id', 'user-id', {
705
+ username: 'newusername'
706
+ });
707
+ ```
708
+
709
+ ##### `removeUser(platformId: string, userId: string): Promise<PlatformControllerRemoveUserForPlatformResult>`
710
+
711
+ Remove user from platform.
712
+
713
+ **Parameters:**
714
+ - `platformId` (`string`): Platform ID
715
+ - `userId` (`string`): User ID
716
+
717
+ **Returns:** `Promise<PlatformControllerRemoveUserForPlatformResult>` - Removal confirmation
718
+
719
+ **Example:**
720
+ ```typescript
721
+ await platform.removeUser('platform-id', 'user-id');
722
+ ```
723
+
724
+ ##### `toggleUserActive(platformId: string, userId: string): Promise<PlatformControllerToggleUserActiveForPlatformResult>`
725
+
726
+ Toggle user active status.
727
+
728
+ **Parameters:**
729
+ - `platformId` (`string`): Platform ID
730
+ - `userId` (`string`): User ID
731
+
732
+ **Returns:** `Promise<PlatformControllerToggleUserActiveForPlatformResult>` - Updated user status
733
+
734
+ **Example:**
735
+ ```typescript
736
+ await platform.toggleUserActive('platform-id', 'user-id');
737
+ ```
738
+
739
+ #### Wallet Management
740
+
741
+ ##### `getWallets(platformId: string, params?: PlatformControllerGetWalletsForPlatformParams): Promise<PlatformControllerGetWalletsForPlatformResult>`
742
+
743
+ Get all wallets for a platform (read-only).
744
+
745
+ **Parameters:**
746
+ - `platformId` (`string`): Platform ID
747
+ - `params?` (`object`): Optional query parameters
748
+ - `page?` (`number`): Page number
749
+ - `limit?` (`number`): Items per page
750
+
751
+ **Returns:** `Promise<PlatformControllerGetWalletsForPlatformResult>` - Paginated list of wallets
752
+
753
+ **Example:**
754
+ ```typescript
755
+ const wallets = await platform.getWallets('platform-id', {
756
+ page: 1,
757
+ limit: 20
758
+ });
759
+ ```
760
+
761
+ #### Subscription Management
762
+
763
+ ##### `getSubscriptions(platformId: string, params?: PlatformControllerGetSubscriptionsForPlatformParams): Promise<PlatformControllerGetSubscriptionsForPlatformResult>`
764
+
765
+ Get all subscriptions for a platform.
766
+
767
+ **Parameters:**
768
+ - `platformId` (`string`): Platform ID
769
+ - `params?` (`object`): Optional query parameters
770
+ - `status?` (`string`): Filter by status
771
+ - `page?` (`number`): Page number
772
+ - `limit?` (`number`): Items per page
773
+
774
+ **Returns:** `Promise<PlatformControllerGetSubscriptionsForPlatformResult>` - Paginated list of subscriptions
775
+
776
+ **Example:**
777
+ ```typescript
778
+ const subscriptions = await platform.getSubscriptions('platform-id', {
779
+ status: 'active'
780
+ });
781
+ ```
782
+
783
+ ##### `getSubscriptionById(platformId: string, subscriptionId: string): Promise<PlatformControllerGetSubscriptionByIdResult>`
784
+
785
+ Get subscription by ID.
786
+
787
+ **Parameters:**
788
+ - `platformId` (`string`): Platform ID
789
+ - `subscriptionId` (`string`): Subscription ID
790
+
791
+ **Returns:** `Promise<PlatformControllerGetSubscriptionByIdResult>` - Subscription details
792
+
793
+ **Example:**
794
+ ```typescript
795
+ const subscription = await platform.getSubscriptionById('platform-id', 'subscription-id');
796
+ ```
797
+
798
+ ##### `renewSubscription(platformId: string, subscriptionId: string, data: RenewSubscriptionDto): Promise<PlatformControllerRenewSubscriptionResult>`
799
+
800
+ Renew a subscription.
801
+
802
+ **Parameters:**
803
+ - `platformId` (`string`): Platform ID
804
+ - `subscriptionId` (`string`): Subscription ID
805
+ - `data` (`RenewSubscriptionDto`): Renewal data
806
+ - `extendByDays?` (`number`): Days to extend
807
+ - `extendByMonths?` (`number`): Months to extend
808
+
809
+ **Returns:** `Promise<PlatformControllerRenewSubscriptionResult>` - Renewed subscription
810
+
811
+ **Example:**
812
+ ```typescript
813
+ await platform.renewSubscription('platform-id', 'subscription-id', {
814
+ extendByMonths: 1
815
+ });
816
+ ```
817
+
818
+ ##### `upgradeSubscription(platformId: string, subscriptionId: string, data: UpgradeSubscriptionDto): Promise<PlatformControllerUpgradeSubscriptionResult>`
819
+
820
+ Upgrade a subscription to a higher tier.
821
+
822
+ **Parameters:**
823
+ - `platformId` (`string`): Platform ID
824
+ - `subscriptionId` (`string`): Subscription ID
825
+ - `data` (`UpgradeSubscriptionDto`): Upgrade data
826
+ - `newPlanId` (`string`): New plan ID
827
+ - `effectiveDate?` (`string`): Effective date (ISO 8601)
828
+
829
+ **Returns:** `Promise<PlatformControllerUpgradeSubscriptionResult>` - Upgraded subscription
830
+
831
+ **Example:**
832
+ ```typescript
833
+ await platform.upgradeSubscription('platform-id', 'subscription-id', {
834
+ newPlanId: 'premium-plan-id',
835
+ effectiveDate: '2024-01-01T00:00:00Z'
836
+ });
837
+ ```
838
+
839
+ ##### `downgradeSubscription(platformId: string, subscriptionId: string, data: DowngradeSubscriptionDto): Promise<PlatformControllerDowngradeSubscriptionResult>`
840
+
841
+ Downgrade a subscription to a lower tier.
842
+
843
+ **Parameters:**
844
+ - `platformId` (`string`): Platform ID
845
+ - `subscriptionId` (`string`): Subscription ID
846
+ - `data` (`DowngradeSubscriptionDto`): Downgrade data
847
+ - `newPlanId` (`string`): New plan ID
848
+
849
+ **Returns:** `Promise<PlatformControllerDowngradeSubscriptionResult>` - Downgraded subscription
850
+
851
+ **Example:**
852
+ ```typescript
853
+ await platform.downgradeSubscription('platform-id', 'subscription-id', {
854
+ newPlanId: 'basic-plan-id'
855
+ });
856
+ ```
857
+
858
+ ##### `cancelSubscription(platformId: string, subscriptionId: string, data: CancelSubscriptionDto): Promise<PlatformControllerCancelSubscriptionResult>`
859
+
860
+ Cancel a subscription.
861
+
862
+ **Parameters:**
863
+ - `platformId` (`string`): Platform ID
864
+ - `subscriptionId` (`string`): Subscription ID
865
+ - `data` (`CancelSubscriptionDto`): Cancellation data
866
+ - `cancelAtPeriodEnd?` (`boolean`): Cancel at period end
867
+
868
+ **Returns:** `Promise<PlatformControllerCancelSubscriptionResult>` - Cancellation confirmation
869
+
870
+ **Example:**
871
+ ```typescript
872
+ await platform.cancelSubscription('platform-id', 'subscription-id', {
873
+ cancelAtPeriodEnd: true
874
+ });
875
+ ```
876
+
877
+ ##### `getSubscriptionHistory(platformId: string, subscriptionId: string): Promise<PlatformControllerGetSubscriptionHistoryResult>`
878
+
879
+ Get subscription history/audit trail.
880
+
881
+ **Parameters:**
882
+ - `platformId` (`string`): Platform ID
883
+ - `subscriptionId` (`string`): Subscription ID
884
+
885
+ **Returns:** `Promise<PlatformControllerGetSubscriptionHistoryResult>` - Subscription history
886
+
887
+ **Example:**
888
+ ```typescript
889
+ const history = await platform.getSubscriptionHistory('platform-id', 'subscription-id');
890
+ ```
891
+
892
+ #### Payment Management
893
+
894
+ ##### `confirmPayment(platformId: string, data: ConfirmPaymentDto): Promise<PlatformControllerConfirmPaymentResult>`
895
+
896
+ Confirm a payment transaction.
897
+
898
+ **Parameters:**
899
+ - `platformId` (`string`): Platform ID
900
+ - `data` (`ConfirmPaymentDto`): Payment confirmation data
901
+ - `paymentId` (`string`): Payment ID
902
+ - `transactionId?` (`string`): Transaction ID
903
+
904
+ **Returns:** `Promise<PlatformControllerConfirmPaymentResult>` - Payment confirmation
905
+
906
+ **Example:**
907
+ ```typescript
908
+ await platform.confirmPayment('platform-id', {
909
+ paymentId: 'payment-id',
910
+ transactionId: 'tx-id'
911
+ });
912
+ ```
913
+
914
+ ##### `linkPayment(platformId: string, data: LinkPaymentDto): Promise<PlatformControllerLinkPaymentResult>`
915
+
916
+ Link a payment method to the platform.
917
+
918
+ **Parameters:**
919
+ - `platformId` (`string`): Platform ID
920
+ - `data` (`LinkPaymentDto`): Payment method data
921
+ - `paymentMethodId` (`string`): Payment method ID
922
+ - `isDefault?` (`boolean`): Set as default
923
+
924
+ **Returns:** `Promise<PlatformControllerLinkPaymentResult>` - Linked payment method
925
+
926
+ **Example:**
927
+ ```typescript
928
+ await platform.linkPayment('platform-id', {
929
+ paymentMethodId: 'pm-id',
930
+ isDefault: true
931
+ });
932
+ ```
933
+
934
+ ##### `getPaymentHistory(platformId: string, params?: PlatformControllerGetPaymentHistoryParams): Promise<PlatformControllerGetPaymentHistoryResult>`
935
+
936
+ Get payment history for a platform.
937
+
938
+ **Parameters:**
939
+ - `platformId` (`string`): Platform ID
940
+ - `params?` (`object`): Optional query parameters
941
+ - `page?` (`number`): Page number
942
+ - `limit?` (`number`): Items per page
943
+ - `startDate?` (`string`): Start date filter
944
+ - `endDate?` (`string`): End date filter
945
+
946
+ **Returns:** `Promise<PlatformControllerGetPaymentHistoryResult>` - Paginated payment history
947
+
948
+ **Example:**
949
+ ```typescript
950
+ const payments = await platform.getPaymentHistory('platform-id', {
951
+ page: 1,
952
+ limit: 20
953
+ });
954
+ ```
955
+
956
+ ### User Module (`cilantro-sdk/user`)
957
+
958
+ #### `create(data: CreateUserDto): Promise<UserControllerCreateResult>`
959
+
960
+ Create a new user account.
961
+
962
+ **Parameters:**
963
+ - `data` (`CreateUserDto`): User creation data
964
+ - `username` (`string`): Username
965
+ - `email` (`string`): Email address
966
+ - `password` (`string`): Password
967
+
968
+ **Returns:** `Promise<UserControllerCreateResult>` - Created user information
969
+
970
+ **Example:**
971
+ ```typescript
972
+ import { user } from 'cilantro-sdk';
973
+
974
+ const newUser = await user.create({
975
+ username: 'johndoe',
976
+ email: 'john@example.com',
977
+ password: 'SecurePass123!'
978
+ });
979
+ ```
980
+
981
+ #### `findOne(userId: string): Promise<UserControllerFindOneResult>`
982
+
983
+ Get user by ID.
984
+
985
+ **Parameters:**
986
+ - `userId` (`string`): User ID
987
+
988
+ **Returns:** `Promise<UserControllerFindOneResult>` - User details
989
+
990
+ **Example:**
991
+ ```typescript
992
+ const userData = await user.findOne('user-id');
993
+ ```
994
+
995
+ #### `update(userId: string, data: UpdateUserDto): Promise<UserControllerUpdateResult>`
996
+
997
+ Update user information.
998
+
999
+ **Parameters:**
1000
+ - `userId` (`string`): User ID
1001
+ - `data` (`UpdateUserDto`): Update data
1002
+ - `username?` (`string`): New username
1003
+ - `email?` (`string`): New email
1004
+ - `isActive?` (`boolean`): Active status
1005
+
1006
+ **Returns:** `Promise<UserControllerUpdateResult>` - Updated user information
1007
+
1008
+ **Example:**
1009
+ ```typescript
1010
+ await user.update('user-id', {
1011
+ username: 'newusername',
1012
+ email: 'newemail@example.com'
1013
+ });
1014
+ ```
1015
+
1016
+ #### `changePassword(userId: string, data: ChangePasswordDto): Promise<UserControllerChangePasswordResult>`
1017
+
1018
+ Change user password.
1019
+
1020
+ **Parameters:**
1021
+ - `userId` (`string`): User ID
1022
+ - `data` (`ChangePasswordDto`): Password change data
1023
+ - `currentPassword` (`string`): Current password
1024
+ - `newPassword` (`string`): New password
1025
+
1026
+ **Returns:** `Promise<UserControllerChangePasswordResult>` - Password change confirmation
1027
+
1028
+ **Example:**
1029
+ ```typescript
1030
+ await user.changePassword('user-id', {
1031
+ currentPassword: 'old-password',
1032
+ newPassword: 'new-secure-password'
1033
+ });
1034
+ ```
1035
+
1036
+ ### Wallet Module (`cilantro-sdk/wallet`)
1037
+
1038
+ #### Basic Operations
1039
+
1040
+ ##### `create(data: CreateWalletDto): Promise<WalletControllerCreateResult>`
1041
+
1042
+ Create a new wallet.
1043
+
1044
+ **Parameters:**
1045
+ - `data` (`CreateWalletDto`): Wallet creation data
1046
+ - `name?` (`string`): Wallet name
1047
+ - `userId?` (`string`): User ID (for user-controlled wallets)
1048
+ - `walletMode?` (`'custodial' | 'nonCustodial'`): Wallet mode
1049
+ - `walletType?` (`'standard' | 'multisig'`): Wallet type
1050
+
1051
+ **Returns:** `Promise<WalletControllerCreateResult>` - Created wallet information
1052
+ - `data.id` (`string`): Wallet ID
1053
+ - `data.address` (`string`): Solana wallet address
1054
+ - `data.publicKey` (`string`): Wallet public key
1055
+
1056
+ **Example:**
1057
+ ```typescript
1058
+ import { wallet } from 'cilantro-sdk';
1059
+
1060
+ const newWallet = await wallet.create({
1061
+ name: 'My Wallet',
1062
+ userId: 'user-id',
1063
+ walletMode: 'nonCustodial'
1064
+ });
1065
+
1066
+ console.log('Wallet Address:', newWallet.data.address);
1067
+ ```
1068
+
1069
+ ##### `findAll(params?: WalletControllerFindAllParams): Promise<WalletControllerFindAllResult>`
1070
+
1071
+ Get all wallets with optional filters.
1072
+
1073
+ **Parameters:**
1074
+ - `params?` (`WalletControllerFindAllParams`): Optional query parameters
1075
+ - `page?` (`number`): Page number
1076
+ - `limit?` (`number`): Items per page
1077
+ - `userId?` (`string`): Filter by user ID
1078
+ - `walletMode?` (`string`): Filter by wallet mode
1079
+
1080
+ **Returns:** `Promise<WalletControllerFindAllResult>` - Paginated list of wallets
1081
+
1082
+ **Example:**
1083
+ ```typescript
1084
+ const wallets = await wallet.findAll({
1085
+ page: 1,
1086
+ limit: 20,
1087
+ walletMode: 'nonCustodial'
1088
+ });
1089
+ ```
1090
+
1091
+ ##### `findOne(walletId: string): Promise<WalletControllerFindOneResult>`
1092
+
1093
+ Get wallet by ID.
1094
+
1095
+ **Parameters:**
1096
+ - `walletId` (`string`): Wallet ID
1097
+
1098
+ **Returns:** `Promise<WalletControllerFindOneResult>` - Wallet details
1099
+
1100
+ **Example:**
1101
+ ```typescript
1102
+ const walletData = await wallet.findOne('wallet-id');
1103
+ ```
1104
+
1105
+ ##### `update(walletId: string, data: UpdateWalletDto): Promise<WalletControllerUpdateResult>`
1106
+
1107
+ Update wallet information.
1108
+
1109
+ **Parameters:**
1110
+ - `walletId` (`string`): Wallet ID
1111
+ - `data` (`UpdateWalletDto`): Update data
1112
+ - `name?` (`string`): New wallet name
1113
+ - `isActive?` (`boolean`): Active status
1114
+
1115
+ **Returns:** `Promise<WalletControllerUpdateResult>` - Updated wallet information
1116
+
1117
+ **Example:**
1118
+ ```typescript
1119
+ await wallet.update('wallet-id', {
1120
+ name: 'Updated Wallet Name'
1121
+ });
1122
+ ```
1123
+
1124
+ ##### `remove(walletId: string): Promise<WalletControllerRemoveResult>`
1125
+
1126
+ Remove (delete) a wallet.
1127
+
1128
+ **Parameters:**
1129
+ - `walletId` (`string`): Wallet ID
1130
+
1131
+ **Returns:** `Promise<WalletControllerRemoveResult>` - Removal confirmation
1132
+
1133
+ **Example:**
1134
+ ```typescript
1135
+ await wallet.remove('wallet-id');
1136
+ ```
1137
+
1138
+ ##### `findByAddress(address: string): Promise<WalletControllerFindByAddressResult>`
1139
+
1140
+ Find wallet by Solana address.
1141
+
1142
+ **Parameters:**
1143
+ - `address` (`string`): Solana wallet address
1144
+
1145
+ **Returns:** `Promise<WalletControllerFindByAddressResult>` - Wallet details
1146
+
1147
+ **Example:**
1148
+ ```typescript
1149
+ const walletData = await wallet.findByAddress('DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK');
1150
+ ```
1151
+
1152
+ ##### `getTotalBalance(walletId: string): Promise<WalletControllerGetTotalBalanceResult>`
1153
+
1154
+ Get total balance across all wallets for a user.
1155
+
1156
+ **Parameters:**
1157
+ - `walletId` (`string`): Wallet ID (used to identify user)
1158
+
1159
+ **Returns:** `Promise<WalletControllerGetTotalBalanceResult>` - Total balance information
1160
+ - `data.totalSOL` (`number`): Total SOL balance in lamports
1161
+ - `data.totalTokens` (`number`): Total token balance
1162
+
1163
+ **Example:**
1164
+ ```typescript
1165
+ const balance = await wallet.getTotalBalance('wallet-id');
1166
+ console.log('Total SOL:', balance.data.totalSOL / 1e9); // Convert lamports to SOL
1167
+ ```
1168
+
1169
+ #### Status Management
1170
+
1171
+ ##### `activate(walletId: string): Promise<WalletControllerActivateWalletResult>`
1172
+
1173
+ Activate a wallet.
1174
+
1175
+ **Parameters:**
1176
+ - `walletId` (`string`): Wallet ID
1177
+
1178
+ **Returns:** `Promise<WalletControllerActivateWalletResult>` - Activation confirmation
1179
+
1180
+ **Example:**
1181
+ ```typescript
1182
+ await wallet.activate('wallet-id');
1183
+ ```
1184
+
1185
+ ##### `deactivate(walletId: string): Promise<WalletControllerDeactivateWalletResult>`
1186
+
1187
+ Deactivate a wallet.
1188
+
1189
+ **Parameters:**
1190
+ - `walletId` (`string`): Wallet ID
1191
+
1192
+ **Returns:** `Promise<WalletControllerDeactivateWalletResult>` - Deactivation confirmation
1193
+
1194
+ **Example:**
1195
+ ```typescript
1196
+ await wallet.deactivate('wallet-id');
1197
+ ```
1198
+
1199
+ #### Transactions
1200
+
1201
+ ##### `sendSOL(walletId: string, data: SendSolDto): Promise<WalletControllerSendSOLResult>`
1202
+
1203
+ Send SOL (custodial mode - server signs the transaction).
1204
+
1205
+ **Parameters:**
1206
+ - `walletId` (`string`): Wallet ID
1207
+ - `data` (`SendSolDto`): Transaction data
1208
+ - `recipientAddress` (`string`): Recipient Solana address
1209
+ - `amountLamports` (`number`): Amount in lamports (1 SOL = 1,000,000,000 lamports)
1210
+
1211
+ **Returns:** `Promise<WalletControllerSendSOLResult>` - Transaction result
1212
+ - `data.signature` (`string`): Transaction signature
1213
+ - `data.status` (`string`): Transaction status
1214
+
1215
+ **Example:**
1216
+ ```typescript
1217
+ const result = await wallet.sendSOL('wallet-id', {
1218
+ recipientAddress: 'DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK',
1219
+ amountLamports: 1000000000 // 1 SOL
1220
+ });
1221
+
1222
+ console.log('Transaction Signature:', result.data.signature);
1223
+ ```
1224
+
1225
+ ##### `sendSOLNonCustodial(walletId: string, data: SendSolNonCustodialDto): Promise<WalletControllerSendSOLNonCustodialResult>`
1226
+
1227
+ Send SOL (non-custodial mode - requires client-side signing).
1228
+
1229
+ **Parameters:**
1230
+ - `walletId` (`string`): Wallet ID
1231
+ - `data` (`SendSolNonCustodialDto`): Transaction data
1232
+ - `recipientAddress` (`string`): Recipient address
1233
+ - `amountLamports` (`number`): Amount in lamports
1234
+ - `signedTransaction` (`string`): Base64-encoded signed transaction
1235
+
1236
+ **Returns:** `Promise<WalletControllerSendSOLNonCustodialResult>` - Transaction result
1237
+
1238
+ **Example:**
1239
+ ```typescript
1240
+ // First prepare and sign transaction client-side, then submit
1241
+ const result = await wallet.sendSOLNonCustodial('wallet-id', {
1242
+ recipientAddress: 'DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK',
1243
+ amountLamports: 1000000000,
1244
+ signedTransaction: signedTxBase64
1245
+ });
1246
+ ```
1247
+
1248
+ ##### `sendSPL(walletId: string, data: SendSplDto): Promise<WalletControllerSendSPLResult>`
1249
+
1250
+ Send SPL token (custodial mode).
1251
+
1252
+ **Parameters:**
1253
+ - `walletId` (`string`): Wallet ID
1254
+ - `data` (`SendSplDto`): Transaction data
1255
+ - `recipientAddress` (`string`): Recipient address
1256
+ - `mintAddress` (`string`): Token mint address
1257
+ - `amount` (`number`): Token amount (in token's decimal places)
1258
+
1259
+ **Returns:** `Promise<WalletControllerSendSPLResult>` - Transaction result
1260
+
1261
+ **Example:**
1262
+ ```typescript
1263
+ const result = await wallet.sendSPL('wallet-id', {
1264
+ recipientAddress: 'DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK',
1265
+ mintAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
1266
+ amount: 1000000 // 1 USDC (6 decimals)
1267
+ });
1268
+ ```
1269
+
1270
+ ##### `sendSPLNonCustodial(walletId: string, data: SendSplNonCustodialDto): Promise<WalletControllerSendSPLNonCustodialResult>`
1271
+
1272
+ Send SPL token (non-custodial mode).
1273
+
1274
+ **Parameters:**
1275
+ - `walletId` (`string`): Wallet ID
1276
+ - `data` (`SendSplNonCustodialDto`): Transaction data
1277
+ - `recipientAddress` (`string`): Recipient address
1278
+ - `mintAddress` (`string`): Token mint address
1279
+ - `amount` (`number`): Token amount
1280
+ - `signedTransaction` (`string`): Base64-encoded signed transaction
1281
+
1282
+ **Returns:** `Promise<WalletControllerSendSPLNonCustodialResult>` - Transaction result
1283
+
1284
+ **Example:**
1285
+ ```typescript
1286
+ const result = await wallet.sendSPLNonCustodial('wallet-id', {
1287
+ recipientAddress: 'DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK',
1288
+ mintAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
1289
+ amount: 1000000,
1290
+ signedTransaction: signedTxBase64
1291
+ });
1292
+ ```
1293
+
1294
+ ##### `executeInstructionNonCustodial(walletId: string, data: ExecuteInstructionNonCustodialDto): Promise<WalletControllerExecuteInstructionNonCustodialResult>`
1295
+
1296
+ Execute a custom Solana instruction (non-custodial mode).
1297
+
1298
+ **Parameters:**
1299
+ - `walletId` (`string`): Wallet ID
1300
+ - `data` (`ExecuteInstructionNonCustodialDto`): Instruction data
1301
+ - `programId` (`string`): Program ID
1302
+ - `accounts` (`array`): Account keys
1303
+ - `data` (`string`): Instruction data
1304
+ - `signedTransaction` (`string`): Base64-encoded signed transaction
1305
+
1306
+ **Returns:** `Promise<WalletControllerExecuteInstructionNonCustodialResult>` - Transaction result
1307
+
1308
+ **Example:**
1309
+ ```typescript
1310
+ const result = await wallet.executeInstructionNonCustodial('wallet-id', {
1311
+ programId: 'program-id',
1312
+ accounts: [...],
1313
+ data: 'instruction-data',
1314
+ signedTransaction: signedTxBase64
1315
+ });
1316
+ ```
1317
+
1318
+ ##### `sendTransaction(walletId: string, data: SendTransactionDto): Promise<WalletControllerSendTransactionResult>`
1319
+
1320
+ Send a custom transaction.
1321
+
1322
+ **Parameters:**
1323
+ - `walletId` (`string`): Wallet ID
1324
+ - `data` (`SendTransactionDto`): Transaction data
1325
+ - `transaction` (`string`): Base64-encoded transaction
1326
+ - `signers?` (`array`): Signer public keys
1327
+
1328
+ **Returns:** `Promise<WalletControllerSendTransactionResult>` - Transaction result
1329
+
1330
+ **Example:**
1331
+ ```typescript
1332
+ const result = await wallet.sendTransaction('wallet-id', {
1333
+ transaction: transactionBase64
1334
+ });
1335
+ ```
1336
+
1337
+ ##### `simulateTransaction(walletId: string, data: SimulateTransactionDto): Promise<WalletControllerSimulateTransactionResult>`
1338
+
1339
+ Simulate a transaction without executing it.
1340
+
1341
+ **Parameters:**
1342
+ - `walletId` (`string`): Wallet ID
1343
+ - `data` (`SimulateTransactionDto`): Transaction data
1344
+ - `transaction` (`string`): Base64-encoded transaction
1345
+
1346
+ **Returns:** `Promise<WalletControllerSimulateTransactionResult>` - Simulation result
1347
+ - `data.logs` (`array`): Transaction logs
1348
+ - `data.err` (`object | null`): Error if simulation failed
1349
+ - `data.unitsConsumed` (`number`): Compute units consumed
1350
+
1351
+ **Example:**
1352
+ ```typescript
1353
+ const simulation = await wallet.simulateTransaction('wallet-id', {
1354
+ transaction: transactionBase64
1355
+ });
1356
+
1357
+ if (simulation.data.err) {
1358
+ console.error('Simulation failed:', simulation.data.err);
1359
+ } else {
1360
+ console.log('Units consumed:', simulation.data.unitsConsumed);
1361
+ }
1362
+ ```
1363
+
1364
+ ##### `prepareTransaction(walletId: string, data: PrepareTransactionDto): Promise<WalletControllerPrepareTransactionResult>`
1365
+
1366
+ Prepare a transaction for signing.
1367
+
1368
+ **Parameters:**
1369
+ - `walletId` (`string`): Wallet ID
1370
+ - `data` (`PrepareTransactionDto`): Transaction preparation data
1371
+ - `type` (`'transfer' | 'tokenTransfer' | 'custom'`): Transaction type
1372
+ - `recipientAddress?` (`string`): Recipient address (for transfers)
1373
+ - `amount?` (`number`): Amount
1374
+ - `mintAddress?` (`string`): Token mint address (for token transfers)
1375
+ - `instructions?` (`array`): Custom instructions
1376
+
1377
+ **Returns:** `Promise<WalletControllerPrepareTransactionResult>` - Prepared transaction
1378
+ - `data.transaction` (`string`): Base64-encoded unsigned transaction
1379
+ - `data.message` (`string`): Transaction message for signing
1380
+
1381
+ **Example:**
1382
+ ```typescript
1383
+ const prepared = await wallet.prepareTransaction('wallet-id', {
1384
+ type: 'transfer',
1385
+ recipientAddress: 'DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK',
1386
+ amount: 1000000000
1387
+ });
1388
+
1389
+ // Sign the transaction client-side, then submit
1390
+ const signedTx = await signTransaction(prepared.data.transaction);
1391
+ await wallet.submitTransaction('wallet-id', {
1392
+ signedTransaction: signedTx
1393
+ });
1394
+ ```
1395
+
1396
+ ##### `submitTransaction(walletId: string, data: SubmitTransactionDto): Promise<WalletControllerSubmitTransactionResult>`
1397
+
1398
+ Submit a signed transaction.
1399
+
1400
+ **Parameters:**
1401
+ - `walletId` (`string`): Wallet ID
1402
+ - `data` (`SubmitTransactionDto`): Transaction data
1403
+ - `signedTransaction` (`string`): Base64-encoded signed transaction
1404
+
1405
+ **Returns:** `Promise<WalletControllerSubmitTransactionResult>` - Transaction result
1406
+ - `data.signature` (`string`): Transaction signature
1407
+ - `data.status` (`string`): Transaction status
1408
+
1409
+ **Example:**
1410
+ ```typescript
1411
+ const result = await wallet.submitTransaction('wallet-id', {
1412
+ signedTransaction: signedTxBase64
1413
+ });
1414
+
1415
+ console.log('Transaction Signature:', result.data.signature);
1416
+ ```
1417
+
1418
+ ##### `signMessage(walletId: string, data: SignMessageDto): Promise<WalletControllerSignMessageResult>`
1419
+
1420
+ Sign a message with the wallet.
1421
+
1422
+ **Parameters:**
1423
+ - `walletId` (`string`): Wallet ID
1424
+ - `data` (`SignMessageDto`): Message data
1425
+ - `message` (`string`): Message to sign (will be base64 encoded)
1426
+ - `signerId?` (`string`): Specific signer ID to use
1427
+
1428
+ **Returns:** `Promise<WalletControllerSignMessageResult>` - Signature result
1429
+ - `data.signature` (`string`): Message signature
1430
+ - `data.publicKey` (`string`): Signer public key
1431
+
1432
+ **Example:**
1433
+ ```typescript
1434
+ const result = await wallet.signMessage('wallet-id', {
1435
+ message: 'Hello, World!',
1436
+ signerId: 'signer-id'
1437
+ });
1438
+
1439
+ console.log('Signature:', result.data.signature);
1440
+ ```
1441
+
1442
+ #### Batch Operations
1443
+
1444
+ ##### `batchCreate(data: BatchCreateWalletDto): Promise<WalletControllerBatchCreateWalletsResult>`
1445
+
1446
+ Create multiple wallets in batch.
1447
+
1448
+ **Parameters:**
1449
+ - `data` (`BatchCreateWalletDto`): Batch creation data
1450
+ - `wallets` (`array`): Array of wallet creation data
1451
+ - `name?` (`string`): Wallet name
1452
+ - `userId?` (`string`): User ID
1453
+
1454
+ **Returns:** `Promise<WalletControllerBatchCreateWalletsResult>` - Created wallets
1455
+
1456
+ **Example:**
1457
+ ```typescript
1458
+ const result = await wallet.batchCreate({
1459
+ wallets: [
1460
+ { name: 'Wallet 1', userId: 'user-id' },
1461
+ { name: 'Wallet 2', userId: 'user-id' }
1462
+ ]
1463
+ });
1464
+ ```
1465
+
1466
+ ##### `batchSendSOL(walletId: string, data: BatchSendSolDto): Promise<WalletControllerBatchSendSOLResult>`
1467
+
1468
+ Send SOL to multiple recipients in a single transaction.
1469
+
1470
+ **Parameters:**
1471
+ - `walletId` (`string`): Wallet ID
1472
+ - `data` (`BatchSendSolDto`): Batch send data
1473
+ - `recipients` (`array`): Array of recipients
1474
+ - `address` (`string`): Recipient address
1475
+ - `amountLamports` (`number`): Amount in lamports
1476
+
1477
+ **Returns:** `Promise<WalletControllerBatchSendSOLResult>` - Transaction result
1478
+
1479
+ **Example:**
1480
+ ```typescript
1481
+ const result = await wallet.batchSendSOL('wallet-id', {
1482
+ recipients: [
1483
+ { address: 'address1', amountLamports: 1000000000 },
1484
+ { address: 'address2', amountLamports: 2000000000 }
1485
+ ]
1486
+ });
1487
+ ```
1488
+
1489
+ ##### `batchSendSPL(walletId: string, data: BatchSendSplDto): Promise<WalletControllerBatchSendSPLResult>`
1490
+
1491
+ Send SPL tokens to multiple recipients.
1492
+
1493
+ **Parameters:**
1494
+ - `walletId` (`string`): Wallet ID
1495
+ - `data` (`BatchSendSplDto`): Batch send data
1496
+ - `mintAddress` (`string`): Token mint address
1497
+ - `recipients` (`array`): Array of recipients
1498
+ - `address` (`string`): Recipient address
1499
+ - `amount` (`number`): Token amount
1500
+
1501
+ **Returns:** `Promise<WalletControllerBatchSendSPLResult>` - Transaction result
1502
+
1503
+ **Example:**
1504
+ ```typescript
1505
+ const result = await wallet.batchSendSPL('wallet-id', {
1506
+ mintAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
1507
+ recipients: [
1508
+ { address: 'address1', amount: 1000000 },
1509
+ { address: 'address2', amount: 2000000 }
1510
+ ]
1511
+ });
1512
+ ```
1513
+
1514
+ #### NFTs & Tokens
1515
+
1516
+ ##### `mintNFT(walletId: string, data: MintNftDto): Promise<WalletControllerMintNFTResult>`
1517
+
1518
+ Mint an NFT with full metadata.
1519
+
1520
+ **Parameters:**
1521
+ - `walletId` (`string`): Wallet ID
1522
+ - `data` (`MintNftDto`): NFT minting data
1523
+ - `name` (`string`): NFT name
1524
+ - `symbol?` (`string`): NFT symbol
1525
+ - `uri?` (`string`): Metadata URI
1526
+ - `metadata?` (`object`): Full metadata object
1527
+ - `recipientAddress?` (`string`): Recipient address (defaults to wallet address)
1528
+
1529
+ **Returns:** `Promise<WalletControllerMintNFTResult>` - Minted NFT information
1530
+ - `data.mintAddress` (`string`): NFT mint address
1531
+ - `data.tokenAddress` (`string`): Token account address
1532
+
1533
+ **Example:**
1534
+ ```typescript
1535
+ const result = await wallet.mintNFT('wallet-id', {
1536
+ name: 'My NFT',
1537
+ symbol: 'MNFT',
1538
+ uri: 'https://example.com/metadata.json',
1539
+ metadata: {
1540
+ description: 'My awesome NFT',
1541
+ image: 'https://example.com/image.png'
1542
+ }
1543
+ });
1544
+
1545
+ console.log('NFT Mint Address:', result.data.mintAddress);
1546
+ ```
1547
+
1548
+ ##### `mintNFTSimple(walletId: string, data: MintNftSimpleDto): Promise<WalletControllerMintNFTSimpleResult>`
1549
+
1550
+ Mint an NFT with simplified parameters.
1551
+
1552
+ **Parameters:**
1553
+ - `walletId` (`string`): Wallet ID
1554
+ - `data` (`MintNftSimpleDto`): Simplified NFT data
1555
+ - `name` (`string`): NFT name
1556
+ - `uri?` (`string`): Metadata URI
1557
+
1558
+ **Returns:** `Promise<WalletControllerMintNFTSimpleResult>` - Minted NFT information
1559
+
1560
+ **Example:**
1561
+ ```typescript
1562
+ const result = await wallet.mintNFTSimple('wallet-id', {
1563
+ name: 'Simple NFT',
1564
+ uri: 'https://example.com/metadata.json'
1565
+ });
1566
+ ```
1567
+
1568
+ ##### `mintToken(walletId: string, data: MintTokenDto): Promise<WalletControllerMintTokenResult>`
1569
+
1570
+ Mint an SPL token.
1571
+
1572
+ **Parameters:**
1573
+ - `walletId` (`string`): Wallet ID
1574
+ - `data` (`MintTokenDto`): Token minting data
1575
+ - `decimals` (`number`): Token decimals (0-9)
1576
+ - `amount` (`number`): Initial supply
1577
+ - `tokenStandard?` (`'fungible' | 'nonFungible'`): Token standard
1578
+ - `name?` (`string`): Token name
1579
+ - `symbol?` (`string`): Token symbol
1580
+
1581
+ **Returns:** `Promise<WalletControllerMintTokenResult>` - Minted token information
1582
+ - `data.mintAddress` (`string`): Token mint address
1583
+
1584
+ **Example:**
1585
+ ```typescript
1586
+ const result = await wallet.mintToken('wallet-id', {
1587
+ decimals: 9,
1588
+ amount: 1000000000,
1589
+ name: 'My Token',
1590
+ symbol: 'MTK'
1591
+ });
1592
+
1593
+ console.log('Token Mint Address:', result.data.mintAddress);
1594
+ ```
1595
+
1596
+ #### Assets
1597
+
1598
+ ##### `getAssets(walletId: string, params?: WalletControllerGetWalletAssetsParams): Promise<WalletControllerGetWalletAssetsResult>`
1599
+
1600
+ Get wallet assets (tokens, NFTs, SOL).
1601
+
1602
+ **Parameters:**
1603
+ - `walletId` (`string`): Wallet ID
1604
+ - `params?` (`WalletControllerGetWalletAssetsParams`): Optional query parameters
1605
+ - `assetType?` (`'sol' | 'token' | 'nft'`): Filter by asset type
1606
+ - `page?` (`number`): Page number
1607
+ - `limit?` (`number`): Items per page
1608
+
1609
+ **Returns:** `Promise<WalletControllerGetWalletAssetsResult>` - Paginated list of assets
1610
+ - `data.assets` (`array`): Array of asset objects
1611
+ - `type` (`string`): Asset type
1612
+ - `balance` (`number`): Asset balance
1613
+ - `mintAddress?` (`string`): Mint address (for tokens/NFTs)
1614
+
1615
+ **Example:**
1616
+ ```typescript
1617
+ const assets = await wallet.getAssets('wallet-id', {
1618
+ assetType: 'token',
1619
+ page: 1,
1620
+ limit: 20
1621
+ });
1622
+
1623
+ console.log('Assets:', assets.data.assets);
1624
+ ```
1625
+
1626
+ ##### `syncAssets(walletId: string): Promise<WalletControllerSyncWalletAssetsResult>`
1627
+
1628
+ Sync wallet assets from blockchain.
1629
+
1630
+ **Parameters:**
1631
+ - `walletId` (`string`): Wallet ID
1632
+
1633
+ **Returns:** `Promise<WalletControllerSyncWalletAssetsResult>` - Sync result
1634
+
1635
+ **Example:**
1636
+ ```typescript
1637
+ await wallet.syncAssets('wallet-id');
1638
+ ```
1639
+
1640
+ #### Custody
1641
+
1642
+ ##### `getCustodyInfo(walletId: string): Promise<WalletControllerGetWalletCustodyInfoResult>`
1643
+
1644
+ Get wallet custody information.
1645
+
1646
+ **Parameters:**
1647
+ - `walletId` (`string`): Wallet ID
1648
+
1649
+ **Returns:** `Promise<WalletControllerGetWalletCustodyInfoResult>` - Custody information
1650
+ - `data.walletMode` (`string`): Wallet mode (custodial/nonCustodial)
1651
+ - `data.signers` (`array`): List of signers
1652
+
1653
+ **Example:**
1654
+ ```typescript
1655
+ const custodyInfo = await wallet.getCustodyInfo('wallet-id');
1656
+ console.log('Wallet Mode:', custodyInfo.data.walletMode);
1657
+ ```
1658
+
1659
+ #### Signer Management
1660
+
1661
+ ##### `createEmailSigner(walletId: string, data: CreateEmailSignerDto): Promise<WalletControllerCreateEmailSignerResult>`
1662
+
1663
+ Create an email signer for the wallet.
1664
+
1665
+ **Parameters:**
1666
+ - `walletId` (`string`): Wallet ID
1667
+ - `data` (`CreateEmailSignerDto`): Email signer data
1668
+ - `email` (`string`): Email address
1669
+ - `devicePublicKey` (`string`): Base64-encoded device public key (P-256 ECDH)
1670
+
1671
+ **Returns:** `Promise<WalletControllerCreateEmailSignerResult>` - Created signer information
1672
+ - `data.signerId` (`string`): Signer ID
1673
+ - `data.deviceId` (`string`): Device ID
1674
+
1675
+ **Example:**
1676
+ ```typescript
1677
+ import { generateDevicePublicKey } from 'cilantro-sdk';
1678
+
1679
+ const devicePublicKey = await generateDevicePublicKey();
1680
+ const signer = await wallet.createEmailSigner('wallet-id', {
1681
+ email: 'user@example.com',
1682
+ devicePublicKey
1683
+ });
1684
+
1685
+ console.log('Signer ID:', signer.data.signerId);
1686
+ ```
1687
+
1688
+ ##### `createPhoneSigner(walletId: string, data: CreatePhoneSignerDto): Promise<WalletControllerCreatePhoneSignerResult>`
1689
+
1690
+ Create a phone signer for the wallet.
1691
+
1692
+ **Parameters:**
1693
+ - `walletId` (`string`): Wallet ID
1694
+ - `data` (`CreatePhoneSignerDto`): Phone signer data
1695
+ - `phone` (`string`): Phone number (E.164 format)
1696
+ - `devicePublicKey` (`string`): Base64-encoded device public key
1697
+
1698
+ **Returns:** `Promise<WalletControllerCreatePhoneSignerResult>` - Created signer information
1699
+
1700
+ **Example:**
1701
+ ```typescript
1702
+ const devicePublicKey = await generateDevicePublicKey();
1703
+ const signer = await wallet.createPhoneSigner('wallet-id', {
1704
+ phone: '+1234567890',
1705
+ devicePublicKey
1706
+ });
1707
+ ```
1708
+
1709
+ ##### `startPasskeyRegistration(walletId: string, data: StartPasskeyRegistrationDto): Promise<WalletControllerStartPasskeyRegistrationResult>`
1710
+
1711
+ Start passkey (WebAuthn) registration process.
1712
+
1713
+ **Parameters:**
1714
+ - `walletId` (`string`): Wallet ID
1715
+ - `data` (`StartPasskeyRegistrationDto`): Registration data
1716
+ - `credentialName?` (`string`): Name for the passkey
1717
+
1718
+ **Returns:** `Promise<WalletControllerStartPasskeyRegistrationResult>` - Registration options
1719
+ - `data.options` (`object`): WebAuthn registration options (for browser)
1720
+
1721
+ **Example:**
1722
+ ```typescript
1723
+ const registration = await wallet.startPasskeyRegistration('wallet-id', {
1724
+ credentialName: 'My Passkey'
1725
+ });
1726
+
1727
+ // Use registration.data.options with WebAuthn API
1728
+ const credential = await navigator.credentials.create({
1729
+ publicKey: registration.data.options
1730
+ });
1731
+
1732
+ // Then verify the registration
1733
+ await wallet.verifyPasskeyRegistration('wallet-id', {
1734
+ credential: credential
1735
+ });
1736
+ ```
1737
+
1738
+ ##### `verifyPasskeyRegistration(walletId: string, data: PasskeyRegistrationDto): Promise<WalletControllerVerifyPasskeyRegistrationResult>`
1739
+
1740
+ Verify and complete passkey registration.
1741
+
1742
+ **Parameters:**
1743
+ - `walletId` (`string`): Wallet ID
1744
+ - `data` (`PasskeyRegistrationDto`): Registration verification data
1745
+ - `credential` (`object`): WebAuthn credential from browser
1746
+
1747
+ **Returns:** `Promise<WalletControllerVerifyPasskeyRegistrationResult>` - Verified signer information
1748
+
1749
+ **Example:**
1750
+ ```typescript
1751
+ // After creating credential with WebAuthn API
1752
+ await wallet.verifyPasskeyRegistration('wallet-id', {
1753
+ credential: credentialResponse
1754
+ });
1755
+ ```
1756
+
1757
+ ##### `startPasskeyAuthentication(walletId: string, data: StartPasskeyAuthenticationDto): Promise<WalletControllerStartPasskeyAuthenticationResult>`
1758
+
1759
+ Start passkey authentication process.
1760
+
1761
+ **Parameters:**
1762
+ - `walletId` (`string`): Wallet ID
1763
+ - `data` (`StartPasskeyAuthenticationDto`): Authentication data
1764
+ - `credentialId?` (`string`): Specific credential ID to use
1765
+
1766
+ **Returns:** `Promise<WalletControllerStartPasskeyAuthenticationResult>` - Authentication options
1767
+
1768
+ **Example:**
1769
+ ```typescript
1770
+ const auth = await wallet.startPasskeyAuthentication('wallet-id', {});
1771
+
1772
+ // Use auth.data.options with WebAuthn API
1773
+ const assertion = await navigator.credentials.get({
1774
+ publicKey: auth.data.options
1775
+ });
1776
+
1777
+ // Then verify
1778
+ await wallet.verifyPasskeyAuthentication('wallet-id', {
1779
+ credential: assertion
1780
+ });
1781
+ ```
1782
+
1783
+ ##### `verifyPasskeyAuthentication(walletId: string, data: PasskeyAuthenticationDto): Promise<WalletControllerVerifyPasskeyAuthenticationResult>`
1784
+
1785
+ Verify passkey authentication.
1786
+
1787
+ **Parameters:**
1788
+ - `walletId` (`string`): Wallet ID
1789
+ - `data` (`PasskeyAuthenticationDto`): Authentication verification data
1790
+ - `credential` (`object`): WebAuthn assertion from browser
1791
+
1792
+ **Returns:** `Promise<WalletControllerVerifyPasskeyAuthenticationResult>` - Authentication result
1793
+
1794
+ **Example:**
1795
+ ```typescript
1796
+ await wallet.verifyPasskeyAuthentication('wallet-id', {
1797
+ credential: assertionResponse
1798
+ });
1799
+ ```
1800
+
1801
+ ##### `createExternalWalletSigner(walletId: string, data: CreateExternalWalletSignerDto): Promise<WalletControllerCreateExternalWalletSignerResult>`
1802
+
1803
+ Create an external wallet signer (e.g., Phantom, Solflare).
1804
+
1805
+ **Parameters:**
1806
+ - `walletId` (`string`): Wallet ID
1807
+ - `data` (`CreateExternalWalletSignerDto`): External wallet data
1808
+ - `publicKey` (`string`): External wallet public key
1809
+ - `walletName?` (`string`): Wallet name (e.g., 'Phantom')
1810
+
1811
+ **Returns:** `Promise<WalletControllerCreateExternalWalletSignerResult>` - Created signer information
1812
+
1813
+ **Example:**
1814
+ ```typescript
1815
+ // After connecting to external wallet
1816
+ const signer = await wallet.createExternalWalletSigner('wallet-id', {
1817
+ publicKey: externalWallet.publicKey.toString(),
1818
+ walletName: 'Phantom'
1819
+ });
1820
+ ```
1821
+
1822
+ ##### `createApiKeySigner(walletId: string, data: CreateApiKeySignerDto): Promise<WalletControllerCreateApiKeySignerResult>`
1823
+
1824
+ Create an API key signer for server-side operations.
1825
+
1826
+ **Parameters:**
1827
+ - `walletId` (`string`): Wallet ID
1828
+ - `data` (`CreateApiKeySignerDto`): API key signer data
1829
+ - `name?` (`string`): Signer name
1830
+ - `permissions?` (`object`): Signer permissions
1831
+
1832
+ **Returns:** `Promise<WalletControllerCreateApiKeySignerResult>` - Created signer information
1833
+
1834
+ **Example:**
1835
+ ```typescript
1836
+ const signer = await wallet.createApiKeySigner('wallet-id', {
1837
+ name: 'Server Signer',
1838
+ permissions: {
1839
+ canTransfer: true,
1840
+ maxAmount: 1000000000
1841
+ }
1842
+ });
1843
+ ```
1844
+
1845
+ ##### `getSignerById(walletId: string, signerId: string): Promise<WalletControllerGetSignerByIdResult>`
1846
+
1847
+ Get signer by ID.
1848
+
1849
+ **Parameters:**
1850
+ - `walletId` (`string`): Wallet ID
1851
+ - `signerId` (`string`): Signer ID
1852
+
1853
+ **Returns:** `Promise<WalletControllerGetSignerByIdResult>` - Signer details
1854
+
1855
+ **Example:**
1856
+ ```typescript
1857
+ const signer = await wallet.getSignerById('wallet-id', 'signer-id');
1858
+ ```
1859
+
1860
+ ##### `updateSigner(walletId: string, signerId: string, data: UpdateSignerDto): Promise<WalletControllerUpdateSignerResult>`
1861
+
1862
+ Update signer information.
1863
+
1864
+ **Parameters:**
1865
+ - `walletId` (`string`): Wallet ID
1866
+ - `signerId` (`string`): Signer ID
1867
+ - `data` (`UpdateSignerDto`): Update data
1868
+ - `isActive?` (`boolean`): Active status
1869
+ - `name?` (`string`): Signer name
1870
+
1871
+ **Returns:** `Promise<WalletControllerUpdateSignerResult>` - Updated signer information
1872
+
1873
+ **Example:**
1874
+ ```typescript
1875
+ await wallet.updateSigner('wallet-id', 'signer-id', {
1876
+ isActive: false,
1877
+ name: 'Updated Name'
1878
+ });
1879
+ ```
1880
+
1881
+ ##### `deleteSigner(walletId: string, signerId: string): Promise<WalletControllerDeleteSignerResult>`
1882
+
1883
+ Delete a signer.
1884
+
1885
+ **Parameters:**
1886
+ - `walletId` (`string`): Wallet ID
1887
+ - `signerId` (`string`): Signer ID
1888
+
1889
+ **Returns:** `Promise<WalletControllerDeleteSignerResult>` - Deletion confirmation
1890
+
1891
+ **Example:**
1892
+ ```typescript
1893
+ await wallet.deleteSigner('wallet-id', 'signer-id');
1894
+ ```
1895
+
1896
+ ##### `addSigner(walletId: string, data: AddSignerDto): Promise<WalletControllerAddSignerResult>`
1897
+
1898
+ Add a signer to the wallet.
1899
+
1900
+ **Parameters:**
1901
+ - `walletId` (`string`): Wallet ID
1902
+ - `data` (`AddSignerDto`): Signer data
1903
+ - `signerType` (`'email' | 'phone' | 'passkey' | 'external' | 'apiKey'`): Signer type
1904
+ - `signerConfig` (`object`): Signer-specific configuration
1905
+
1906
+ **Returns:** `Promise<WalletControllerAddSignerResult>` - Added signer information
1907
+
1908
+ **Example:**
1909
+ ```typescript
1910
+ await wallet.addSigner('wallet-id', {
1911
+ signerType: 'email',
1912
+ signerConfig: {
1913
+ email: 'user@example.com',
1914
+ devicePublicKey: await generateDevicePublicKey()
1915
+ }
1916
+ });
1917
+ ```
1918
+
1919
+ ##### `listSigners(walletId: string): Promise<WalletControllerListSignersResult>`
1920
+
1921
+ List all signers for a wallet.
1922
+
1923
+ **Parameters:**
1924
+ - `walletId` (`string`): Wallet ID
1925
+
1926
+ **Returns:** `Promise<WalletControllerListSignersResult>` - List of signers
1927
+ - `data.authenticationSigners` (`array`): Email/phone/passkey signers
1928
+ - `data.onChainSigners` (`array`): External/API key signers
1929
+
1930
+ **Example:**
1931
+ ```typescript
1932
+ const signers = await wallet.listSigners('wallet-id');
1933
+ console.log('Authentication Signers:', signers.data.authenticationSigners);
1934
+ console.log('On-Chain Signers:', signers.data.onChainSigners);
1935
+ ```
1936
+
1937
+ ##### `removeSigner(walletId: string, signerId: string): Promise<WalletControllerRemoveSignerResult>`
1938
+
1939
+ Remove a signer from the wallet.
1940
+
1941
+ **Parameters:**
1942
+ - `walletId` (`string`): Wallet ID
1943
+ - `signerId` (`string`): Signer ID
1944
+
1945
+ **Returns:** `Promise<WalletControllerRemoveSignerResult>` - Removal confirmation
1946
+
1947
+ **Example:**
1948
+ ```typescript
1949
+ await wallet.removeSigner('wallet-id', 'signer-id');
1950
+ ```
1951
+
1952
+ ##### `updateSignerPermissions(walletId: string, signerId: string, data: UpdateSignerPermissionsDto): Promise<WalletControllerUpdateSignerPermissionsResult>`
1953
+
1954
+ Update signer permissions.
1955
+
1956
+ **Parameters:**
1957
+ - `walletId` (`string`): Wallet ID
1958
+ - `signerId` (`string`): Signer ID
1959
+ - `data` (`UpdateSignerPermissionsDto`): Permission data
1960
+ - `canTransfer?` (`boolean`): Can transfer funds
1961
+ - `maxAmount?` (`number`): Maximum transfer amount
1962
+ - `allowedPrograms?` (`array`): Allowed program IDs
1963
+
1964
+ **Returns:** `Promise<WalletControllerUpdateSignerPermissionsResult>` - Updated permissions
1965
+
1966
+ **Example:**
1967
+ ```typescript
1968
+ await wallet.updateSignerPermissions('wallet-id', 'signer-id', {
1969
+ canTransfer: true,
1970
+ maxAmount: 1000000000,
1971
+ allowedPrograms: ['program-id-1']
1972
+ });
1973
+ ```
1974
+
1975
+ ##### `getDeviceEncryptedSecret(walletId: string, signerId: string, params: WalletControllerGetDeviceEncryptedSecretParams): Promise<WalletControllerGetDeviceEncryptedSecretResult>`
1976
+
1977
+ Get device encrypted secret for deriving signer keypair.
1978
+
1979
+ **Parameters:**
1980
+ - `walletId` (`string`): Wallet ID
1981
+ - `signerId` (`string`): Signer ID
1982
+ - `params` (`WalletControllerGetDeviceEncryptedSecretParams`): Query parameters
1983
+ - `devicePublicKey` (`string`): Device public key
1984
+ - `deviceId?` (`string`): Device ID
1985
+
1986
+ **Returns:** `Promise<WalletControllerGetDeviceEncryptedSecretResult>` - Encrypted secret
1987
+ - `data.encryptedSecret` (`string`): Encrypted secret (base64)
1988
+ - `data.deviceId` (`string`): Device ID
1989
+
1990
+ **Example:**
1991
+ ```typescript
1992
+ const secret = await wallet.getDeviceEncryptedSecret('wallet-id', 'signer-id', {
1993
+ devicePublicKey: devicePublicKey
1994
+ });
1995
+
1996
+ // Use with helpers.deriveSignerKeypair() to get keypair
1997
+ ```
1998
+
1999
+ ##### `updateDeviceIdentity(walletId: string, signerId: string, data: UpdateDeviceIdentityDto): Promise<WalletControllerUpdateDeviceIdentityResult>`
2000
+
2001
+ Update device identity for a signer.
2002
+
2003
+ **Parameters:**
2004
+ - `walletId` (`string`): Wallet ID
2005
+ - `signerId` (`string`): Signer ID
2006
+ - `data` (`UpdateDeviceIdentityDto`): Device identity data
2007
+ - `devicePublicKey` (`string`): New device public key
2008
+ - `deviceId?` (`string`): Device ID (for replacing)
2009
+ - `replace?` (`boolean`): Replace existing device
2010
+
2011
+ **Returns:** `Promise<WalletControllerUpdateDeviceIdentityResult>` - Updated device identity
2012
+
2013
+ **Example:**
2014
+ ```typescript
2015
+ const newDeviceKey = await generateDevicePublicKey();
2016
+ await wallet.updateDeviceIdentity('wallet-id', 'signer-id', {
2017
+ devicePublicKey: newDeviceKey,
2018
+ replace: true
2019
+ });
2020
+ ```
2021
+
2022
+ ### Auth Module (`cilantro-sdk/auth`)
2023
+
2024
+ #### `login(credentials: CommonLoginDto, options?: AuthRequestOptions): Promise<AuthControllerLoginResult>`
2025
+
2026
+ Authenticate as platform or user. Returns user type and appropriate JWT token.
2027
+
2028
+ **Parameters:**
2029
+ - `credentials` (`CommonLoginDto`): Login credentials
2030
+ - `usernameOrEmail` (`string`): Username or email address
2031
+ - `password` (`string`): Password
2032
+ - `options?` (`AuthRequestOptions`): Optional request options (axios config)
2033
+
2034
+ **Returns:** `Promise<AuthControllerLoginResult>` - Login response with JWT token and user information
2035
+ - `data.jwt` (`string`): JWT token for authentication
2036
+ - `data.userType` (`string`): User type (platform or user)
2037
+ - `data.user` (`object`): User information
2038
+
2039
+ **Example:**
2040
+ ```typescript
2041
+ import { login } from 'cilantro-sdk/auth';
2042
+
2043
+ const result = await login({
2044
+ usernameOrEmail: 'user@example.com',
2045
+ password: 'SecurePass123!'
2046
+ });
2047
+
2048
+ console.log('JWT Token:', result.data.jwt);
2049
+ console.log('User Type:', result.data.userType);
2050
+ ```
2051
+
2052
+ #### `loginAndSetAuth(credentials: CommonLoginDto, options?: AuthRequestOptions): Promise<AuthControllerLoginResult>`
2053
+
2054
+ Login and automatically set authentication credentials. This is a convenience function that calls `login()` and `setAuth()` automatically.
2055
+
2056
+ **Parameters:**
2057
+ - `credentials` (`CommonLoginDto`): Login credentials
2058
+ - `usernameOrEmail` (`string`): Username or email address
2059
+ - `password` (`string`): Password
2060
+ - `options?` (`AuthRequestOptions`): Optional request options
2061
+
2062
+ **Returns:** `Promise<AuthControllerLoginResult>` - Login response (auth is automatically set)
2063
+
2064
+ **Example:**
2065
+ ```typescript
2066
+ import { loginAndSetAuth } from 'cilantro-sdk/auth';
2067
+ import { sendSOL } from 'cilantro-sdk/wallet';
2068
+
2069
+ // Login and set auth in one step
2070
+ await loginAndSetAuth({
2071
+ usernameOrEmail: 'user@example.com',
2072
+ password: 'SecurePass123!'
2073
+ });
2074
+
2075
+ // Now you can make authenticated requests immediately
2076
+ await sendSOL('wallet-id', {
2077
+ recipientAddress: 'DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK',
2078
+ amountLamports: 1000000000
2079
+ });
2080
+ ```
2081
+
2082
+ ### Subscriptions Module (`cilantro-sdk/subscriptions`)
2083
+
2084
+ #### `create(data: CreateSubscriptionDto): Promise<SubscriptionControllerCreateResult>`
2085
+
2086
+ Create a new subscription.
2087
+
2088
+ **Parameters:**
2089
+ - `data` (`CreateSubscriptionDto`): Subscription creation data
2090
+ - `platformId` (`string`): Platform ID
2091
+ - `planId` (`string`): Plan ID
2092
+ - `billingCycle` (`'monthly' | 'yearly'`): Billing cycle
2093
+ - `trialDays?` (`number`): Trial period in days
2094
+
2095
+ **Returns:** `Promise<SubscriptionControllerCreateResult>` - Created subscription
2096
+
2097
+ **Example:**
2098
+ ```typescript
2099
+ import { subscriptions } from 'cilantro-sdk';
2100
+
2101
+ const subscription = await subscriptions.create({
2102
+ platformId: 'platform-id',
2103
+ planId: 'plan-id',
2104
+ billingCycle: 'monthly',
2105
+ trialDays: 7
2106
+ });
2107
+ ```
2108
+
2109
+ #### `findAll(params?: SubscriptionControllerFindAllParams): Promise<SubscriptionControllerFindAllResult>`
2110
+
2111
+ Get all subscriptions with optional filters.
2112
+
2113
+ **Parameters:**
2114
+ - `params?` (`SubscriptionControllerFindAllParams`): Optional query parameters
2115
+ - `status?` (`string`): Filter by status
2116
+ - `platformId?` (`string`): Filter by platform ID
2117
+ - `page?` (`number`): Page number
2118
+ - `limit?` (`number`): Items per page
2119
+
2120
+ **Returns:** `Promise<SubscriptionControllerFindAllResult>` - Paginated list of subscriptions
2121
+
2122
+ **Example:**
2123
+ ```typescript
2124
+ const allSubscriptions = await subscriptions.findAll({
2125
+ status: 'active',
2126
+ platformId: 'platform-id'
2127
+ });
2128
+ ```
2129
+
2130
+ #### `findOne(subscriptionId: string): Promise<SubscriptionControllerFindOneResult>`
2131
+
2132
+ Get subscription by ID.
2133
+
2134
+ **Parameters:**
2135
+ - `subscriptionId` (`string`): Subscription ID
2136
+
2137
+ **Returns:** `Promise<SubscriptionControllerFindOneResult>` - Subscription details
2138
+
2139
+ **Example:**
2140
+ ```typescript
2141
+ const subscription = await subscriptions.findOne('subscription-id');
2142
+ ```
2143
+
2144
+ #### `getPlatformSubscription(platformId: string): Promise<SubscriptionControllerGetPlatformSubscriptionResult>`
2145
+
2146
+ Get platform's active subscription.
2147
+
2148
+ **Parameters:**
2149
+ - `platformId` (`string`): Platform ID
2150
+
2151
+ **Returns:** `Promise<SubscriptionControllerGetPlatformSubscriptionResult>` - Active subscription
2152
+
2153
+ **Example:**
2154
+ ```typescript
2155
+ const subscription = await subscriptions.getPlatformSubscription('platform-id');
2156
+ ```
2157
+
2158
+ #### `upgrade(subscriptionId: string, data: UpgradeSubscriptionDto): Promise<SubscriptionControllerUpgradeResult>`
2159
+
2160
+ Upgrade subscription to a higher tier.
2161
+
2162
+ **Parameters:**
2163
+ - `subscriptionId` (`string`): Subscription ID
2164
+ - `data` (`UpgradeSubscriptionDto`): Upgrade data
2165
+ - `newPlanId` (`string`): New plan ID
2166
+ - `effectiveDate?` (`string`): Effective date (ISO 8601)
2167
+
2168
+ **Returns:** `Promise<SubscriptionControllerUpgradeResult>` - Upgraded subscription
2169
+
2170
+ **Example:**
2171
+ ```typescript
2172
+ await subscriptions.upgrade('subscription-id', {
2173
+ newPlanId: 'premium-plan-id',
2174
+ effectiveDate: '2024-01-01T00:00:00Z'
2175
+ });
2176
+ ```
2177
+
2178
+ #### `downgrade(subscriptionId: string, data: DowngradeSubscriptionDto): Promise<SubscriptionControllerDowngradeResult>`
2179
+
2180
+ Downgrade subscription to a lower tier.
2181
+
2182
+ **Parameters:**
2183
+ - `subscriptionId` (`string`): Subscription ID
2184
+ - `data` (`DowngradeSubscriptionDto`): Downgrade data
2185
+ - `newPlanId` (`string`): New plan ID
2186
+
2187
+ **Returns:** `Promise<SubscriptionControllerDowngradeResult>` - Downgraded subscription
2188
+
2189
+ **Example:**
2190
+ ```typescript
2191
+ await subscriptions.downgrade('subscription-id', {
2192
+ newPlanId: 'basic-plan-id'
2193
+ });
2194
+ ```
2195
+
2196
+ #### `cancel(subscriptionId: string, data: CancelSubscriptionDto): Promise<SubscriptionControllerCancelResult>`
2197
+
2198
+ Cancel a subscription.
2199
+
2200
+ **Parameters:**
2201
+ - `subscriptionId` (`string`): Subscription ID
2202
+ - `data` (`CancelSubscriptionDto`): Cancellation data
2203
+ - `cancelAtPeriodEnd?` (`boolean`): Cancel at period end
2204
+
2205
+ **Returns:** `Promise<SubscriptionControllerCancelResult>` - Cancellation confirmation
2206
+
2207
+ **Example:**
2208
+ ```typescript
2209
+ await subscriptions.cancel('subscription-id', {
2210
+ cancelAtPeriodEnd: true
2211
+ });
2212
+ ```
2213
+
2214
+ #### `renew(subscriptionId: string, data: RenewSubscriptionDto): Promise<SubscriptionControllerRenewResult>`
2215
+
2216
+ Renew a subscription.
2217
+
2218
+ **Parameters:**
2219
+ - `subscriptionId` (`string`): Subscription ID
2220
+ - `data` (`RenewSubscriptionDto`): Renewal data
2221
+ - `extendByDays?` (`number`): Days to extend
2222
+ - `extendByMonths?` (`number`): Months to extend
2223
+
2224
+ **Returns:** `Promise<SubscriptionControllerRenewResult>` - Renewed subscription
2225
+
2226
+ **Example:**
2227
+ ```typescript
2228
+ await subscriptions.renew('subscription-id', {
2229
+ extendByMonths: 1
2230
+ });
2231
+ ```
2232
+
2233
+ #### `getHistory(subscriptionId: string): Promise<SubscriptionControllerGetHistoryResult>`
2234
+
2235
+ Get subscription audit trail/history.
2236
+
2237
+ **Parameters:**
2238
+ - `subscriptionId` (`string`): Subscription ID
2239
+
2240
+ **Returns:** `Promise<SubscriptionControllerGetHistoryResult>` - Subscription history
2241
+
2242
+ **Example:**
2243
+ ```typescript
2244
+ const history = await subscriptions.getHistory('subscription-id');
2245
+ ```
2246
+
2247
+ ### Plans Module (`cilantro-sdk/plans`)
2248
+
2249
+ #### `findAll(): Promise<PlanControllerFindAllResult>`
2250
+
2251
+ Get all subscription plans.
2252
+
2253
+ **Parameters:** None
2254
+
2255
+ **Returns:** `Promise<PlanControllerFindAllResult>` - List of all plans
2256
+
2257
+ **Example:**
2258
+ ```typescript
2259
+ import { plans } from 'cilantro-sdk';
2260
+
2261
+ const allPlans = await plans.findAll();
2262
+ ```
2263
+
2264
+ #### `findOne(planId: string): Promise<PlanControllerFindOneResult>`
2265
+
2266
+ Get plan by ID.
2267
+
2268
+ **Parameters:**
2269
+ - `planId` (`string`): Plan ID
2270
+
2271
+ **Returns:** `Promise<PlanControllerFindOneResult>` - Plan details
2272
+
2273
+ **Example:**
2274
+ ```typescript
2275
+ const plan = await plans.findOne('plan-id');
2276
+ ```
2277
+
2278
+ #### `update(planId: string, data: UpdatePlanDto): Promise<PlanControllerUpdateResult>`
2279
+
2280
+ Update plan information.
2281
+
2282
+ **Parameters:**
2283
+ - `planId` (`string`): Plan ID
2284
+ - `data` (`UpdatePlanDto`): Update data
2285
+ - `planName?` (`string`): Plan name
2286
+ - `description?` (`string`): Description
2287
+ - `price?` (`number`): Price
2288
+ - `isActive?` (`boolean`): Active status
2289
+
2290
+ **Returns:** `Promise<PlanControllerUpdateResult>` - Updated plan
2291
+
2292
+ **Example:**
2293
+ ```typescript
2294
+ await plans.update('plan-id', {
2295
+ planName: 'Updated Plan Name',
2296
+ description: 'New description'
2297
+ });
2298
+ ```
2299
+
2300
+ #### `remove(planId: string): Promise<PlanControllerRemoveResult>`
2301
+
2302
+ Remove (deactivate) a plan.
2303
+
2304
+ **Parameters:**
2305
+ - `planId` (`string`): Plan ID
2306
+
2307
+ **Returns:** `Promise<PlanControllerRemoveResult>` - Removal confirmation
2308
+
2309
+ **Example:**
2310
+ ```typescript
2311
+ await plans.remove('plan-id');
2312
+ ```
2313
+
2314
+ #### `assignToPlatform(planId: string, platformId: string, data: AssignPlanDto): Promise<PlanControllerAssignToPlatformResult>`
2315
+
2316
+ Assign plan to platform.
2317
+
2318
+ **Parameters:**
2319
+ - `planId` (`string`): Plan ID
2320
+ - `platformId` (`string`): Platform ID
2321
+ - `data` (`AssignPlanDto`): Assignment data
2322
+ - `startDate?` (`string`): Start date (ISO 8601)
2323
+ - `billingCycle?` (`string`): Billing cycle
2324
+
2325
+ **Returns:** `Promise<PlanControllerAssignToPlatformResult>` - Assignment confirmation
2326
+
2327
+ **Example:**
2328
+ ```typescript
2329
+ await plans.assignToPlatform('plan-id', 'platform-id', {
2330
+ startDate: '2024-01-01T00:00:00Z',
2331
+ billingCycle: 'monthly'
2332
+ });
2333
+ ```
2334
+
2335
+ #### `assignToUser(planId: string, userId: string, data: AssignPlanDto): Promise<PlanControllerAssignToUserResult>`
2336
+
2337
+ Assign plan to user.
2338
+
2339
+ **Parameters:**
2340
+ - `planId` (`string`): Plan ID
2341
+ - `userId` (`string`): User ID
2342
+ - `data` (`AssignPlanDto`): Assignment data
2343
+
2344
+ **Returns:** `Promise<PlanControllerAssignToUserResult>` - Assignment confirmation
2345
+
2346
+ **Example:**
181
2347
  ```typescript
182
- import { configure } from 'cilantro-sdk';
2348
+ await plans.assignToUser('plan-id', 'user-id', {
2349
+ startDate: '2024-01-01T00:00:00Z',
2350
+ billingCycle: 'monthly'
2351
+ });
2352
+ ```
183
2353
 
184
- configure({
185
- apiKey: 'your-api-key',
186
- jwt: 'your-jwt-token', // Optional
187
- baseURL: 'https://api.cilantro.gg' // Optional: Custom API base URL
2354
+ ### Transactions Module (`cilantro-sdk/transactions`)
2355
+
2356
+ #### `getWalletTransactions(walletId: string, params?: TransactionControllerGetWalletTransactionsParams): Promise<TransactionControllerGetWalletTransactionsResult>`
2357
+
2358
+ Get paginated transaction history for a wallet.
2359
+
2360
+ **Parameters:**
2361
+ - `walletId` (`string`): Wallet ID
2362
+ - `params?` (`TransactionControllerGetWalletTransactionsParams`): Optional query parameters
2363
+ - `page?` (`number`): Page number
2364
+ - `limit?` (`number`): Items per page
2365
+ - `type?` (`TransactionType`): Filter by transaction type
2366
+ - `status?` (`TransactionStatus`): Filter by status
2367
+ - `startDate?` (`string`): Start date filter
2368
+ - `endDate?` (`string`): End date filter
2369
+
2370
+ **Returns:** `Promise<TransactionControllerGetWalletTransactionsResult>` - Paginated transaction history
2371
+
2372
+ **Example:**
2373
+ ```typescript
2374
+ import { getWalletTransactions } from 'cilantro-sdk/transactions';
2375
+
2376
+ const transactions = await getWalletTransactions('wallet-id', {
2377
+ page: 1,
2378
+ limit: 20,
2379
+ type: 'transfer',
2380
+ status: 'confirmed'
188
2381
  });
189
2382
  ```
190
2383
 
191
- ### `setAuth(auth)`
2384
+ #### `getTransactionStatus(signature: string): Promise<TransactionControllerGetTransactionStatusResult>`
192
2385
 
193
- Update authentication credentials after initialization.
2386
+ Get transaction status by Solana signature.
2387
+
2388
+ **Parameters:**
2389
+ - `signature` (`string`): Transaction signature
194
2390
 
2391
+ **Returns:** `Promise<TransactionControllerGetTransactionStatusResult>` - Transaction status
2392
+ - `data.status` (`string`): Transaction status (pending, confirmed, failed)
2393
+ - `data.confirmations?` (`number`): Number of confirmations
2394
+ - `data.error?` (`string`): Error message if failed
2395
+
2396
+ **Example:**
195
2397
  ```typescript
196
- import { setAuth } from 'cilantro-sdk';
2398
+ import { getTransactionStatus } from 'cilantro-sdk/transactions';
2399
+
2400
+ const status = await getTransactionStatus('transaction-signature-here');
2401
+ console.log('Status:', status.data.status);
2402
+ ```
2403
+
2404
+ #### `sendRawPasskeyTransaction(data: SendRawPasskeyTransactionDto): Promise<TransactionControllerSendRawPasskeyTransactionResult>`
2405
+
2406
+ Send transaction signed with passkey.
2407
+
2408
+ **Parameters:**
2409
+ - `data` (`SendRawPasskeyTransactionDto`): Transaction data
2410
+ - `walletId` (`string`): Wallet ID
2411
+ - `credentialId` (`string`): Passkey credential ID
2412
+ - `unsignedTransaction` (`string`): Base64-encoded unsigned transaction
2413
+ - `signature` (`string`): Transaction signature from passkey
197
2414
 
198
- setAuth({
199
- jwt: 'your-jwt-token',
200
- apiKey: 'your-api-key'
2415
+ **Returns:** `Promise<TransactionControllerSendRawPasskeyTransactionResult>` - Transaction result
2416
+
2417
+ **Example:**
2418
+ ```typescript
2419
+ import { sendRawPasskeyTransaction } from 'cilantro-sdk/transactions';
2420
+
2421
+ const result = await sendRawPasskeyTransaction({
2422
+ walletId: 'wallet-id',
2423
+ credentialId: 'credential-id',
2424
+ unsignedTransaction: unsignedTxBase64,
2425
+ signature: signatureBase64
201
2426
  });
202
2427
  ```
203
2428
 
204
- ### `clearAuth()`
2429
+ #### `sendPasskeyTransaction(data: SendRawPasskeyTransactionDto): Promise<TransactionControllerSendRawPasskeyTransactionResult>`
205
2430
 
206
- Clear all authentication credentials.
2431
+ Alias for `sendRawPasskeyTransaction`. Send transaction signed with passkey.
207
2432
 
2433
+ **Parameters:** Same as `sendRawPasskeyTransaction`
2434
+
2435
+ **Returns:** Same as `sendRawPasskeyTransaction`
2436
+
2437
+ **Example:**
208
2438
  ```typescript
209
- import { clearAuth } from 'cilantro-sdk';
2439
+ import { sendPasskeyTransaction } from 'cilantro-sdk/transactions';
210
2440
 
211
- clearAuth();
2441
+ // Same as sendRawPasskeyTransaction
2442
+ await sendPasskeyTransaction({ ... });
212
2443
  ```
213
2444
 
214
- ### Authentication Types
2445
+ #### `getTransactionHistory(walletId: string, options?: TransactionControllerGetWalletTransactionsParams): Promise<TransactionControllerGetWalletTransactionsResult>`
215
2446
 
216
- The SDK supports two types of authentication:
2447
+ Alias for `getWalletTransactions`. Get transaction history for a wallet.
217
2448
 
218
- 1. **API Key Authentication**: For server-side applications and platform-level access
219
- 2. **JWT Token Authentication**: For user-specific operations after login
2449
+ **Parameters:** Same as `getWalletTransactions`
220
2450
 
221
- You can use either or both simultaneously. The SDK will automatically include the appropriate headers in all requests.
2451
+ **Returns:** Same as `getWalletTransactions`
222
2452
 
223
- ## Documentation
2453
+ **Example:**
2454
+ ```typescript
2455
+ import { getTransactionHistory } from 'cilantro-sdk/transactions';
224
2456
 
225
- ### Getting Started Guides
2457
+ const history = await getTransactionHistory('wallet-id', {
2458
+ page: 1,
2459
+ limit: 20
2460
+ });
2461
+ ```
226
2462
 
227
- - **[Complete Wallet & Transaction Flow Guide](./WALLET_TRANSACTION_FLOW.md)** - Comprehensive step-by-step guide covering:
228
- - Wallet creation (platform-controlled vs user-controlled)
229
- - Understanding and creating signers (email, phone, passkey, external, API key)
230
- - Device key management and ECDH encryption
231
- - Complete transaction flows (server-side and client-side signing)
232
- - Real-world examples and best practices
2463
+ #### `checkTransactionStatus(signature: string): Promise<TransactionControllerGetTransactionStatusResult>`
233
2464
 
234
- - **[Device Key Management Guide](./DEVICE_KEY_MANAGEMENT.md)** - Deep dive into device key architecture
2465
+ Alias for `getTransactionStatus`. Check transaction status.
235
2466
 
236
- ### Quick Links
2467
+ **Parameters:** Same as `getTransactionStatus`
237
2468
 
238
- - [Examples](./examples/) - Code examples
239
- - [API Documentation](https://api.cilantro.gg/docs) - Complete API reference
2469
+ **Returns:** Same as `getTransactionStatus`
240
2470
 
241
- ## Module Structure
2471
+ **Example:**
2472
+ ```typescript
2473
+ import { checkTransactionStatus } from 'cilantro-sdk/transactions';
242
2474
 
243
- The SDK is organized into modules for better code organization:
2475
+ const status = await checkTransactionStatus('signature');
2476
+ ```
244
2477
 
245
- - **Platform** (`cilantro-sdk/platform`) - Platform management and user operations
246
- - **User** (`cilantro-sdk/user`) - User account operations
247
- - **Wallet** (`cilantro-sdk/wallet`) - Wallet and blockchain operations
248
- - **Admin** (`cilantro-sdk/admin`) - Administrative operations
249
- - **Auth** (`cilantro-sdk/auth`) - Universal authentication
250
- - **Subscriptions** (`cilantro-sdk/subscriptions`) - Subscription management operations
251
- - **Plans** (`cilantro-sdk/plans`) - Subscription plan management operations
252
- - **Transactions** (`cilantro-sdk/transactions`) - Transaction history and status queries
253
- - **Delegated Keys** (`cilantro-sdk/delegated-keys`) - Temporary key management for session-based signing
254
- - **Webhooks** (`cilantro-sdk/webhooks`) - Webhook endpoint management for event notifications
255
- - **Utils** (`cilantro-sdk/utils`) - Utility functions
256
- - **Helpers** (`cilantro-sdk/helpers`) - Device key management and signer helpers
2478
+ ### Delegated Keys Module (`cilantro-sdk/delegated-keys`)
2479
+
2480
+ #### `create(walletId: string, data: CreateDelegatedKeyDto): Promise<DelegatedKeyControllerCreateResult>`
2481
+
2482
+ Create a temporary delegated key for session-based signing.
2483
+
2484
+ **Parameters:**
2485
+ - `walletId` (`string`): Wallet ID
2486
+ - `data` (`CreateDelegatedKeyDto`): Delegated key data
2487
+ - `publicKey` (`string`): Delegated public key
2488
+ - `expiresAt` (`string`): Expiration date (ISO 8601)
2489
+ - `permissions?` (`DelegatedKeyPermissionsDto`): Key permissions
2490
+ - `canTransfer?` (`boolean`): Can transfer funds
2491
+ - `maxAmount?` (`number`): Maximum transfer amount
2492
+ - `allowedPrograms?` (`array`): Allowed program IDs
2493
+
2494
+ **Returns:** `Promise<DelegatedKeyControllerCreateResult>` - Created delegated key
2495
+
2496
+ **Example:**
2497
+ ```typescript
2498
+ import { create } from 'cilantro-sdk/delegated-keys';
2499
+
2500
+ const delegatedKey = await create('wallet-id', {
2501
+ publicKey: 'delegated-public-key',
2502
+ expiresAt: '2024-12-31T23:59:59Z',
2503
+ permissions: {
2504
+ canTransfer: true,
2505
+ maxAmount: 1000000000,
2506
+ allowedPrograms: ['program-id-1']
2507
+ }
2508
+ });
2509
+ ```
2510
+
2511
+ #### `findAll(walletId: string): Promise<DelegatedKeyControllerFindAllResult>`
2512
+
2513
+ List all delegated keys for a wallet.
2514
+
2515
+ **Parameters:**
2516
+ - `walletId` (`string`): Wallet ID
2517
+
2518
+ **Returns:** `Promise<DelegatedKeyControllerFindAllResult>` - List of delegated keys
2519
+
2520
+ **Example:**
2521
+ ```typescript
2522
+ import { findAll } from 'cilantro-sdk/delegated-keys';
2523
+
2524
+ const keys = await findAll('wallet-id');
2525
+ ```
2526
+
2527
+ #### `findOne(walletId: string, keyId: string): Promise<DelegatedKeyControllerFindOneResult>`
2528
+
2529
+ Get delegated key by ID.
2530
+
2531
+ **Parameters:**
2532
+ - `walletId` (`string`): Wallet ID
2533
+ - `keyId` (`string`): Delegated key ID
2534
+
2535
+ **Returns:** `Promise<DelegatedKeyControllerFindOneResult>` - Delegated key details
2536
+
2537
+ **Example:**
2538
+ ```typescript
2539
+ import { findOne } from 'cilantro-sdk/delegated-keys';
2540
+
2541
+ const key = await findOne('wallet-id', 'key-id');
2542
+ ```
2543
+
2544
+ #### `update(walletId: string, keyId: string, data: UpdateDelegatedKeyDto): Promise<DelegatedKeyControllerUpdateResult>`
2545
+
2546
+ Update delegated key configuration.
2547
+
2548
+ **Parameters:**
2549
+ - `walletId` (`string`): Wallet ID
2550
+ - `keyId` (`string`): Delegated key ID
2551
+ - `data` (`UpdateDelegatedKeyDto`): Update data
2552
+ - `expiresAt?` (`string`): New expiration date
2553
+ - `permissions?` (`DelegatedKeyPermissionsDto`): Updated permissions
2554
+
2555
+ **Returns:** `Promise<DelegatedKeyControllerUpdateResult>` - Updated delegated key
2556
+
2557
+ **Example:**
2558
+ ```typescript
2559
+ import { update } from 'cilantro-sdk/delegated-keys';
2560
+
2561
+ await update('wallet-id', 'key-id', {
2562
+ permissions: {
2563
+ canTransfer: false,
2564
+ maxAmount: 500000000
2565
+ }
2566
+ });
2567
+ ```
2568
+
2569
+ #### `remove(walletId: string, keyId: string): Promise<DelegatedKeyControllerRemoveResult>`
2570
+
2571
+ Revoke a delegated key.
2572
+
2573
+ **Parameters:**
2574
+ - `walletId` (`string`): Wallet ID
2575
+ - `keyId` (`string`): Delegated key ID
2576
+
2577
+ **Returns:** `Promise<DelegatedKeyControllerRemoveResult>` - Revocation confirmation
2578
+
2579
+ **Example:**
2580
+ ```typescript
2581
+ import { remove } from 'cilantro-sdk/delegated-keys';
2582
+
2583
+ await remove('wallet-id', 'key-id');
2584
+ ```
2585
+
2586
+ ### Webhooks Module (`cilantro-sdk/webhooks`)
2587
+
2588
+ #### `create(data: CreateWebhookDto): Promise<WebhookControllerCreateResult>`
2589
+
2590
+ Register a new webhook endpoint.
2591
+
2592
+ **Parameters:**
2593
+ - `data` (`CreateWebhookDto`): Webhook data
2594
+ - `url` (`string`): Webhook endpoint URL
2595
+ - `events` (`WebhookEvent[]`): Array of events to subscribe to
2596
+ - `description?` (`string`): Webhook description
2597
+ - `isActive?` (`boolean`): Active status (default: true)
2598
+
2599
+ **Returns:** `Promise<WebhookControllerCreateResult>` - Created webhook
2600
+
2601
+ **Example:**
2602
+ ```typescript
2603
+ import { create } from 'cilantro-sdk/webhooks';
2604
+
2605
+ const webhook = await create({
2606
+ url: 'https://your-domain.com/webhooks/cilantro',
2607
+ events: ['wallet.created', 'transaction.confirmed', 'transaction.failed'],
2608
+ description: 'Production webhook',
2609
+ isActive: true
2610
+ });
2611
+ ```
2612
+
2613
+ #### `findAll(): Promise<WebhookControllerFindAllResult>`
2614
+
2615
+ List all webhooks for the platform.
2616
+
2617
+ **Parameters:** None
2618
+
2619
+ **Returns:** `Promise<WebhookControllerFindAllResult>` - List of webhooks
2620
+
2621
+ **Example:**
2622
+ ```typescript
2623
+ import { findAll } from 'cilantro-sdk/webhooks';
2624
+
2625
+ const webhooks = await findAll();
2626
+ ```
2627
+
2628
+ #### `findOne(webhookId: string): Promise<WebhookControllerFindOneResult>`
2629
+
2630
+ Get webhook by ID.
2631
+
2632
+ **Parameters:**
2633
+ - `webhookId` (`string`): Webhook ID
2634
+
2635
+ **Returns:** `Promise<WebhookControllerFindOneResult>` - Webhook details
2636
+
2637
+ **Example:**
2638
+ ```typescript
2639
+ import { findOne } from 'cilantro-sdk/webhooks';
2640
+
2641
+ const webhook = await findOne('webhook-id');
2642
+ ```
2643
+
2644
+ #### `update(webhookId: string, data: UpdateWebhookDto): Promise<WebhookControllerUpdateResult>`
2645
+
2646
+ Update webhook configuration.
2647
+
2648
+ **Parameters:**
2649
+ - `webhookId` (`string`): Webhook ID
2650
+ - `data` (`UpdateWebhookDto`): Update data
2651
+ - `url?` (`string`): New URL
2652
+ - `events?` (`WebhookEvent[]`): Updated events
2653
+ - `isActive?` (`boolean`): Active status
2654
+ - `description?` (`string`): Description
2655
+
2656
+ **Returns:** `Promise<WebhookControllerUpdateResult>` - Updated webhook
2657
+
2658
+ **Example:**
2659
+ ```typescript
2660
+ import { update } from 'cilantro-sdk/webhooks';
2661
+
2662
+ await update('webhook-id', {
2663
+ events: ['wallet.created', 'transaction.confirmed'],
2664
+ isActive: false
2665
+ });
2666
+ ```
2667
+
2668
+ #### `remove(webhookId: string): Promise<WebhookControllerRemoveResult>`
2669
+
2670
+ Delete a webhook.
2671
+
2672
+ **Parameters:**
2673
+ - `webhookId` (`string`): Webhook ID
2674
+
2675
+ **Returns:** `Promise<WebhookControllerRemoveResult>` - Deletion confirmation
2676
+
2677
+ **Example:**
2678
+ ```typescript
2679
+ import { remove } from 'cilantro-sdk/webhooks';
2680
+
2681
+ await remove('webhook-id');
2682
+ ```
2683
+
2684
+ ### Helpers Module (`cilantro-sdk/helpers`)
2685
+
2686
+ **Device Key Management:**
2687
+ - `generateDeviceKeyPair()` - Generate new device key pair
2688
+ - `getOrCreateDeviceKeyPair(storage, keyId?)` - Get or create device key pair with caching
2689
+ - `getDevicePublicKey(storage, keyId)` - Get device public key
2690
+ - `getDevicePrivateKey(storage, keyId)` - Get device private key
2691
+ - `rotateDeviceKey(storage, keyId)` - Rotate device keys
2692
+ - `clearDeviceKeyCache(keyId?)` - Clear device key cache
2693
+ - `deleteDeviceKey(storage, keyId)` - Delete device key
2694
+ - `listDeviceKeys(storage)` - List all device key IDs
2695
+ - `findDeviceKeyByPublicKey(storage, publicKey)` - Find device key by public key
2696
+ - `listAllDeviceKeys(storage)` - List all device keys with metadata
2697
+
2698
+ **Storage Adapters:**
2699
+ - `createMemoryAdapter()` - Create in-memory storage adapter (for testing)
2700
+ - `createLocalStorageAdapter()` - Create browser localStorage adapter
2701
+ - `createFileSystemAdapter(basePath)` - Create Node.js filesystem adapter
2702
+ - `getDefaultStorageAdapter()` - Get platform-appropriate storage adapter
2703
+
2704
+ **Key Format Utilities:**
2705
+ - `normalizeSPKI(spkiKey)` - Normalize SPKI key format
2706
+ - `base64ToPEM(base64Key, keyType)` - Convert base64 to PEM format
2707
+ - `pemToBase64(pemKey)` - Convert PEM to base64
2708
+ - `base64ToArrayBuffer(base64)` - Convert base64 to ArrayBuffer
2709
+ - `arrayBufferToBase64(buffer)` - Convert ArrayBuffer to base64
2710
+ - `importSPKIPublicKey(spkiBase64)` - Import SPKI public key
2711
+ - `exportToSPKI(key)` - Export key to SPKI format
2712
+ - `isValidBase64(str)` - Validate base64 string
2713
+
2714
+ **Core Signer Helpers:**
2715
+ - `deriveSignerKeypair(walletId, signerId, options)` - Derive signer keypair from encrypted secret
2716
+ - `signWithSigner(walletId, signerId, message, options)` - Sign message with signer
2717
+ - `parseSignerResponse(response)` - Parse signer API response to SignerInfo
2718
+ - `clearSignerCache(walletId?, signerId?)` - Clear signer keypair cache
2719
+ - `getCacheStats()` - Get cache statistics
2720
+
2721
+ **Email Signer Helpers:**
2722
+ - `createEmailSignerHelper(walletId, options)` - Create email signer with automatic device key generation
2723
+ - `getEmailSignerKeypair(walletId, signerId, options)` - Get keypair with automatic device key resolution
2724
+ - `signWithEmailSigner(walletId, signerId, message, options)` - Sign messages with email signer
2725
+ - `clearEmailSignerCache(walletId, signerId?)` - Clear email signer cache
2726
+ - `getEmailSignerByEmail(walletId, email)` - Find email signer by email address
2727
+
2728
+ **Phone Signer Helpers:**
2729
+ - `createPhoneSignerHelper(walletId, options)` - Create phone signer with automatic device key generation
2730
+ - `getPhoneSignerKeypair(walletId, signerId, options)` - Get keypair with automatic device key resolution
2731
+ - `signWithPhoneSigner(walletId, signerId, message, options)` - Sign messages with phone signer
2732
+ - `clearPhoneSignerCache(walletId, signerId?)` - Clear phone signer cache
2733
+ - `getPhoneSignerByPhone(walletId, phone)` - Find phone signer by phone number
2734
+
2735
+ **Passkey (WebAuthn) Helpers:**
2736
+ - `isWebAuthnSupported()` - Check if WebAuthn is supported
2737
+ - `isPlatformAuthenticatorAvailable()` - Check if platform authenticator is available
2738
+ - `registerPasskey(walletId, options?)` - Register a new passkey
2739
+ - `authenticateWithPasskey(walletId, options?)` - Authenticate with existing passkey
2740
+ - `formatRegistrationResponse(response)` - Format passkey registration response
2741
+ - `formatAuthenticationResponse(response)` - Format passkey authentication response
2742
+ - `formatAuthenticationForVerification(response)` - Format authentication for verification
2743
+ - `findExistingPasskeySigner(walletId, credentialId?)` - Find existing passkey signer
2744
+ - `registerPasskeyComplete(walletId, registrationData, verificationData)` - Complete passkey registration
2745
+ - `signWithPasskeySigner(walletId, signerId, message, options)` - Sign with passkey signer
2746
+
2747
+ **Device Key Validation & Resolution:**
2748
+ - `getSignerDeviceKeys(walletId, signerId)` - Get all device keys for a signer from API
2749
+ - `validateDeviceKey(storage, keyId, expectedPublicKey)` - Validate device key matches API
2750
+ - `resolveDeviceKey(storage, walletId, signerId)` - Automatically find matching device key
2751
+ - `findAndValidateDeviceKey(storage, walletId, signerId, devicePublicKey)` - Find and validate device key
2752
+ - `getBestDeviceIdentity(walletId, signerId)` - Get most recently used device identity
2753
+
2754
+ **Device Identity Management:**
2755
+ - `addDeviceIdentityToSigner(walletId, signerId, options)` - Add new device to existing signer
2756
+ - `replaceDeviceIdentity(walletId, signerId, options)` - Replace existing device identity
2757
+ - `addNewDeviceToSigner(walletId, signerId, options)` - Convenience function for adding new device
2758
+ - `canAddDeviceToSigner(walletId, signerId)` - Check if device can be added to signer
2759
+
2760
+ **Signer Lifecycle:**
2761
+ - `createSigner(walletId, signerType, config)` - Create a new signer
2762
+ - `revokeSigner(walletId, signerId)` - Revoke a signer
2763
+ - `getSigners(walletId)` - Get all signers for a wallet
2764
+
2765
+ **Multi-Device Management:**
2766
+ - `addDevice(walletId, signerId, devicePublicKey)` - Add device to signer
2767
+ - `replaceDevice(walletId, signerId, oldDeviceId, newDevicePublicKey)` - Replace device
2768
+ - `getDevices(walletId, signerId)` - Get all devices for a signer
2769
+ - `updateDevice(walletId, signerId, deviceId, data)` - Update device information
2770
+
2771
+ **Validation:**
2772
+ - `isValidEmail(email)` - Validate email format
2773
+ - `isValidPhone(phone)` - Validate phone number format
2774
+ - `isBrowserCompatible()` - Check if browser is compatible
2775
+
2776
+ **External Wallet Adapter:**
2777
+ - `detectWallets()` - Detect available Solana wallets
2778
+ - `getWallet(name)` - Get wallet by name
2779
+ - `connectWallet(wallet)` - Connect to external wallet
2780
+ - `signTransaction(wallet, transaction)` - Sign transaction with external wallet
2781
+ - `signMessage(wallet, message)` - Sign message with external wallet
2782
+
2783
+ **Wallet Transaction Helpers:**
2784
+ - `signTransactionWithEmailSigner(walletId, signerId, transaction, options)` - Sign transaction with email signer
2785
+ - `signTransactionWithPhoneSigner(walletId, signerId, transaction, options)` - Sign transaction with phone signer
2786
+ - `signTransactionWithPasskeySigner(walletId, signerId, transaction, options)` - Sign transaction with passkey signer
2787
+ - `signTransactionWithExternalWallet(wallet, transaction)` - Sign transaction with external wallet
2788
+ - `prepareSignAndSubmitTransaction(walletId, transaction, signerConfig)` - Prepare, sign, and submit transaction
2789
+ - `sendSOLWithSigner(walletId, recipientAddress, amountLamports, signerConfig)` - Send SOL using signer
2790
+ - `sendSPLWithSigner(walletId, recipientAddress, mintAddress, amount, signerConfig)` - Send SPL token using signer
2791
+
2792
+ ### Utils Module (`cilantro-sdk/utils`)
2793
+
2794
+ #### `generateDevicePublicKey(): Promise<string>`
2795
+
2796
+ Generate device public key for ECDH (P-256) encryption. Works in both browser and Node.js environments.
2797
+
2798
+ **Parameters:** None
2799
+
2800
+ **Returns:** `Promise<string>` - Base64-encoded P-256 ECDH public key (65 bytes, uncompressed format)
2801
+
2802
+ **Example:**
2803
+ ```typescript
2804
+ import { generateDevicePublicKey } from 'cilantro-sdk/utils';
257
2805
 
258
- ### Quick Reference
259
-
260
- **Platform Module:**
261
- - Basic: `create`, `findAll`, `findOne`, `update`, `remove`, `getOwnProfile`, `updateOwnProfile`
262
- - Users: `getUsers`, `createUser`, `updateUser`, `removeUser`, `toggleUserActive`
263
- - Wallets: `getWallets` (read-only)
264
-
265
- **User Module:**
266
- - `create`, `findOne`, `update`
267
-
268
- **Wallet Module:**
269
- - Basic: `create`, `findAll`, `findOne`, `update`, `remove`, `findByAddress`, `getTotalBalance`
270
- - Status: `activate`, `deactivate`
271
- - Transactions: `sendSOL`, `sendSPL`, `sendTransaction`, `simulateTransaction`
272
- - Batch: `batchCreate`, `batchSendSOL`, `batchSendSPL`
273
- - NFTs & Tokens: `mintNFT`, `mintNFTSimple`, `mintToken`
274
- - Assets: `getAssets`, `syncAssets`
275
- - Signers: Email, phone, external, API key, and passkey signer management
276
-
277
- **Auth Module:**
278
- - `login` - Login and get JWT token
279
- - `loginAndSetAuth` - Login and automatically set authentication
280
-
281
- **Subscriptions Module:**
282
- - Basic: `create`, `findAll`, `findOne`, `getPlatformSubscription`
283
- - Management: `upgrade`, `downgrade`, `cancel`, `renew`
284
- - History: `getHistory` - Get subscription audit trail
285
-
286
- **Plans Module:**
287
- - Basic: `findAll`, `findOne`, `update`, `remove`
288
- - Assignment: `assignToPlatform`, `assignToUser`
289
-
290
- **Subscriptions Module:**
291
- - Basic: `create`, `findAll`, `findOne`, `getPlatformSubscription`
292
- - Management: `upgrade`, `downgrade`, `cancel`, `renew`
293
- - History: `getHistory` - Get subscription audit trail
294
-
295
- **Plans Module:**
296
- - Basic: `findAll`, `findOne`, `update`, `remove`
297
- - Assignment: `assignToPlatform`, `assignToUser`
298
-
299
- **Transactions Module:**
300
- - `getWalletTransactions` - Get paginated transaction history for a wallet
301
- - `getTransactionStatus` - Get transaction status by Solana signature
302
-
303
- **Delegated Keys Module:**
304
- - `create` - Create temporary delegated key for wallet
305
- - `findAll` - List all delegated keys for a wallet
306
- - `findOne` - Get delegated key by ID
307
- - `update` - Update delegated key configuration
308
- - `remove` - Revoke delegated key
309
-
310
- **Webhooks Module:**
311
- - `create` - Register new webhook endpoint
312
- - `findAll` - List all webhooks for platform
313
- - `findOne` - Get webhook by ID
314
- - `update` - Update webhook configuration
315
- - `remove` - Delete webhook
316
-
317
- **Helpers Module:**
318
- - Device key management, signer helpers, validation, and storage adapters (see above)
2806
+ const devicePublicKey = await generateDevicePublicKey();
2807
+ // Use with createEmailSigner or createPhoneSigner
2808
+ ```
2809
+
2810
+ **Note:** This function automatically detects the environment (browser vs Node.js) and uses the appropriate crypto implementation.
319
2811
 
320
2812
  ## Examples
321
2813
 
@@ -581,7 +3073,6 @@ import type {
581
3073
  **Response Types:**
582
3074
  - `WalletControllerCreateResult`, `WalletControllerFindAllResult`
583
3075
  - `PlatformControllerCreateResult`, `UserControllerCreateResult`
584
- - `AdminControllerGetOverviewAnalyticsResult`
585
3076
  - All API endpoints have corresponding response types
586
3077
 
587
3078
  **Helper Types:**
@@ -592,7 +3083,6 @@ import type {
592
3083
  **Parameter Types:**
593
3084
  - `WalletControllerGetWalletAssetsParams`
594
3085
  - `TransactionControllerGetWalletTransactionsParams`
595
- - `AdminControllerFindAllParams`
596
3086
 
597
3087
  **Enum Types:**
598
3088
  - `TransactionType`, `TransactionStatus`, `WebhookEvent`
@@ -718,6 +3208,204 @@ module.exports = {
718
3208
  };
719
3209
  ```
720
3210
 
3211
+ ## Best Practices
3212
+
3213
+ ### Security
3214
+
3215
+ 1. **Never expose API keys or JWT tokens in client-side code**
3216
+ - Use API keys only on the server
3217
+ - Store JWT tokens securely (httpOnly cookies, secure storage)
3218
+ - Rotate API keys regularly
3219
+
3220
+ 2. **Protect device keys**
3221
+ - Store device private keys securely (use provided storage adapters)
3222
+ - Never log or expose private keys
3223
+ - Use encryption for sensitive data
3224
+
3225
+ 3. **Validate inputs**
3226
+ - Always validate user inputs before making API calls
3227
+ - Use TypeScript types for compile-time safety
3228
+ - Validate addresses and amounts
3229
+
3230
+ 4. **Handle errors gracefully**
3231
+ - Always wrap API calls in try-catch blocks
3232
+ - Check transaction status before considering operations complete
3233
+ - Implement retry logic for transient failures
3234
+
3235
+ ### Performance
3236
+
3237
+ 1. **Cache device keys and signers**
3238
+ - Use the built-in caching mechanisms in helpers
3239
+ - Cache keypairs to avoid redundant derivations
3240
+ - Clear cache when needed (e.g., after key rotation)
3241
+
3242
+ 2. **Batch operations when possible**
3243
+ - Use `batchSendSOL` and `batchSendSPL` for multiple transfers
3244
+ - Use `batchCreate` for creating multiple wallets
3245
+
3246
+ 3. **Optimize transaction preparation**
3247
+ - Use `simulateTransaction` before submitting
3248
+ - Check transaction status asynchronously
3249
+ - Use pagination for large data sets
3250
+
3251
+ ### Error Handling
3252
+
3253
+ ```typescript
3254
+ import {
3255
+ SDKError,
3256
+ DeviceKeyNotFoundError,
3257
+ DeviceKeyMismatchError,
3258
+ TransactionSigningError
3259
+ } from 'cilantro-sdk';
3260
+
3261
+ try {
3262
+ const result = await wallet.sendSOL('wallet-id', {
3263
+ recipientAddress: 'address',
3264
+ amountLamports: 1000000000
3265
+ });
3266
+ } catch (error) {
3267
+ if (error instanceof DeviceKeyNotFoundError) {
3268
+ // Handle missing device key
3269
+ console.error('Device key not found');
3270
+ } else if (error instanceof TransactionSigningError) {
3271
+ // Handle signing error
3272
+ console.error('Transaction signing failed');
3273
+ } else if (error instanceof SDKError) {
3274
+ // Handle other SDK errors
3275
+ console.error('SDK Error:', error.message);
3276
+ } else {
3277
+ // Handle unexpected errors
3278
+ console.error('Unexpected error:', error);
3279
+ }
3280
+ }
3281
+ ```
3282
+
3283
+ ### Common Patterns
3284
+
3285
+ #### Wallet Creation Flow
3286
+
3287
+ ```typescript
3288
+ // 1. Create wallet
3289
+ const wallet = await wallet.create({
3290
+ name: 'My Wallet',
3291
+ userId: 'user-id',
3292
+ walletMode: 'nonCustodial'
3293
+ });
3294
+
3295
+ // 2. Create signer
3296
+ const deviceKey = await generateDevicePublicKey();
3297
+ const signer = await wallet.createEmailSigner(wallet.data.id, {
3298
+ email: 'user@example.com',
3299
+ devicePublicKey: deviceKey
3300
+ });
3301
+
3302
+ // 3. Store device key securely
3303
+ const storage = createLocalStorageAdapter();
3304
+ await storage.save(`device-${signer.data.deviceId}`, {
3305
+ publicKey: deviceKey,
3306
+ privateKey: devicePrivateKey, // Store securely
3307
+ keyId: signer.data.deviceId,
3308
+ createdAt: new Date()
3309
+ });
3310
+ ```
3311
+
3312
+ #### Transaction Flow (Non-Custodial)
3313
+
3314
+ ```typescript
3315
+ // 1. Prepare transaction
3316
+ const prepared = await wallet.prepareTransaction('wallet-id', {
3317
+ type: 'transfer',
3318
+ recipientAddress: 'recipient-address',
3319
+ amount: 1000000000
3320
+ });
3321
+
3322
+ // 2. Sign transaction client-side
3323
+ const keypair = await getEmailSignerKeypair('wallet-id', 'signer-id', {
3324
+ deviceKeyManager: storage
3325
+ });
3326
+ const signedTx = await signTransaction(prepared.data.transaction, keypair);
3327
+
3328
+ // 3. Submit transaction
3329
+ const result = await wallet.submitTransaction('wallet-id', {
3330
+ signedTransaction: signedTx
3331
+ });
3332
+
3333
+ // 4. Check status
3334
+ const status = await getTransactionStatus(result.data.signature);
3335
+ ```
3336
+
3337
+ #### Multi-Device Support
3338
+
3339
+ ```typescript
3340
+ // Add new device to existing signer
3341
+ const newDeviceKey = await generateDevicePublicKey();
3342
+ await wallet.updateDeviceIdentity('wallet-id', 'signer-id', {
3343
+ devicePublicKey: newDeviceKey,
3344
+ replace: false // Add new device, don't replace
3345
+ });
3346
+
3347
+ // Store new device key
3348
+ await storage.save(`device-${newDeviceId}`, {
3349
+ publicKey: newDeviceKey,
3350
+ privateKey: newDevicePrivateKey,
3351
+ keyId: newDeviceId,
3352
+ createdAt: new Date()
3353
+ });
3354
+ ```
3355
+
3356
+ ### TypeScript Best Practices
3357
+
3358
+ 1. **Use type imports for better tree-shaking**
3359
+ ```typescript
3360
+ import type { CreateWalletDto, WalletControllerCreateResult } from 'cilantro-sdk';
3361
+ ```
3362
+
3363
+ 2. **Leverage type inference**
3364
+ ```typescript
3365
+ const wallet = await wallet.create({ ... });
3366
+ // wallet is automatically typed as WalletControllerCreateResult
3367
+ ```
3368
+
3369
+ 3. **Use const assertions for literal types**
3370
+ ```typescript
3371
+ const events = ['wallet.created', 'transaction.confirmed'] as const;
3372
+ ```
3373
+
3374
+ ### Testing
3375
+
3376
+ 1. **Use memory adapter for tests**
3377
+ ```typescript
3378
+ import { createMemoryAdapter } from 'cilantro-sdk/helpers';
3379
+
3380
+ const storage = createMemoryAdapter();
3381
+ // Use in tests - no persistence
3382
+ ```
3383
+
3384
+ 2. **Mock API calls in unit tests**
3385
+ ```typescript
3386
+ // Mock configure for tests
3387
+ configure({ apiKey: 'test-key', baseURL: 'http://localhost:3000' });
3388
+ ```
3389
+
3390
+ 3. **Test error handling**
3391
+ ```typescript
3392
+ await expect(wallet.sendSOL('invalid-id', { ... }))
3393
+ .rejects.toThrow(SDKError);
3394
+ ```
3395
+
3396
+ ### Production Checklist
3397
+
3398
+ - [ ] Configure SDK with production API key
3399
+ - [ ] Set up proper error logging and monitoring
3400
+ - [ ] Implement retry logic for network failures
3401
+ - [ ] Set up webhooks for important events
3402
+ - [ ] Use secure storage for device keys
3403
+ - [ ] Implement proper authentication flow
3404
+ - [ ] Add transaction status polling
3405
+ - [ ] Set up rate limiting on client side
3406
+ - [ ] Monitor API usage and costs
3407
+ - [ ] Keep SDK updated to latest version
3408
+
721
3409
  ## License
722
3410
 
723
3411
  ISC