@ottochain/sdk 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/README.md +305 -0
  2. package/dist/apps/contracts/index.d.ts +21 -0
  3. package/dist/apps/contracts/index.js +39 -0
  4. package/dist/apps/contracts/types.d.ts +24 -0
  5. package/dist/apps/contracts/types.js +48 -0
  6. package/dist/apps/identity/index.d.ts +22 -0
  7. package/dist/apps/identity/index.js +40 -0
  8. package/dist/apps/identity/types.d.ts +30 -0
  9. package/dist/apps/identity/types.js +53 -0
  10. package/dist/apps/index.d.ts +29 -0
  11. package/dist/apps/index.js +60 -0
  12. package/dist/apps/markets/index.d.ts +26 -0
  13. package/dist/apps/markets/index.js +46 -0
  14. package/dist/apps/markets/types.d.ts +185 -0
  15. package/dist/apps/markets/types.js +252 -0
  16. package/dist/apps/oracles/index.d.ts +26 -0
  17. package/dist/apps/oracles/index.js +46 -0
  18. package/dist/apps/oracles/types.d.ts +211 -0
  19. package/dist/apps/oracles/types.js +306 -0
  20. package/dist/cjs/apps/contracts/index.js +60 -0
  21. package/dist/cjs/apps/contracts/state-machines/contract.json +420 -0
  22. package/dist/cjs/apps/contracts/state-machines/escrow.json +426 -0
  23. package/dist/cjs/apps/contracts/types.js +48 -0
  24. package/dist/cjs/apps/corporate/index.js +112 -0
  25. package/dist/cjs/apps/corporate/state-machines/corporate-board.json +1064 -0
  26. package/dist/cjs/apps/corporate/state-machines/corporate-bylaws.json +751 -0
  27. package/dist/cjs/apps/corporate/state-machines/corporate-committee.json +957 -0
  28. package/dist/cjs/apps/corporate/state-machines/corporate-compliance.json +1293 -0
  29. package/dist/cjs/apps/corporate/state-machines/corporate-entity.json +861 -0
  30. package/dist/cjs/apps/corporate/state-machines/corporate-officers.json +843 -0
  31. package/dist/cjs/apps/corporate/state-machines/corporate-proxy.json +783 -0
  32. package/dist/cjs/apps/corporate/state-machines/corporate-resolution.json +1174 -0
  33. package/dist/cjs/apps/corporate/state-machines/corporate-securities.json +1215 -0
  34. package/dist/cjs/apps/corporate/state-machines/corporate-shareholders.json +1298 -0
  35. package/dist/cjs/apps/corporate/types.js +44 -0
  36. package/dist/cjs/apps/governance/index.js +203 -0
  37. package/dist/cjs/apps/governance/state-machines/dao-multisig.json +711 -0
  38. package/dist/cjs/apps/governance/state-machines/dao-single.json +258 -0
  39. package/dist/cjs/apps/governance/state-machines/dao-threshold.json +660 -0
  40. package/dist/cjs/apps/governance/state-machines/dao-token.json +680 -0
  41. package/dist/cjs/apps/governance/state-machines/governance-constitution.json +401 -0
  42. package/dist/cjs/apps/governance/state-machines/governance-executive.json +441 -0
  43. package/dist/cjs/apps/governance/state-machines/governance-judiciary.json +626 -0
  44. package/dist/cjs/apps/governance/state-machines/governance-legislature.json +726 -0
  45. package/dist/cjs/apps/governance/state-machines/governance-simple.json +679 -0
  46. package/dist/cjs/apps/governance/types.js +42 -0
  47. package/dist/cjs/apps/identity/constants.js +58 -0
  48. package/dist/cjs/apps/identity/index.js +78 -0
  49. package/dist/cjs/apps/identity/state-machines/agent-identity.json +320 -0
  50. package/dist/cjs/apps/identity/types.js +53 -0
  51. package/dist/cjs/apps/index.js +58 -0
  52. package/dist/cjs/apps/markets/index.js +55 -0
  53. package/dist/cjs/apps/markets/state-machines/market-universal.json +354 -0
  54. package/dist/cjs/apps/markets/types.js +219 -0
  55. package/dist/cjs/apps/oracles/index.js +62 -0
  56. package/dist/cjs/apps/oracles/state-machines/oracle.json +452 -0
  57. package/dist/cjs/apps/oracles/types.js +282 -0
  58. package/dist/cjs/errors.js +293 -0
  59. package/dist/cjs/generated/google/protobuf/struct.js +514 -0
  60. package/dist/cjs/generated/google/protobuf/timestamp.js +92 -0
  61. package/dist/cjs/generated/index.js +150 -0
  62. package/dist/cjs/generated/ottochain/apps/contracts/v1/contract.js +873 -0
  63. package/dist/cjs/generated/ottochain/apps/contracts/v1/contract_pb.js +100 -0
  64. package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +4515 -0
  65. package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate_pb.js +392 -0
  66. package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +3255 -0
  67. package/dist/cjs/generated/ottochain/apps/governance/v1/governance_pb.js +235 -0
  68. package/dist/cjs/generated/ottochain/apps/identity/v1/agent.js +619 -0
  69. package/dist/cjs/generated/ottochain/apps/identity/v1/agent_pb.js +116 -0
  70. package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +780 -0
  71. package/dist/cjs/generated/ottochain/apps/identity/v1/attestation_pb.js +79 -0
  72. package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +1261 -0
  73. package/dist/cjs/generated/ottochain/apps/markets/v1/market_pb.js +151 -0
  74. package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle.js +1223 -0
  75. package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle_pb.js +109 -0
  76. package/dist/cjs/generated/ottochain/v1/common.js +10 -0
  77. package/dist/cjs/generated/ottochain/v1/common_pb.js +37 -0
  78. package/dist/cjs/generated/ottochain/v1/fiber.js +1057 -0
  79. package/dist/cjs/generated/ottochain/v1/fiber_pb.js +86 -0
  80. package/dist/cjs/generated/ottochain/v1/messages.js +740 -0
  81. package/dist/cjs/generated/ottochain/v1/messages_pb.js +44 -0
  82. package/dist/cjs/generated/ottochain/v1/records.js +1253 -0
  83. package/dist/cjs/generated/ottochain/v1/records_pb.js +44 -0
  84. package/dist/cjs/index.js +79 -0
  85. package/dist/cjs/metakit/binary.js +58 -0
  86. package/dist/cjs/metakit/canonicalize.js +40 -0
  87. package/dist/cjs/metakit/codec.js +45 -0
  88. package/dist/cjs/metakit/currency-transaction.js +319 -0
  89. package/dist/cjs/metakit/currency-types.js +13 -0
  90. package/dist/cjs/metakit/hash.js +84 -0
  91. package/dist/cjs/metakit/index.js +74 -0
  92. package/dist/cjs/metakit/network/client.js +78 -0
  93. package/dist/cjs/metakit/network/currency-l1-client.js +101 -0
  94. package/dist/cjs/metakit/network/data-l1-client.js +76 -0
  95. package/dist/cjs/metakit/network/index.js +16 -0
  96. package/dist/cjs/metakit/network/types.js +20 -0
  97. package/dist/cjs/metakit/sign.js +120 -0
  98. package/dist/cjs/metakit/signed-object.js +100 -0
  99. package/dist/cjs/metakit/types.js +14 -0
  100. package/dist/cjs/metakit/verify.js +217 -0
  101. package/dist/cjs/metakit/wallet.js +127 -0
  102. package/dist/cjs/ottochain/index.js +47 -0
  103. package/dist/cjs/ottochain/metagraph-client.js +157 -0
  104. package/dist/cjs/ottochain/snapshot.js +110 -0
  105. package/dist/cjs/ottochain/types.js +11 -0
  106. package/dist/cjs/package.json +1 -0
  107. package/dist/cjs/types.js +25 -0
  108. package/dist/cjs/validation.js +312 -0
  109. package/dist/errors.d.ts +221 -0
  110. package/dist/errors.js +293 -0
  111. package/dist/esm/apps/contracts/index.js +42 -0
  112. package/dist/esm/apps/contracts/state-machines/contract.json +420 -0
  113. package/dist/esm/apps/contracts/state-machines/escrow.json +426 -0
  114. package/dist/esm/apps/contracts/types.js +44 -0
  115. package/dist/esm/apps/corporate/index.js +57 -0
  116. package/dist/esm/apps/corporate/state-machines/corporate-board.json +1064 -0
  117. package/dist/esm/apps/corporate/state-machines/corporate-bylaws.json +751 -0
  118. package/dist/esm/apps/corporate/state-machines/corporate-committee.json +957 -0
  119. package/dist/esm/apps/corporate/state-machines/corporate-compliance.json +1293 -0
  120. package/dist/esm/apps/corporate/state-machines/corporate-entity.json +861 -0
  121. package/dist/esm/apps/corporate/state-machines/corporate-officers.json +843 -0
  122. package/dist/esm/apps/corporate/state-machines/corporate-proxy.json +783 -0
  123. package/dist/esm/apps/corporate/state-machines/corporate-resolution.json +1174 -0
  124. package/dist/esm/apps/corporate/state-machines/corporate-securities.json +1215 -0
  125. package/dist/esm/apps/corporate/state-machines/corporate-shareholders.json +1298 -0
  126. package/dist/esm/apps/corporate/types.js +38 -0
  127. package/dist/esm/apps/governance/index.js +154 -0
  128. package/dist/esm/apps/governance/state-machines/dao-multisig.json +711 -0
  129. package/dist/esm/apps/governance/state-machines/dao-single.json +258 -0
  130. package/dist/esm/apps/governance/state-machines/dao-threshold.json +660 -0
  131. package/dist/esm/apps/governance/state-machines/dao-token.json +680 -0
  132. package/dist/esm/apps/governance/state-machines/governance-constitution.json +401 -0
  133. package/dist/esm/apps/governance/state-machines/governance-executive.json +441 -0
  134. package/dist/esm/apps/governance/state-machines/governance-judiciary.json +626 -0
  135. package/dist/esm/apps/governance/state-machines/governance-legislature.json +726 -0
  136. package/dist/esm/apps/governance/state-machines/governance-simple.json +679 -0
  137. package/dist/esm/apps/governance/types.js +35 -0
  138. package/dist/esm/apps/identity/constants.js +53 -0
  139. package/dist/esm/apps/identity/index.js +50 -0
  140. package/dist/esm/apps/identity/state-machines/agent-identity.json +320 -0
  141. package/dist/esm/apps/identity/types.js +50 -0
  142. package/dist/esm/apps/index.js +32 -0
  143. package/dist/esm/apps/markets/index.js +34 -0
  144. package/dist/esm/apps/markets/state-machines/market-universal.json +354 -0
  145. package/dist/esm/apps/markets/types.js +206 -0
  146. package/dist/esm/apps/oracles/index.js +42 -0
  147. package/dist/esm/apps/oracles/state-machines/oracle.json +452 -0
  148. package/dist/esm/apps/oracles/types.js +267 -0
  149. package/dist/esm/errors.js +283 -0
  150. package/dist/esm/generated/google/protobuf/struct.js +508 -0
  151. package/dist/esm/generated/google/protobuf/timestamp.js +89 -0
  152. package/dist/esm/generated/index.js +26 -0
  153. package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +867 -0
  154. package/dist/esm/generated/ottochain/apps/contracts/v1/contract_pb.js +97 -0
  155. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +4493 -0
  156. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate_pb.js +389 -0
  157. package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +3240 -0
  158. package/dist/esm/generated/ottochain/apps/governance/v1/governance_pb.js +232 -0
  159. package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +610 -0
  160. package/dist/esm/generated/ottochain/apps/identity/v1/agent_pb.js +113 -0
  161. package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +774 -0
  162. package/dist/esm/generated/ottochain/apps/identity/v1/attestation_pb.js +76 -0
  163. package/dist/esm/generated/ottochain/apps/markets/v1/market.js +1252 -0
  164. package/dist/esm/generated/ottochain/apps/markets/v1/market_pb.js +148 -0
  165. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +1217 -0
  166. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle_pb.js +106 -0
  167. package/dist/esm/generated/ottochain/v1/common.js +7 -0
  168. package/dist/esm/generated/ottochain/v1/common_pb.js +34 -0
  169. package/dist/esm/generated/ottochain/v1/fiber.js +1051 -0
  170. package/dist/esm/generated/ottochain/v1/fiber_pb.js +83 -0
  171. package/dist/esm/generated/ottochain/v1/messages.js +737 -0
  172. package/dist/esm/generated/ottochain/v1/messages_pb.js +41 -0
  173. package/dist/esm/generated/ottochain/v1/records.js +1250 -0
  174. package/dist/esm/generated/ottochain/v1/records_pb.js +41 -0
  175. package/dist/esm/index.js +33 -0
  176. package/dist/esm/metakit/binary.js +53 -0
  177. package/dist/esm/metakit/canonicalize.js +33 -0
  178. package/dist/esm/metakit/codec.js +38 -0
  179. package/dist/esm/metakit/currency-transaction.js +306 -0
  180. package/dist/esm/metakit/currency-types.js +10 -0
  181. package/dist/esm/metakit/hash.js +77 -0
  182. package/dist/esm/metakit/index.js +30 -0
  183. package/dist/esm/metakit/network/client.js +74 -0
  184. package/dist/esm/metakit/network/currency-l1-client.js +97 -0
  185. package/dist/esm/metakit/network/data-l1-client.js +72 -0
  186. package/dist/esm/metakit/network/index.js +9 -0
  187. package/dist/esm/metakit/network/types.js +16 -0
  188. package/dist/esm/metakit/sign.js +114 -0
  189. package/dist/esm/metakit/signed-object.js +94 -0
  190. package/dist/esm/metakit/types.js +11 -0
  191. package/dist/esm/metakit/verify.js +210 -0
  192. package/dist/esm/metakit/wallet.js +117 -0
  193. package/dist/esm/ottochain/index.js +13 -0
  194. package/dist/esm/ottochain/metagraph-client.js +153 -0
  195. package/dist/esm/ottochain/snapshot.js +100 -0
  196. package/dist/esm/ottochain/types.js +10 -0
  197. package/dist/esm/package.json +1 -0
  198. package/dist/esm/types.js +20 -0
  199. package/dist/esm/validation.js +301 -0
  200. package/dist/generated/index.d.ts +15 -0
  201. package/dist/generated/index.js +34 -0
  202. package/dist/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +274 -0
  203. package/dist/generated/ottochain/apps/contracts/v1/contract_pb.js +100 -0
  204. package/dist/generated/ottochain/apps/identity/v1/agent_pb.d.ts +211 -0
  205. package/dist/generated/ottochain/apps/identity/v1/agent_pb.js +116 -0
  206. package/dist/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +238 -0
  207. package/dist/generated/ottochain/apps/identity/v1/attestation_pb.js +79 -0
  208. package/dist/generated/ottochain/apps/markets/v1/market_pb.d.ts +436 -0
  209. package/dist/generated/ottochain/apps/markets/v1/market_pb.js +151 -0
  210. package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +393 -0
  211. package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.js +109 -0
  212. package/dist/generated/ottochain/v1/common_pb.d.ts +86 -0
  213. package/dist/generated/ottochain/v1/common_pb.js +37 -0
  214. package/dist/generated/ottochain/v1/fiber_pb.d.ts +292 -0
  215. package/dist/generated/ottochain/v1/fiber_pb.js +86 -0
  216. package/dist/generated/ottochain/v1/messages_pb.d.ts +190 -0
  217. package/dist/generated/ottochain/v1/messages_pb.js +44 -0
  218. package/dist/generated/ottochain/v1/records_pb.d.ts +221 -0
  219. package/dist/generated/ottochain/v1/records_pb.js +44 -0
  220. package/dist/index.d.ts +21 -0
  221. package/dist/index.js +77 -0
  222. package/dist/metakit/binary.d.ts +38 -0
  223. package/dist/metakit/binary.js +58 -0
  224. package/dist/metakit/canonicalize.d.ts +26 -0
  225. package/dist/metakit/canonicalize.js +40 -0
  226. package/dist/metakit/codec.d.ts +16 -0
  227. package/dist/metakit/codec.js +45 -0
  228. package/dist/metakit/currency-transaction.d.ts +157 -0
  229. package/dist/metakit/currency-transaction.js +319 -0
  230. package/dist/metakit/currency-types.d.ts +55 -0
  231. package/dist/metakit/currency-types.js +13 -0
  232. package/dist/metakit/hash.d.ts +50 -0
  233. package/dist/metakit/hash.js +84 -0
  234. package/dist/metakit/index.d.ts +23 -0
  235. package/dist/metakit/index.js +74 -0
  236. package/dist/metakit/network/client.d.ts +23 -0
  237. package/dist/metakit/network/client.js +78 -0
  238. package/dist/metakit/network/currency-l1-client.d.ts +71 -0
  239. package/dist/metakit/network/currency-l1-client.js +101 -0
  240. package/dist/metakit/network/data-l1-client.d.ts +57 -0
  241. package/dist/metakit/network/data-l1-client.js +76 -0
  242. package/dist/metakit/network/index.d.ts +10 -0
  243. package/dist/metakit/network/index.js +16 -0
  244. package/dist/metakit/network/types.d.ts +74 -0
  245. package/dist/metakit/network/types.js +20 -0
  246. package/dist/metakit/sign.d.ts +65 -0
  247. package/dist/metakit/sign.js +120 -0
  248. package/dist/metakit/signed-object.d.ts +66 -0
  249. package/dist/metakit/signed-object.js +100 -0
  250. package/dist/metakit/types.d.ts +67 -0
  251. package/dist/metakit/types.js +14 -0
  252. package/dist/metakit/verify.d.ts +55 -0
  253. package/dist/metakit/verify.js +217 -0
  254. package/dist/metakit/wallet.d.ts +70 -0
  255. package/dist/metakit/wallet.js +127 -0
  256. package/dist/ottochain/index.d.ts +13 -0
  257. package/dist/ottochain/index.js +45 -0
  258. package/dist/ottochain/metagraph-client.d.ts +111 -0
  259. package/dist/ottochain/metagraph-client.js +157 -0
  260. package/dist/ottochain/snapshot.d.ts +86 -0
  261. package/dist/ottochain/snapshot.js +110 -0
  262. package/dist/ottochain/types.d.ts +278 -0
  263. package/dist/ottochain/types.js +11 -0
  264. package/dist/types/apps/contracts/index.d.ts +30 -0
  265. package/dist/types/apps/contracts/types.d.ts +24 -0
  266. package/dist/types/apps/corporate/index.d.ts +27 -0
  267. package/dist/types/apps/corporate/types.d.ts +9861 -0
  268. package/dist/types/apps/governance/index.d.ts +77 -0
  269. package/dist/types/apps/governance/types.d.ts +344 -0
  270. package/dist/types/apps/identity/constants.d.ts +27 -0
  271. package/dist/types/apps/identity/index.d.ts +39 -0
  272. package/dist/types/apps/identity/types.d.ts +30 -0
  273. package/dist/types/apps/index.d.ts +31 -0
  274. package/dist/types/apps/markets/index.d.ts +26 -0
  275. package/dist/types/apps/markets/types.d.ts +155 -0
  276. package/dist/types/apps/oracles/index.d.ts +34 -0
  277. package/dist/types/apps/oracles/types.d.ts +193 -0
  278. package/dist/types/errors.d.ts +221 -0
  279. package/dist/types/generated/google/protobuf/struct.d.ts +134 -0
  280. package/dist/types/generated/google/protobuf/timestamp.d.ts +134 -0
  281. package/dist/types/generated/index.d.ts +18 -0
  282. package/dist/types/generated/ottochain/apps/contracts/v1/contract.d.ts +112 -0
  283. package/dist/types/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +274 -0
  284. package/dist/types/generated/ottochain/apps/corporate/v1/corporate.d.ts +376 -0
  285. package/dist/types/generated/ottochain/apps/corporate/v1/corporate_pb.d.ts +1172 -0
  286. package/dist/types/generated/ottochain/apps/governance/v1/governance.d.ts +296 -0
  287. package/dist/types/generated/ottochain/apps/governance/v1/governance_pb.d.ts +772 -0
  288. package/dist/types/generated/ottochain/apps/identity/v1/agent.d.ts +94 -0
  289. package/dist/types/generated/ottochain/apps/identity/v1/agent_pb.d.ts +211 -0
  290. package/dist/types/generated/ottochain/apps/identity/v1/attestation.d.ts +102 -0
  291. package/dist/types/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +238 -0
  292. package/dist/types/generated/ottochain/apps/markets/v1/market.d.ts +174 -0
  293. package/dist/types/generated/ottochain/apps/markets/v1/market_pb.d.ts +436 -0
  294. package/dist/types/generated/ottochain/apps/oracles/v1/oracle.d.ts +150 -0
  295. package/dist/types/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +393 -0
  296. package/dist/types/generated/ottochain/v1/common.d.ts +1 -0
  297. package/dist/types/generated/ottochain/v1/common_pb.d.ts +86 -0
  298. package/dist/types/generated/ottochain/v1/fiber.d.ts +130 -0
  299. package/dist/types/generated/ottochain/v1/fiber_pb.d.ts +292 -0
  300. package/dist/types/generated/ottochain/v1/messages.d.ts +89 -0
  301. package/dist/types/generated/ottochain/v1/messages_pb.d.ts +190 -0
  302. package/dist/types/generated/ottochain/v1/records.d.ts +128 -0
  303. package/dist/types/generated/ottochain/v1/records_pb.d.ts +221 -0
  304. package/dist/types/index.d.ts +22 -0
  305. package/dist/types/metakit/binary.d.ts +38 -0
  306. package/dist/types/metakit/canonicalize.d.ts +26 -0
  307. package/dist/types/metakit/codec.d.ts +16 -0
  308. package/dist/types/metakit/currency-transaction.d.ts +157 -0
  309. package/dist/types/metakit/currency-types.d.ts +55 -0
  310. package/dist/types/metakit/hash.d.ts +50 -0
  311. package/dist/types/metakit/index.d.ts +23 -0
  312. package/dist/types/metakit/network/client.d.ts +23 -0
  313. package/dist/types/metakit/network/currency-l1-client.d.ts +71 -0
  314. package/dist/types/metakit/network/data-l1-client.d.ts +57 -0
  315. package/dist/types/metakit/network/index.d.ts +10 -0
  316. package/dist/types/metakit/network/types.d.ts +74 -0
  317. package/dist/types/metakit/sign.d.ts +65 -0
  318. package/dist/types/metakit/signed-object.d.ts +66 -0
  319. package/dist/types/metakit/types.d.ts +67 -0
  320. package/dist/types/metakit/verify.d.ts +55 -0
  321. package/dist/types/metakit/wallet.d.ts +70 -0
  322. package/dist/types/ottochain/index.d.ts +13 -0
  323. package/dist/types/ottochain/metagraph-client.d.ts +111 -0
  324. package/dist/types/ottochain/snapshot.d.ts +86 -0
  325. package/dist/types/ottochain/types.d.ts +210 -0
  326. package/dist/types/types.d.ts +51 -0
  327. package/dist/types/validation.d.ts +449 -0
  328. package/dist/validation.d.ts +449 -0
  329. package/dist/validation.js +312 -0
  330. package/package.json +136 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Signing Functions
