@unconfirmed/effect-sui 0.0.0-stage → 0.1.1

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 (573) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -2
  3. package/dist/Address.d.ts +18 -0
  4. package/dist/Address.d.ts.map +1 -0
  5. package/dist/Address.js +33 -0
  6. package/dist/Address.js.map +1 -0
  7. package/dist/AddressAlias.d.ts +107 -0
  8. package/dist/AddressAlias.d.ts.map +1 -0
  9. package/dist/AddressAlias.js +104 -0
  10. package/dist/AddressAlias.js.map +1 -0
  11. package/dist/Bip32.d.ts +6 -0
  12. package/dist/Bip32.d.ts.map +1 -0
  13. package/dist/Bip32.js +34 -0
  14. package/dist/Bip32.js.map +1 -0
  15. package/dist/Chain.d.ts +23 -0
  16. package/dist/Chain.d.ts.map +1 -0
  17. package/dist/Chain.js +7 -0
  18. package/dist/Chain.js.map +1 -0
  19. package/dist/CheckpointData.d.ts +74 -0
  20. package/dist/CheckpointData.d.ts.map +1 -0
  21. package/dist/CheckpointData.js +48 -0
  22. package/dist/CheckpointData.js.map +1 -0
  23. package/dist/Checkpoints.d.ts +23 -0
  24. package/dist/Checkpoints.d.ts.map +1 -0
  25. package/dist/Checkpoints.js +7 -0
  26. package/dist/Checkpoints.js.map +1 -0
  27. package/dist/CoinReservation.d.ts +18 -0
  28. package/dist/CoinReservation.d.ts.map +1 -0
  29. package/dist/CoinReservation.js +58 -0
  30. package/dist/CoinReservation.js.map +1 -0
  31. package/dist/Coins.d.ts +42 -0
  32. package/dist/Coins.d.ts.map +1 -0
  33. package/dist/Coins.js +49 -0
  34. package/dist/Coins.js.map +1 -0
  35. package/dist/DynamicFields.d.ts +115 -0
  36. package/dist/DynamicFields.d.ts.map +1 -0
  37. package/dist/DynamicFields.js +101 -0
  38. package/dist/DynamicFields.js.map +1 -0
  39. package/dist/Ecdsa.d.ts +39 -0
  40. package/dist/Ecdsa.d.ts.map +1 -0
  41. package/dist/Ecdsa.js +76 -0
  42. package/dist/Ecdsa.js.map +1 -0
  43. package/dist/Ed25519.d.ts +22 -0
  44. package/dist/Ed25519.d.ts.map +1 -0
  45. package/dist/Ed25519.js +77 -0
  46. package/dist/Ed25519.js.map +1 -0
  47. package/dist/Events.d.ts +105 -0
  48. package/dist/Events.d.ts.map +1 -0
  49. package/dist/Events.js +51 -0
  50. package/dist/Events.js.map +1 -0
  51. package/dist/Hash.d.ts +16 -0
  52. package/dist/Hash.d.ts.map +1 -0
  53. package/dist/Hash.js +32 -0
  54. package/dist/Hash.js.map +1 -0
  55. package/dist/MlDsa65.d.ts +17 -0
  56. package/dist/MlDsa65.d.ts.map +1 -0
  57. package/dist/MlDsa65.js +84 -0
  58. package/dist/MlDsa65.js.map +1 -0
  59. package/dist/Mnemonic.d.ts +20 -0
  60. package/dist/Mnemonic.d.ts.map +1 -0
  61. package/dist/Mnemonic.js +71 -0
  62. package/dist/Mnemonic.js.map +1 -0
  63. package/dist/Move.d.ts +261 -0
  64. package/dist/Move.d.ts.map +1 -0
  65. package/dist/Move.js +232 -0
  66. package/dist/Move.js.map +1 -0
  67. package/dist/MultiSig.d.ts +106 -0
  68. package/dist/MultiSig.d.ts.map +1 -0
  69. package/dist/MultiSig.js +254 -0
  70. package/dist/MultiSig.js.map +1 -0
  71. package/dist/Objects.d.ts +95 -0
  72. package/dist/Objects.d.ts.map +1 -0
  73. package/dist/Objects.js +57 -0
  74. package/dist/Objects.js.map +1 -0
  75. package/dist/Packages.d.ts +49 -0
  76. package/dist/Packages.d.ts.map +1 -0
  77. package/dist/Packages.js +16 -0
  78. package/dist/Packages.js.map +1 -0
  79. package/dist/Passkey.d.ts +11 -0
  80. package/dist/Passkey.d.ts.map +1 -0
  81. package/dist/Passkey.js +11 -0
  82. package/dist/Passkey.js.map +1 -0
  83. package/dist/PrivateKey.d.ts +39 -0
  84. package/dist/PrivateKey.d.ts.map +1 -0
  85. package/dist/PrivateKey.js +118 -0
  86. package/dist/PrivateKey.js.map +1 -0
  87. package/dist/Ptb.d.ts +413 -0
  88. package/dist/Ptb.d.ts.map +1 -0
  89. package/dist/Ptb.js +338 -0
  90. package/dist/Ptb.js.map +1 -0
  91. package/dist/Resolve.d.ts +502 -0
  92. package/dist/Resolve.d.ts.map +1 -0
  93. package/dist/Resolve.js +1188 -0
  94. package/dist/Resolve.js.map +1 -0
  95. package/dist/RpcError.d.ts +19 -0
  96. package/dist/RpcError.d.ts.map +1 -0
  97. package/dist/RpcError.js +37 -0
  98. package/dist/RpcError.js.map +1 -0
  99. package/dist/Secp256k1.d.ts +11 -0
  100. package/dist/Secp256k1.d.ts.map +1 -0
  101. package/dist/Secp256k1.js +23 -0
  102. package/dist/Secp256k1.js.map +1 -0
  103. package/dist/Secp256r1.d.ts +11 -0
  104. package/dist/Secp256r1.d.ts.map +1 -0
  105. package/dist/Secp256r1.js +23 -0
  106. package/dist/Secp256r1.js.map +1 -0
  107. package/dist/SignatureScheme.d.ts +103 -0
  108. package/dist/SignatureScheme.d.ts.map +1 -0
  109. package/dist/SignatureScheme.js +93 -0
  110. package/dist/SignatureScheme.js.map +1 -0
  111. package/dist/Signer.d.ts +54 -0
  112. package/dist/Signer.d.ts.map +1 -0
  113. package/dist/Signer.js +31 -0
  114. package/dist/Signer.js.map +1 -0
  115. package/dist/Testing.d.ts +171 -0
  116. package/dist/Testing.d.ts.map +1 -0
  117. package/dist/Testing.js +531 -0
  118. package/dist/Testing.js.map +1 -0
  119. package/dist/TransactionData.d.ts +3218 -0
  120. package/dist/TransactionData.d.ts.map +1 -0
  121. package/dist/TransactionData.js +105 -0
  122. package/dist/TransactionData.js.map +1 -0
  123. package/dist/TransactionJson.d.ts +1544 -0
  124. package/dist/TransactionJson.d.ts.map +1 -0
  125. package/dist/TransactionJson.js +926 -0
  126. package/dist/TransactionJson.js.map +1 -0
  127. package/dist/Transactions.d.ts +181 -0
  128. package/dist/Transactions.d.ts.map +1 -0
  129. package/dist/Transactions.js +49 -0
  130. package/dist/Transactions.js.map +1 -0
  131. package/dist/Tx.d.ts +1419 -0
  132. package/dist/Tx.d.ts.map +1 -0
  133. package/dist/Tx.js +266 -0
  134. package/dist/Tx.js.map +1 -0
  135. package/dist/TypeTag.d.ts +42 -0
  136. package/dist/TypeTag.d.ts.map +1 -0
  137. package/dist/TypeTag.js +110 -0
  138. package/dist/TypeTag.js.map +1 -0
  139. package/dist/Verify.d.ts +23 -0
  140. package/dist/Verify.d.ts.map +1 -0
  141. package/dist/Verify.js +29 -0
  142. package/dist/Verify.js.map +1 -0
  143. package/dist/enoki/EnokiClient.d.ts +184 -0
  144. package/dist/enoki/EnokiClient.d.ts.map +1 -0
  145. package/dist/enoki/EnokiClient.js +105 -0
  146. package/dist/enoki/EnokiClient.js.map +1 -0
  147. package/dist/enoki/EnokiHttp.d.ts +33 -0
  148. package/dist/enoki/EnokiHttp.d.ts.map +1 -0
  149. package/dist/enoki/EnokiHttp.js +160 -0
  150. package/dist/enoki/EnokiHttp.js.map +1 -0
  151. package/dist/enoki/Sponsor.d.ts +119 -0
  152. package/dist/enoki/Sponsor.d.ts.map +1 -0
  153. package/dist/enoki/Sponsor.js +170 -0
  154. package/dist/enoki/Sponsor.js.map +1 -0
  155. package/dist/enoki/ZkLoginFlow.d.ts +84 -0
  156. package/dist/enoki/ZkLoginFlow.d.ts.map +1 -0
  157. package/dist/enoki/ZkLoginFlow.js +138 -0
  158. package/dist/enoki/ZkLoginFlow.js.map +1 -0
  159. package/dist/enoki/index.d.ts +9 -0
  160. package/dist/enoki/index.d.ts.map +1 -0
  161. package/dist/enoki/index.js +9 -0
  162. package/dist/enoki/index.js.map +1 -0
  163. package/dist/graphql/ChainGraphQL.d.ts +35 -0
  164. package/dist/graphql/ChainGraphQL.d.ts.map +1 -0
  165. package/dist/graphql/ChainGraphQL.js +62 -0
  166. package/dist/graphql/ChainGraphQL.js.map +1 -0
  167. package/dist/graphql/CheckpointDataGraphQL.d.ts +785 -0
  168. package/dist/graphql/CheckpointDataGraphQL.d.ts.map +1 -0
  169. package/dist/graphql/CheckpointDataGraphQL.js +157 -0
  170. package/dist/graphql/CheckpointDataGraphQL.js.map +1 -0
  171. package/dist/graphql/CheckpointsGraphQL.d.ts +91 -0
  172. package/dist/graphql/CheckpointsGraphQL.d.ts.map +1 -0
  173. package/dist/graphql/CheckpointsGraphQL.js +80 -0
  174. package/dist/graphql/CheckpointsGraphQL.js.map +1 -0
  175. package/dist/graphql/CoinsGraphQL.d.ts +81 -0
  176. package/dist/graphql/CoinsGraphQL.d.ts.map +1 -0
  177. package/dist/graphql/CoinsGraphQL.js +63 -0
  178. package/dist/graphql/CoinsGraphQL.js.map +1 -0
  179. package/dist/graphql/DynamicFieldsGraphQL.d.ts +94 -0
  180. package/dist/graphql/DynamicFieldsGraphQL.d.ts.map +1 -0
  181. package/dist/graphql/DynamicFieldsGraphQL.js +126 -0
  182. package/dist/graphql/DynamicFieldsGraphQL.js.map +1 -0
  183. package/dist/graphql/EventsGraphQL.d.ts +266 -0
  184. package/dist/graphql/EventsGraphQL.d.ts.map +1 -0
  185. package/dist/graphql/EventsGraphQL.js +249 -0
  186. package/dist/graphql/EventsGraphQL.js.map +1 -0
  187. package/dist/graphql/ObjectsGraphQL.d.ts +130 -0
  188. package/dist/graphql/ObjectsGraphQL.d.ts.map +1 -0
  189. package/dist/graphql/ObjectsGraphQL.js +79 -0
  190. package/dist/graphql/ObjectsGraphQL.js.map +1 -0
  191. package/dist/graphql/PackagesGraphQL.d.ts +82 -0
  192. package/dist/graphql/PackagesGraphQL.d.ts.map +1 -0
  193. package/dist/graphql/PackagesGraphQL.js +145 -0
  194. package/dist/graphql/PackagesGraphQL.js.map +1 -0
  195. package/dist/graphql/SuiGraphQL.d.ts +37 -0
  196. package/dist/graphql/SuiGraphQL.d.ts.map +1 -0
  197. package/dist/graphql/SuiGraphQL.js +47 -0
  198. package/dist/graphql/SuiGraphQL.js.map +1 -0
  199. package/dist/graphql/TransactionsGraphQL.d.ts +1309 -0
  200. package/dist/graphql/TransactionsGraphQL.d.ts.map +1 -0
  201. package/dist/graphql/TransactionsGraphQL.js +206 -0
  202. package/dist/graphql/TransactionsGraphQL.js.map +1 -0
  203. package/dist/graphql/convert.d.ts +505 -0
  204. package/dist/graphql/convert.d.ts.map +1 -0
  205. package/dist/graphql/convert.js +384 -0
  206. package/dist/graphql/convert.js.map +1 -0
  207. package/dist/graphql/index.d.ts +41 -0
  208. package/dist/graphql/index.d.ts.map +1 -0
  209. package/dist/graphql/index.js +20 -0
  210. package/dist/graphql/index.js.map +1 -0
  211. package/dist/graphql/merge.d.ts +8 -0
  212. package/dist/graphql/merge.d.ts.map +1 -0
  213. package/dist/graphql/merge.js +55 -0
  214. package/dist/graphql/merge.js.map +1 -0
  215. package/dist/graphql/paging.d.ts +219 -0
  216. package/dist/graphql/paging.d.ts.map +1 -0
  217. package/dist/graphql/paging.js +74 -0
  218. package/dist/graphql/paging.js.map +1 -0
  219. package/dist/graphql/subscription.d.ts +27 -0
  220. package/dist/graphql/subscription.d.ts.map +1 -0
  221. package/dist/graphql/subscription.js +47 -0
  222. package/dist/graphql/subscription.js.map +1 -0
  223. package/dist/graphql/tip.d.ts +31 -0
  224. package/dist/graphql/tip.d.ts.map +1 -0
  225. package/dist/graphql/tip.js +29 -0
  226. package/dist/graphql/tip.js.map +1 -0
  227. package/dist/grpc/ChainGrpc.d.ts +11 -0
  228. package/dist/grpc/ChainGrpc.d.ts.map +1 -0
  229. package/dist/grpc/ChainGrpc.js +40 -0
  230. package/dist/grpc/ChainGrpc.js.map +1 -0
  231. package/dist/grpc/CheckpointDataGrpc.d.ts +6 -0
  232. package/dist/grpc/CheckpointDataGrpc.d.ts.map +1 -0
  233. package/dist/grpc/CheckpointDataGrpc.js +27 -0
  234. package/dist/grpc/CheckpointDataGrpc.js.map +1 -0
  235. package/dist/grpc/CheckpointsGrpc.d.ts +6 -0
  236. package/dist/grpc/CheckpointsGrpc.d.ts.map +1 -0
  237. package/dist/grpc/CheckpointsGrpc.js +25 -0
  238. package/dist/grpc/CheckpointsGrpc.js.map +1 -0
  239. package/dist/grpc/CoinsGrpc.d.ts +7 -0
  240. package/dist/grpc/CoinsGrpc.d.ts.map +1 -0
  241. package/dist/grpc/CoinsGrpc.js +34 -0
  242. package/dist/grpc/CoinsGrpc.js.map +1 -0
  243. package/dist/grpc/DynamicFieldsGrpc.d.ts +11 -0
  244. package/dist/grpc/DynamicFieldsGrpc.d.ts.map +1 -0
  245. package/dist/grpc/DynamicFieldsGrpc.js +91 -0
  246. package/dist/grpc/DynamicFieldsGrpc.js.map +1 -0
  247. package/dist/grpc/EventsGrpc.d.ts +13 -0
  248. package/dist/grpc/EventsGrpc.d.ts.map +1 -0
  249. package/dist/grpc/EventsGrpc.js +88 -0
  250. package/dist/grpc/EventsGrpc.js.map +1 -0
  251. package/dist/grpc/GrpcWeb.d.ts +71 -0
  252. package/dist/grpc/GrpcWeb.d.ts.map +1 -0
  253. package/dist/grpc/GrpcWeb.js +243 -0
  254. package/dist/grpc/GrpcWeb.js.map +1 -0
  255. package/dist/grpc/ObjectsGrpc.d.ts +10 -0
  256. package/dist/grpc/ObjectsGrpc.d.ts.map +1 -0
  257. package/dist/grpc/ObjectsGrpc.js +72 -0
  258. package/dist/grpc/ObjectsGrpc.js.map +1 -0
  259. package/dist/grpc/PackagesGrpc.d.ts +9 -0
  260. package/dist/grpc/PackagesGrpc.d.ts.map +1 -0
  261. package/dist/grpc/PackagesGrpc.js +78 -0
  262. package/dist/grpc/PackagesGrpc.js.map +1 -0
  263. package/dist/grpc/Rpc.d.ts +46 -0
  264. package/dist/grpc/Rpc.d.ts.map +1 -0
  265. package/dist/grpc/Rpc.js +111 -0
  266. package/dist/grpc/Rpc.js.map +1 -0
  267. package/dist/grpc/TransactionsGrpc.d.ts +6 -0
  268. package/dist/grpc/TransactionsGrpc.d.ts.map +1 -0
  269. package/dist/grpc/TransactionsGrpc.js +56 -0
  270. package/dist/grpc/TransactionsGrpc.js.map +1 -0
  271. package/dist/grpc/cache.d.ts +7 -0
  272. package/dist/grpc/cache.d.ts.map +1 -0
  273. package/dist/grpc/cache.js +55 -0
  274. package/dist/grpc/cache.js.map +1 -0
  275. package/dist/grpc/convert.d.ts +43 -0
  276. package/dist/grpc/convert.d.ts.map +1 -0
  277. package/dist/grpc/convert.js +198 -0
  278. package/dist/grpc/convert.js.map +1 -0
  279. package/dist/grpc/generated/lean.d.ts +36 -0
  280. package/dist/grpc/generated/lean.d.ts.map +1 -0
  281. package/dist/grpc/generated/lean.js +205 -0
  282. package/dist/grpc/generated/lean.js.map +1 -0
  283. package/dist/grpc/generated/proto.d.ts +2000 -0
  284. package/dist/grpc/generated/proto.d.ts.map +1 -0
  285. package/dist/grpc/generated/proto.js +356 -0
  286. package/dist/grpc/generated/proto.js.map +1 -0
  287. package/dist/grpc/generated/rpc.d.ts +62 -0
  288. package/dist/grpc/generated/rpc.d.ts.map +1 -0
  289. package/dist/grpc/generated/rpc.js +324 -0
  290. package/dist/grpc/generated/rpc.js.map +1 -0
  291. package/dist/grpc/index.d.ts +58 -0
  292. package/dist/grpc/index.d.ts.map +1 -0
  293. package/dist/grpc/index.js +43 -0
  294. package/dist/grpc/index.js.map +1 -0
  295. package/dist/grpc/scan.d.ts +79 -0
  296. package/dist/grpc/scan.d.ts.map +1 -0
  297. package/dist/grpc/scan.js +126 -0
  298. package/dist/grpc/scan.js.map +1 -0
  299. package/dist/grpc/transaction.d.ts +9 -0
  300. package/dist/grpc/transaction.d.ts.map +1 -0
  301. package/dist/grpc/transaction.js +168 -0
  302. package/dist/grpc/transaction.js.map +1 -0
  303. package/dist/index.d.ts +36 -0
  304. package/dist/index.d.ts.map +1 -0
  305. package/dist/index.js +36 -0
  306. package/dist/index.js.map +1 -0
  307. package/dist/internal/allowances.d.ts +18 -0
  308. package/dist/internal/allowances.d.ts.map +1 -0
  309. package/dist/internal/allowances.js +194 -0
  310. package/dist/internal/allowances.js.map +1 -0
  311. package/dist/internal/mnemonic.d.ts +53 -0
  312. package/dist/internal/mnemonic.d.ts.map +1 -0
  313. package/dist/internal/mnemonic.js +66 -0
  314. package/dist/internal/mnemonic.js.map +1 -0
  315. package/dist/internal/passkey/BrowserProvider.d.ts +10 -0
  316. package/dist/internal/passkey/BrowserProvider.d.ts.map +1 -0
  317. package/dist/internal/passkey/BrowserProvider.js +101 -0
  318. package/dist/internal/passkey/BrowserProvider.js.map +1 -0
  319. package/dist/internal/passkey/Passkey.d.ts +104 -0
  320. package/dist/internal/passkey/Passkey.d.ts.map +1 -0
  321. package/dist/internal/passkey/Passkey.js +333 -0
  322. package/dist/internal/passkey/Passkey.js.map +1 -0
  323. package/dist/internal/passkey/SoftwareProvider.d.ts +23 -0
  324. package/dist/internal/passkey/SoftwareProvider.d.ts.map +1 -0
  325. package/dist/internal/passkey/SoftwareProvider.js +61 -0
  326. package/dist/internal/passkey/SoftwareProvider.js.map +1 -0
  327. package/dist/lifecycle/Evidence.d.ts +62 -0
  328. package/dist/lifecycle/Evidence.d.ts.map +1 -0
  329. package/dist/lifecycle/Evidence.js +30 -0
  330. package/dist/lifecycle/Evidence.js.map +1 -0
  331. package/dist/lifecycle/EvidenceGraphQL.d.ts +59 -0
  332. package/dist/lifecycle/EvidenceGraphQL.d.ts.map +1 -0
  333. package/dist/lifecycle/EvidenceGraphQL.js +53 -0
  334. package/dist/lifecycle/EvidenceGraphQL.js.map +1 -0
  335. package/dist/lifecycle/EvidenceGrpc.d.ts +4 -0
  336. package/dist/lifecycle/EvidenceGrpc.d.ts.map +1 -0
  337. package/dist/lifecycle/EvidenceGrpc.js +37 -0
  338. package/dist/lifecycle/EvidenceGrpc.js.map +1 -0
  339. package/dist/lifecycle/Journal.d.ts +69 -0
  340. package/dist/lifecycle/Journal.d.ts.map +1 -0
  341. package/dist/lifecycle/Journal.js +70 -0
  342. package/dist/lifecycle/Journal.js.map +1 -0
  343. package/dist/lifecycle/JournalEntry.d.ts +67 -0
  344. package/dist/lifecycle/JournalEntry.d.ts.map +1 -0
  345. package/dist/lifecycle/JournalEntry.js +45 -0
  346. package/dist/lifecycle/JournalEntry.js.map +1 -0
  347. package/dist/lifecycle/JournalKeyValueStore.d.ts +30 -0
  348. package/dist/lifecycle/JournalKeyValueStore.d.ts.map +1 -0
  349. package/dist/lifecycle/JournalKeyValueStore.js +217 -0
  350. package/dist/lifecycle/JournalKeyValueStore.js.map +1 -0
  351. package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts +54 -0
  352. package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts.map +1 -0
  353. package/dist/lifecycle/KeyValueStoreIndexedDb.js +321 -0
  354. package/dist/lifecycle/KeyValueStoreIndexedDb.js.map +1 -0
  355. package/dist/lifecycle/KeyValueStoreOpfs.d.ts +65 -0
  356. package/dist/lifecycle/KeyValueStoreOpfs.d.ts.map +1 -0
  357. package/dist/lifecycle/KeyValueStoreOpfs.js +207 -0
  358. package/dist/lifecycle/KeyValueStoreOpfs.js.map +1 -0
  359. package/dist/lifecycle/Lifecycle.d.ts +416 -0
  360. package/dist/lifecycle/Lifecycle.d.ts.map +1 -0
  361. package/dist/lifecycle/Lifecycle.js +666 -0
  362. package/dist/lifecycle/Lifecycle.js.map +1 -0
  363. package/dist/lifecycle/Outcome.d.ts +132 -0
  364. package/dist/lifecycle/Outcome.d.ts.map +1 -0
  365. package/dist/lifecycle/Outcome.js +106 -0
  366. package/dist/lifecycle/Outcome.js.map +1 -0
  367. package/dist/lifecycle/SenderLock.d.ts +37 -0
  368. package/dist/lifecycle/SenderLock.d.ts.map +1 -0
  369. package/dist/lifecycle/SenderLock.js +57 -0
  370. package/dist/lifecycle/SenderLock.js.map +1 -0
  371. package/dist/lifecycle/SenderLockWebLocks.d.ts +37 -0
  372. package/dist/lifecycle/SenderLockWebLocks.d.ts.map +1 -0
  373. package/dist/lifecycle/SenderLockWebLocks.js +100 -0
  374. package/dist/lifecycle/SenderLockWebLocks.js.map +1 -0
  375. package/dist/lifecycle/SignedTransaction.d.ts +55 -0
  376. package/dist/lifecycle/SignedTransaction.d.ts.map +1 -0
  377. package/dist/lifecycle/SignedTransaction.js +109 -0
  378. package/dist/lifecycle/SignedTransaction.js.map +1 -0
  379. package/dist/lifecycle/SubmitConfig.d.ts +44 -0
  380. package/dist/lifecycle/SubmitConfig.d.ts.map +1 -0
  381. package/dist/lifecycle/SubmitConfig.js +39 -0
  382. package/dist/lifecycle/SubmitConfig.js.map +1 -0
  383. package/dist/lifecycle/index.d.ts +13 -0
  384. package/dist/lifecycle/index.d.ts.map +1 -0
  385. package/dist/lifecycle/index.js +13 -0
  386. package/dist/lifecycle/index.js.map +1 -0
  387. package/dist/wallet/Connection.d.ts +119 -0
  388. package/dist/wallet/Connection.d.ts.map +1 -0
  389. package/dist/wallet/Connection.js +197 -0
  390. package/dist/wallet/Connection.js.map +1 -0
  391. package/dist/wallet/Features.d.ts +91 -0
  392. package/dist/wallet/Features.d.ts.map +1 -0
  393. package/dist/wallet/Features.js +14 -0
  394. package/dist/wallet/Features.js.map +1 -0
  395. package/dist/wallet/Wallet.d.ts +151 -0
  396. package/dist/wallet/Wallet.d.ts.map +1 -0
  397. package/dist/wallet/Wallet.js +399 -0
  398. package/dist/wallet/Wallet.js.map +1 -0
  399. package/dist/wallet/index.d.ts +7 -0
  400. package/dist/wallet/index.d.ts.map +1 -0
  401. package/dist/wallet/index.js +7 -0
  402. package/dist/wallet/index.js.map +1 -0
  403. package/dist/zklogin/AddressSeed.d.ts +40 -0
  404. package/dist/zklogin/AddressSeed.d.ts.map +1 -0
  405. package/dist/zklogin/AddressSeed.js +91 -0
  406. package/dist/zklogin/AddressSeed.js.map +1 -0
  407. package/dist/zklogin/Errors.d.ts +24 -0
  408. package/dist/zklogin/Errors.d.ts.map +1 -0
  409. package/dist/zklogin/Errors.js +25 -0
  410. package/dist/zklogin/Errors.js.map +1 -0
  411. package/dist/zklogin/Jwt.d.ts +51 -0
  412. package/dist/zklogin/Jwt.d.ts.map +1 -0
  413. package/dist/zklogin/Jwt.js +159 -0
  414. package/dist/zklogin/Jwt.js.map +1 -0
  415. package/dist/zklogin/Nonce.d.ts +9 -0
  416. package/dist/zklogin/Nonce.d.ts.map +1 -0
  417. package/dist/zklogin/Nonce.js +34 -0
  418. package/dist/zklogin/Nonce.js.map +1 -0
  419. package/dist/zklogin/Poseidon.d.ts +24 -0
  420. package/dist/zklogin/Poseidon.d.ts.map +1 -0
  421. package/dist/zklogin/Poseidon.js +54 -0
  422. package/dist/zklogin/Poseidon.js.map +1 -0
  423. package/dist/zklogin/PublicIdentifier.d.ts +49 -0
  424. package/dist/zklogin/PublicIdentifier.d.ts.map +1 -0
  425. package/dist/zklogin/PublicIdentifier.js +90 -0
  426. package/dist/zklogin/PublicIdentifier.js.map +1 -0
  427. package/dist/zklogin/Signature.d.ts +55 -0
  428. package/dist/zklogin/Signature.d.ts.map +1 -0
  429. package/dist/zklogin/Signature.js +70 -0
  430. package/dist/zklogin/Signature.js.map +1 -0
  431. package/dist/zklogin/ZkLogin.d.ts +41 -0
  432. package/dist/zklogin/ZkLogin.d.ts.map +1 -0
  433. package/dist/zklogin/ZkLogin.js +87 -0
  434. package/dist/zklogin/ZkLogin.js.map +1 -0
  435. package/dist/zklogin/ZkLoginAddress.d.ts +30 -0
  436. package/dist/zklogin/ZkLoginAddress.d.ts.map +1 -0
  437. package/dist/zklogin/ZkLoginAddress.js +31 -0
  438. package/dist/zklogin/ZkLoginAddress.js.map +1 -0
  439. package/dist/zklogin/ZkLoginVerifier.d.ts +37 -0
  440. package/dist/zklogin/ZkLoginVerifier.d.ts.map +1 -0
  441. package/dist/zklogin/ZkLoginVerifier.js +4 -0
  442. package/dist/zklogin/ZkLoginVerifier.js.map +1 -0
  443. package/dist/zklogin/ZkLoginVerifierGrpc.d.ts +12 -0
  444. package/dist/zklogin/ZkLoginVerifierGrpc.d.ts.map +1 -0
  445. package/dist/zklogin/ZkLoginVerifierGrpc.js +53 -0
  446. package/dist/zklogin/ZkLoginVerifierGrpc.js.map +1 -0
  447. package/dist/zklogin/index.d.ts +17 -0
  448. package/dist/zklogin/index.d.ts.map +1 -0
  449. package/dist/zklogin/index.js +17 -0
  450. package/dist/zklogin/index.js.map +1 -0
  451. package/dist/zklogin/internal/parse.d.ts +9 -0
  452. package/dist/zklogin/internal/parse.d.ts.map +1 -0
  453. package/dist/zklogin/internal/parse.js +33 -0
  454. package/dist/zklogin/internal/parse.js.map +1 -0
  455. package/dist/zklogin/internal/poseidon.d.ts +21 -0
  456. package/dist/zklogin/internal/poseidon.d.ts.map +1 -0
  457. package/dist/zklogin/internal/poseidon.js +40 -0
  458. package/dist/zklogin/internal/poseidon.js.map +1 -0
  459. package/package.json +69 -4
  460. package/src/Address.ts +45 -0
  461. package/src/AddressAlias.ts +160 -0
  462. package/src/Bip32.ts +37 -0
  463. package/src/Chain.ts +21 -0
  464. package/src/CheckpointData.ts +106 -0
  465. package/src/Checkpoints.ts +18 -0
  466. package/src/CoinReservation.ts +65 -0
  467. package/src/Coins.ts +86 -0
  468. package/src/DynamicFields.ts +179 -0
  469. package/src/Ecdsa.ts +103 -0
  470. package/src/Ed25519.ts +84 -0
  471. package/src/Events.ts +133 -0
  472. package/src/Hash.ts +39 -0
  473. package/src/MlDsa65.ts +92 -0
  474. package/src/Mnemonic.ts +109 -0
  475. package/src/Move.ts +440 -0
  476. package/src/MultiSig.ts +320 -0
  477. package/src/Objects.ts +112 -0
  478. package/src/Packages.ts +52 -0
  479. package/src/Passkey.ts +10 -0
  480. package/src/PrivateKey.ts +138 -0
  481. package/src/Ptb.ts +579 -0
  482. package/src/Resolve.ts +1367 -0
  483. package/src/RpcError.ts +41 -0
  484. package/src/Secp256k1.ts +29 -0
  485. package/src/Secp256r1.ts +29 -0
  486. package/src/SignatureScheme.ts +166 -0
  487. package/src/Signer.ts +62 -0
  488. package/src/Testing.ts +830 -0
  489. package/src/TransactionData.ts +134 -0
  490. package/src/TransactionJson.ts +1002 -0
  491. package/src/Transactions.ts +211 -0
  492. package/src/Tx.ts +367 -0
  493. package/src/TypeTag.ts +123 -0
  494. package/src/Verify.ts +42 -0
  495. package/src/enoki/EnokiClient.ts +204 -0
  496. package/src/enoki/EnokiHttp.ts +222 -0
  497. package/src/enoki/Sponsor.ts +280 -0
  498. package/src/enoki/ZkLoginFlow.ts +176 -0
  499. package/src/enoki/index.ts +8 -0
  500. package/src/graphql/ChainGraphQL.ts +76 -0
  501. package/src/graphql/CheckpointDataGraphQL.ts +191 -0
  502. package/src/graphql/CheckpointsGraphQL.ts +96 -0
  503. package/src/graphql/CoinsGraphQL.ts +85 -0
  504. package/src/graphql/DynamicFieldsGraphQL.ts +167 -0
  505. package/src/graphql/EventsGraphQL.ts +301 -0
  506. package/src/graphql/ObjectsGraphQL.ts +112 -0
  507. package/src/graphql/PackagesGraphQL.ts +173 -0
  508. package/src/graphql/SuiGraphQL.ts +77 -0
  509. package/src/graphql/TransactionsGraphQL.ts +292 -0
  510. package/src/graphql/convert.ts +450 -0
  511. package/src/graphql/index.ts +74 -0
  512. package/src/graphql/merge.ts +62 -0
  513. package/src/graphql/paging.ts +110 -0
  514. package/src/graphql/subscription.ts +58 -0
  515. package/src/graphql/tip.ts +38 -0
  516. package/src/grpc/ChainGrpc.ts +51 -0
  517. package/src/grpc/CheckpointDataGrpc.ts +47 -0
  518. package/src/grpc/CheckpointsGrpc.ts +37 -0
  519. package/src/grpc/CoinsGrpc.ts +50 -0
  520. package/src/grpc/DynamicFieldsGrpc.ts +128 -0
  521. package/src/grpc/EventsGrpc.ts +101 -0
  522. package/src/grpc/GrpcWeb.ts +343 -0
  523. package/src/grpc/ObjectsGrpc.ts +95 -0
  524. package/src/grpc/PackagesGrpc.ts +98 -0
  525. package/src/grpc/Rpc.ts +156 -0
  526. package/src/grpc/TransactionsGrpc.ts +88 -0
  527. package/src/grpc/cache.ts +68 -0
  528. package/src/grpc/convert.ts +227 -0
  529. package/src/grpc/generated/lean.ts +276 -0
  530. package/src/grpc/generated/proto.ts +2130 -0
  531. package/src/grpc/generated/rpc.ts +417 -0
  532. package/src/grpc/index.ts +97 -0
  533. package/src/grpc/scan.ts +183 -0
  534. package/src/grpc/transaction.ts +182 -0
  535. package/src/index.ts +35 -0
  536. package/src/internal/allowances.ts +238 -0
  537. package/src/internal/mnemonic.ts +99 -0
  538. package/src/internal/passkey/BrowserProvider.ts +131 -0
  539. package/src/internal/passkey/Passkey.ts +408 -0
  540. package/src/internal/passkey/SoftwareProvider.ts +90 -0
  541. package/src/lifecycle/Evidence.ts +85 -0
  542. package/src/lifecycle/EvidenceGraphQL.ts +67 -0
  543. package/src/lifecycle/EvidenceGrpc.ts +47 -0
  544. package/src/lifecycle/Journal.ts +117 -0
  545. package/src/lifecycle/JournalEntry.ts +68 -0
  546. package/src/lifecycle/JournalKeyValueStore.ts +276 -0
  547. package/src/lifecycle/KeyValueStoreIndexedDb.ts +361 -0
  548. package/src/lifecycle/KeyValueStoreOpfs.ts +230 -0
  549. package/src/lifecycle/Lifecycle.ts +990 -0
  550. package/src/lifecycle/Outcome.ts +130 -0
  551. package/src/lifecycle/SenderLock.ts +73 -0
  552. package/src/lifecycle/SenderLockWebLocks.ts +136 -0
  553. package/src/lifecycle/SignedTransaction.ts +133 -0
  554. package/src/lifecycle/SubmitConfig.ts +77 -0
  555. package/src/lifecycle/index.ts +12 -0
  556. package/src/wallet/Connection.ts +323 -0
  557. package/src/wallet/Features.ts +114 -0
  558. package/src/wallet/Wallet.ts +550 -0
  559. package/src/wallet/index.ts +6 -0
  560. package/src/zklogin/AddressSeed.ts +130 -0
  561. package/src/zklogin/Errors.ts +27 -0
  562. package/src/zklogin/Jwt.ts +186 -0
  563. package/src/zklogin/Nonce.ts +46 -0
  564. package/src/zklogin/Poseidon.ts +62 -0
  565. package/src/zklogin/PublicIdentifier.ts +111 -0
  566. package/src/zklogin/Signature.ts +88 -0
  567. package/src/zklogin/ZkLogin.ts +145 -0
  568. package/src/zklogin/ZkLoginAddress.ts +72 -0
  569. package/src/zklogin/ZkLoginVerifier.ts +37 -0
  570. package/src/zklogin/ZkLoginVerifierGrpc.ts +66 -0
  571. package/src/zklogin/index.ts +16 -0
  572. package/src/zklogin/internal/parse.ts +30 -0
  573. package/src/zklogin/internal/poseidon.ts +47 -0
@@ -0,0 +1,408 @@
1
+ /**
2
+ * Passkeys (WebAuthn, SIP-9) for `@unconfirmed/effect-sui`: the flag-0x06 scheme to
3
+ * install in the registry, a `Signer` over any authenticator, and recovery of
4
+ * a returning user's public key.
5
+ *
6
+ * SignatureSchemes.layer(Ed25519.scheme, Passkey.scheme)
7
+ * const signer = yield* Passkey.create(Passkey.browserProvider("My app")) // new passkey
8
+ * const signer = yield* Passkey.recover(provider) // existing passkey
9
+ *
10
+ * A passkey signature is `0x06 || bcs(PasskeyAuthenticator)`. The authenticator
11
+ * signs `authenticatorData || sha256(clientDataJSON)` with P-256, and the
12
+ * WebAuthn challenge inside `clientDataJSON` is `blake2b256(intentMessage)`, so
13
+ * the signature commits to the intent message through the challenge.
14
+ *
15
+ * The authenticator is a `Provider` value (create a credential, get an
16
+ * assertion), so the signer is the same against a browser, a native bridge, or
17
+ * the software authenticator used in tests.
18
+ */
19
+ import { p256 } from "@noble/curves/nist.js"
20
+ import { sha256 } from "@noble/hashes/sha2.js"
21
+ import { base64urlnopad } from "@scure/base"
22
+ import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
23
+ import * as Address from "../../Address.ts"
24
+ import * as Hash from "../../Hash.ts"
25
+ import * as SignatureScheme from "../../SignatureScheme.ts"
26
+ import * as Signer from "../../Signer.ts"
27
+ import * as Effect from "effect/Effect"
28
+ import * as Result from "effect/Result"
29
+ import * as Schema from "effect/Schema"
30
+ import * as Bytes from "@unconfirmed/effect-bcs/Bytes"
31
+
32
+ export const FLAG = 0x06
33
+ const NAME = "Passkey"
34
+ const SECP256R1_FLAG = 0x02
35
+ /** A passkey public key: a compressed P-256 point. */
36
+ export const PUBLIC_KEY_SIZE = 33
37
+ const SIG = 64
38
+ const USER_SIGNATURE_SIZE = 1 + SIG + PUBLIC_KEY_SIZE
39
+
40
+ /** Sui's `PasskeyAuthenticator`. `userSignature` is a Secp256r1 signature: `0x02 || r || s || publicKey`. */
41
+ export const PasskeyAuthenticatorBcs = Bcs.struct({
42
+ authenticatorData: Bcs.byteVector,
43
+ clientDataJson: Bcs.string,
44
+ userSignature: Bcs.byteVector
45
+ })
46
+
47
+ // -----------------------------------------------------------------------------
48
+ // Provider
49
+ // -----------------------------------------------------------------------------
50
+
51
+ /** A newly created credential. */
52
+ export interface Credential {
53
+ /** The credential id (`rawId`). */
54
+ readonly id: Uint8Array
55
+ /** The public key as DER SubjectPublicKeyInfo (`AuthenticatorAttestationResponse.getPublicKey()`). */
56
+ readonly publicKey: Uint8Array
57
+ }
58
+
59
+ /** A WebAuthn assertion (`AuthenticatorAssertionResponse`), as raw bytes. */
60
+ export interface Assertion {
61
+ /** The id of the credential that signed (`rawId`). */
62
+ readonly credentialId: Uint8Array
63
+ readonly authenticatorData: Uint8Array
64
+ readonly clientDataJSON: Uint8Array
65
+ /** DER-encoded ECDSA signature over `authenticatorData || sha256(clientDataJSON)`. */
66
+ readonly signature: Uint8Array
67
+ }
68
+
69
+ /**
70
+ * An authenticator. `browserProvider` speaks to `navigator.credentials`,
71
+ * `softwareProvider` is an in-memory P-256 key for tests and servers; anything
72
+ * else (a native bridge, a remote device) only has to implement these two.
73
+ *
74
+ * Fail with `SigningError` reason `"rejected"` when the user cancels and
75
+ * `"unavailable"` when there is no authenticator to ask.
76
+ */
77
+ export interface Provider {
78
+ readonly create: () => Effect.Effect<Credential, Signer.SigningError>
79
+ /** Ask for an assertion over `challenge`, restricted to `credentialId` when given. */
80
+ readonly get: (challenge: Uint8Array, credentialId?: Uint8Array) => Effect.Effect<Assertion, Signer.SigningError>
81
+ }
82
+
83
+ // -----------------------------------------------------------------------------
84
+ // Keys and addresses
85
+ // -----------------------------------------------------------------------------
86
+
87
+ /** DER header of a P-256 SubjectPublicKeyInfo, up to the uncompressed point. */
88
+ const SPKI_HEADER = Uint8Array.from([
89
+ 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01,
90
+ 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00
91
+ ])
92
+
93
+ const invalidKey = (reason: string) => new Signer.InvalidKey({ scheme: NAME, reason })
94
+
95
+ /** The compressed public key in a P-256 DER SubjectPublicKeyInfo, as WebAuthn returns it on creation. */
96
+ export const publicKeyFromSpki = (der: Uint8Array): Effect.Effect<Uint8Array, Signer.InvalidKey> => {
97
+ if (der.length !== SPKI_HEADER.length + 65) {
98
+ return Effect.fail(invalidKey(`expected a ${SPKI_HEADER.length + 65}-byte P-256 SubjectPublicKeyInfo, got ${der.length} bytes`))
99
+ }
100
+ if (!Bytes.equal(der.subarray(0, SPKI_HEADER.length), SPKI_HEADER)) {
101
+ return Effect.fail(invalidKey("not a P-256 SubjectPublicKeyInfo (is the credential ES256?)"))
102
+ }
103
+ if (der[SPKI_HEADER.length] !== 0x04) return Effect.fail(invalidKey("public key is not an uncompressed point"))
104
+ try {
105
+ return Effect.succeed(p256.Point.fromBytes(der.subarray(SPKI_HEADER.length)).toBytes(true))
106
+ } catch {
107
+ return Effect.fail(invalidKey("public key is not on P-256"))
108
+ }
109
+ }
110
+
111
+ /** A compressed P-256 public key as a DER SubjectPublicKeyInfo. */
112
+ export const spkiFromPublicKey = (publicKey: Uint8Array): Effect.Effect<Uint8Array, Signer.InvalidKey> => {
113
+ if (publicKey.length !== PUBLIC_KEY_SIZE) {
114
+ return Effect.fail(invalidKey(`expected a ${PUBLIC_KEY_SIZE}-byte compressed P-256 key, got ${publicKey.length} bytes`))
115
+ }
116
+ let point: Uint8Array
117
+ try {
118
+ point = p256.Point.fromBytes(publicKey).toBytes(false)
119
+ } catch {
120
+ return Effect.fail(invalidKey("public key is not on P-256"))
121
+ }
122
+ const out = new Uint8Array(SPKI_HEADER.length + 65)
123
+ out.set(SPKI_HEADER)
124
+ out.set(point, SPKI_HEADER.length)
125
+ return Effect.succeed(out)
126
+ }
127
+
128
+ /** `blake2b256(0x06 || publicKey)`. */
129
+ export const address = (publicKey: Uint8Array): Address.Address => Address.fromPublicKey(FLAG, publicKey)
130
+
131
+ /**
132
+ * A compressed P-256 key (33 bytes, as `create` / `recover` give it) as a passkey `PublicKey`
133
+ * (flag 0x06), checked to be on the curve: a multisig member, or an address without a provider.
134
+ */
135
+ export const publicKeyResult = (compressed: Uint8Array): Result.Result<SignatureScheme.PublicKey, Signer.InvalidKey> => {
136
+ if (compressed.length !== PUBLIC_KEY_SIZE) {
137
+ return Result.fail(invalidKey(`expected a ${PUBLIC_KEY_SIZE}-byte compressed P-256 key, got ${compressed.length} bytes`))
138
+ }
139
+ try {
140
+ p256.Point.fromBytes(compressed)
141
+ } catch {
142
+ return Result.fail(invalidKey("public key is not on P-256"))
143
+ }
144
+ return Result.succeed({ flag: FLAG, bytes: compressed.slice() })
145
+ }
146
+
147
+ // -----------------------------------------------------------------------------
148
+ // Verification
149
+ // -----------------------------------------------------------------------------
150
+
151
+ const invalid = (reason: string) => new SignatureScheme.InvalidSignature({ scheme: NAME, reason })
152
+
153
+ const decodeAuthenticator = Bcs.decode(PasskeyAuthenticatorBcs)
154
+ const encodeAuthenticator = Bcs.encodeSync(PasskeyAuthenticatorBcs)
155
+ const utf8 = new TextEncoder()
156
+
157
+ /** What the authenticator signs: `authenticatorData || sha256(clientDataJSON)`. */
158
+ const signedMessage = (authenticatorData: Uint8Array, clientDataJSON: Uint8Array) =>
159
+ Bytes.concat([authenticatorData, sha256(clientDataJSON)])
160
+
161
+ /** `serde_json`'s recursion limit: a container nested this deep (the outer object is 1) is refused. */
162
+ const SERDE_MAX_DEPTH = 128
163
+
164
+ /**
165
+ * What `JSON.parse` accepts but `serde_json` (which validators parse
166
+ * `clientDataJSON` with) refuses, in any key, known or not: a number out of
167
+ * `f64` range (`1e999`, which parses to `Infinity`) and nesting at its
168
+ * recursion limit. Duplicate keys and lone surrogates remain accepted gaps.
169
+ */
170
+ const serdeRefuses = (value: unknown): string | undefined => {
171
+ const stack: Array<[unknown, number]> = [[value, 1]]
172
+ while (stack.length > 0) {
173
+ const [v, depth] = stack.pop()!
174
+ if (typeof v === "number" && !Number.isFinite(v)) return "has a number out of range"
175
+ if (typeof v === "object" && v !== null) {
176
+ if (depth >= SERDE_MAX_DEPTH) return `nests ${SERDE_MAX_DEPTH} levels deep or more`
177
+ for (const child of Object.values(v)) stack.push([child, depth + 1])
178
+ }
179
+ }
180
+ return undefined
181
+ }
182
+
183
+ /**
184
+ * The `clientDataJSON` checks validators make: it parses as WebAuthn
185
+ * `CollectedClientData` (so `type` and `origin` are present), `type` is
186
+ * `webauthn.get`, and `challenge` is unpadded base64url of exactly
187
+ * `blake2b256(intentMessage)`.
188
+ */
189
+ const checkClientData = (clientDataJson: string, intentMessage: Uint8Array): SignatureScheme.InvalidSignature | undefined => {
190
+ let parsed: unknown
191
+ try {
192
+ parsed = JSON.parse(clientDataJson)
193
+ } catch {
194
+ return invalid("clientDataJSON is not JSON")
195
+ }
196
+ const serdeError = serdeRefuses(parsed)
197
+ if (serdeError) return invalid(`clientDataJSON ${serdeError}`)
198
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return invalid("clientDataJSON is not an object")
199
+ const { type, challenge, origin, crossOrigin } = parsed as Record<string, unknown>
200
+ if (type !== "webauthn.get") return invalid(`clientDataJSON type is ${JSON.stringify(type)}, expected "webauthn.get"`)
201
+ if (typeof origin !== "string") return invalid("clientDataJSON has no origin")
202
+ if (typeof challenge !== "string") return invalid("clientDataJSON has no challenge")
203
+ // WebAuthn's CollectedClientData has `crossOrigin: Option<bool>`; validators refuse anything else.
204
+ if (crossOrigin !== undefined && crossOrigin !== null && typeof crossOrigin !== "boolean") {
205
+ return invalid("clientDataJSON crossOrigin is not a boolean")
206
+ }
207
+ let decoded: Uint8Array
208
+ try {
209
+ decoded = base64urlnopad.decode(challenge)
210
+ } catch {
211
+ return invalid("clientDataJSON challenge is not unpadded base64url")
212
+ }
213
+ if (!Bytes.equal(decoded, Hash.blake2b256(intentMessage))) return invalid("clientDataJSON challenge is not this intent message's digest")
214
+ return undefined
215
+ }
216
+
217
+ /** Verify a passkey signature body (after the 0x06 flag) over an intent message; answer the public key. */
218
+ const verifyBody = (body: Uint8Array, intentMessage: Uint8Array): Effect.Effect<Uint8Array, SignatureScheme.InvalidSignature> => {
219
+ const decoded = decodeAuthenticator(body)
220
+ if (Result.isFailure(decoded)) return Effect.fail(invalid(`malformed PasskeyAuthenticator: ${decoded.failure.message}`))
221
+ const { authenticatorData, clientDataJson, userSignature } = decoded.success
222
+ if (userSignature.length !== USER_SIGNATURE_SIZE) {
223
+ return Effect.fail(invalid(`userSignature must be ${USER_SIGNATURE_SIZE} bytes, got ${userSignature.length}`))
224
+ }
225
+ if (userSignature[0] !== SECP256R1_FLAG) return Effect.fail(invalid("userSignature is not a Secp256r1 signature"))
226
+ const clientDataError = checkClientData(clientDataJson, intentMessage)
227
+ if (clientDataError) return Effect.fail(clientDataError)
228
+ const signature = userSignature.subarray(1, 1 + SIG)
229
+ const publicKey = userSignature.slice(1 + SIG)
230
+ let ok = false
231
+ try {
232
+ // prehash: sha256 of the message; lowS: high-S signatures are refused, as validators do.
233
+ ok = p256.verify(signature, signedMessage(authenticatorData, utf8.encode(clientDataJson)), publicKey, {
234
+ lowS: true,
235
+ prehash: true
236
+ })
237
+ } catch {
238
+ ok = false
239
+ }
240
+ return ok ? Effect.succeed(publicKey) : Effect.fail(invalid("signature does not verify"))
241
+ }
242
+
243
+ export const scheme: SignatureScheme.SignatureScheme = {
244
+ name: NAME,
245
+ flag: FLAG,
246
+ verify: (body, intentMessage) => Effect.map(verifyBody(body, intentMessage), (bytes) => ({ flag: FLAG, bytes })),
247
+ verifyMember: (publicKey, signature, intentMessage) => {
248
+ // Sui stores a passkey member's signature in full, `0x06 || body`, and the multisig scheme hands it over as is.
249
+ if (signature[0] !== FLAG) return Effect.fail(invalid("member signature is not a serialized passkey signature (0x06 || body)"))
250
+ return Effect.flatMap(verifyBody(signature.subarray(1), intentMessage), (signer) =>
251
+ Bytes.equal(signer, publicKey) ? Effect.void : Effect.fail(invalid("signature is not from this member's passkey")))
252
+ }
253
+ }
254
+
255
+ // -----------------------------------------------------------------------------
256
+ // Signing
257
+ // -----------------------------------------------------------------------------
258
+
259
+ export interface PasskeySigner extends Signer.Signer {
260
+ /** Restricts assertions to this credential; `undefined` lets the authenticator offer any passkey for the site. */
261
+ readonly credentialId: Uint8Array | undefined
262
+ }
263
+
264
+ const failed = (message: string) => new Signer.SigningError({ reason: "failed", message })
265
+
266
+ const parseDer = (der: Uint8Array) => {
267
+ try {
268
+ return Result.succeed(p256.Signature.fromBytes(der, "der"))
269
+ } catch (e) {
270
+ return Result.fail(failed(`the authenticator returned a malformed signature: ${String(e)}`))
271
+ }
272
+ }
273
+
274
+ const strictUtf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true })
275
+
276
+ /** Turn an assertion into a passkey signature body, as `@mysten/sui` does (the signature normalized to low-S). */
277
+ const authenticatorBody = (assertion: Assertion, publicKey: Uint8Array): Effect.Effect<Uint8Array, Signer.SigningError> => {
278
+ const sig = parseDer(assertion.signature)
279
+ if (Result.isFailure(sig)) return Effect.fail(sig.failure)
280
+ const s = sig.success
281
+ const compact = (s.hasHighS() ? new p256.Signature(s.r, p256.Point.Fn.neg(s.s)) : s).toBytes("compact")
282
+ let clientDataJson: string
283
+ try {
284
+ clientDataJson = strictUtf8.decode(assertion.clientDataJSON)
285
+ } catch {
286
+ return Effect.fail(failed("the authenticator's clientDataJSON is not UTF-8"))
287
+ }
288
+ const userSignature = new Uint8Array(USER_SIGNATURE_SIZE)
289
+ userSignature[0] = SECP256R1_FLAG
290
+ userSignature.set(compact, 1)
291
+ userSignature.set(publicKey, 1 + SIG)
292
+ return Effect.succeed(encodeAuthenticator({ authenticatorData: assertion.authenticatorData, clientDataJson, userSignature }))
293
+ }
294
+
295
+ /**
296
+ * A signer over a passkey whose public key you know (stored from `create`, or
297
+ * found by `recover`). Pass the `credentialId` to keep the authenticator from
298
+ * offering the user a different passkey.
299
+ */
300
+ export const fromPublicKey = (
301
+ provider: Provider,
302
+ publicKey: Uint8Array,
303
+ options?: { readonly credentialId?: Uint8Array | undefined }
304
+ ): Effect.Effect<PasskeySigner, Signer.InvalidKey> => {
305
+ const checked = publicKeyResult(publicKey)
306
+ if (Result.isFailure(checked)) return Effect.fail(checked.failure)
307
+ const pk = checked.success.bytes
308
+ const credentialId = options?.credentialId?.slice()
309
+ return Effect.succeed({
310
+ address: address(pk),
311
+ publicKey: checked.success,
312
+ credentialId,
313
+ sign: (intentMessage) =>
314
+ Effect.gen(function*() {
315
+ const assertion = yield* provider.get(Hash.blake2b256(intentMessage), credentialId)
316
+ const body = yield* authenticatorBody(assertion, pk)
317
+ // Never hand out a signature that won't verify: the user may have picked another passkey.
318
+ const checked = yield* Effect.result(verifyBody(body, intentMessage))
319
+ if (Result.isFailure(checked)) {
320
+ return yield* failed(`the assertion does not verify for this passkey (was another passkey used?): ${checked.failure.reason}`)
321
+ }
322
+ const out = new Uint8Array(1 + body.length)
323
+ out[0] = FLAG
324
+ out.set(body, 1)
325
+ return out
326
+ })
327
+ })
328
+ }
329
+
330
+ /** Create a new passkey with the provider and answer its signer. For first-time users; returning users `recover`. */
331
+ export const create = (provider: Provider): Effect.Effect<PasskeySigner, Signer.SigningError | Signer.InvalidKey> =>
332
+ Effect.flatMap(provider.create(), (credential) =>
333
+ Effect.flatMap(publicKeyFromSpki(credential.publicKey), (pk) => fromPublicKey(provider, pk, { credentialId: credential.id })))
334
+
335
+ // -----------------------------------------------------------------------------
336
+ // Recovery
337
+ // -----------------------------------------------------------------------------
338
+
339
+ /** No single public key is common to both recovery candidate sets. */
340
+ export class NoUniquePublicKey extends Schema.TaggedError<NoUniquePublicKey>()("NoUniquePublicKey", {
341
+ matches: Schema.Number
342
+ }) {
343
+ override get message() {
344
+ return this.matches === 0
345
+ ? "no public key is common to both assertions (were they made by different passkeys?)"
346
+ : `${this.matches} public keys are common to both assertions`
347
+ }
348
+ }
349
+
350
+ export interface Recovered {
351
+ /** Every public key (up to 4) that verifies the assertion. */
352
+ readonly publicKeys: ReadonlyArray<Uint8Array>
353
+ /** The credential that signed. */
354
+ readonly credentialId: Uint8Array
355
+ }
356
+
357
+ /**
358
+ * Ask the authenticator to sign `message` and recover every public key the
359
+ * signature could be from. An assertion doesn't carry the public key, so a
360
+ * returning user's key is found by intersecting two of these
361
+ * (`findCommonPublicKey`), or by checking each candidate address on chain.
362
+ */
363
+ export const recoverPublicKeys = (
364
+ provider: Provider,
365
+ message: Uint8Array,
366
+ options?: { readonly credentialId?: Uint8Array | undefined }
367
+ ): Effect.Effect<Recovered, Signer.SigningError> =>
368
+ Effect.flatMap(provider.get(message, options?.credentialId), (assertion) => {
369
+ const sig = parseDer(assertion.signature)
370
+ if (Result.isFailure(sig)) return Effect.fail(sig.failure)
371
+ const hash = sha256(signedMessage(assertion.authenticatorData, assertion.clientDataJSON))
372
+ const publicKeys: Array<Uint8Array> = []
373
+ for (let bit = 0; bit < 4; bit++) {
374
+ try {
375
+ publicKeys.push(sig.success.addRecoveryBit(bit).recoverPublicKey(hash).toBytes(true))
376
+ } catch {
377
+ continue
378
+ }
379
+ }
380
+ return Effect.succeed({ publicKeys, credentialId: assertion.credentialId })
381
+ })
382
+
383
+ /** The one public key present in both candidate sets. */
384
+ export const findCommonPublicKey = (
385
+ a: ReadonlyArray<Uint8Array>,
386
+ b: ReadonlyArray<Uint8Array>
387
+ ): Effect.Effect<Uint8Array, NoUniquePublicKey> => {
388
+ const matches = a.filter((x) => b.some((y) => Bytes.equal(x, y)))
389
+ return matches.length === 1 ? Effect.succeed(matches[0]!) : Effect.fail(new NoUniquePublicKey({ matches: matches.length }))
390
+ }
391
+
392
+ /**
393
+ * Recover a returning user's passkey signer: two assertions over distinct
394
+ * messages (random by default), the second restricted to the credential the
395
+ * user chose for the first, and the public key common to both.
396
+ */
397
+ export const recover = (
398
+ provider: Provider,
399
+ options?: { readonly messages?: readonly [Uint8Array, Uint8Array] }
400
+ ): Effect.Effect<PasskeySigner, Signer.SigningError | NoUniquePublicKey> =>
401
+ Effect.gen(function*() {
402
+ const [m1, m2] = options?.messages ?? [crypto.getRandomValues(new Uint8Array(32)), crypto.getRandomValues(new Uint8Array(32))]
403
+ const first = yield* recoverPublicKeys(provider, m1)
404
+ const second = yield* recoverPublicKeys(provider, m2, { credentialId: first.credentialId })
405
+ const publicKey = yield* findCommonPublicKey(first.publicKeys, second.publicKeys)
406
+ // A recovered point is always a valid 33-byte key.
407
+ return yield* Effect.orDie(fromPublicKey(provider, publicKey, { credentialId: first.credentialId }))
408
+ })
@@ -0,0 +1,90 @@
1
+ /**
2
+ * A software authenticator: a P-256 key in memory answering WebAuthn the way a
3
+ * platform authenticator does (DER signatures, which may be high-S;
4
+ * `authenticatorData = sha256(rpId) || flags || signCount`; a `clientDataJSON`
5
+ * with type, challenge, origin and crossOrigin). For tests and for running the
6
+ * passkey signer outside a browser. It is not a secure place for a key.
7
+ *
8
+ * const provider = yield* SoftwareProvider.softwareProvider()
9
+ * const signer = yield* Passkey.create(provider)
10
+ */
11
+ import { p256 } from "@noble/curves/nist.js"
12
+ import { sha256 } from "@noble/hashes/sha2.js"
13
+ import { base64urlnopad } from "@scure/base"
14
+ import * as Signer from "../../Signer.ts"
15
+ import * as Effect from "effect/Effect"
16
+ import * as Passkey from "./Passkey.ts"
17
+
18
+ export interface SoftwareProviderOptions {
19
+ /** A 32-byte P-256 secret key. Random by default. */
20
+ readonly secretKey?: Uint8Array
21
+ /** Random 16 bytes by default. */
22
+ readonly credentialId?: Uint8Array
23
+ /** Default `"localhost"`. */
24
+ readonly rpId?: string
25
+ /** Default `https://${rpId}`. */
26
+ readonly origin?: string
27
+ /** The signature counter written into `authenticatorData`. Default 0 (synced passkeys don't count). */
28
+ readonly signCount?: number
29
+ }
30
+
31
+ export interface SoftwareProvider extends Passkey.Provider {
32
+ readonly secretKey: Uint8Array
33
+ readonly credentialId: Uint8Array
34
+ /** The compressed public key. */
35
+ readonly publicKey: Uint8Array
36
+ }
37
+
38
+ const FLAG_USER_PRESENT = 0x01
39
+ const FLAG_USER_VERIFIED = 0x04
40
+
41
+ const utf8 = new TextEncoder()
42
+
43
+ export const softwareProvider = (options?: SoftwareProviderOptions): Effect.Effect<SoftwareProvider, Signer.InvalidKey> =>
44
+ Effect.suspend(() => {
45
+ const secretKey = options?.secretKey?.slice() ?? p256.utils.randomSecretKey()
46
+ let publicKey: Uint8Array
47
+ try {
48
+ publicKey = p256.getPublicKey(secretKey, true)
49
+ } catch {
50
+ // A fixed reason: the curve library's message is not ours to vouch for (it must never carry key bytes).
51
+ return Effect.fail(
52
+ new Signer.InvalidKey({
53
+ scheme: "Passkey",
54
+ reason: "invalid secret key (expected 32 bytes, a non-zero scalar below the curve order)"
55
+ })
56
+ )
57
+ }
58
+ const credentialId = options?.credentialId?.slice() ?? crypto.getRandomValues(new Uint8Array(16))
59
+ const rpId = options?.rpId ?? "localhost"
60
+ const origin = options?.origin ?? `https://${rpId}`
61
+ const authenticatorData = new Uint8Array(37)
62
+ authenticatorData.set(sha256(utf8.encode(rpId)))
63
+ authenticatorData[32] = FLAG_USER_PRESENT | FLAG_USER_VERIFIED
64
+ new DataView(authenticatorData.buffer).setUint32(33, options?.signCount ?? 0)
65
+ const sameId = (id: Uint8Array) => id.length === credentialId.length && id.every((x, i) => x === credentialId[i])
66
+
67
+ return Effect.succeed<SoftwareProvider>({
68
+ secretKey,
69
+ credentialId,
70
+ publicKey,
71
+ // `publicKey` came from the curve, so it always encodes.
72
+ create: () =>
73
+ Effect.map(Effect.orDie(Passkey.spkiFromPublicKey(publicKey)), (spki) => ({ id: credentialId.slice(), publicKey: spki })),
74
+ get: (challenge, allowed) =>
75
+ Effect.suspend(() => {
76
+ if (allowed !== undefined && !sameId(allowed)) {
77
+ return Effect.fail(new Signer.SigningError({ reason: "failed", message: "no credential matches the requested credential id" }))
78
+ }
79
+ const clientDataJSON = utf8.encode(
80
+ JSON.stringify({ type: "webauthn.get", challenge: base64urlnopad.encode(challenge), origin, crossOrigin: false })
81
+ )
82
+ const message = new Uint8Array(authenticatorData.length + 32)
83
+ message.set(authenticatorData)
84
+ message.set(sha256(clientDataJSON), authenticatorData.length)
85
+ // Authenticators don't normalize S; the signer must.
86
+ const signature = p256.sign(message, secretKey, { lowS: false, format: "der" })
87
+ return Effect.succeed({ credentialId: credentialId.slice(), authenticatorData: authenticatorData.slice(), clientDataJSON, signature })
88
+ })
89
+ })
90
+ })
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Evidence of absence: the one thing `reconcile` needs beyond the core
3
+ * capability services, and only for the expiry rule (`NotApplied{expired}`).
4
+ *
5
+ * "Its window closed and it is not there" is only sound when one backend
6
+ * vouches for the whole observation: the epoch it has reached, that *it* does
7
+ * not serve the transaction, and that its history still reaches back to the
8
+ * window. Joining the epoch from one service (`Chain`) with a miss from another
9
+ * (`Transactions`, perhaps an indexer seconds behind) can judge a transaction
10
+ * that landed at the end of its window as never applied. So `observe` returns
11
+ * all three from one backend, read in an order that makes them consistent:
12
+ * the epoch first, then the lookup (a backend only moves forward, so anything
13
+ * landed before that epoch is already served), then the retention floor (a
14
+ * backend only prunes forward, so the floor read after the miss covers it).
15
+ *
16
+ * The lifecycle also requires a `Transactions.get` miss at both rounds, so
17
+ * when `Transactions` and `Evidence` are different backends both must agree.
18
+ *
19
+ * A `Context.Reference` whose default answers "cannot tell", so it never
20
+ * enters an `R`: **without an `Evidence` layer the expiry rule is off** and a
21
+ * transaction that never reached the network stays `SubmissionUnknown` (and
22
+ * `Signed`/`Unknown` in the journal) until `resubmit` sends it or
23
+ * `Journal.remove` drops it. Provide `EvidenceGrpc.layer` or
24
+ * `EvidenceGraphQL.layer` (pointed at the same backend as `Transactions`),
25
+ * or your own.
26
+ */
27
+ import type { RpcError } from "../RpcError.ts"
28
+ import * as Context from "effect/Context"
29
+ import * as Effect from "effect/Effect"
30
+ import * as Layer from "effect/Layer"
31
+ import * as Option from "effect/Option"
32
+
33
+ /** One backend's view of a digest, read in the order described above. */
34
+ export interface Observation {
35
+ /** The epoch the backend has reached, read before the lookup. */
36
+ readonly epoch: bigint
37
+ /** Whether the same backend serves the transaction. */
38
+ readonly found: boolean
39
+ /**
40
+ * Whether its history, read after the lookup, reaches the first checkpoint
41
+ * of the window's first epoch: none when it does, otherwise why a miss
42
+ * proves nothing (pruned, or not reported: "cannot tell", never "full history").
43
+ */
44
+ readonly gap: Option.Option<string>
45
+ }
46
+
47
+ export interface EvidenceService {
48
+ /**
49
+ * Observe `digest` on one backend; `fromEpoch` is the first epoch of its
50
+ * validity window. None: this service cannot tell (the expiry rule is off).
51
+ */
52
+ readonly observe: (digest: string, fromEpoch: bigint) => Effect.Effect<Option.Option<Observation>, RpcError>
53
+ }
54
+
55
+ /** Answers "cannot tell" to every question. */
56
+ export const unreported: EvidenceService = {
57
+ observe: () => Effect.succeedNone
58
+ }
59
+
60
+ export const Evidence = Context.Reference<EvidenceService>("@unconfirmed/effect-sui/lifecycle/Evidence", {
61
+ defaultValue: () => unreported
62
+ })
63
+
64
+ export const layer = (service: EvidenceService): Layer.Layer<never> => Layer.succeed(Evidence, service)
65
+
66
+ /**
67
+ * The history-gap check shared by the implementations: `lowest` is the
68
+ * backend's lowest available checkpoint read after the lookup, `first` reads
69
+ * the first checkpoint of `fromEpoch` on the same backend.
70
+ */
71
+ export const historyGap = <E>(
72
+ lowest: Option.Option<bigint>,
73
+ fromEpoch: bigint,
74
+ first: (epoch: bigint) => Effect.Effect<Option.Option<bigint>, E>
75
+ ): Effect.Effect<Option.Option<string>, E> => {
76
+ if (Option.isNone(lowest)) return Effect.succeedSome("the node does not report how much history it holds")
77
+ if (lowest.value === 0n) return Effect.succeedNone
78
+ const floor = lowest.value
79
+ return Effect.map(first(fromEpoch), (start) =>
80
+ Option.isNone(start)
81
+ ? Option.some(`the node has pruned to checkpoint ${floor} and does not say where epoch ${fromEpoch} starts`)
82
+ : floor <= start.value
83
+ ? Option.none()
84
+ : Option.some(`the node has pruned to checkpoint ${floor}, after checkpoint ${start.value} where epoch ${fromEpoch} starts`))
85
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * `Evidence` over GraphQL: one query, answered at one checkpoint by one
3
+ * indexer, reads the epoch it has reached, whether it serves the digest, its
4
+ * retention floor for transaction lookups and the first checkpoint of the
5
+ * window's first epoch, so the observation is consistent by construction.
6
+ * Nothing is cached. Its own subpath, so nothing else loads it.
7
+ *
8
+ * EvidenceGraphQL.layer.pipe(Layer.provide(SuiGraphQL.protocol({ url })))
9
+ *
10
+ * Point it at the same endpoint as `Transactions`.
11
+ */
12
+ import { call, U64 } from "../graphql/convert.ts"
13
+ import * as Effect from "effect/Effect"
14
+ import * as GraphQL from "effect/graphql/GraphQL"
15
+ import * as GraphQLClient from "effect/graphql/GraphQLClient"
16
+ import * as GraphQLGroup from "effect/graphql/GraphQLGroup"
17
+ import type * as GraphQLProtocol from "effect/graphql/GraphQLProtocol"
18
+ import * as Layer from "effect/Layer"
19
+ import * as Option from "effect/Option"
20
+ import * as Schema from "effect/Schema"
21
+ import { Evidence, historyGap } from "./Evidence.ts"
22
+
23
+ const Sequence = Schema.NullOr(Schema.Struct({ sequenceNumber: U64 }))
24
+
25
+ export const ObserveTransaction = GraphQL.query("ObserveTransaction", {
26
+ document: "query ObserveTransaction($digest:String!,$epoch:UInt53!){epoch{epochId} " +
27
+ "transactionEffects(digest:$digest){digest} " +
28
+ "serviceConfig{availableRange(type:\"Query\",field:\"transactionEffects\"){first{sequenceNumber}}} " +
29
+ "start:epoch(epochId:$epoch){epochId checkpoints(first:1){nodes{sequenceNumber}}}}",
30
+ variables: { digest: Schema.String, epoch: Schema.Number },
31
+ result: Schema.Struct({
32
+ epoch: Schema.NullOr(Schema.Struct({ epochId: U64 })),
33
+ transactionEffects: Schema.NullOr(Schema.Struct({ digest: Schema.String })),
34
+ serviceConfig: Schema.NullOr(Schema.Struct({ availableRange: Schema.NullOr(Schema.Struct({ first: Sequence })) })),
35
+ start: Schema.NullOr(Schema.Struct({
36
+ epochId: U64,
37
+ checkpoints: Schema.NullOr(Schema.Struct({ nodes: Schema.Array(Schema.Struct({ sequenceNumber: U64 })) }))
38
+ }))
39
+ })
40
+ })
41
+
42
+ export const group = GraphQLGroup.make(ObserveTransaction)
43
+
44
+ export const layer: Layer.Layer<never, never, GraphQLProtocol.GraphQLProtocol> = Layer.effect(
45
+ Evidence,
46
+ Effect.gen(function*() {
47
+ const client = yield* GraphQLClient.make(group)
48
+ return {
49
+ observe: (digest, fromEpoch) =>
50
+ client.ObserveTransaction({ digest, epoch: Number(fromEpoch) }).pipe(
51
+ call,
52
+ Effect.flatMap((r) => {
53
+ if (r.epoch === null) return Effect.succeedNone
54
+ const lowest = Option.fromNullishOr(r.serviceConfig?.availableRange?.first?.sequenceNumber)
55
+ const start = r.start !== null && r.start.epochId === fromEpoch
56
+ ? Option.fromNullishOr(r.start.checkpoints?.nodes[0]?.sequenceNumber)
57
+ : Option.none<bigint>()
58
+ return Effect.map(
59
+ historyGap(lowest, fromEpoch, () => Effect.succeed(start)),
60
+ (gap) => Option.some({ epoch: r.epoch!.epochId, found: r.transactionEffects?.digest === digest, gap })
61
+ )
62
+ }),
63
+ Effect.withSpan("Evidence.observe", { attributes: { digest } })
64
+ )
65
+ }
66
+ })
67
+ )