3
+ *
4
+ * ECDSA signing using secp256k1 curve via dag4js.
5
+ * Implements the Constellation signature protocol.
6
+ */
7
+ import { SignatureProof } from './types.js';
8
+ /**
9
+ * Sign data using the regular Constellation protocol (non-DataUpdate)
10
+ *
11
+ * Protocol:
12
+ * 1. Canonicalize JSON (RFC 8785)
13
+ * 2. SHA-256 hash the canonical JSON string
14
+ * 3. Sign using dag4.keyStore.sign
15
+ *
16
+ * @param data - Any JSON-serializable object
17
+ * @param privateKey - Private key in hex format
18
+ * @returns SignatureProof with public key ID and signature
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const proof = await sign({ action: 'test' }, privateKeyHex);
23
+ * console.log(proof.id); // public key (128 chars)
24
+ * console.log(proof.signature); // DER signature
25
+ * ```
26
+ */
27
+ export declare function sign<T>(data: T, privateKey: string): Promise<SignatureProof>;
28
+ /**
29
+ * Sign data as a DataUpdate (with Constellation prefix)
30
+ *
31
+ * Protocol:
32
+ * 1. Canonicalize JSON (RFC 8785)
33
+ * 2. Base64 encode the canonical JSON
34
+ * 3. Sign using dag4.keyStore.dataSign (adds Constellation prefix internally)
35
+ *
36
+ * @param data - Any JSON-serializable object
37
+ * @param privateKey - Private key in hex format
38
+ * @returns SignatureProof
39
+ */
40
+ export declare function signDataUpdate<T>(data: T, privateKey: string): Promise<SignatureProof>;
41
+ /**
42
+ * Sign a pre-computed SHA-256 hash
43
+ *
44
+ * This is the low-level signing function. Use `sign()` or `signDataUpdate()`
45
+ * for most use cases.
46
+ *
47
+ * Protocol (performed by dag4.keyStore.sign):
48
+ * 1. Treat hashHex as UTF-8 bytes (64 ASCII characters = 64 bytes)
49
+ * 2. SHA-512 hash those bytes (produces 64 bytes)
50
+ * 3. Truncate to first 32 bytes (for secp256k1 curve order)
51
+ * 4. Sign with ECDSA secp256k1
52
+ * 5. Return DER-encoded signature
53
+ *
54
+ * @param hashHex - SHA-256 hash as 64-character hex string
55
+ * @param privateKey - Private key in hex format (64 characters)
56
+ * @returns DER-encoded signature in hex format
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Compute your own hash
61
+ * const hashHex = sha256(myData);
62
+ * const signature = await signHash(hashHex, privateKey);
63
+ * ```
64
+ */
65
+ export declare function signHash(hashHex: string, privateKey: string): Promise<string>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * Signing Functions
4
+ *
5
+ * ECDSA signing using secp256k1 curve via dag4js.
6
+ * Implements the Constellation signature protocol.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.signHash = exports.signDataUpdate = exports.sign = void 0;
10
+ const dag4_1 = require("@stardust-collective/dag4");
11
+ const js_sha256_1 = require("js-sha256");
12
+ const canonicalize_js_1 = require("./canonicalize.js");
13
+ /**
14
+ * Sign data using the regular Constellation protocol (non-DataUpdate)
15
+ *
16
+ * Protocol:
17
+ * 1. Canonicalize JSON (RFC 8785)
18
+ * 2. SHA-256 hash the canonical JSON string
19
+ * 3. Sign using dag4.keyStore.sign
20
+ *
21
+ * @param data - Any JSON-serializable object
22
+ * @param privateKey - Private key in hex format
23
+ * @returns SignatureProof with public key ID and signature
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const proof = await sign({ action: 'test' }, privateKeyHex);
28
+ * console.log(proof.id); // public key (128 chars)
29
+ * console.log(proof.signature); // DER signature
30
+ * ```
31
+ */
32
+ async function sign(data, privateKey) {
33
+ // Step 1: Canonicalize JSON (RFC 8785)
34
+ const canonicalJson = (0, canonicalize_js_1.canonicalize)(data);
35
+ // Step 2-3: UTF-8 encode and SHA-256 hash (sha256 handles UTF-8 encoding internally)
36
+ // Returns 64-character hex string
37
+ const hashHex = (0, js_sha256_1.sha256)(canonicalJson);
38
+ // Step 4-6: dag4.keyStore.sign internally:
39
+ // 4. Treats hashHex as UTF-8 bytes
40
+ // 5. SHA-512 hashes those bytes, truncates to 32 bytes
41
+ // 6. Signs with ECDSA secp256k1
42
+ const signature = await dag4_1.dag4.keyStore.sign(privateKey, hashHex);
43
+ // Get public key ID (without 04 prefix)
44
+ const publicKey = dag4_1.dag4.keyStore.getPublicKeyFromPrivate(privateKey, false);
45
+ const id = normalizePublicKeyId(publicKey);
46
+ return { id, signature };
47
+ }
48
+ exports.sign = sign;
49
+ /**
50
+ * Sign data as a DataUpdate (with Constellation prefix)
51
+ *
52
+ * Protocol:
53
+ * 1. Canonicalize JSON (RFC 8785)
54
+ * 2. Base64 encode the canonical JSON
55
+ * 3. Sign using dag4.keyStore.dataSign (adds Constellation prefix internally)
56
+ *
57
+ * @param data - Any JSON-serializable object
58
+ * @param privateKey - Private key in hex format
59
+ * @returns SignatureProof
60
+ */
61
+ async function signDataUpdate(data, privateKey) {
62
+ // Step 1: Canonicalize JSON
63
+ const canonicalJson = (0, canonicalize_js_1.canonicalize)(data);
64
+ // Step 2: Base64 encode for dataSign
65
+ const base64String = Buffer.from(canonicalJson, 'utf-8').toString('base64');
66
+ // Step 3: Sign using dag4's dataSign (handles Constellation prefix internally)
67
+ const signature = await dag4_1.dag4.keyStore.dataSign(privateKey, base64String);
68
+ // Get public key ID
69
+ const publicKey = dag4_1.dag4.keyStore.getPublicKeyFromPrivate(privateKey, false);
70
+ const id = normalizePublicKeyId(publicKey);
71
+ return { id, signature };
72
+ }
73
+ exports.signDataUpdate = signDataUpdate;
74
+ /**
75
+ * Sign a pre-computed SHA-256 hash
76
+ *
77
+ * This is the low-level signing function. Use `sign()` or `signDataUpdate()`
78
+ * for most use cases.
79
+ *
80
+ * Protocol (performed by dag4.keyStore.sign):
81
+ * 1. Treat hashHex as UTF-8 bytes (64 ASCII characters = 64 bytes)
82
+ * 2. SHA-512 hash those bytes (produces 64 bytes)
83
+ * 3. Truncate to first 32 bytes (for secp256k1 curve order)
84
+ * 4. Sign with ECDSA secp256k1
85
+ * 5. Return DER-encoded signature
86
+ *
87
+ * @param hashHex - SHA-256 hash as 64-character hex string
88
+ * @param privateKey - Private key in hex format (64 characters)
89
+ * @returns DER-encoded signature in hex format
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * // Compute your own hash
94
+ * const hashHex = sha256(myData);
95
+ * const signature = await signHash(hashHex, privateKey);
96
+ * ```
97
+ */
98
+ async function signHash(hashHex, privateKey) {
99
+ // dag4.keyStore.sign performs:
100
+ // 1. SHA-512 of hashHex (treating 64 hex chars as UTF-8 bytes)
101
+ // 2. Truncation to 32 bytes (handled internally by crypto library)
102
+ // 3. ECDSA signing with secp256k1
103
+ return dag4_1.dag4.keyStore.sign(privateKey, hashHex);
104
+ }
105
+ exports.signHash = signHash;
106
+ /**
107
+ * Normalize public key to ID format (without 04 prefix, 128 chars)
108
+ */
109
+ function normalizePublicKeyId(publicKey) {
110
+ // If 130 chars (with 04 prefix), remove prefix
111
+ if (publicKey.length === 130 && publicKey.startsWith('04')) {
112
+ return publicKey.substring(2);
113
+ }
114
+ // If 128 chars (without prefix), return as-is
115
+ if (publicKey.length === 128) {
116
+ return publicKey;
117
+ }
118
+ // Otherwise return as-is and let validation catch issues
119
+ return publicKey;
120
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * High-Level Signed Object API
3
+ *
4
+ * Convenience functions for creating and managing signed objects.
5
+ */
6
+ import { Signed, SigningOptions } from './types.js';
7
+ /**
8
+ * Create a signed object with a single signature
9
+ *
10
+ * @param value - Any JSON-serializable object
11
+ * @param privateKey - Private key in hex format
12
+ * @param options - Signing options
13
+ * @returns Signed object ready for submission
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Sign a regular data object
18
+ * const signed = await createSignedObject(myData, privateKey);
19
+ *
20
+ * // Sign as DataUpdate for L1 submission
21
+ * const signedUpdate = await createSignedObject(myData, privateKey, { isDataUpdate: true });
22
+ * ```
23
+ */
24
+ export declare function createSignedObject<T>(value: T, privateKey: string, options?: SigningOptions): Promise<Signed<T>>;
25
+ /**
26
+ * Add an additional signature to an existing signed object
27
+ *
28
+ * This allows building multi-signature objects where multiple parties
29
+ * need to sign the same data.
30
+ *
31
+ * @param signed - Existing signed object
32
+ * @param privateKey - Private key in hex format
33
+ * @param options - Signing options (must match original signing)
34
+ * @returns New signed object with additional proof
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // First party signs
39
+ * let signed = await createSignedObject(data, party1Key);
40
+ *
41
+ * // Second party adds signature
42
+ * signed = await addSignature(signed, party2Key);
43
+ *
44
+ * // Now has 2 proofs
45
+ * console.log(signed.proofs.length); // 2
46
+ * ```
47
+ */
48
+ export declare function addSignature<T>(signed: Signed<T>, privateKey: string, options?: SigningOptions): Promise<Signed<T>>;
49
+ /**
50
+ * Create a signed object with multiple signatures at once
51
+ *
52
+ * Useful when you have access to multiple private keys and want
53
+ * to create a multi-sig object in one operation.
54
+ *
55
+ * @param value - Any JSON-serializable object
56
+ * @param privateKeys - Array of private keys in hex format
57
+ * @param options - Signing options
58
+ * @returns Signed object with multiple proofs
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const signed = await batchSign(data, [key1, key2, key3]);
63
+ * console.log(signed.proofs.length); // 3
64
+ * ```
65
+ */
66
+ export declare function batchSign<T>(value: T, privateKeys: string[], options?: SigningOptions): Promise<Signed<T>>;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * High-Level Signed Object API
4
+ *
5
+ * Convenience functions for creating and managing signed objects.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.batchSign = exports.addSignature = exports.createSignedObject = void 0;
9
+ const sign_js_1 = require("./sign.js");
10
+ /**
11
+ * Create a signed object with a single signature
12
+ *
13
+ * @param value - Any JSON-serializable object
14
+ * @param privateKey - Private key in hex format
15
+ * @param options - Signing options
16
+ * @returns Signed object ready for submission
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Sign a regular data object
21
+ * const signed = await createSignedObject(myData, privateKey);
22
+ *
23
+ * // Sign as DataUpdate for L1 submission
24
+ * const signedUpdate = await createSignedObject(myData, privateKey, { isDataUpdate: true });
25
+ * ```
26
+ */
27
+ async function createSignedObject(value, privateKey, options = {}) {
28
+ const { isDataUpdate = false } = options;
29
+ const proof = isDataUpdate
30
+ ? await (0, sign_js_1.signDataUpdate)(value, privateKey)
31
+ : await (0, sign_js_1.sign)(value, privateKey);
32
+ return {
33
+ value,
34
+ proofs: [proof],
35
+ };
36
+ }
37
+ exports.createSignedObject = createSignedObject;
38
+ /**
39
+ * Add an additional signature to an existing signed object
40
+ *
41
+ * This allows building multi-signature objects where multiple parties
42
+ * need to sign the same data.
43
+ *
44
+ * @param signed - Existing signed object
45
+ * @param privateKey - Private key in hex format
46
+ * @param options - Signing options (must match original signing)
47
+ * @returns New signed object with additional proof
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // First party signs
52
+ * let signed = await createSignedObject(data, party1Key);
53
+ *
54
+ * // Second party adds signature
55
+ * signed = await addSignature(signed, party2Key);
56
+ *
57
+ * // Now has 2 proofs
58
+ * console.log(signed.proofs.length); // 2
59
+ * ```
60
+ */
61
+ async function addSignature(signed, privateKey, options = {}) {
62
+ const { isDataUpdate = false } = options;
63
+ const newProof = isDataUpdate
64
+ ? await (0, sign_js_1.signDataUpdate)(signed.value, privateKey)
65
+ : await (0, sign_js_1.sign)(signed.value, privateKey);
66
+ return {
67
+ value: signed.value,
68
+ proofs: [...signed.proofs, newProof],
69
+ };
70
+ }
71
+ exports.addSignature = addSignature;
72
+ /**
73
+ * Create a signed object with multiple signatures at once
74
+ *
75
+ * Useful when you have access to multiple private keys and want
76
+ * to create a multi-sig object in one operation.
77
+ *
78
+ * @param value - Any JSON-serializable object
79
+ * @param privateKeys - Array of private keys in hex format
80
+ * @param options - Signing options
81
+ * @returns Signed object with multiple proofs
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const signed = await batchSign(data, [key1, key2, key3]);
86
+ * console.log(signed.proofs.length); // 3
87
+ * ```
88
+ */
89
+ async function batchSign(value, privateKeys, options = {}) {
90
+ if (privateKeys.length === 0) {
91
+ throw new Error('At least one private key is required');
92
+ }
93
+ const { isDataUpdate = false } = options;
94
+ const proofs = await Promise.all(privateKeys.map((key) => (isDataUpdate ? (0, sign_js_1.signDataUpdate)(value, key) : (0, sign_js_1.sign)(value, key))));
95
+ return {
96
+ value,
97
+ proofs,
98
+ };
99
+ }
100
+ exports.batchSign = batchSign;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Core type definitions for the Ottochain SDK
3
+ */
4
+ /**
5
+ * A signature proof containing the signer's public key ID and signature
6
+ */
7
+ export interface SignatureProof {
8
+ /** Public key hex (uncompressed, without 04 prefix) - 128 characters */
9
+ id: string;
10
+ /** DER-encoded ECDSA signature in hex format */
11
+ signature: string;
12
+ }
13
+ /**
14
+ * A signed object wrapping a value with one or more signature proofs
15
+ */
16
+ export interface Signed<T> {
17
+ /** The signed value */
18
+ value: T;
19
+ /** Array of signature proofs */
20
+ proofs: SignatureProof[];
21
+ }
22
+ /**
23
+ * A key pair for signing operations
24
+ */
25
+ export interface KeyPair {
26
+ /** Private key in hex format */
27
+ privateKey: string;
28
+ /** Public key in hex format (uncompressed, with 04 prefix) */
29
+ publicKey: string;
30
+ /** DAG address derived from the public key */
31
+ address: string;
32
+ }
33
+ /**
34
+ * A hash result containing both hex string and raw bytes
35
+ */
36
+ export interface Hash {
37
+ /** SHA-256 hash as 64-character hex string */
38
+ value: string;
39
+ /** Raw 32-byte hash as Uint8Array */
40
+ bytes: Uint8Array;
41
+ }
42
+ /**
43
+ * Result of signature verification
44
+ */
45
+ export interface VerificationResult {
46
+ /** Whether all signatures are valid */
47
+ isValid: boolean;
48
+ /** Proofs that passed verification */
49
+ validProofs: SignatureProof[];
50
+ /** Proofs that failed verification */
51
+ invalidProofs: SignatureProof[];
52
+ }
53
+ /**
54
+ * Options for signing operations
55
+ */
56
+ export interface SigningOptions {
57
+ /** Whether to sign as a DataUpdate (with Constellation prefix) */
58
+ isDataUpdate?: boolean;
59
+ }
60
+ /**
61
+ * Supported signature algorithm
62
+ */
63
+ export declare const ALGORITHM: "SECP256K1_RFC8785_V1";
64
+ /**
65
+ * Constellation prefix for DataUpdate signing
66
+ */
67
+ export declare const CONSTELLATION_PREFIX = "\u0019Constellation Signed Data:\n";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /**
3
+ * Core type definitions for the Ottochain SDK
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CONSTELLATION_PREFIX = exports.ALGORITHM = void 0;
7
+ /**
8
+ * Supported signature algorithm
9
+ */
10
+ exports.ALGORITHM = 'SECP256K1_RFC8785_V1';
11
+ /**
12
+ * Constellation prefix for DataUpdate signing
13
+ */
14
+ exports.CONSTELLATION_PREFIX = '\x19Constellation Signed Data:\n';
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Signature Verification
3
+ *
4
+ * Verify ECDSA signatures using secp256k1 curve via dag4js.
5
+ */
6
+ import { Signed, SignatureProof, VerificationResult } from './types.js';
7
+ /**
8
+ * Verify a signed object
9
+ *
10
+ * @param signed - Signed object with value and proofs
11
+ * @param isDataUpdate - Whether the value was signed as a DataUpdate
12
+ * @returns VerificationResult with valid/invalid proof lists
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const result = await verify(signedObject);
17
+ * if (result.isValid) {
18
+ * console.log('All signatures valid');
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function verify<T>(signed: Signed<T>, isDataUpdate?: boolean): Promise<VerificationResult>;
23
+ /**
24
+ * Verify a signature against a SHA-256 hash
25
+ *
26
+ * Protocol:
27
+ * 1. Treat hash hex as UTF-8 bytes (NOT hex decode)
28
+ * 2. SHA-512 hash
29
+ * 3. Truncate to 32 bytes (handled internally by dag4)
30
+ * 4. Verify ECDSA signature
31
+ *
32
+ * @param hashHex - SHA-256 hash as 64-character hex string
33
+ * @param signature - DER-encoded signature in hex format
34
+ * @param publicKeyId - Public key in hex (with or without 04 prefix)
35
+ * @returns true if signature is valid
36
+ */
37
+ export declare function verifyHash(hashHex: string, signature: string, publicKeyId: string): Promise<boolean>;
38
+ /**
39
+ * Verify a single signature proof against data
40
+ *
41
+ * @param data - The original data that was signed
42
+ * @param proof - The signature proof to verify
43
+ * @param isDataUpdate - Whether data was signed as DataUpdate
44
+ * @returns true if signature is valid
45
+ */
46
+ export declare function verifySignature<T>(data: T, proof: SignatureProof, isDataUpdate?: boolean): Promise<boolean>;
47
+ /**
48
+ * Normalize a DER-encoded signature to use low-S value.
49
+ *
50
+ * BIP 62/146 requires S values to be in the lower half of the curve order.
51
+ * Some signing implementations produce high-S signatures which are mathematically
52
+ * valid but rejected by strict verifiers. This normalizes high-S to low-S by
53
+ * computing S' = N - S where N is the curve order.
54
+ */
55
+ export declare function normalizeSignatureToLowS(signatureHex: string): string;