@aptos-labs/ts-sdk 5.1.0 → 5.1.1-side-effect-free.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 (421) hide show
  1. package/dist/common/{account-BW99GTa5.d.ts → account-Dr4y1uZG.d.ts} +1 -0
  2. package/dist/common/chunk-AWFAHZSB.js +4 -0
  3. package/dist/common/{chunk-A2XB7TVI.js.map → chunk-AWFAHZSB.js.map} +1 -1
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/cli/index.js.map +1 -1
  7. package/dist/common/index.d.ts +94 -16
  8. package/dist/common/index.js +34 -34
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.mjs.map +1 -1
  12. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  13. package/dist/esm/account/AbstractedAccount.mjs.map +1 -1
  14. package/dist/esm/account/Account.mjs +1 -1
  15. package/dist/esm/account/Account.mjs.map +1 -1
  16. package/dist/esm/account/AccountUtils.mjs +1 -1
  17. package/dist/esm/account/AccountUtils.mjs.map +1 -1
  18. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  19. package/dist/esm/account/DerivableAbstractedAccount.mjs.map +1 -1
  20. package/dist/esm/account/Ed25519Account.mjs +1 -1
  21. package/dist/esm/account/Ed25519Account.mjs.map +1 -1
  22. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  23. package/dist/esm/account/EphemeralKeyPair.mjs.map +1 -1
  24. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  25. package/dist/esm/account/FederatedKeylessAccount.mjs.map +1 -1
  26. package/dist/esm/account/KeylessAccount.mjs +1 -1
  27. package/dist/esm/account/KeylessAccount.mjs.map +1 -1
  28. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  29. package/dist/esm/account/MultiEd25519Account.mjs.map +1 -1
  30. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  31. package/dist/esm/account/MultiKeyAccount.mjs.map +1 -1
  32. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  33. package/dist/esm/account/SingleKeyAccount.mjs.map +1 -1
  34. package/dist/esm/account/index.mjs +1 -1
  35. package/dist/esm/account/index.mjs.map +1 -1
  36. package/dist/esm/account/utils.mjs +1 -1
  37. package/dist/esm/account/utils.mjs.map +1 -1
  38. package/dist/esm/api/account/abstraction.mjs +1 -1
  39. package/dist/esm/api/account/abstraction.mjs.map +1 -1
  40. package/dist/esm/api/account.d.mts +1 -1
  41. package/dist/esm/api/account.mjs +1 -1
  42. package/dist/esm/api/account.mjs.map +1 -1
  43. package/dist/esm/api/ans.mjs +1 -1
  44. package/dist/esm/api/ans.mjs.map +1 -1
  45. package/dist/esm/api/aptos.d.mts +81 -14
  46. package/dist/esm/api/aptos.mjs +1 -1
  47. package/dist/esm/api/aptos.mjs.map +1 -1
  48. package/dist/esm/api/aptosConfig.mjs +1 -1
  49. package/dist/esm/api/aptosConfig.mjs.map +1 -1
  50. package/dist/esm/api/coin.mjs +1 -1
  51. package/dist/esm/api/coin.mjs.map +1 -1
  52. package/dist/esm/api/digitalAsset.mjs +1 -1
  53. package/dist/esm/api/digitalAsset.mjs.map +1 -1
  54. package/dist/esm/api/faucet.mjs +1 -1
  55. package/dist/esm/api/faucet.mjs.map +1 -1
  56. package/dist/esm/api/fungibleAsset.mjs +1 -1
  57. package/dist/esm/api/fungibleAsset.mjs.map +1 -1
  58. package/dist/esm/api/general.mjs +1 -1
  59. package/dist/esm/api/general.mjs.map +1 -1
  60. package/dist/esm/api/index.d.mts +2 -2
  61. package/dist/esm/api/index.mjs +1 -1
  62. package/dist/esm/api/index.mjs.map +1 -1
  63. package/dist/esm/api/keyless.mjs +1 -1
  64. package/dist/esm/api/keyless.mjs.map +1 -1
  65. package/dist/esm/api/object.mjs +1 -1
  66. package/dist/esm/api/object.mjs.map +1 -1
  67. package/dist/esm/api/staking.mjs +1 -1
  68. package/dist/esm/api/staking.mjs.map +1 -1
  69. package/dist/esm/api/table.mjs +1 -1
  70. package/dist/esm/api/table.mjs.map +1 -1
  71. package/dist/esm/api/transaction.mjs +1 -1
  72. package/dist/esm/api/transaction.mjs.map +1 -1
  73. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  74. package/dist/esm/api/transactionSubmission/build.mjs.map +1 -1
  75. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  76. package/dist/esm/api/transactionSubmission/helpers.mjs.map +1 -1
  77. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  78. package/dist/esm/api/transactionSubmission/management.mjs.map +1 -1
  79. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  80. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  81. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  82. package/dist/esm/api/transactionSubmission/simulate.mjs.map +1 -1
  83. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  84. package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -1
  85. package/dist/esm/api/utils.mjs +1 -1
  86. package/dist/esm/api/utils.mjs.map +1 -1
  87. package/dist/esm/bcs/consts.mjs +1 -1
  88. package/dist/esm/bcs/consts.mjs.map +1 -1
  89. package/dist/esm/bcs/deserializer.mjs +1 -1
  90. package/dist/esm/bcs/deserializer.mjs.map +1 -1
  91. package/dist/esm/bcs/index.mjs +1 -1
  92. package/dist/esm/bcs/index.mjs.map +1 -1
  93. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  94. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs.map +1 -1
  95. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  96. package/dist/esm/bcs/serializable/fixedBytes.mjs.map +1 -1
  97. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  98. package/dist/esm/bcs/serializable/movePrimitives.mjs.map +1 -1
  99. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  100. package/dist/esm/bcs/serializable/moveStructs.mjs.map +1 -1
  101. package/dist/esm/bcs/serializer.mjs +1 -1
  102. package/dist/esm/bcs/serializer.mjs.map +1 -1
  103. package/dist/esm/cli/index.mjs +1 -1
  104. package/dist/esm/cli/index.mjs.map +1 -1
  105. package/dist/esm/cli/localNode.mjs +1 -1
  106. package/dist/esm/cli/localNode.mjs.map +1 -1
  107. package/dist/esm/cli/move.mjs +1 -1
  108. package/dist/esm/cli/move.mjs.map +1 -1
  109. package/dist/esm/client/core.mjs +1 -1
  110. package/dist/esm/client/core.mjs.map +1 -1
  111. package/dist/esm/client/get.mjs +1 -1
  112. package/dist/esm/client/get.mjs.map +1 -1
  113. package/dist/esm/client/index.mjs +1 -1
  114. package/dist/esm/client/index.mjs.map +1 -1
  115. package/dist/esm/client/post.mjs +1 -1
  116. package/dist/esm/client/post.mjs.map +1 -1
  117. package/dist/esm/core/account/index.d.mts +1 -1
  118. package/dist/esm/core/account/index.mjs +1 -1
  119. package/dist/esm/core/account/index.mjs.map +1 -1
  120. package/dist/esm/core/account/utils/address.d.mts +12 -1
  121. package/dist/esm/core/account/utils/address.mjs +1 -1
  122. package/dist/esm/core/account/utils/address.mjs.map +1 -1
  123. package/dist/esm/core/account/utils/index.d.mts +1 -1
  124. package/dist/esm/core/account/utils/index.mjs +1 -1
  125. package/dist/esm/core/account/utils/index.mjs.map +1 -1
  126. package/dist/esm/core/accountAddress.mjs +3 -1
  127. package/dist/esm/core/accountAddress.mjs.map +1 -1
  128. package/dist/esm/core/authenticationKey.mjs +1 -1
  129. package/dist/esm/core/authenticationKey.mjs.map +1 -1
  130. package/dist/esm/core/common.mjs +1 -1
  131. package/dist/esm/core/common.mjs.map +1 -1
  132. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  133. package/dist/esm/core/crypto/abstraction.mjs.map +1 -1
  134. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  135. package/dist/esm/core/crypto/deserializationUtils.mjs.map +1 -1
  136. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  137. package/dist/esm/core/crypto/ed25519.mjs.map +1 -1
  138. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  139. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -1
  140. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  141. package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -1
  142. package/dist/esm/core/crypto/hdKey.mjs +1 -1
  143. package/dist/esm/core/crypto/hdKey.mjs.map +1 -1
  144. package/dist/esm/core/crypto/index.mjs +1 -1
  145. package/dist/esm/core/crypto/index.mjs.map +1 -1
  146. package/dist/esm/core/crypto/keyless.mjs +1 -1
  147. package/dist/esm/core/crypto/keyless.mjs.map +1 -1
  148. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  149. package/dist/esm/core/crypto/multiEd25519.mjs.map +1 -1
  150. package/dist/esm/core/crypto/multiKey.mjs +3 -1
  151. package/dist/esm/core/crypto/multiKey.mjs.map +1 -1
  152. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  153. package/dist/esm/core/crypto/poseidon.mjs.map +1 -1
  154. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  155. package/dist/esm/core/crypto/privateKey.mjs.map +1 -1
  156. package/dist/esm/core/crypto/proof.mjs +1 -1
  157. package/dist/esm/core/crypto/proof.mjs.map +1 -1
  158. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  159. package/dist/esm/core/crypto/publicKey.mjs.map +1 -1
  160. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  161. package/dist/esm/core/crypto/secp256k1.mjs.map +1 -1
  162. package/dist/esm/core/crypto/secp256r1.mjs +1 -1
  163. package/dist/esm/core/crypto/secp256r1.mjs.map +1 -1
  164. package/dist/esm/core/crypto/signature.mjs +1 -1
  165. package/dist/esm/core/crypto/signature.mjs.map +1 -1
  166. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  167. package/dist/esm/core/crypto/singleKey.mjs.map +1 -1
  168. package/dist/esm/core/crypto/types.mjs +0 -1
  169. package/dist/esm/core/crypto/utils.mjs +1 -1
  170. package/dist/esm/core/crypto/utils.mjs.map +1 -1
  171. package/dist/esm/core/hex.mjs +1 -1
  172. package/dist/esm/core/hex.mjs.map +1 -1
  173. package/dist/esm/core/index.d.mts +1 -1
  174. package/dist/esm/core/index.mjs +1 -1
  175. package/dist/esm/core/index.mjs.map +1 -1
  176. package/dist/esm/errors/index.mjs +6 -1
  177. package/dist/esm/errors/index.mjs.map +1 -1
  178. package/dist/esm/index.d.mts +2 -2
  179. package/dist/esm/index.mjs +1 -1
  180. package/dist/esm/index.mjs.map +1 -1
  181. package/dist/esm/internal/abstraction.mjs +1 -1
  182. package/dist/esm/internal/abstraction.mjs.map +1 -1
  183. package/dist/esm/internal/account.mjs +1 -1
  184. package/dist/esm/internal/account.mjs.map +1 -1
  185. package/dist/esm/internal/ans.mjs +1 -1
  186. package/dist/esm/internal/ans.mjs.map +1 -1
  187. package/dist/esm/internal/coin.mjs +1 -1
  188. package/dist/esm/internal/coin.mjs.map +1 -1
  189. package/dist/esm/internal/digitalAsset.mjs +1 -1
  190. package/dist/esm/internal/digitalAsset.mjs.map +1 -1
  191. package/dist/esm/internal/faucet.mjs +1 -1
  192. package/dist/esm/internal/faucet.mjs.map +1 -1
  193. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  194. package/dist/esm/internal/fungibleAsset.mjs.map +1 -1
  195. package/dist/esm/internal/general.mjs +1 -1
  196. package/dist/esm/internal/general.mjs.map +1 -1
  197. package/dist/esm/internal/keyless.mjs +1 -1
  198. package/dist/esm/internal/keyless.mjs.map +1 -1
  199. package/dist/esm/internal/object.mjs +1 -1
  200. package/dist/esm/internal/object.mjs.map +1 -1
  201. package/dist/esm/internal/staking.mjs +1 -1
  202. package/dist/esm/internal/staking.mjs.map +1 -1
  203. package/dist/esm/internal/table.mjs +1 -1
  204. package/dist/esm/internal/table.mjs.map +1 -1
  205. package/dist/esm/internal/transaction.mjs +1 -1
  206. package/dist/esm/internal/transaction.mjs.map +1 -1
  207. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  208. package/dist/esm/internal/transactionSubmission.mjs.map +1 -1
  209. package/dist/esm/internal/utils/index.mjs +1 -1
  210. package/dist/esm/internal/utils/index.mjs.map +1 -1
  211. package/dist/esm/internal/utils/utils.mjs +1 -1
  212. package/dist/esm/internal/utils/utils.mjs.map +1 -1
  213. package/dist/esm/internal/view.mjs +1 -1
  214. package/dist/esm/internal/view.mjs.map +1 -1
  215. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  216. package/dist/esm/transactions/authenticator/account.mjs.map +1 -1
  217. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  218. package/dist/esm/transactions/authenticator/index.mjs.map +1 -1
  219. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  220. package/dist/esm/transactions/authenticator/transaction.mjs.map +1 -1
  221. package/dist/esm/transactions/index.mjs +1 -1
  222. package/dist/esm/transactions/index.mjs.map +1 -1
  223. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  224. package/dist/esm/transactions/instances/chainId.mjs.map +1 -1
  225. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  226. package/dist/esm/transactions/instances/identifier.mjs.map +1 -1
  227. package/dist/esm/transactions/instances/index.mjs +1 -1
  228. package/dist/esm/transactions/instances/index.mjs.map +1 -1
  229. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  230. package/dist/esm/transactions/instances/moduleId.mjs.map +1 -1
  231. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  232. package/dist/esm/transactions/instances/multiAgentTransaction.mjs.map +1 -1
  233. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  234. package/dist/esm/transactions/instances/rawTransaction.mjs.map +1 -1
  235. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  236. package/dist/esm/transactions/instances/rotationProofChallenge.mjs.map +1 -1
  237. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  238. package/dist/esm/transactions/instances/signedTransaction.mjs.map +1 -1
  239. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  240. package/dist/esm/transactions/instances/simpleTransaction.mjs.map +1 -1
  241. package/dist/esm/transactions/instances/transactionArgument.mjs +0 -1
  242. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  243. package/dist/esm/transactions/instances/transactionPayload.mjs.map +1 -1
  244. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  245. package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -1
  246. package/dist/esm/transactions/management/asyncQueue.mjs +1 -1
  247. package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -1
  248. package/dist/esm/transactions/management/index.mjs +1 -1
  249. package/dist/esm/transactions/management/index.mjs.map +1 -1
  250. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  251. package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -1
  252. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  253. package/dist/esm/transactions/transactionBuilder/helpers.mjs.map +1 -1
  254. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  255. package/dist/esm/transactions/transactionBuilder/index.mjs.map +1 -1
  256. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  257. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs.map +1 -1
  258. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  259. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -1
  260. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -2
  261. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  262. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs.map +1 -1
  263. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  264. package/dist/esm/transactions/typeTag/index.mjs.map +1 -1
  265. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  266. package/dist/esm/transactions/typeTag/parser.mjs.map +1 -1
  267. package/dist/esm/transactions/types.mjs +0 -1
  268. package/dist/esm/types/abstraction.mjs +1 -1
  269. package/dist/esm/types/abstraction.mjs.map +1 -1
  270. package/dist/esm/types/generated/queries.mjs +493 -1
  271. package/dist/esm/types/generated/queries.mjs.map +1 -1
  272. package/dist/esm/types/generated/types.mjs +1 -1
  273. package/dist/esm/types/generated/types.mjs.map +1 -1
  274. package/dist/esm/types/index.mjs +1 -1
  275. package/dist/esm/types/index.mjs.map +1 -1
  276. package/dist/esm/types/indexer.mjs +0 -1
  277. package/dist/esm/types/types.mjs +1 -1
  278. package/dist/esm/types/types.mjs.map +1 -1
  279. package/dist/esm/utils/apiEndpoints.d.mts +1 -0
  280. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  281. package/dist/esm/utils/apiEndpoints.mjs.map +1 -1
  282. package/dist/esm/utils/const.mjs +1 -1
  283. package/dist/esm/utils/const.mjs.map +1 -1
  284. package/dist/esm/utils/helpers.mjs +1 -1
  285. package/dist/esm/utils/helpers.mjs.map +1 -1
  286. package/dist/esm/utils/index.mjs +1 -1
  287. package/dist/esm/utils/index.mjs.map +1 -1
  288. package/dist/esm/utils/memoize.mjs +1 -1
  289. package/dist/esm/utils/memoize.mjs.map +1 -1
  290. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  291. package/dist/esm/utils/normalizeBundle.mjs.map +1 -1
  292. package/dist/esm/version.d.mts +1 -1
  293. package/dist/esm/version.mjs +1 -1
  294. package/dist/esm/version.mjs.map +1 -1
  295. package/package.json +39 -20
  296. package/src/api/aptos.ts +193 -51
  297. package/src/core/account/utils/address.ts +22 -0
  298. package/src/internal/ans.ts +1 -0
  299. package/src/utils/apiEndpoints.ts +7 -0
  300. package/src/version.ts +1 -1
  301. package/dist/common/chunk-A2XB7TVI.js +0 -4
  302. package/dist/esm/chunk-2PASUPUO.mjs +0 -2
  303. package/dist/esm/chunk-2PASUPUO.mjs.map +0 -1
  304. package/dist/esm/chunk-2XQKGWHQ.mjs +0 -2
  305. package/dist/esm/chunk-2XQKGWHQ.mjs.map +0 -1
  306. package/dist/esm/chunk-35DKMW7Q.mjs +0 -2
  307. package/dist/esm/chunk-35DKMW7Q.mjs.map +0 -1
  308. package/dist/esm/chunk-4AI7KQQ7.mjs +0 -2
  309. package/dist/esm/chunk-4AI7KQQ7.mjs.map +0 -1
  310. package/dist/esm/chunk-4QMXOWHP.mjs +0 -1
  311. package/dist/esm/chunk-4QMXOWHP.mjs.map +0 -1
  312. package/dist/esm/chunk-4RXKALLC.mjs +0 -2
  313. package/dist/esm/chunk-4RXKALLC.mjs.map +0 -1
  314. package/dist/esm/chunk-4WPQQPUF.mjs +0 -1
  315. package/dist/esm/chunk-4WPQQPUF.mjs.map +0 -1
  316. package/dist/esm/chunk-56CNRT2K.mjs +0 -2
  317. package/dist/esm/chunk-56CNRT2K.mjs.map +0 -1
  318. package/dist/esm/chunk-5HXLZHDW.mjs +0 -1
  319. package/dist/esm/chunk-5HXLZHDW.mjs.map +0 -1
  320. package/dist/esm/chunk-6OWBKU7N.mjs +0 -2
  321. package/dist/esm/chunk-6OWBKU7N.mjs.map +0 -1
  322. package/dist/esm/chunk-6WDVDEQZ.mjs +0 -7
  323. package/dist/esm/chunk-6WDVDEQZ.mjs.map +0 -1
  324. package/dist/esm/chunk-7DQDJ2SA.mjs +0 -2
  325. package/dist/esm/chunk-7DQDJ2SA.mjs.map +0 -1
  326. package/dist/esm/chunk-7ECCT6PK.mjs +0 -1
  327. package/dist/esm/chunk-7ECCT6PK.mjs.map +0 -1
  328. package/dist/esm/chunk-7EER7GWV.mjs +0 -2
  329. package/dist/esm/chunk-7EER7GWV.mjs.map +0 -1
  330. package/dist/esm/chunk-A5L76YP7.mjs +0 -2
  331. package/dist/esm/chunk-A5L76YP7.mjs.map +0 -1
  332. package/dist/esm/chunk-AMXZQPUQ.mjs +0 -2
  333. package/dist/esm/chunk-AMXZQPUQ.mjs.map +0 -1
  334. package/dist/esm/chunk-B563XRSZ.mjs +0 -2
  335. package/dist/esm/chunk-B563XRSZ.mjs.map +0 -1
  336. package/dist/esm/chunk-C3Q23D22.mjs +0 -2
  337. package/dist/esm/chunk-C3Q23D22.mjs.map +0 -1
  338. package/dist/esm/chunk-CIJA7ONS.mjs +0 -2
  339. package/dist/esm/chunk-CIJA7ONS.mjs.map +0 -1
  340. package/dist/esm/chunk-CW35YAMN.mjs +0 -2
  341. package/dist/esm/chunk-CW35YAMN.mjs.map +0 -1
  342. package/dist/esm/chunk-EBMEXURY.mjs +0 -2
  343. package/dist/esm/chunk-EBMEXURY.mjs.map +0 -1
  344. package/dist/esm/chunk-EF4FA5I6.mjs +0 -2
  345. package/dist/esm/chunk-EF4FA5I6.mjs.map +0 -1
  346. package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
  347. package/dist/esm/chunk-FD6FGKYY.mjs.map +0 -1
  348. package/dist/esm/chunk-FGFLPH5K.mjs +0 -2
  349. package/dist/esm/chunk-FGFLPH5K.mjs.map +0 -1
  350. package/dist/esm/chunk-FLZPUYXQ.mjs +0 -2
  351. package/dist/esm/chunk-FLZPUYXQ.mjs.map +0 -1
  352. package/dist/esm/chunk-FZY4PMEE.mjs +0 -1
  353. package/dist/esm/chunk-FZY4PMEE.mjs.map +0 -1
  354. package/dist/esm/chunk-G3MHXDYA.mjs +0 -1
  355. package/dist/esm/chunk-G3MHXDYA.mjs.map +0 -1
  356. package/dist/esm/chunk-GOXRBEIJ.mjs +0 -2
  357. package/dist/esm/chunk-GOXRBEIJ.mjs.map +0 -1
  358. package/dist/esm/chunk-HGLO5LDS.mjs +0 -1
  359. package/dist/esm/chunk-HGLO5LDS.mjs.map +0 -1
  360. package/dist/esm/chunk-HNBVYE3N.mjs +0 -2
  361. package/dist/esm/chunk-HNBVYE3N.mjs.map +0 -1
  362. package/dist/esm/chunk-I7XT6L7S.mjs +0 -2
  363. package/dist/esm/chunk-I7XT6L7S.mjs.map +0 -1
  364. package/dist/esm/chunk-IF4UU2MT.mjs +0 -2
  365. package/dist/esm/chunk-IF4UU2MT.mjs.map +0 -1
  366. package/dist/esm/chunk-JABP65XD.mjs +0 -2
  367. package/dist/esm/chunk-JABP65XD.mjs.map +0 -1
  368. package/dist/esm/chunk-KDMSOCZY.mjs +0 -2
  369. package/dist/esm/chunk-KDMSOCZY.mjs.map +0 -1
  370. package/dist/esm/chunk-L72TIN7T.mjs +0 -4
  371. package/dist/esm/chunk-L72TIN7T.mjs.map +0 -1
  372. package/dist/esm/chunk-M3AO73ZL.mjs +0 -2
  373. package/dist/esm/chunk-M3AO73ZL.mjs.map +0 -1
  374. package/dist/esm/chunk-MCFQE4GC.mjs +0 -2
  375. package/dist/esm/chunk-MCFQE4GC.mjs.map +0 -1
  376. package/dist/esm/chunk-MT2RJ7H3.mjs +0 -2
  377. package/dist/esm/chunk-MT2RJ7H3.mjs.map +0 -1
  378. package/dist/esm/chunk-N6YTF76Q.mjs +0 -2
  379. package/dist/esm/chunk-N6YTF76Q.mjs.map +0 -1
  380. package/dist/esm/chunk-NECL5FCQ.mjs +0 -1
  381. package/dist/esm/chunk-NECL5FCQ.mjs.map +0 -1
  382. package/dist/esm/chunk-OLILO7VD.mjs +0 -2
  383. package/dist/esm/chunk-OLILO7VD.mjs.map +0 -1
  384. package/dist/esm/chunk-ORMOQWWH.mjs +0 -2
  385. package/dist/esm/chunk-ORMOQWWH.mjs.map +0 -1
  386. package/dist/esm/chunk-Q4W3WJ2U.mjs +0 -2
  387. package/dist/esm/chunk-Q4W3WJ2U.mjs.map +0 -1
  388. package/dist/esm/chunk-QP2BY4PK.mjs +0 -2
  389. package/dist/esm/chunk-QP2BY4PK.mjs.map +0 -1
  390. package/dist/esm/chunk-QREVMGQZ.mjs +0 -2
  391. package/dist/esm/chunk-QREVMGQZ.mjs.map +0 -1
  392. package/dist/esm/chunk-RCSJFTST.mjs +0 -2
  393. package/dist/esm/chunk-RCSJFTST.mjs.map +0 -1
  394. package/dist/esm/chunk-RGKRCZ36.mjs +0 -4
  395. package/dist/esm/chunk-RGKRCZ36.mjs.map +0 -1
  396. package/dist/esm/chunk-SJDCGNWU.mjs +0 -2
  397. package/dist/esm/chunk-SJDCGNWU.mjs.map +0 -1
  398. package/dist/esm/chunk-STY74NUA.mjs +0 -2
  399. package/dist/esm/chunk-STY74NUA.mjs.map +0 -1
  400. package/dist/esm/chunk-TOBQ5UE6.mjs +0 -2
  401. package/dist/esm/chunk-TOBQ5UE6.mjs.map +0 -1
  402. package/dist/esm/chunk-UL777LTI.mjs +0 -494
  403. package/dist/esm/chunk-UL777LTI.mjs.map +0 -1
  404. package/dist/esm/chunk-UYVPNUH3.mjs +0 -1
  405. package/dist/esm/chunk-UYVPNUH3.mjs.map +0 -1
  406. package/dist/esm/chunk-V3MBJJTL.mjs +0 -1
  407. package/dist/esm/chunk-V3MBJJTL.mjs.map +0 -1
  408. package/dist/esm/chunk-WCMW2L3P.mjs +0 -2
  409. package/dist/esm/chunk-WCMW2L3P.mjs.map +0 -1
  410. package/dist/esm/chunk-WHSTLR3F.mjs +0 -2
  411. package/dist/esm/chunk-WHSTLR3F.mjs.map +0 -1
  412. package/dist/esm/chunk-WSR5EBJM.mjs +0 -2
  413. package/dist/esm/chunk-WSR5EBJM.mjs.map +0 -1
  414. package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
  415. package/dist/esm/chunk-XJJVJOX5.mjs.map +0 -1
  416. package/dist/esm/chunk-XKUIMGKU.mjs +0 -2
  417. package/dist/esm/chunk-XKUIMGKU.mjs.map +0 -1
  418. package/dist/esm/chunk-YOZBVVKL.mjs +0 -2
  419. package/dist/esm/chunk-YOZBVVKL.mjs.map +0 -1
  420. package/dist/esm/chunk-ZP4DWSQA.mjs +0 -2
  421. package/dist/esm/chunk-ZP4DWSQA.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import{gb as a,hb as b,ib as c}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{b as AbstractKeylessAccount,c as TransactionAndProof,a as isKeylessSigner};
1
+ import k from"eventemitter3";import{jwtDecode as O}from"jwt-decode";import{EphemeralCertificateVariant as R,SigningScheme as H}from"../types";import{AccountAddress as m}from"../core/accountAddress";import{AnyPublicKey as d,AnySignature as P,KeylessSignature as I,EphemeralCertificate as C,ZeroKnowledgeSig as w,getKeylessConfig as _,fetchJWK as D}from"../core/crypto";import{EphemeralKeyPair as N}from"./EphemeralKeyPair";import{Hex as a}from"../core/hex";import{AccountAuthenticatorSingleKey as A}from"../transactions/authenticator/account";import{Serializable as S}from"../bcs";import{deriveTransactionType as E,generateSigningMessage as U}from"../transactions/transactionBuilder/signingMessage";import{base64UrlDecode as V}from"../utils/helpers";import{KeylessError as r,KeylessErrorType as o}from"../errors";function ue(c){return c!=null&&typeof c.checkKeylessAccountValidity=="function"}const s=class s extends S{constructor(e){super();this.signingScheme=H.SingleKey;const{address:i,ephemeralKeyPair:t,publicKey:n,uidKey:p,uidVal:h,aud:l,pepper:f,proof:y,proofFetchCallback:K,jwt:v,verificationKeyHash:u}=e;if(this.ephemeralKeyPair=t,this.publicKey=n,this.accountAddress=i?m.from(i):this.publicKey.authKey().derivedAddress(),this.uidKey=p,this.uidVal=h,this.aud=l,this.jwt=v,this.emitter=new k,this.proofOrPromise=y,y instanceof w)this.proof=y;else{if(K===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async x=>{await K(x),this.emitter.removeAllListeners()}),this.init(y)}const g=a.fromHexInput(f).toUint8Array();if(g.length!==s.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${s.PEPPER_LENGTH}`);if(this.pepper=g,u!==void 0){if(a.hexInputToUint8Array(u).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=a.hexInputToUint8Array(u)}}getAnyPublicKey(){return new d(this.publicKey)}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(i){i instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:i.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(this.accountAddress.serialize(e),e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(e),e.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(e){const i=m.deserialize(e),t=e.deserializeStr(),n=e.deserializeStr(),p=e.deserializeFixedBytes(31),h=N.deserialize(e),l=w.deserialize(e),f=e.deserializeOption("fixedBytes",32);return{address:i,jwt:t,uidKey:n,pepper:p,ephemeralKeyPair:h,proof:l,verificationKeyHash:f}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){const i=new P(this.sign(e)),t=new d(this.publicKey);return new A(t,i)}signTransactionWithAuthenticator(e){const i=new P(this.signTransaction(e)),t=new d(this.publicKey);return new A(t,i)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(e){if(this.isExpired())throw r.fromErrorType({type:o.EPHEMERAL_KEY_PAIR_EXPIRED});if(await this.waitForProofFetch(),this.proof===void 0)throw r.fromErrorType({type:o.ASYNC_PROOF_FETCH_FAILED});const i=O(this.jwt,{header:!0});if(i.kid===void 0)throw r.fromErrorType({type:o.JWT_PARSING_ERROR,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){const{verificationKey:t}=await _({aptosConfig:e});if(a.hexInputToString(t.hash())!==a.hexInputToString(this.verificationKeyHash))throw r.fromErrorType({type:o.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await s.fetchJWK({aptosConfig:e,publicKey:this.publicKey,kid:i.kid})}sign(e){const{expiryDateSecs:i}=this.ephemeralKeyPair;if(this.isExpired())throw r.fromErrorType({type:o.EPHEMERAL_KEY_PAIR_EXPIRED});if(this.proof===void 0)throw r.fromErrorType({type:o.PROOF_NOT_FOUND,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});const t=this.ephemeralKeyPair.getPublicKey(),n=this.ephemeralKeyPair.sign(e);return new I({jwtHeader:V(this.jwt.split(".")[0]),ephemeralCertificate:new C(this.proof,R.ZkProof),expiryDateSecs:i,ephemeralPublicKey:t,ephemeralSignature:n})}signTransaction(e){if(this.proof===void 0)throw r.fromErrorType({type:o.PROOF_NOT_FOUND,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});const i=E(e),n=new b(i,this.proof.proof).hash();return this.sign(n)}getSigningMessage(e){if(this.proof===void 0)throw r.fromErrorType({type:o.PROOF_NOT_FOUND,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});const i=E(e);return new b(i,this.proof.proof).hash()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e})}static async fetchJWK(e){return D(e)}};s.PEPPER_LENGTH=31;let F=s;class b extends S{constructor(e,i){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=e,this.proof=i}serialize(e){e.serializeFixedBytes(this.transaction.bcsToBytes()),e.serializeOption(this.proof)}hash(){return U(this.bcsToBytes(),this.domainSeparator)}}export{F as AbstractKeylessAccount,b as TransactionAndProof,ue as isKeylessSigner};
2
2
  //# sourceMappingURL=AbstractKeylessAccount.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/AbstractKeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport EventEmitter from \"eventemitter3\";\nimport { jwtDecode } from \"jwt-decode\";\nimport { EphemeralCertificateVariant, HexInput, SigningScheme } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport {\n AnyPublicKey,\n AnySignature,\n KeylessPublicKey,\n KeylessSignature,\n EphemeralCertificate,\n ZeroKnowledgeSig,\n ZkProof,\n MoveJWK,\n getKeylessConfig,\n fetchJWK,\n KeylessConfiguration,\n} from \"../core/crypto\";\n\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Hex } from \"../core/hex\";\nimport { AccountAuthenticatorSingleKey } from \"../transactions/authenticator/account\";\nimport { Deserializer, Serializable, Serializer } from \"../bcs\";\nimport { deriveTransactionType, generateSigningMessage } from \"../transactions/transactionBuilder/signingMessage\";\nimport { AnyRawTransaction, AnyRawTransactionInstance } from \"../transactions/types\";\nimport { base64UrlDecode } from \"../utils/helpers\";\nimport { FederatedKeylessPublicKey } from \"../core/crypto/federatedKeyless\";\nimport { Account } from \"./Account\";\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { KeylessError, KeylessErrorType } from \"../errors\";\nimport type { SingleKeySigner } from \"./SingleKeyAccount\";\n\n/**\n * An interface which defines if an Account utilizes Keyless signing.\n */\nexport interface KeylessSigner extends Account {\n checkKeylessAccountValidity(aptosConfig: AptosConfig): Promise<void>;\n}\n\nexport function isKeylessSigner(obj: any): obj is KeylessSigner {\n return obj !== null && obj !== undefined && typeof obj.checkKeylessAccountValidity === \"function\";\n}\n\n/**\n * Account implementation for the Keyless authentication scheme. This abstract class is used for standard Keyless Accounts\n * and Federated Keyless Accounts.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport abstract class AbstractKeylessAccount extends Serializable implements KeylessSigner, SingleKeySigner {\n static readonly PEPPER_LENGTH: number = 31;\n\n /**\n * The KeylessPublicKey associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly publicKey: KeylessPublicKey | FederatedKeylessPublicKey;\n\n /**\n * The EphemeralKeyPair used to generate sign.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly ephemeralKeyPair: EphemeralKeyPair;\n\n /**\n * The claim on the JWT to identify a user. This is typically 'sub' or 'email'.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly uidKey: string;\n\n /**\n * The value of the uidKey claim on the JWT. This intended to be a stable user identifier.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly uidVal: string;\n\n /**\n * The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's\n * OIDC registration with the identity provider.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly aud: string;\n\n /**\n * A value contains 31 bytes of entropy that preserves privacy of the account. Typically fetched from a pepper provider.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly pepper: Uint8Array;\n\n /**\n * Account address associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly accountAddress: AccountAddress;\n\n /**\n * The zero knowledge signature (if ready) which contains the proof used to validate the EphemeralKeyPair.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n proof: ZeroKnowledgeSig | undefined;\n\n /**\n * The proof of the EphemeralKeyPair or a promise that provides the proof. This is used to allow for awaiting on\n * fetching the proof.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly proofOrPromise: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n\n /**\n * Signing scheme used to sign transactions\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly signingScheme: SigningScheme = SigningScheme.SingleKey;\n\n /**\n * The JWT token used to derive the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly jwt: string;\n\n /**\n * The hash of the verification key used to verify the proof. This is optional and can be used to check verifying key\n * rotations which may invalidate the proof.\n */\n readonly verificationKeyHash?: Uint8Array;\n\n /**\n * An event emitter used to assist in handling asynchronous proof fetching.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n private readonly emitter: EventEmitter<ProofFetchEvents>;\n\n /**\n * Use the static generator `create(...)` instead.\n * Creates an instance of the KeylessAccount with an optional proof.\n *\n * @param args - The parameters for creating a KeylessAccount.\n * @param args.address - Optional account address associated with the KeylessAccount.\n * @param args.publicKey - A KeylessPublicKey or FederatedKeylessPublicKey.\n * @param args.ephemeralKeyPair - The ephemeral key pair used in the account creation.\n * @param args.iss - A JWT issuer.\n * @param args.uidKey - The claim on the JWT to identify a user. This is typically 'sub' or 'email'.\n * @param args.uidVal - The unique id for this user, intended to be a stable user identifier.\n * @param args.aud - The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's\n * OIDC registration with the identity provider.\n * @param args.pepper - A hexadecimal input used for additional security.\n * @param args.proof - A Zero Knowledge Signature or a promise that resolves to one.\n * @param args.proofFetchCallback - Optional callback function for fetching proof.\n * @param args.jwt - A JSON Web Token used for authentication.\n * @param args.verificationKeyHash Optional 32-byte verification key hash as hex input used to check proof validity.\n */\n protected constructor(args: {\n address?: AccountAddress;\n publicKey: KeylessPublicKey | FederatedKeylessPublicKey;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n verificationKeyHash?: HexInput;\n }) {\n super();\n const {\n address,\n ephemeralKeyPair,\n publicKey,\n uidKey,\n uidVal,\n aud,\n pepper,\n proof,\n proofFetchCallback,\n jwt,\n verificationKeyHash,\n } = args;\n this.ephemeralKeyPair = ephemeralKeyPair;\n this.publicKey = publicKey;\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n this.uidKey = uidKey;\n this.uidVal = uidVal;\n this.aud = aud;\n this.jwt = jwt;\n this.emitter = new EventEmitter<ProofFetchEvents>();\n this.proofOrPromise = proof;\n if (proof instanceof ZeroKnowledgeSig) {\n this.proof = proof;\n } else {\n if (proofFetchCallback === undefined) {\n throw new Error(\"Must provide callback for async proof fetch\");\n }\n this.emitter.on(\"proofFetchFinish\", async (status) => {\n await proofFetchCallback(status);\n this.emitter.removeAllListeners();\n });\n // Note, this is purposely not awaited to be non-blocking. The caller should await on the proofFetchCallback.\n this.init(proof);\n }\n const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();\n if (pepperBytes.length !== AbstractKeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper length in bytes should be ${AbstractKeylessAccount.PEPPER_LENGTH}`);\n }\n this.pepper = pepperBytes;\n if (verificationKeyHash !== undefined) {\n if (Hex.hexInputToUint8Array(verificationKeyHash).length !== 32) {\n throw new Error(\"verificationKeyHash must be 32 bytes\");\n }\n this.verificationKeyHash = Hex.hexInputToUint8Array(verificationKeyHash);\n }\n }\n\n getAnyPublicKey(): AnyPublicKey {\n return new AnyPublicKey(this.publicKey);\n }\n\n /**\n * This initializes the asynchronous proof fetch\n * @return Emits whether the proof succeeds or fails, but has no return.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n async init(promise: Promise<ZeroKnowledgeSig>) {\n try {\n this.proof = await promise;\n this.emitter.emit(\"proofFetchFinish\", { status: \"Success\" });\n } catch (error) {\n if (error instanceof Error) {\n this.emitter.emit(\"proofFetchFinish\", { status: \"Failed\", error: error.toString() });\n } else {\n this.emitter.emit(\"proofFetchFinish\", { status: \"Failed\", error: \"Unknown\" });\n }\n }\n }\n\n /**\n * Serializes the jwt data into a format suitable for transmission or storage.\n * This function ensures that both the jwt data and the proof are properly serialized.\n *\n * @param serializer - The serializer instance used to convert the jwt data into bytes.\n */\n serialize(serializer: Serializer): void {\n this.accountAddress.serialize(serializer);\n serializer.serializeStr(this.jwt);\n serializer.serializeStr(this.uidKey);\n serializer.serializeFixedBytes(this.pepper);\n this.ephemeralKeyPair.serialize(serializer);\n if (this.proof === undefined) {\n throw new Error(\"Cannot serialize - proof undefined\");\n }\n this.proof.serialize(serializer);\n serializer.serializeOption(this.verificationKeyHash, 32);\n }\n\n static partialDeserialize(deserializer: Deserializer): {\n address: AccountAddress;\n jwt: string;\n uidKey: string;\n pepper: Uint8Array;\n ephemeralKeyPair: EphemeralKeyPair;\n proof: ZeroKnowledgeSig;\n verificationKeyHash?: Uint8Array;\n } {\n const address = AccountAddress.deserialize(deserializer);\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = ZeroKnowledgeSig.deserialize(deserializer);\n const verificationKeyHash = deserializer.deserializeOption(\"fixedBytes\", 32);\n\n return { address, jwt, uidKey, pepper, ephemeralKeyPair, proof, verificationKeyHash };\n }\n\n /**\n * Checks if the proof is expired. If so the account must be re-derived with a new EphemeralKeyPair\n * and JWT token.\n * @return boolean\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n isExpired(): boolean {\n return this.ephemeralKeyPair.isExpired();\n }\n\n /**\n * Sign a message using Keyless.\n * @param message the message to sign, as binary input\n * @return the AccountAuthenticator containing the signature, together with the account's public key\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signWithAuthenticator(message: HexInput): AccountAuthenticatorSingleKey {\n const signature = new AnySignature(this.sign(message));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n /**\n * Sign a transaction using Keyless.\n * @param transaction the raw transaction\n * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey {\n const signature = new AnySignature(this.signTransaction(transaction));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n /**\n * Waits for asynchronous proof fetching to finish.\n * @return\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n async waitForProofFetch() {\n if (this.proofOrPromise instanceof Promise) {\n await this.proofOrPromise;\n }\n }\n\n /**\n * Validates that the Keyless Account can be used to sign transactions.\n * @return\n */\n async checkKeylessAccountValidity(aptosConfig: AptosConfig): Promise<void> {\n if (this.isExpired()) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.EPHEMERAL_KEY_PAIR_EXPIRED,\n });\n }\n await this.waitForProofFetch();\n if (this.proof === undefined) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.ASYNC_PROOF_FETCH_FAILED,\n });\n }\n const header = jwtDecode(this.jwt, { header: true });\n if (header.kid === undefined) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.JWT_PARSING_ERROR,\n details: \"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen.\",\n });\n }\n if (this.verificationKeyHash !== undefined) {\n const { verificationKey } = await getKeylessConfig({ aptosConfig });\n if (Hex.hexInputToString(verificationKey.hash()) !== Hex.hexInputToString(this.verificationKeyHash)) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND,\n });\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(\n \"[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.\",\n );\n }\n await AbstractKeylessAccount.fetchJWK({ aptosConfig, publicKey: this.publicKey, kid: header.kid });\n }\n\n /**\n * Sign the given message using Keyless.\n * @param message in HexInput format\n * @returns Signature\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n sign(message: HexInput): KeylessSignature {\n const { expiryDateSecs } = this.ephemeralKeyPair;\n if (this.isExpired()) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.EPHEMERAL_KEY_PAIR_EXPIRED,\n });\n }\n if (this.proof === undefined) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.PROOF_NOT_FOUND,\n details: \"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing.\",\n });\n }\n const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();\n const ephemeralSignature = this.ephemeralKeyPair.sign(message);\n\n return new KeylessSignature({\n jwtHeader: base64UrlDecode(this.jwt.split(\".\")[0]),\n ephemeralCertificate: new EphemeralCertificate(this.proof, EphemeralCertificateVariant.ZkProof),\n expiryDateSecs,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n /**\n * Sign the given transaction with Keyless.\n * Signs the transaction and proof to guard against proof malleability.\n * @param transaction the transaction to be signed\n * @returns KeylessSignature\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signTransaction(transaction: AnyRawTransaction): KeylessSignature {\n if (this.proof === undefined) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.PROOF_NOT_FOUND,\n details: \"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing.\",\n });\n }\n const raw = deriveTransactionType(transaction);\n const txnAndProof = new TransactionAndProof(raw, this.proof.proof);\n const signMess = txnAndProof.hash();\n return this.sign(signMess);\n }\n\n getSigningMessage(transaction: AnyRawTransaction): Uint8Array {\n if (this.proof === undefined) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.PROOF_NOT_FOUND,\n details: \"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing.\",\n });\n }\n const raw = deriveTransactionType(transaction);\n const txnAndProof = new TransactionAndProof(raw, this.proof.proof);\n return txnAndProof.hash();\n }\n\n /**\n * Note - This function is currently incomplete and should only be used to verify ownership of the KeylessAccount\n *\n * Verifies a signature given the message.\n *\n * @param args.message the message that was signed.\n * @param args.signature the KeylessSignature to verify\n * @returns boolean\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n verifySignature(args: {\n message: HexInput;\n signature: KeylessSignature;\n jwk: MoveJWK;\n keylessConfig: KeylessConfiguration;\n }): boolean {\n return this.publicKey.verifySignature(args);\n }\n\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: KeylessSignature;\n options?: { throwErrorWithReason?: boolean };\n }): Promise<boolean> {\n return this.publicKey.verifySignatureAsync({\n ...args,\n });\n }\n\n /**\n * Fetches the JWK from the issuer's well-known JWKS endpoint.\n *\n * @param args.publicKey The keyless public key to query\n * @param args.kid The kid of the JWK to fetch\n * @returns A JWK matching the `kid` in the JWT header.\n * @throws {KeylessError} If the JWK cannot be fetched\n */\n static async fetchJWK(args: {\n aptosConfig: AptosConfig;\n publicKey: KeylessPublicKey | FederatedKeylessPublicKey;\n kid: string;\n }): Promise<MoveJWK> {\n return fetchJWK(args);\n }\n}\n\n/**\n * A container class to hold a transaction and a proof. It implements CryptoHashable which is used to create\n * the signing message for Keyless transactions. We sign over the proof to ensure non-malleability.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport class TransactionAndProof extends Serializable {\n /**\n * The transaction to sign.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n transaction: AnyRawTransactionInstance;\n\n /**\n * The zero knowledge proof used in signing the transaction.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n proof?: ZkProof;\n\n /**\n * The domain separator prefix used when hashing.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly domainSeparator = \"APTOS::TransactionAndProof\";\n\n constructor(transaction: AnyRawTransactionInstance, proof?: ZkProof) {\n super();\n this.transaction = transaction;\n this.proof = proof;\n }\n\n /**\n * Serializes the transaction data into a format suitable for transmission or storage.\n * This function ensures that both the transaction bytes and the proof are properly serialized.\n *\n * @param serializer - The serializer instance used to convert the transaction data into bytes.\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.transaction.bcsToBytes());\n serializer.serializeOption(this.proof);\n }\n\n /**\n * Hashes the bcs serialized from of the class. This is the typescript corollary to the BCSCryptoHash macro in aptos-core.\n *\n * @returns Uint8Array\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n hash(): Uint8Array {\n return generateSigningMessage(this.bcsToBytes(), this.domainSeparator);\n }\n}\n/**\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport type ProofFetchSuccess = {\n status: \"Success\";\n};\n/**\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport type ProofFetchFailure = {\n status: \"Failed\";\n error: string;\n};\n/**\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport type ProofFetchStatus = ProofFetchSuccess | ProofFetchFailure;\n/**\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport type ProofFetchCallback = (status: ProofFetchStatus) => Promise<void>;\n/**\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface ProofFetchEvents {\n proofFetchFinish: (status: ProofFetchStatus) => void;\n}\n"],"mappings":"AAGA,OAAOA,MAAkB,gBACzB,OAAS,aAAAC,MAAiB,aAC1B,OAAS,+BAAAC,EAAuC,iBAAAC,MAAqB,WACrE,OAAS,kBAAAC,MAAsB,yBAC/B,OACE,gBAAAC,EACA,gBAAAC,EAEA,oBAAAC,EACA,wBAAAC,EACA,oBAAAC,EAGA,oBAAAC,EACA,YAAAC,MAEK,iBAEP,OAAS,oBAAAC,MAAwB,qBACjC,OAAS,OAAAC,MAAW,cACpB,OAAS,iCAAAC,MAAqC,wCAC9C,OAAuB,gBAAAC,MAAgC,SACvD,OAAS,yBAAAC,EAAuB,0BAAAC,MAA8B,oDAE9D,OAAS,mBAAAC,MAAuB,mBAIhC,OAAS,gBAAAC,EAAc,oBAAAC,MAAwB,YAUxC,SAASC,GAAgBC,EAAgC,CAC9D,OAAOA,GAAQ,MAA6B,OAAOA,EAAI,6BAAgC,UACzF,CAQO,MAAeC,EAAf,MAAeA,UAA+BR,CAAuD,CAkHhG,YAAYS,EAanB,CACD,MAAM,EAvDR,KAAS,cAA+BrB,EAAc,UAwDpD,KAAM,CACJ,QAAAsB,EACA,iBAAAC,EACA,UAAAC,EACA,OAAAC,EACA,OAAAC,EACA,IAAAC,EACA,OAAAC,EACA,MAAAC,EACA,mBAAAC,EACA,IAAAC,EACA,oBAAAC,CACF,EAAIX,EAUJ,GATA,KAAK,iBAAmBE,EACxB,KAAK,UAAYC,EACjB,KAAK,eAAiBF,EAAUrB,EAAe,KAAKqB,CAAO,EAAI,KAAK,UAAU,QAAQ,EAAE,eAAe,EACvG,KAAK,OAASG,EACd,KAAK,OAASC,EACd,KAAK,IAAMC,EACX,KAAK,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oBF,EAAK,KAAK,MAAM,KAAK,EACpC,KAAK,EAClC,OAAO,KAAK,KAAKC,CAAQ,CAC3B,CAEA,kBAAkBR,EAA4C,CAC5D,GAAI,KAAK,QAAU,OACjB,MAAMzB,EAAa,cAAc,CAC/B,KAAMC,EAAiB,gBACvB,QAAS,mGACX,CAAC,EAEH,MAAM+B,EAAMnC,EAAsB4B,CAAW,EAE7C,OADoB,IAAIS,EAAoBF,EAAK,KAAK,MAAM,KAAK,EAC9C,KAAK,CAC1B,CAaA,gBAAgB3B,EAKJ,CACV,OAAO,KAAK,UAAU,gBAAgBA,CAAI,CAC5C,CAEA,MAAM,qBAAqBA,EAKN,CACnB,OAAO,KAAK,UAAU,qBAAqB,CACzC,GAAGA,CACL,CAAC,CACH,CAUA,aAAa,SAASA,EAID,CACnB,OAAOb,EAASa,CAAI,CACtB,CACF,EAtbsBD,EACJ,cAAwB,GADnC,IAAe+B,EAAf/B,EA8bA,MAAM8B,UAA4BtC,CAAa,CAsBpD,YAAY6B,EAAwCZ,EAAiB,CACnE,MAAM,EAHR,KAAS,gBAAkB,6BAIzB,KAAK,YAAcY,EACnB,KAAK,MAAQZ,CACf,CAQA,UAAUQ,EAA8B,CACtCA,EAAW,oBAAoB,KAAK,YAAY,WAAW,CAAC,EAC5DA,EAAW,gBAAgB,KAAK,KAAK,CACvC,CASA,MAAmB,CACjB,OAAOvB,EAAuB,KAAK,WAAW,EAAG,KAAK,eAAe,CACvE,CACF","names":["EventEmitter","jwtDecode","EphemeralCertificateVariant","SigningScheme","AccountAddress","AnyPublicKey","AnySignature","KeylessSignature","EphemeralCertificate","ZeroKnowledgeSig","getKeylessConfig","fetchJWK","EphemeralKeyPair","Hex","AccountAuthenticatorSingleKey","Serializable","deriveTransactionType","generateSigningMessage","base64UrlDecode","KeylessError","KeylessErrorType","isKeylessSigner","obj","_AbstractKeylessAccount","args","address","ephemeralKeyPair","publicKey","uidKey","uidVal","aud","pepper","proof","proofFetchCallback","jwt","verificationKeyHash","status","pepperBytes","promise","error","serializer","deserializer","message","signature","transaction","aptosConfig","header","verificationKey","expiryDateSecs","ephemeralPublicKey","ephemeralSignature","raw","signMess","TransactionAndProof","AbstractKeylessAccount"]}
@@ -1,2 +1,2 @@
1
- import{pb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as AbstractedAccount};
1
+ import{sha3_256 as s}from"@noble/hashes/sha3";import{AbstractPublicKey as a,AbstractSignature as c}from"../core/crypto/abstraction";import{SigningScheme as u}from"../types";import{Account as A}from"./Account";import{generateSigningMessage as g,generateSigningMessageForTransaction as o}from"../transactions/transactionBuilder/signingMessage";import{AccountAbstractionMessage as d,AccountAuthenticatorAbstraction as p}from"../transactions/authenticator/account";import{Serializer as h}from"../bcs/serializer";import{isValidFunctionInfo as m}from"../utils/helpers";import{ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT as b}from"../utils/const";class r extends A{constructor({signer:t,accountAddress:n,authenticationFunction:i}){super();this.signingScheme=u.SingleKey;if(!m(i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=n,this.publicKey=new a(this.accountAddress),this.sign=e=>new c(t(e))}static fromPermissionedSigner({signer:t,accountAddress:n}){return new r({signer:i=>{const e=new h;return t.publicKey.serialize(e),t.sign(i).serialize(e),e.toUint8Array()},accountAddress:n??t.accountAddress,authenticationFunction:"0x1::permissioned_delegation::authenticate"})}static generateAccountAbstractionMessage(t,n){const i=new d(t,n);return g(i.bcsToBytes(),b)}signWithAuthenticator(t){return new p(this.authenticationFunction,s(t),this.sign(s(t)).toUint8Array())}signTransactionWithAuthenticator(t){const n=r.generateAccountAbstractionMessage(o(t),this.authenticationFunction);return this.signWithAuthenticator(n)}signTransaction(t){return this.sign(o(t))}setSigner(t){this.sign=n=>new c(t(n))}}export{r as AbstractedAccount};
2
2
  //# sourceMappingURL=AbstractedAccount.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/AbstractedAccount.ts"],"sourcesContent":["import { sha3_256 } from \"@noble/hashes/sha3\";\nimport { AccountAddress } from \"../core\";\nimport { AbstractPublicKey, AbstractSignature } from \"../core/crypto/abstraction\";\nimport { SigningScheme, HexInput } from \"../types\";\nimport { Account } from \"./Account\";\nimport { AnyRawTransaction } from \"../transactions/types\";\nimport {\n generateSigningMessage,\n generateSigningMessageForTransaction,\n} from \"../transactions/transactionBuilder/signingMessage\";\nimport { AccountAbstractionMessage, AccountAuthenticatorAbstraction } from \"../transactions/authenticator/account\";\nimport { Ed25519Account } from \"./Ed25519Account\";\nimport { Serializer } from \"../bcs/serializer\";\nimport { isValidFunctionInfo } from \"../utils/helpers\";\nimport { ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT } from \"../utils/const\";\n\ntype AbstractedAccountConstructorArgs = {\n /**\n * The account address of the account.\n */\n accountAddress: AccountAddress;\n /**\n * The signer function signs transactions and returns the `authenticator` bytes in the `AbstractionAuthData`.\n *\n * @param digest - The SHA256 hash of the transaction signing message\n * @returns The `authenticator` bytes that can be used to verify the signature.\n */\n signer: (digest: HexInput) => Uint8Array;\n /**\n * The authentication function that will be used to verify the signature.\n *\n * @example\n * ```ts\n * const authenticationFunction = `${accountAddress}::permissioned_delegation::authenticate`;\n * ```\n */\n authenticationFunction: string;\n};\n\nexport class AbstractedAccount extends Account {\n public readonly publicKey: AbstractPublicKey;\n\n readonly accountAddress: AccountAddress;\n\n readonly authenticationFunction: string;\n\n readonly signingScheme = SigningScheme.SingleKey;\n\n constructor({ signer, accountAddress, authenticationFunction }: AbstractedAccountConstructorArgs) {\n super();\n\n if (!isValidFunctionInfo(authenticationFunction)) {\n throw new Error(`Invalid authentication function ${authenticationFunction} passed into AbstractedAccount`);\n }\n\n this.authenticationFunction = authenticationFunction;\n this.accountAddress = accountAddress;\n this.publicKey = new AbstractPublicKey(this.accountAddress);\n this.sign = (digest: HexInput) => new AbstractSignature(signer(digest));\n }\n\n /**\n * Creates an `AbstractedAccount` from an `Ed25519Account` that has a permissioned signer function and\n * using the `0x1::permissioned_delegation::authenticate` function to verify the signature.\n *\n * @param signer - The `Ed25519Account` that can be used to sign permissioned transactions.\n * @returns The `AbstractedAccount`\n */\n public static fromPermissionedSigner({\n signer,\n accountAddress,\n }: {\n signer: Ed25519Account;\n accountAddress?: AccountAddress;\n }) {\n return new AbstractedAccount({\n signer: (digest: HexInput) => {\n const serializer = new Serializer();\n signer.publicKey.serialize(serializer);\n signer.sign(digest).serialize(serializer);\n return serializer.toUint8Array();\n },\n accountAddress: accountAddress ?? signer.accountAddress,\n authenticationFunction: \"0x1::permissioned_delegation::authenticate\",\n });\n }\n\n public static generateAccountAbstractionMessage(message: HexInput, functionInfo: string): HexInput {\n const accountAbstractionMessage = new AccountAbstractionMessage(message, functionInfo);\n return generateSigningMessage(accountAbstractionMessage.bcsToBytes(), ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT);\n }\n\n signWithAuthenticator(message: HexInput): AccountAuthenticatorAbstraction {\n return new AccountAuthenticatorAbstraction(\n this.authenticationFunction,\n sha3_256(message),\n this.sign(sha3_256(message)).toUint8Array(),\n );\n }\n\n signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorAbstraction {\n const message = AbstractedAccount.generateAccountAbstractionMessage(\n generateSigningMessageForTransaction(transaction),\n this.authenticationFunction,\n );\n return this.signWithAuthenticator(message);\n }\n\n sign: (message: HexInput) => AbstractSignature;\n\n signTransaction(transaction: AnyRawTransaction): AbstractSignature {\n return this.sign(generateSigningMessageForTransaction(transaction));\n }\n\n /**\n * Update the signer function for the account. This can be done after asynchronous operations are complete\n * to update the context of the signer function.\n *\n * @param signer - The new signer function to use for the account.\n */\n public setSigner(signer: (digest: HexInput) => HexInput): void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LR,EAASkB,CAAO,EAChB,KAAK,KAAKlB,EAASkB,CAAO,CAAC,EAAE,aAAa,CAC5C,CACF,CAEA,iCAAiCG,EAAiE,CAChG,MAAMH,EAAUN,EAAkB,kCAChCN,EAAqCe,CAAW,EAChD,KAAK,sBACP,EACA,OAAO,KAAK,sBAAsBH,CAAO,CAC3C,CAIA,gBAAgBG,EAAmD,CACjE,OAAO,KAAK,KAAKf,EAAqCe,CAAW,CAAC,CACpE,CAQO,UAAUR,EAA8C,CAC7D,KAAK,KAAQG,GAAqB,IAAId,EAAkBW,EAAOG,CAAM,CAAC,CACxE,CACF","names":["sha3_256","AbstractPublicKey","AbstractSignature","SigningScheme","Account","generateSigningMessage","generateSigningMessageForTransaction","AccountAbstractionMessage","AccountAuthenticatorAbstraction","Serializer","isValidFunctionInfo","ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT","AbstractedAccount","signer","accountAddress","authenticationFunction","digest","serializer","message","functionInfo","accountAbstractionMessage","transaction"]}
@@ -1,2 +1,2 @@
1
- import{eb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as Account};
1
+ import{SigningSchemeInput as a}from"../types";import{Ed25519PrivateKey as s}from"../core/crypto";import{Ed25519Account as c}from"./Ed25519Account";import{SingleKeyAccount as i}from"./SingleKeyAccount";class x{static generate(e={}){const{scheme:t=a.Ed25519,legacy:r=!0}=e;return t===a.Ed25519&&r?c.generate():i.generate({scheme:t})}static fromPrivateKey(e){const{privateKey:t,address:r,legacy:n=!0}=e;return t instanceof s&&n?new c({privateKey:t,address:r}):new i({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){const{scheme:t=a.Ed25519,mnemonic:r,path:n,legacy:o=!0}=e;return t===a.Ed25519&&o?c.fromDerivationPath({mnemonic:r,path:n}):i.fromDerivationPath({scheme:t,mnemonic:r,path:n})}static authKey(e){const{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}}export{x as Account};
2
2
  //# sourceMappingURL=Account.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/Account.ts"],"sourcesContent":["import type { AccountAuthenticator } from \"../transactions/authenticator/account\";\nimport { HexInput, SigningScheme, SigningSchemeInput } from \"../types\";\nimport type { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { AuthenticationKey } from \"../core/authenticationKey\";\nimport { AccountPublicKey, Ed25519PrivateKey, PrivateKeyInput, Signature, VerifySignatureArgs } from \"../core/crypto\";\nimport { Ed25519Account } from \"./Ed25519Account\";\nimport { SingleKeyAccount } from \"./SingleKeyAccount\";\nimport { AnyRawTransaction } from \"../transactions/types\";\nimport { AptosConfig } from \"../api\";\n\n/**\n * Arguments for creating an `Ed25519Account` from an `Ed25519PrivateKey`.\n * To use the SingleKey authentication scheme, set `legacy` to false.\n *\n * @param privateKey - The private key used to create the account.\n * @param address - Optional address for the account.\n * @param legacy - Indicates whether to use legacy authentication (default is true).\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface CreateEd25519AccountFromPrivateKeyArgs {\n privateKey: Ed25519PrivateKey;\n address?: AccountAddressInput;\n legacy?: true;\n}\n\n/**\n * Arguments for creating a `SingleKeyAccount` using an `Ed25519PrivateKey`.\n * The `legacy` property must be set to false to utilize the `SingleKey` authentication scheme.\n *\n * @param privateKey - The Ed25519 private key used for account creation.\n * @param address - Optional account address input.\n * @param legacy - Must be false to enable the `SingleKey` authentication scheme.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface CreateEd25519SingleKeyAccountFromPrivateKeyArgs {\n privateKey: Ed25519PrivateKey;\n address?: AccountAddressInput;\n legacy: false;\n}\n\n/**\n * Arguments for creating a `SingleKeyAccount` from a supported private key, excluding `Ed25519PrivateKey`.\n * The `legacy` argument is always false and cannot be set to true.\n *\n * @param privateKey - The private key used to create the account.\n * @param address - Optional address input for the account.\n * @param legacy - Always false; cannot be explicitly set to true.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface CreateSingleKeyAccountFromPrivateKeyArgs {\n privateKey: PrivateKeyInput;\n address?: AccountAddressInput;\n legacy?: false;\n}\n\n/**\n * Arguments for creating an `Account` from a private key when the key type is unknown at compile time.\n *\n * @param privateKey - The private key used to create the account.\n * @param address - Optional address for the account.\n * @param legacy - Optional flag indicating if the account is a legacy account.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface CreateAccountFromPrivateKeyArgs {\n privateKey: PrivateKeyInput;\n address?: AccountAddressInput;\n legacy?: boolean;\n}\n\n/**\n * Arguments for generating an Ed25519 account, specifying the signing scheme and legacy option.\n *\n * @param scheme - The signing scheme to use for the account.\n * @param legacy - Indicates if the account should be created in legacy mode.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface GenerateEd25519AccountArgs {\n scheme?: SigningSchemeInput.Ed25519;\n legacy?: true;\n}\n\n/**\n * Arguments for generating a `SingleKeyAccount` with an underlying `Ed25519PrivateKey`.\n * The `legacy` argument must be set to false to ensure an `Ed25519SingleKeyAccount` is returned.\n *\n * @param scheme - Optional signing scheme input for the account.\n * @param legacy - Indicates whether to use legacy account generation.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface GenerateEd25519SingleKeyAccountArgs {\n scheme?: SigningSchemeInput.Ed25519;\n legacy: false;\n}\n\n/**\n * Arguments for generating a `SingleKeyAccount` using a supported private key other than `Ed25519PrivateKey`.\n * The `legacy` argument is optional and defaults to false, and cannot be set to true.\n *\n * @param scheme - The signing scheme to use for the account.\n * @param legacy - Indicates whether to use legacy account generation (defaults to false).\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface GenerateSingleKeyAccountArgs {\n scheme: Exclude<SigningSchemeInput, SigningSchemeInput.Ed25519>;\n legacy?: false;\n}\n\n/**\n * Arguments for generating an opaque `Account` when the input signature scheme is unknown at compile time.\n *\n * @param scheme - The signing scheme to use for account generation.\n * @param legacy - Indicates whether to use legacy account generation methods.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface GenerateAccountArgs {\n scheme?: SigningSchemeInput;\n legacy?: boolean;\n}\n\n/**\n * Arguments for deriving a private key using a mnemonic phrase and a specified BIP44 path.\n *\n * @param path - The BIP44 derivation path for the key.\n * @param mnemonic - The mnemonic phrase used for key generation.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface PrivateKeyFromDerivationPathArgs {\n path: string;\n mnemonic: string;\n}\n\n/**\n * Abstract class representing a generic Aptos account.\n *\n * This class serves as a single entry point for account generation, allowing accounts to be created\n * either through `Account.generate()` or `Account.fromDerivationPath`. Although it is defined as an\n * abstract class, it should be treated as an interface and enforced using the `implements` keyword.\n *\n * Note: Generating an account instance does not create the account on-chain.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport abstract class Account {\n /**\n * Public key associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n abstract readonly publicKey: AccountPublicKey;\n\n /**\n * Account address associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n abstract readonly accountAddress: AccountAddress;\n\n /**\n * Signing scheme used to sign transactions\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n abstract signingScheme: SigningScheme;\n\n /**\n * Generates a new account based on the specified signing scheme and legacy option.\n * This function allows you to create an account with either the Ed25519 signing scheme or a different scheme as specified.\n *\n * @param args - The arguments for generating the account.\n * @param args.scheme - The signing scheme to use for account generation. Defaults to Ed25519.\n * @param args.legacy - Indicates whether to use the legacy account generation method. Defaults to true.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static generate(args?: GenerateEd25519AccountArgs): Ed25519Account;\n static generate(args: GenerateEd25519SingleKeyAccountArgs): SingleKeyAccount;\n static generate(args: GenerateSingleKeyAccountArgs): SingleKeyAccount;\n static generate(args: GenerateAccountArgs): Account;\n static generate(args: GenerateAccountArgs = {}) {\n const { scheme = SigningSchemeInput.Ed25519, legacy = true } = args;\n if (scheme === SigningSchemeInput.Ed25519 && legacy) {\n return Ed25519Account.generate();\n }\n return SingleKeyAccount.generate({ scheme });\n }\n\n /**\n * Creates an account from a given private key and address.\n * This function allows you to instantiate an account based on the provided private key,\n * and it can differentiate between legacy and non-legacy accounts.\n *\n * @param args - The arguments for creating the account.\n * @param args.privateKey - The private key used to create the account.\n * @param args.address - The address associated with the account.\n * @param args.legacy - A boolean indicating whether to create a legacy account (default is true).\n * @returns An instance of either Ed25519Account or SingleKeyAccount based on the provided private key.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static fromPrivateKey(args: CreateEd25519AccountFromPrivateKeyArgs): Ed25519Account;\n static fromPrivateKey(args: CreateSingleKeyAccountFromPrivateKeyArgs): SingleKeyAccount;\n static fromPrivateKey(args: CreateAccountFromPrivateKeyArgs): SingleKeyAccount;\n static fromPrivateKey(args: CreateAccountFromPrivateKeyArgs): Ed25519Account | SingleKeyAccount {\n const { privateKey, address, legacy = true } = args;\n if (privateKey instanceof Ed25519PrivateKey && legacy) {\n return new Ed25519Account({\n privateKey,\n address,\n });\n }\n return new SingleKeyAccount({ privateKey, address });\n }\n\n /**\n * @deprecated use `fromPrivateKey` instead.\n * Instantiates an account using a private key and a specified account address. This is primarily used to instantiate an\n * `Account` that has had its authentication key rotated.\n *\n * @param args - The arguments required to create an account from a private key.\n * @param args.privateKey - The underlying private key for the account.\n * @param args.address - The account address the `Account` will sign for.\n * @param args.legacy - Optional. If set to false, the keypair generated is a Unified keypair. Defaults to generating a Legacy\n * Ed25519 keypair.\n *\n * @returns Account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static fromPrivateKeyAndAddress(args: CreateAccountFromPrivateKeyArgs) {\n return this.fromPrivateKey(args);\n }\n\n /**\n * Generates an account from a specified derivation path and mnemonic.\n * This function allows you to create an account using different signing schemes based on the provided arguments.\n *\n * @param args - The arguments for generating the account.\n * @param args.scheme - The signing scheme to use for account generation. Defaults to Ed25519.\n * @param args.mnemonic - The mnemonic phrase used to derive the account.\n * @param args.path - The derivation path used to generate the account.\n * @param args.legacy - A boolean indicating whether to use the legacy account generation method. Defaults to true.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static fromDerivationPath(args: GenerateEd25519AccountArgs & PrivateKeyFromDerivationPathArgs): Ed25519Account;\n static fromDerivationPath(\n args: GenerateEd25519SingleKeyAccountArgs & PrivateKeyFromDerivationPathArgs,\n ): SingleKeyAccount;\n static fromDerivationPath(args: GenerateSingleKeyAccountArgs & PrivateKeyFromDerivationPathArgs): SingleKeyAccount;\n static fromDerivationPath(args: GenerateAccountArgs & PrivateKeyFromDerivationPathArgs): Account;\n static fromDerivationPath(args: GenerateAccountArgs & PrivateKeyFromDerivationPathArgs) {\n const { scheme = SigningSchemeInput.Ed25519, mnemonic, path, legacy = true } = args;\n if (scheme === SigningSchemeInput.Ed25519 && legacy) {\n return Ed25519Account.fromDerivationPath({ mnemonic, path });\n }\n return SingleKeyAccount.fromDerivationPath({ scheme, mnemonic, path });\n }\n\n /**\n * Retrieve the authentication key for the associated account using the provided public key.\n * This key enables account owners to rotate their private key(s) associated with the account without changing the address that\n * hosts their account.\n * See here for more info: {@link https://aptos.dev/concepts/accounts#single-signer-authentication}\n *\n * @param args - The arguments for retrieving the authentication key.\n * @param args.publicKey - The public key of the account.\n * @returns The authentication key for the associated account.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static authKey(args: { publicKey: AccountPublicKey }): AuthenticationKey {\n const { publicKey } = args;\n return publicKey.authKey();\n }\n\n /**\n * Sign a message using the available signing capabilities.\n * @param message the signing message, as binary input\n * @return the AccountAuthenticator containing the signature, together with the account's public key\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n abstract signWithAuthenticator(message: HexInput): AccountAuthenticator;\n\n /**\n * Sign a transaction using the available signing capabilities.\n * @param transaction the raw transaction\n * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n abstract signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticator;\n\n /**\n * Sign the given message using the available signing capabilities.\n * @param message in HexInput format\n * @returns Signature\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n abstract sign(message: HexInput): Signature;\n\n /**\n * Sign the given transaction using the available signing capabilities.\n * @param transaction the transaction to be signed\n * @returns Signature\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n abstract signTransaction(transaction: AnyRawTransaction): Signature;\n\n /**\n * Verify the given message and signature with the public key.\n * This function helps ensure the integrity and authenticity of a message by validating its signature.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The raw message data in HexInput format.\n * @param args.signature - The signed message signature.\n * @returns A boolean indicating whether the signature is valid.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n verifySignature(args: VerifySignatureArgs): boolean {\n return this.publicKey.verifySignature(args);\n }\n\n /**\n * Verify the given message and signature with the public key. It fetches any on chain state if needed for verification.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network\n * @param args.message - Raw message data in HexInput format.\n * @param args.signature - Signed message signature.\n * @returns A boolean indicating whether the signature is valid.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: Signature;\n }): Promise<boolean> {\n return this.publicKey.verifySignatureAsync(args);\n }\n}\n"],"mappings":"AACA,OAAkC,sBAAAA,MAA0B,WAG5D,OAA2B,qBAAAC,MAA0E,iBACrG,OAAS,kBAAAC,MAAsB,mBAC/B,OAAS,oBAAAC,MAAwB,qBAiJ1B,MAAeC,CAAQ,CAoC5B,OAAO,SAASC,EAA4B,CAAC,EAAG,CAC9C,KAAM,CAAE,OAAAC,EAASN,EAAmB,QAAS,OAAAO,EAAS,EAAK,EAAIF,EAC/D,OAAIC,IAAWN,EAAmB,SAAWO,EACpCL,EAAe,SAAS,EAE1BC,EAAiB,SAAS,CAAE,OAAAG,CAAO,CAAC,CAC7C,CAkBA,OAAO,eAAeD,EAA0E,CAC9F,KAAM,CAAE,WAAAG,EAAY,QAAAC,EAAS,OAAAF,EAAS,EAAK,EAAIF,EAC/C,OAAIG,aAAsBP,GAAqBM,EACtC,IAAIL,EAAe,CACxB,WAAAM,EACA,QAAAC,CACF,CAAC,EAEI,IAAIN,EAAiB,CAAE,WAAAK,EAAY,QAAAC,CAAQ,CAAC,CACrD,CAiBA,OAAO,yBAAyBJ,EAAuC,CACrE,OAAO,KAAK,eAAeA,CAAI,CACjC,CAoBA,OAAO,mBAAmBA,EAA8D,CACtF,KAAM,CAAE,OAAAC,EAASN,EAAmB,QAAS,SAAAU,EAAU,KAAAC,EAAM,OAAAJ,EAAS,EAAK,EAAIF,EAC/E,OAAIC,IAAWN,EAAmB,SAAWO,EACpCL,EAAe,mBAAmB,CAAE,SAAAQ,EAAU,KAAAC,CAAK,CAAC,EAEtDR,EAAiB,mBAAmB,CAAE,OAAAG,EAAQ,SAAAI,EAAU,KAAAC,CAAK,CAAC,CACvE,CAcA,OAAO,QAAQN,EAA0D,CACvE,KAAM,CAAE,UAAAO,CAAU,EAAIP,EACtB,OAAOO,EAAU,QAAQ,CAC3B,CAiDA,gBAAgBP,EAAoC,CAClD,OAAO,KAAK,UAAU,gBAAgBA,CAAI,CAC5C,CAaA,MAAM,qBAAqBA,EAIN,CACnB,OAAO,KAAK,UAAU,qBAAqBA,CAAI,CACjD,CACF","names":["SigningSchemeInput","Ed25519PrivateKey","Ed25519Account","SingleKeyAccount","Account","args","scheme","legacy","privateKey","address","mnemonic","path","publicKey"]}
@@ -1,2 +1,2 @@
1
- import{ob as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as AccountUtils};
1
+ import{Deserializer as k,Serializer as I}from"../bcs";import{AnyPublicKeyVariant as c,SigningScheme as u}from"../types";import{MultiKeyAccount as S}from"./MultiKeyAccount";import{Ed25519Account as A}from"./Ed25519Account";import{isSingleKeySigner as h,SingleKeyAccount as p}from"./SingleKeyAccount";import{KeylessAccount as x}from"./KeylessAccount";import{FederatedKeylessAccount as z}from"./FederatedKeylessAccount";import{AccountAddress as P,Ed25519PrivateKey as E,getIssAudAndUidVal as v,Hex as H,MultiKey as D,Secp256k1PrivateKey as B,ZeroKnowledgeSig as M}from"../core";import{deserializeSchemeAndAddress as j}from"./utils";import{EphemeralKeyPair as C}from"./EphemeralKeyPair";function U(n,s){if(s.serializeStr(n.jwt),s.serializeStr(n.uidKey),s.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(s),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(s),s.serializeOption(n.verificationKeyHash,32)}function b(n){const s=n.deserializeStr(),K=n.deserializeStr(),d=n.deserializeFixedBytes(31),m=C.deserialize(n),g=M.deserialize(n),w=n.deserializeOption("fixedBytes",32);return{jwt:s,uidKey:K,pepper:d,ephemeralKeyPair:m,proof:g,verificationKeyHash:w}}var F;(T=>{function n(e){const t=new I;switch(t.serializeU32AsUleb128(e.signingScheme),e.accountAddress.serialize(t),e.signingScheme){case u.Ed25519:return e.privateKey.serialize(t),t.toUint8Array();case u.SingleKey:{if(!h(e))throw new Error("Account is not a SingleKeySigner");const o=e.getAnyPublicKey();switch(t.serializeU32AsUleb128(o.variant),o.variant){case c.Keyless:return U(e,t),t.toUint8Array();case c.FederatedKeyless:{const r=e;return U(r,t),r.publicKey.jwkAddress.serialize(t),t.serializeBool(r.audless),t.toUint8Array()}case c.Secp256k1:case c.Ed25519:return e.privateKey.serialize(t),t.toUint8Array();default:throw new Error(`Invalid public key variant: ${o.variant}`)}}case u.MultiKey:{const o=e;return o.publicKey.serialize(t),t.serializeU32AsUleb128(o.signers.length),o.signers.forEach(r=>{t.serializeFixedBytes(n(r))}),t.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${e.signingScheme}`)}}T.toBytes=n;function s(e){return H.hexInputToStringWithoutPrefix(n(e))}T.toHexStringWithoutPrefix=s;function K(e){return H.hexInputToString(n(e))}T.toHexString=K;function d(e){const{address:t,signingScheme:o}=j(e);switch(o){case u.Ed25519:{const r=E.deserialize(e);return new A({privateKey:r,address:t})}case u.SingleKey:{const r=e.deserializeUleb128AsU32();switch(r){case c.Ed25519:{const i=E.deserialize(e);return new p({privateKey:i,address:t})}case c.Secp256k1:{const i=B.deserialize(e);return new p({privateKey:i,address:t})}case c.Keyless:{const i=b(e),l=v(i);return new x({...i,...l})}case c.FederatedKeyless:{const i=b(e),l=P.deserialize(e),f=e.deserializeBool(),y=v(i);return new z({...i,...y,jwkAddress:l,audless:f})}default:throw new Error(`Unsupported public key variant ${r}`)}}case u.MultiKey:{const r=D.deserialize(e),i=e.deserializeUleb128AsU32(),l=new Array;for(let f=0;f<i;f+=1){const y=d(e);if(!h(y)&&!(y instanceof A))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");l.push(y)}return new S({multiKey:r,signers:l,address:t})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${o}`)}}T.deserialize=d;function m(e){const t=a(e);if(!(t instanceof x))throw new Error("Deserialization of KeylessAccount failed");return t}T.keylessAccountFromHex=m;function g(e){const t=a(e);if(!(t instanceof z))throw new Error("Deserialization of FederatedKeylessAccount failed");return t}T.federatedKeylessAccountFromHex=g;function w(e){const t=a(e);if(!(t instanceof S))throw new Error("Deserialization of MultiKeyAccount failed");return t}T.multiKeyAccountFromHex=w;function O(e){const t=a(e);if(!(t instanceof p))throw new Error("Deserialization of SingleKeyAccount failed");return t}T.singleKeyAccountFromHex=O;function $(e){const t=a(e);if(!(t instanceof A))throw new Error("Deserialization of Ed25519Account failed");return t}T.ed25519AccountFromHex=$;function a(e){return d(k.fromHex(e))}T.fromHex=a;function L(e){return a(e)}T.fromBytes=L})(F||(F={}));export{F as AccountUtils};
2
2
  //# sourceMappingURL=AccountUtils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/AccountUtils.ts"],"sourcesContent":["import { Deserializer, Serializer } from \"../bcs\";\nimport { AnyPublicKeyVariant, HexInput, SigningScheme } from \"../types\";\nimport { MultiKeyAccount } from \"./MultiKeyAccount\";\nimport { Account } from \"./Account\";\nimport { Ed25519Account } from \"./Ed25519Account\";\nimport { isSingleKeySigner, SingleKeyAccount, SingleKeySignerOrLegacyEd25519Account } from \"./SingleKeyAccount\";\nimport { KeylessAccount } from \"./KeylessAccount\";\nimport { FederatedKeylessAccount } from \"./FederatedKeylessAccount\";\nimport { AbstractKeylessAccount } from \"./AbstractKeylessAccount\";\nimport {\n AccountAddress,\n Ed25519PrivateKey,\n getIssAudAndUidVal,\n Hex,\n MultiKey,\n Secp256k1PrivateKey,\n ZeroKnowledgeSig,\n} from \"../core\";\nimport { deserializeSchemeAndAddress } from \"./utils\";\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\n\nfunction serializeKeylessAccountCommon(account: AbstractKeylessAccount, serializer: Serializer): void {\n serializer.serializeStr(account.jwt);\n serializer.serializeStr(account.uidKey);\n serializer.serializeFixedBytes(account.pepper);\n account.ephemeralKeyPair.serialize(serializer);\n if (account.proof === undefined) {\n throw new Error(\"Cannot serialize - proof undefined\");\n }\n account.proof.serialize(serializer);\n serializer.serializeOption(account.verificationKeyHash, 32);\n}\n\nfunction deserializeKeylessAccountCommon(deserializer: Deserializer): {\n jwt: string;\n uidKey: string;\n pepper: Uint8Array;\n ephemeralKeyPair: EphemeralKeyPair;\n proof: ZeroKnowledgeSig;\n verificationKeyHash?: Uint8Array;\n} {\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = ZeroKnowledgeSig.deserialize(deserializer);\n const verificationKeyHash = deserializer.deserializeOption(\"fixedBytes\", 32);\n return { jwt, uidKey, pepper, ephemeralKeyPair, proof, verificationKeyHash };\n}\n\n/**\n * Utility functions for working with accounts.\n */\nexport namespace AccountUtils {\n export function toBytes(account: Account): Uint8Array {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(account.signingScheme);\n account.accountAddress.serialize(serializer);\n switch (account.signingScheme) {\n case SigningScheme.Ed25519:\n (account as Ed25519Account).privateKey.serialize(serializer);\n return serializer.toUint8Array();\n case SigningScheme.SingleKey: {\n if (!isSingleKeySigner(account)) {\n throw new Error(\"Account is not a SingleKeySigner\");\n }\n const anyPublicKey = account.getAnyPublicKey();\n serializer.serializeU32AsUleb128(anyPublicKey.variant);\n switch (anyPublicKey.variant) {\n case AnyPublicKeyVariant.Keyless: {\n const keylessAccount = account as KeylessAccount;\n serializeKeylessAccountCommon(keylessAccount, serializer);\n return serializer.toUint8Array();\n }\n case AnyPublicKeyVariant.FederatedKeyless: {\n const federatedKeylessAccount = account as FederatedKeylessAccount;\n serializeKeylessAccountCommon(federatedKeylessAccount, serializer);\n federatedKeylessAccount.publicKey.jwkAddress.serialize(serializer);\n serializer.serializeBool(federatedKeylessAccount.audless);\n return serializer.toUint8Array();\n }\n case AnyPublicKeyVariant.Secp256k1:\n case AnyPublicKeyVariant.Ed25519: {\n const singleKeyAccount = account as SingleKeyAccount;\n singleKeyAccount.privateKey.serialize(serializer);\n return serializer.toUint8Array();\n }\n default: {\n throw new Error(`Invalid public key variant: ${anyPublicKey.variant}`);\n }\n }\n }\n case SigningScheme.MultiKey: {\n const multiKeyAccount = account as MultiKeyAccount;\n multiKeyAccount.publicKey.serialize(serializer);\n serializer.serializeU32AsUleb128(multiKeyAccount.signers.length);\n multiKeyAccount.signers.forEach((signer) => {\n serializer.serializeFixedBytes(toBytes(signer));\n });\n return serializer.toUint8Array();\n }\n default:\n throw new Error(`Deserialization of Account failed: invalid signingScheme value ${account.signingScheme}`);\n }\n }\n\n export function toHexStringWithoutPrefix(account: Account): string {\n return Hex.hexInputToStringWithoutPrefix(toBytes(account));\n }\n\n export function toHexString(account: Account): string {\n return Hex.hexInputToString(toBytes(account));\n }\n\n export function deserialize(deserializer: Deserializer): Account {\n const { address, signingScheme } = deserializeSchemeAndAddress(deserializer);\n switch (signingScheme) {\n case SigningScheme.Ed25519: {\n const privateKey = Ed25519PrivateKey.deserialize(deserializer);\n return new Ed25519Account({ privateKey, address });\n }\n case SigningScheme.SingleKey: {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n switch (variantIndex) {\n case AnyPublicKeyVariant.Ed25519: {\n const privateKey = Ed25519PrivateKey.deserialize(deserializer);\n return new SingleKeyAccount({ privateKey, address });\n }\n case AnyPublicKeyVariant.Secp256k1: {\n const privateKey = Secp256k1PrivateKey.deserialize(deserializer);\n return new SingleKeyAccount({ privateKey, address });\n }\n case AnyPublicKeyVariant.Keyless: {\n const keylessComponents = deserializeKeylessAccountCommon(deserializer);\n const jwtClaims = getIssAudAndUidVal(keylessComponents);\n return new KeylessAccount({ ...keylessComponents, ...jwtClaims });\n }\n case AnyPublicKeyVariant.FederatedKeyless: {\n const keylessComponents = deserializeKeylessAccountCommon(deserializer);\n const jwkAddress = AccountAddress.deserialize(deserializer);\n const audless = deserializer.deserializeBool();\n const jwtClaims = getIssAudAndUidVal(keylessComponents);\n return new FederatedKeylessAccount({ ...keylessComponents, ...jwtClaims, jwkAddress, audless });\n }\n default:\n throw new Error(`Unsupported public key variant ${variantIndex}`);\n }\n }\n case SigningScheme.MultiKey: {\n const multiKey = MultiKey.deserialize(deserializer);\n const length = deserializer.deserializeUleb128AsU32();\n const signers = new Array<SingleKeySignerOrLegacyEd25519Account>();\n for (let i = 0; i < length; i += 1) {\n const signer = deserialize(deserializer);\n if (!isSingleKeySigner(signer) && !(signer instanceof Ed25519Account)) {\n throw new Error(\n \"Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account\",\n );\n }\n signers.push(signer);\n }\n return new MultiKeyAccount({ multiKey, signers, address });\n }\n default:\n throw new Error(`Deserialization of Account failed: invalid signingScheme value ${signingScheme}`);\n }\n }\n\n export function keylessAccountFromHex(hex: HexInput): KeylessAccount {\n const account = fromHex(hex);\n if (!(account instanceof KeylessAccount)) {\n throw new Error(\"Deserialization of KeylessAccount failed\");\n }\n return account;\n }\n\n export function federatedKeylessAccountFromHex(hex: HexInput): FederatedKeylessAccount {\n const account = fromHex(hex);\n if (!(account instanceof FederatedKeylessAccount)) {\n throw new Error(\"Deserialization of FederatedKeylessAccount failed\");\n }\n return account;\n }\n\n export function multiKeyAccountFromHex(hex: HexInput): MultiKeyAccount {\n const account = fromHex(hex);\n if (!(account instanceof MultiKeyAccount)) {\n throw new Error(\"Deserialization of MultiKeyAccount failed\");\n }\n return account;\n }\n\n export function singleKeyAccountFromHex(hex: HexInput): SingleKeyAccount {\n const account = fromHex(hex);\n if (!(account instanceof SingleKeyAccount)) {\n throw new Error(\"Deserialization of SingleKeyAccount failed\");\n }\n return account;\n }\n\n export function ed25519AccountFromHex(hex: HexInput): Ed25519Account {\n const account = fromHex(hex);\n if (!(account instanceof Ed25519Account)) {\n throw new Error(\"Deserialization of Ed25519Account failed\");\n }\n return account;\n }\n\n export function fromHex(hex: HexInput): Account {\n return deserialize(Deserializer.fromHex(hex));\n }\n\n export function fromBytes(bytes: Uint8Array): Account {\n return fromHex(bytes);\n }\n}\n"],"mappings":"AAAA,OAAS,gBAAAA,EAAc,cAAAC,MAAkB,SACzC,OAAS,uBAAAC,EAA+B,iBAAAC,MAAqB,WAC7D,OAAS,mBAAAC,MAAuB,oBAEhC,OAAS,kBAAAC,MAAsB,mBAC/B,OAAS,qBAAAC,EAAmB,oBAAAC,MAA+D,qBA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AAUC,EAA4B,CACpD,OAAON,EAAQM,CAAK,CACtB,CAFO7B,EAAS,UAAA4B,IA/JD5B,MAAA","names":["Deserializer","Serializer","AnyPublicKeyVariant","SigningScheme","MultiKeyAccount","Ed25519Account","isSingleKeySigner","SingleKeyAccount","KeylessAccount","FederatedKeylessAccount","AccountAddress","Ed25519PrivateKey","getIssAudAndUidVal","Hex","MultiKey","Secp256k1PrivateKey","ZeroKnowledgeSig","deserializeSchemeAndAddress","EphemeralKeyPair","serializeKeylessAccountCommon","account","serializer","deserializeKeylessAccountCommon","deserializer","jwt","uidKey","pepper","ephemeralKeyPair","proof","verificationKeyHash","AccountUtils","toBytes","anyPublicKey","federatedKeylessAccount","multiKeyAccount","signer","toHexStringWithoutPrefix","toHexString","deserialize","address","signingScheme","privateKey","variantIndex","keylessComponents","jwtClaims","jwkAddress","audless","multiKey","length","signers","i","keylessAccountFromHex","hex","fromHex","federatedKeylessAccountFromHex","multiKeyAccountFromHex","singleKeyAccountFromHex","ed25519AccountFromHex","fromBytes","bytes"]}
@@ -1,2 +1,2 @@
1
- import{qb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as DerivableAbstractedAccount};
1
+ import{sha3_256 as a}from"@noble/hashes/sha3";import{Serializer as A}from"../bcs/serializer";import{AccountAddress as u}from"../core/accountAddress";import{AccountAuthenticatorAbstraction as p}from"../transactions/authenticator/account";import{isValidFunctionInfo as l}from"../utils/helpers";import{AbstractedAccount as y}from"./AbstractedAccount";const r=class r extends y{constructor({signer:t,authenticationFunction:e,abstractPublicKey:i}){const o=new u(r.computeAccountAddress(e,i));super({accountAddress:o,signer:t,authenticationFunction:e}),this.abstractPublicKey=i}static computeAccountAddress(t,e){if(!l(t))throw new Error(`Invalid authentication function ${t} passed into DerivableAbstractedAccount`);const[i,o,m]=t.split("::"),n=a.create(),s=new A;u.fromString(i).serialize(s),s.serializeStr(o),s.serializeStr(m),n.update(s.toUint8Array());const c=new A;return c.serializeBytes(e),n.update(c.toUint8Array()),n.update(new Uint8Array([r.ADDRESS_DOMAIN_SEPERATOR])),n.digest()}signWithAuthenticator(t){return new p(this.authenticationFunction,a(t),this.sign(a(t)).value,this.abstractPublicKey)}};r.ADDRESS_DOMAIN_SEPERATOR=5;let d=r;export{d as DerivableAbstractedAccount};
2
2
  //# sourceMappingURL=DerivableAbstractedAccount.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/DerivableAbstractedAccount.ts"],"sourcesContent":["import { sha3_256 } from \"@noble/hashes/sha3\";\nimport { Serializer } from \"../bcs/serializer\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport { AccountAbstractionMessage, AccountAuthenticatorAbstraction } from \"../transactions/authenticator/account\";\nimport { HexInput } from \"../types\";\nimport { isValidFunctionInfo } from \"../utils/helpers\";\nimport { AbstractedAccount } from \"./AbstractedAccount\";\nimport { generateSigningMessage } from \"../transactions/transactionBuilder/signingMessage\";\nimport { ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT } from \"../utils/const\";\n\ntype DerivableAbstractedAccountArgs = {\n /**\n * The signer function signs transactions and returns the `authenticator` bytes in the `AbstractionAuthData`.\n *\n * @param digest - The SHA256 hash of the transaction signing message\n * @returns The `authenticator` bytes that can be used to verify the signature.\n */\n signer: (digest: HexInput) => Uint8Array;\n\n /**\n * The authentication function that will be used to verify the signature.\n *\n * @example\n * ```ts\n * const authenticationFunction = `${accountAddress}::permissioned_delegation::authenticate`;\n * ```\n */\n authenticationFunction: string;\n\n /**\n * The abstract public key that is used to identify the account.\n * Depends on the use cases, most of the time it is the public key of the source wallet\n */\n abstractPublicKey: Uint8Array;\n};\n\nexport class DerivableAbstractedAccount extends AbstractedAccount {\n /**\n * The abstract public key that is used to identify the account.\n * Depends on the use cases, most of the time it is the public key of the source wallet\n */\n readonly abstractPublicKey: Uint8Array;\n\n /**\n * The domain separator used to calculate the DAA account address.\n */\n static readonly ADDRESS_DOMAIN_SEPERATOR: number = 5;\n\n constructor({ signer, authenticationFunction, abstractPublicKey }: DerivableAbstractedAccountArgs) {\n const daaAccountAddress = new AccountAddress(\n DerivableAbstractedAccount.computeAccountAddress(authenticationFunction, abstractPublicKey),\n );\n super({\n accountAddress: daaAccountAddress,\n signer,\n authenticationFunction,\n });\n this.abstractPublicKey = abstractPublicKey;\n }\n\n /**\n * Compute the account address of the DAA\n * The DAA account address is computed by hashing the function info and the account identity\n * and appending the domain separator (5)\n *\n * @param functionInfo - The authentication function\n * @param accountIdentifier - The account identity\n * @returns The account address\n */\n static computeAccountAddress(functionInfo: string, accountIdentifier: Uint8Array): Uint8Array {\n if (!isValidFunctionInfo(functionInfo)) {\n throw new Error(`Invalid authentication function ${functionInfo} passed into DerivableAbstractedAccount`);\n }\n const [moduleAddress, moduleName, functionName] = functionInfo.split(\"::\");\n\n const hash = sha3_256.create();\n // Serialize and append the function info\n const serializer = new Serializer();\n AccountAddress.fromString(moduleAddress).serialize(serializer);\n serializer.serializeStr(moduleName);\n serializer.serializeStr(functionName);\n hash.update(serializer.toUint8Array());\n\n // Serialize and append the account identity\n const s2 = new Serializer();\n s2.serializeBytes(accountIdentifier);\n hash.update(s2.toUint8Array());\n\n // Append the domain separator\n hash.update(new Uint8Array([DerivableAbstractedAccount.ADDRESS_DOMAIN_SEPERATOR]));\n\n return hash.digest();\n }\n\n signWithAuthenticator(message: HexInput): AccountAuthenticatorAbstraction {\n return new AccountAuthenticatorAbstraction(\n this.authenticationFunction,\n sha3_256(message),\n this.sign(sha3_256(message)).value,\n this.abstractPublicKey,\n );\n }\n}\n"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,cAAAC,MAAkB,oBAC3B,OAAS,kBAAAC,MAAsB,yBAC/B,OAAoC,mCAAAC,MAAuC,wCAE3E,OAAS,uBAAAC,MAA2B,mBACpC,OAAS,qBAAAC,MAAyB,sBA8B3B,MAAMC,EAAN,MAAMA,UAAmCD,CAAkB,CAYhE,YAAY,CAAE,OAAAE,EAAQ,uBAAAC,EAAwB,kBAAAC,CAAkB,EAAmC,CACjG,MAAMC,EAAoB,IAAIR,EAC5BI,EAA2B,sBAAsBE,EAAwBC,CAAiB,CAC5F,EACA,MAAM,CACJ,eAAgBC,EAChB,OAAAH,EACA,uBAAAC,CACF,CAAC,EACD,KAAK,kBAAoBC,CAC3B,CAWA,OAAO,sBAAsBE,EAAsBC,EAA2C,CAC5F,GAAI,CAACR,EAAoBO,CAAY,EACnC,MAAM,IAAI,MAAM,mCAAmCA,CAAY,yCAAyC,EAE1G,KAAM,CAACE,EAAeC,EAAYC,CAAY,EAAIJ,EAAa,MAAM,IAAI,EAEnEK,EAAOhB,EAAS,OAAO,EAEvBiB,EAAa,IAAIhB,EACvBC,EAAe,WAAWW,CAAa,EAAE,UAAUI,CAAU,EAC7DA,EAAW,aAAaH,CAAU,EAClCG,EAAW,aAAaF,CAAY,EACpCC,EAAK,OAAOC,EAAW,aAAa,CAAC,EAGrC,MAAMC,EAAK,IAAIjB,EACf,OAAAiB,EAAG,eAAeN,CAAiB,EACnCI,EAAK,OAAOE,EAAG,aAAa,CAAC,EAG7BF,EAAK,OAAO,IAAI,WAAW,CAACV,EAA2B,wBAAwB,CAAC,CAAC,EAE1EU,EAAK,OAAO,CACrB,CAEA,sBAAsBG,EAAoD,CACxE,OAAO,IAAIhB,EACT,KAAK,uBACLH,EAASmB,CAAO,EAChB,KAAK,KAAKnB,EAASmB,CAAO,CAAC,EAAE,MAC7B,KAAK,iBACP,CACF,CACF,EAlEab,EAUK,yBAAmC,EAV9C,IAAMc,EAANd","names":["sha3_256","Serializer","AccountAddress","AccountAuthenticatorAbstraction","isValidFunctionInfo","AbstractedAccount","_DerivableAbstractedAccount","signer","authenticationFunction","abstractPublicKey","daaAccountAddress","functionInfo","accountIdentifier","moduleAddress","moduleName","functionName","hash","serializer","s2","message","DerivableAbstractedAccount"]}
@@ -1,2 +1,2 @@
1
- import{bb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as Ed25519Account};
1
+ import{AccountAuthenticatorEd25519 as i}from"../transactions/authenticator/account";import{SigningScheme as o}from"../types";import{AccountAddress as c}from"../core/accountAddress";import{Ed25519PrivateKey as a}from"../core/crypto";import{generateSigningMessageForTransaction as u}from"../transactions/transactionBuilder/signingMessage";class n{constructor(t){this.signingScheme=o.Ed25519;const{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=e.publicKey(),this.accountAddress=r?c.from(r):this.publicKey.authKey().derivedAddress()}static generate(){const t=a.generate();return new n({privateKey:t})}static fromDerivationPath(t){const{path:e,mnemonic:r}=t,s=a.fromDerivationPath(e,r);return new n({privateKey:s})}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t,signature:t.signature})}signWithAuthenticator(t){return new i(this.publicKey,this.privateKey.sign(t))}signTransactionWithAuthenticator(t){return new i(this.publicKey,this.signTransaction(t))}sign(t){return this.privateKey.sign(t)}signTransaction(t){return this.sign(u(t))}}export{n as Ed25519Account};
2
2
  //# sourceMappingURL=Ed25519Account.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/Ed25519Account.ts"],"sourcesContent":["import { AccountAuthenticatorEd25519 } from \"../transactions/authenticator/account\";\nimport { HexInput, SigningScheme } from \"../types\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { Ed25519PrivateKey, Ed25519PublicKey, Ed25519Signature, Signature } from \"../core/crypto\";\nimport type { Account } from \"./Account\";\nimport { AnyRawTransaction } from \"../transactions/types\";\nimport { generateSigningMessageForTransaction } from \"../transactions/transactionBuilder/signingMessage\";\nimport { AptosConfig } from \"../api\";\n\n/**\n * Arguments required to create an instance of an Ed25519 signer.\n *\n * @param privateKey - The private key used for signing.\n * @param address - Optional account address associated with the signer.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface Ed25519SignerConstructorArgs {\n privateKey: Ed25519PrivateKey;\n address?: AccountAddressInput;\n}\n\n/**\n * Arguments for creating an Ed25519 signer from a derivation path.\n *\n * @param path - The derivation path for the Ed25519 key.\n * @param mnemonic - The mnemonic phrase used to generate the key.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface Ed25519SignerFromDerivationPathArgs {\n path: string;\n mnemonic: string;\n}\n\n/**\n * Arguments required to verify an Ed25519 signature against a given message.\n *\n * @param message - The message to be verified, represented in hexadecimal format.\n * @param signature - The Ed25519 signature to validate.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface VerifyEd25519SignatureArgs {\n message: HexInput;\n signature: Ed25519Signature;\n}\n\n/**\n * Represents an Ed25519 account that provides signing capabilities through an Ed25519 private key.\n * This class allows for the creation of accounts, signing messages and transactions, and verifying signatures.\n *\n * Note: Generating an instance of this class does not create the account on-chain.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport class Ed25519Account implements Account {\n /**\n * Private key associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly privateKey: Ed25519PrivateKey;\n\n readonly publicKey: Ed25519PublicKey;\n\n readonly accountAddress: AccountAddress;\n\n readonly signingScheme = SigningScheme.Ed25519;\n\n // region Constructors\n\n /**\n * Creates an instance of the Ed25519Signer with the specified parameters.\n * This constructor initializes the private key, public key, and account address for the signer.\n *\n * @param args - The constructor arguments for the Ed25519Signer.\n * @param args.privateKey - The private key used for signing.\n * @param args.address - The optional account address; if not provided, it will derive the address from the public key.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n constructor(args: Ed25519SignerConstructorArgs) {\n const { privateKey, address } = args;\n this.privateKey = privateKey;\n this.publicKey = privateKey.publicKey();\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n }\n\n /**\n * Generates a new Ed25519 account using a randomly generated private key.\n * This function is useful for creating a signer that can be used for cryptographic operations.\n *\n * @returns {Ed25519Account} The newly generated Ed25519 account.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static generate(): Ed25519Account {\n const privateKey = Ed25519PrivateKey.generate();\n return new Ed25519Account({ privateKey });\n }\n\n /**\n * Derives an Ed25519 account using a specified BIP44 path and mnemonic seed phrase.\n *\n * @param args - The arguments for deriving the account.\n * @param args.path - The BIP44 derive hardened path, e.g., m/44'/637'/0'/0'/0'.\n * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}\n * @param args.mnemonic - The mnemonic seed phrase of the account.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static fromDerivationPath(args: Ed25519SignerFromDerivationPathArgs) {\n const { path, mnemonic } = args;\n const privateKey = Ed25519PrivateKey.fromDerivationPath(path, mnemonic);\n return new Ed25519Account({ privateKey });\n }\n // endregion\n\n // region Account\n /**\n * Verify the given message and signature with the public key.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - Raw message data in HexInput format.\n * @param args.signature - Signed message signature.\n * @returns A boolean indicating whether the signature is valid.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n verifySignature(args: VerifyEd25519SignatureArgs): boolean {\n return this.publicKey.verifySignature(args);\n }\n\n /**\n * Verify the given message and signature with the public key.\n *\n * Ed25519 signatures do not depend on chain state, so this function is equivalent to the synchronous verifySignature method.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network\n * @param args.message - Raw message data in HexInput format.\n * @param args.signature - Signed message signature.\n * @returns A boolean indicating whether the signature is valid.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: Signature;\n }): Promise<boolean> {\n return this.publicKey.verifySignatureAsync({\n ...args,\n signature: args.signature,\n });\n }\n\n /**\n * Sign a message using the account's Ed25519 private key.\n * This function returns an AccountAuthenticator containing the signature along with the account's public key.\n *\n * @param message - The signing message, represented as hexadecimal input.\n * @returns An AccountAuthenticator containing the signature and the account's public key.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signWithAuthenticator(message: HexInput): AccountAuthenticatorEd25519 {\n return new AccountAuthenticatorEd25519(this.publicKey, this.privateKey.sign(message));\n }\n\n /**\n * Sign a transaction using the account's Ed25519 private key.\n * This function returns an AccountAuthenticator that contains the signature of the transaction along with the account's public key.\n *\n * @param transaction - The raw transaction to be signed.\n * @returns An AccountAuthenticator containing the signature and the public key.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorEd25519 {\n return new AccountAuthenticatorEd25519(this.publicKey, this.signTransaction(transaction));\n }\n\n /**\n * Sign the given message using the account's Ed25519 private key.\n * @param message - The message to be signed in HexInput format.\n * @returns Signature - The resulting signature of the signed message.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n sign(message: HexInput): Ed25519Signature {\n return this.privateKey.sign(message);\n }\n\n /**\n * Sign the given transaction using the available signing capabilities.\n * This function helps ensure that the transaction is properly authenticated before submission.\n *\n * @param transaction - The transaction to be signed.\n * @returns Signature - The resulting signature for the transaction.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signTransaction(transaction: AnyRawTransaction): Ed25519Signature {\n return this.sign(generateSigningMessageForTransaction(transaction));\n }\n\n // endregion\n}\n"],"mappings":"AAAA,OAAS,+BAAAA,MAAmC,wCAC5C,OAAmB,iBAAAC,MAAqB,WACxC,OAAS,kBAAAC,MAA2C,yBACpD,OAAS,qBAAAC,MAAwE,iBAGjF,OAAS,wCAAAC,MAA4C,oDAkD9C,MAAMC,CAAkC,CA0B7C,YAAYC,EAAoC,CAdhD,KAAS,cAAgBL,EAAc,QAerC,KAAM,CAAE,WAAAM,EAAY,QAAAC,CAAQ,EAAIF,EAChC,KAAK,WAAaC,EAClB,KAAK,UAAYA,EAAW,UAAU,EACtC,KAAK,eAAiBC,EAAUN,EAAe,KAAKM,CAAO,EAAI,KAAK,UAAU,QAAQ,EAAE,eAAe,CACzG,CAUA,OAAO,UAA2B,CAChC,MAAMD,EAAaJ,EAAkB,SAAS,EAC9C,OAAO,IAAIE,EAAe,CAAE,WAAAE,CAAW,CAAC,CAC1C,CAYA,OAAO,mBAAmBD,EAA2C,CACnE,KAAM,CAAE,KAAAG,EAAM,SAAAC,CAAS,EAAIJ,EACrBC,EAAaJ,EAAkB,mBAAmBM,EAAMC,CAAQ,EACtE,OAAO,IAAIL,EAAe,CAAE,WAAAE,CAAW,CAAC,CAC1C,CAcA,gBAAgBD,EAA2C,CACzD,OAAO,KAAK,UAAU,gBAAgBA,CAAI,CAC5C,CAeA,MAAM,qBAAqBA,EAIN,CACnB,OAAO,KAAK,UAAU,qBAAqB,CACzC,GAAGA,EACH,UAAWA,EAAK,SAClB,CAAC,CACH,CAWA,sBAAsBK,EAAgD,CACpE,OAAO,IAAIX,EAA4B,KAAK,UAAW,KAAK,WAAW,KAAKW,CAAO,CAAC,CACtF,CAWA,iCAAiCC,EAA6D,CAC5F,OAAO,IAAIZ,EAA4B,KAAK,UAAW,KAAK,gBAAgBY,CAAW,CAAC,CAC1F,CASA,KAAKD,EAAqC,CACxC,OAAO,KAAK,WAAW,KAAKA,CAAO,CACrC,CAWA,gBAAgBC,EAAkD,CAChE,OAAO,KAAK,KAAKR,EAAqCQ,CAAW,CAAC,CACpE,CAGF","names":["AccountAuthenticatorEd25519","SigningScheme","AccountAddress","Ed25519PrivateKey","generateSigningMessageForTransaction","Ed25519Account","args","privateKey","address","path","mnemonic","message","transaction"]}
@@ -1,2 +1,2 @@
1
- import{fb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as EphemeralKeyPair};
1
+ import{randomBytes as c}from"@noble/hashes/utils";import{bytesToBigIntLE as p,padAndPackBytesWithLen as u,poseidonHash as h,Ed25519PrivateKey as o,EphemeralPublicKey as d,EphemeralSignature as m}from"../core/crypto";import{Hex as b}from"../core/hex";import{EphemeralPublicKeyVariant as l}from"../types";import{Deserializer as K,Serializable as x}from"../bcs";import{floorToWholeHour as E,nowInSeconds as S}from"../utils/helpers";const v=1209600,i=class i extends x{constructor(e){super();const{privateKey:r,expiryDateSecs:a,blinder:n}=e;this.privateKey=r,this.publicKey=new d(r.publicKey()),this.expiryDateSecs=a||E(S()+v),this.blinder=n!==void 0?b.fromHexInput(n).toUint8Array():D();const t=u(this.publicKey.bcsToBytes(),93);t.push(BigInt(this.expiryDateSecs)),t.push(p(this.blinder));const y=h(t);this.nonce=y.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){const r=e.deserializeUleb128AsU32();let a;switch(r){case l.Ed25519:a=o.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}const n=e.deserializeU64(),t=e.deserializeFixedBytes(31);return new i({privateKey:a,expiryDateSecs:Number(n),blinder:t})}static fromBytes(e){return i.deserialize(new K(e))}static generate(e){let r;switch(e?.scheme){case l.Ed25519:default:r=o.generate()}return new i({privateKey:r,expiryDateSecs:e?.expiryDateSecs})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new m(this.privateKey.sign(e))}};i.BLINDER_LENGTH=31;let s=i;function D(){return c(s.BLINDER_LENGTH)}export{s as EphemeralKeyPair};
2
2
  //# sourceMappingURL=EphemeralKeyPair.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/EphemeralKeyPair.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { randomBytes } from \"@noble/hashes/utils\";\n\nimport {\n bytesToBigIntLE,\n padAndPackBytesWithLen,\n poseidonHash,\n Ed25519PrivateKey,\n EphemeralPublicKey,\n EphemeralSignature,\n PrivateKey,\n} from \"../core/crypto\";\nimport { Hex } from \"../core/hex\";\nimport { EphemeralPublicKeyVariant, HexInput } from \"../types\";\nimport { Deserializer, Serializable, Serializer } from \"../bcs\";\nimport { floorToWholeHour, nowInSeconds } from \"../utils/helpers\";\n\nconst TWO_WEEKS_IN_SECONDS = 1_209_600;\n\n/**\n * Represents an ephemeral key pair used for signing transactions via the Keyless authentication scheme.\n * This key pair is temporary and includes an expiration time.\n * For more details on how this class is used, refer to the documentation:\n * https://aptos.dev/guides/keyless-accounts/#1-present-the-user-with-a-sign-in-with-idp-button-on-the-ui\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport class EphemeralKeyPair extends Serializable {\n static readonly BLINDER_LENGTH: number = 31;\n\n /**\n * A byte array of length BLINDER_LENGTH used to obfuscate the public key from the IdP.\n * Used in calculating the nonce passed to the IdP and as a secret witness in proof generation.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly blinder: Uint8Array;\n\n /**\n * A timestamp in seconds indicating when the ephemeral key pair is expired. After expiry, a new\n * EphemeralKeyPair must be generated and a new JWT needs to be created.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly expiryDateSecs: number;\n\n /**\n * The value passed to the IdP when the user authenticates. It consists of a hash of the\n * ephemeral public key, expiry date, and blinder.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly nonce: string;\n\n /**\n * A private key used to sign transactions. This private key is not tied to any account on the chain as it\n * is ephemeral (not permanent) in nature.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n private privateKey: PrivateKey;\n\n /**\n * A public key used to verify transactions. This public key is not tied to any account on the chain as it\n * is ephemeral (not permanent) in nature.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n private publicKey: EphemeralPublicKey;\n\n /**\n * Creates an instance of the class with a specified private key, optional expiry date, and optional blinder.\n * This constructor initializes the public key, sets the expiry date to a default value if not provided,\n * generates a blinder if not supplied, and calculates the nonce based on the public key, expiry date, and blinder.\n *\n * @param args - The parameters for constructing the instance.\n * @param args.privateKey - The private key used for creating the instance.\n * @param args.expiryDateSecs - Optional expiry date in seconds from the current time. Defaults to two weeks from now.\n * @param args.blinder - Optional blinder value. If not provided, a new blinder will be generated.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n constructor(args: { privateKey: PrivateKey; expiryDateSecs?: number; blinder?: HexInput }) {\n super();\n const { privateKey, expiryDateSecs, blinder } = args;\n this.privateKey = privateKey;\n this.publicKey = new EphemeralPublicKey(privateKey.publicKey());\n // By default, we set the expiry date to be two weeks in the future floored to the nearest hour\n this.expiryDateSecs = expiryDateSecs || floorToWholeHour(nowInSeconds() + TWO_WEEKS_IN_SECONDS);\n // Generate the blinder if not provided\n this.blinder = blinder !== undefined ? Hex.fromHexInput(blinder).toUint8Array() : generateBlinder();\n // Calculate the nonce\n const fields = padAndPackBytesWithLen(this.publicKey.bcsToBytes(), 93);\n fields.push(BigInt(this.expiryDateSecs));\n fields.push(bytesToBigIntLE(this.blinder));\n const nonceHash = poseidonHash(fields);\n this.nonce = nonceHash.toString();\n }\n\n /**\n * Returns the public key of the key pair.\n * @return EphemeralPublicKey\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n getPublicKey(): EphemeralPublicKey {\n return this.publicKey;\n }\n\n /**\n * Checks if the current time has surpassed the expiry date of the key pair.\n * @return boolean - Returns true if the key pair is expired, otherwise false.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n isExpired(): boolean {\n const currentTimeSecs: number = Math.floor(Date.now() / 1000);\n return currentTimeSecs > this.expiryDateSecs;\n }\n\n /**\n * Serializes the object's properties into a format suitable for transmission or storage.\n * This function is essential for preparing the object data for serialization processes.\n *\n * @param serializer - The serializer instance used to serialize the object's properties.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.publicKey.variant);\n serializer.serializeBytes(this.privateKey.toUint8Array());\n serializer.serializeU64(this.expiryDateSecs);\n serializer.serializeFixedBytes(this.blinder);\n }\n\n /**\n * Deserializes an ephemeral key pair from the provided deserializer.\n * This function helps in reconstructing an ephemeral key pair, which is essential for cryptographic operations.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static deserialize(deserializer: Deserializer): EphemeralKeyPair {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let privateKey: PrivateKey;\n switch (variantIndex) {\n case EphemeralPublicKeyVariant.Ed25519:\n privateKey = Ed25519PrivateKey.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for EphemeralPublicKey: ${variantIndex}`);\n }\n const expiryDateSecs = deserializer.deserializeU64();\n const blinder = deserializer.deserializeFixedBytes(31);\n return new EphemeralKeyPair({ privateKey, expiryDateSecs: Number(expiryDateSecs), blinder });\n }\n\n /**\n * Deserialize a byte array into an EphemeralKeyPair object.\n * This function allows you to reconstruct an EphemeralKeyPair from its serialized byte representation.\n *\n * @param bytes - The byte array representing the serialized EphemeralKeyPair.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static fromBytes(bytes: Uint8Array): EphemeralKeyPair {\n return EphemeralKeyPair.deserialize(new Deserializer(bytes));\n }\n\n /**\n * Generates a new ephemeral key pair with an optional expiry date.\n * This function allows you to create a temporary key pair for secure operations.\n *\n * @param args - Optional parameters for key pair generation.\n * @param args.scheme - The type of key pair to use for the EphemeralKeyPair. Only Ed25519 is supported for now.\n * @param args.expiryDateSecs - The date of expiry for the key pair in seconds.\n * @returns An instance of EphemeralKeyPair containing the generated private key and expiry date.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static generate(args?: { scheme?: EphemeralPublicKeyVariant; expiryDateSecs?: number }): EphemeralKeyPair {\n let privateKey: PrivateKey;\n\n switch (args?.scheme) {\n case EphemeralPublicKeyVariant.Ed25519:\n default:\n privateKey = Ed25519PrivateKey.generate();\n }\n\n return new EphemeralKeyPair({ privateKey, expiryDateSecs: args?.expiryDateSecs });\n }\n\n /**\n * Sign the given data using the private key, returning an ephemeral signature.\n * This function is essential for creating a secure signature that can be used for authentication or verification purposes.\n *\n * @param data - The data to be signed, provided in HexInput format.\n * @returns EphemeralSignature - The resulting ephemeral signature.\n * @throws Error - Throws an error if the EphemeralKeyPair has expired.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n sign(data: HexInput): EphemeralSignature {\n if (this.isExpired()) {\n throw new Error(\"EphemeralKeyPair has expired\");\n }\n return new EphemeralSignature(this.privateKey.sign(data));\n }\n}\n\n/**\n * Generates a random byte array of length EphemeralKeyPair.BLINDER_LENGTH.\n * @returns Uint8Array A random byte array used for blinding.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nfunction generateBlinder(): Uint8Array {\n return randomBytes(EphemeralKeyPair.BLINDER_LENGTH);\n}\n"],"mappings":"AAGA,OAAS,eAAAA,MAAmB,sBAE5B,OACE,mBAAAC,EACA,0BAAAC,EACA,gBAAAC,EACA,qBAAAC,EACA,sBAAAC,EACA,sBAAAC,MAEK,iBACP,OAAS,OAAAC,MAAW,cACpB,OAAS,6BAAAC,MAA2C,WACpD,OAAS,gBAAAC,EAAc,gBAAAC,MAAgC,SACvD,OAAS,oBAAAC,EAAkB,gBAAAC,MAAoB,mBAE/C,MAAMC,EAAuB,QAUhBC,EAAN,MAAMA,UAAyBJ,CAAa,CAuDjD,YAAYK,EAA+E,CACzF,MAAM,EACN,KAAM,CAAE,WAAAC,EAAY,eAAAC,EA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A,OAAO,SAASV,EAA0F,CACxG,IAAIC,EAEJ,OAAQD,GAAM,OAAQ,CACpB,KAAKP,EAA0B,QAC/B,QACEQ,EAAaZ,EAAkB,SAAS,CAC5C,CAEA,OAAO,IAAIU,EAAiB,CAAE,WAAAE,EAAY,eAAgBD,GAAM,cAAe,CAAC,CAClF,CAYA,KAAKW,EAAoC,CACvC,GAAI,KAAK,UAAU,EACjB,MAAM,IAAI,MAAM,8BAA8B,EAEhD,OAAO,IAAIpB,EAAmB,KAAK,WAAW,KAAKoB,CAAI,CAAC,CAC1D,CACF,EAtLaZ,EACK,eAAyB,GADpC,IAAMa,EAANb,EA8LP,SAASK,GAA8B,CACrC,OAAOnB,EAAY2B,EAAiB,cAAc,CACpD","names":["randomBytes","bytesToBigIntLE","padAndPackBytesWithLen","poseidonHash","Ed25519PrivateKey","EphemeralPublicKey","EphemeralSignature","Hex","EphemeralPublicKeyVariant","Deserializer","Serializable","floorToWholeHour","nowInSeconds","TWO_WEEKS_IN_SECONDS","_EphemeralKeyPair","args","privateKey","expiryDateSecs","blinder","generateBlinder","fields","nonceHash","serializer","deserializer","variantIndex","bytes","data","EphemeralKeyPair"]}
@@ -1,2 +1,2 @@
1
- import{kb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as FederatedKeylessAccount};
1
+ import{AccountAddress as K}from"../core/accountAddress";import{getIssAudAndUidVal as y}from"../core/crypto";import{Deserializer as A}from"../bcs";import{FederatedKeylessPublicKey as w}from"../core/crypto/federatedKeyless";import{AbstractKeylessAccount as f}from"./AbstractKeylessAccount";class n extends f{constructor(e){const r=w.create(e);super({publicKey:r,...e}),this.publicKey=r,this.audless=e.audless??!1}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){const{address:r,proof:c,ephemeralKeyPair:s,jwt:o,uidKey:t,pepper:l,verificationKeyHash:a}=f.partialDeserialize(e),p=K.deserialize(e),{iss:i,aud:d,uidVal:u}=y({jwt:o,uidKey:t});return new n({address:r,proof:c,ephemeralKeyPair:s,iss:i,uidKey:t,uidVal:u,aud:d,pepper:l,jwt:o,verificationKeyHash:a,jwkAddress:p})}static fromBytes(e){return n.deserialize(A.fromHex(e))}static create(e){const{address:r,proof:c,jwt:s,ephemeralKeyPair:o,pepper:t,jwkAddress:l,uidKey:a="sub",proofFetchCallback:p,verificationKey:i,verificationKeyHash:d}=e;if(d&&i)throw new Error("Cannot provide both verificationKey and verificationKeyHash");const{iss:u,aud:h,uidVal:m}=y({jwt:s,uidKey:a});return new n({address:r,proof:c,ephemeralKeyPair:o,iss:u,uidKey:a,uidVal:m,aud:h,pepper:t,jwkAddress:K.from(l),jwt:s,proofFetchCallback:p,verificationKeyHash:d??(i?i.hash():void 0)})}}export{n as FederatedKeylessAccount};
2
2
  //# sourceMappingURL=FederatedKeylessAccount.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/FederatedKeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { HexInput } from \"../types\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { getIssAudAndUidVal, Groth16VerificationKey, ZeroKnowledgeSig } from \"../core/crypto\";\n\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Deserializer, Serializer } from \"../bcs\";\nimport { FederatedKeylessPublicKey } from \"../core/crypto/federatedKeyless\";\nimport { AbstractKeylessAccount, ProofFetchCallback } from \"./AbstractKeylessAccount\";\n\n/**\n * Account implementation for the FederatedKeyless authentication scheme.\n *\n * Used to represent a FederatedKeyless based account and sign transactions with it.\n *\n * Use `FederatedKeylessAccount.create()` to instantiate a KeylessAccount with a JSON Web Token (JWT), proof, EphemeralKeyPair and the\n * address the JSON Web Key Set (JWKS) are installed that will be used to verify the JWT.\n *\n * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,\n * EphemeralKeyPair, and corresponding proof.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport class FederatedKeylessAccount extends AbstractKeylessAccount {\n /**\n * The FederatedKeylessPublicKey associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly publicKey: FederatedKeylessPublicKey;\n\n readonly audless: boolean;\n\n /**\n * Use the static generator `FederatedKeylessAccount.create(...)` instead.\n * Creates a KeylessAccount instance using the provided parameters.\n * This function allows you to set up a KeylessAccount with specific attributes such as address, proof, and JWT.\n *\n * @param args - The parameters for creating a KeylessAccount.\n * @param args.address - Optional account address associated with the KeylessAccount.\n * @param args.proof - A Zero Knowledge Signature or a promise that resolves to one.\n * @param args.jwt - A JSON Web Token used for authentication.\n * @param args.ephemeralKeyPair - The ephemeral key pair used in the account creation.\n * @param args.jwkAddress - The address which stores the JSON Web Key Set (JWKS) used to verify the JWT.\n * @param args.uidKey - Optional key for user identification, defaults to \"sub\".\n * @param args.proofFetchCallback - Optional callback function for fetching proof.\n */\n constructor(args: {\n address?: AccountAddress;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n jwkAddress: AccountAddress;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n verificationKeyHash?: HexInput;\n audless?: boolean;\n }) {\n const publicKey = FederatedKeylessPublicKey.create(args);\n super({ publicKey, ...args });\n this.publicKey = publicKey;\n this.audless = args.audless ?? false;\n }\n\n /**\n * Serializes the transaction data into a format suitable for transmission or storage.\n * This function ensures that both the transaction bytes and the proof are properly serialized.\n *\n * @param serializer - The serializer instance used to convert the transaction data into bytes.\n */\n serialize(serializer: Serializer): void {\n super.serialize(serializer);\n this.publicKey.jwkAddress.serialize(serializer);\n }\n\n /**\n * Deserializes the provided deserializer to create a KeylessAccount instance.\n * This function extracts necessary components such as the JWT, UID key, pepper, ephemeral key pair, and proof from the deserializer.\n *\n * @param deserializer - The deserializer instance used to retrieve the serialized data.\n * @returns A KeylessAccount instance created from the deserialized data.\n */\n static deserialize(deserializer: Deserializer): FederatedKeylessAccount {\n const { address, proof, ephemeralKeyPair, jwt, uidKey, pepper, verificationKeyHash } =\n AbstractKeylessAccount.partialDeserialize(deserializer);\n const jwkAddress = AccountAddress.deserialize(deserializer);\n const { iss, aud, uidVal } = getIssAudAndUidVal({ jwt, uidKey });\n return new FederatedKeylessAccount({\n address,\n proof,\n ephemeralKeyPair,\n iss,\n uidKey,\n uidVal,\n aud,\n pepper,\n jwt,\n verificationKeyHash,\n jwkAddress,\n });\n }\n\n /**\n * Deserialize bytes using this account's information.\n *\n * @param bytes The bytes being interpreted.\n * @returns\n */\n static fromBytes(bytes: HexInput): FederatedKeylessAccount {\n return FederatedKeylessAccount.deserialize(Deserializer.fromHex(bytes));\n }\n\n /**\n * Creates a KeylessAccount instance using the provided parameters.\n * This function allows you to set up a KeylessAccount with specific attributes such as address, proof, and JWT.\n * This is used instead of the KeylessAccount constructor.\n *\n * @param args - The parameters for creating a KeylessAccount.\n * @param args.address - Optional account address associated with the KeylessAccount.\n * @param args.proof - A Zero Knowledge Signature or a promise that resolves to one.\n * @param args.jwt - A JSON Web Token used for authentication.\n * @param args.ephemeralKeyPair - The ephemeral key pair used in the account creation.\n * @param args.jwkAddress - The address which stores the JSON Web Key Set (JWKS) used to verify the JWT.\n * @param args.uidKey - Optional key for user identification, defaults to \"sub\".\n * @param args.proofFetchCallback - Optional callback function for fetching proof.\n */\n static create(args: {\n address?: AccountAddress;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n jwkAddress: AccountAddressInput;\n uidKey?: string;\n proofFetchCallback?: ProofFetchCallback;\n verificationKey?: Groth16VerificationKey;\n verificationKeyHash?: Uint8Array;\n }): FederatedKeylessAccount {\n const {\n address,\n proof,\n jwt,\n ephemeralKeyPair,\n pepper,\n jwkAddress,\n uidKey = \"sub\",\n proofFetchCallback,\n verificationKey,\n verificationKeyHash,\n } = args;\n\n if (verificationKeyHash && verificationKey) {\n throw new Error(\"Cannot provide both verificationKey and verificationKeyHash\");\n }\n\n const { iss, aud, uidVal } = getIssAudAndUidVal({ jwt, uidKey });\n return new FederatedKeylessAccount({\n address,\n proof,\n ephemeralKeyPair,\n iss,\n uidKey,\n uidVal,\n aud,\n pepper,\n jwkAddress: AccountAddress.from(jwkAddress),\n jwt,\n proofFetchCallback,\n verificationKeyHash: verificationKeyHash ?? (verificationKey ? verificationKey.hash() : undefined),\n });\n }\n}\n"],"mappings":"AAIA,OAAS,kBAAAA,MAA2C,yBACpD,OAAS,sBAAAC,MAAoE,iBAG7E,OAAS,gBAAAC,MAAgC,SACzC,OAAS,6BAAAC,MAAiC,kCAC1C,OAAS,0BAAAC,MAAkD,2BAepD,MAAMC,UAAgCD,CAAuB,CAwBlE,YAAYE,EAcT,CACD,MAAMC,EAAYJ,EAA0B,OAAOG,CAAI,EACvD,MAAM,CAAE,UAAAC,EAAW,GAAGD,CAAK,CAAC,EAC5B,KAAK,UAAYC,EACjB,KAAK,QAAUD,EAAK,SAAW,EACjC,CAQA,UAAUE,EAA8B,CACtC,MAAM,UAAUA,CAAU,EAC1B,KAAK,UAAU,WAAW,UAAUA,CAAU,CAChD,CASA,OAAO,YAAYC,EAAqD,CACtE,KAAM,CAAE,QAAAC,EAAS,MAAAC,EAAO,iBAAAC,EAAkB,IAAAC,EAAK,OAAAC,EAAQ,OAAAC,EAAQ,oBAAAC,CAAoB,EACjFZ,EAAuB,mBAAmBK,CAAY,EAClDQ,EAAajB,EAAe,YAAYS,CAAY,EACpD,CAAE,IAAAS,EAAK,IAAAC,EAAK,OAAAC,CAAO,EAAInB,EAAmB,CAAE,IAAAY,EAAK,OAAAC,CAAO,CAAC,EAC/D,OAAO,IAAIT,EAAwB,CACjC,QAAAK,EACA,MAAAC,EACA,iBAAAC,EACA,IAAAM,EACA,OAAAJ,EACA,OAAAM,EACA,IAAAD,EACA,OAAAJ,EACA,IAAAF,EACA,oBAAAG,EACA,WAAAC,CACF,CAAC,CACH,CAQA,OAAO,UAAUI,EAA0C,CACzD,OAAOhB,EAAwB,YAAYH,EAAa,QAAQmB,CAAK,CAAC,CACxE,CAgBA,OAAO,OAAOf,EAWc,CAC1B,KAAM,CACJ,QAAAI,EACA,MAAAC,EACA,IAAAE,EACA,iBAAAD,EACA,OAAAG,EACA,WAAAE,EACA,OAAAH,EAAS,MACT,mBAAAQ,EACA,gBAAAC,EACA,oBAAAP,CACF,EAAIV,EAEJ,GAAIU,GAAuBO,EACzB,MAAM,IAAI,MAAM,6DAA6D,EAG/E,KAAM,CAAE,IAAAL,EAAK,IAAAC,EAAK,OAAAC,CAAO,EAAInB,EAAmB,CAAE,IAAAY,EAAK,OAAAC,CAAO,CAAC,EAC/D,OAAO,IAAIT,EAAwB,CACjC,QAAAK,EACA,MAAAC,EACA,iBAAAC,EACA,IAAAM,EACA,OAAAJ,EACA,OAAAM,EACA,IAAAD,EACA,OAAAJ,EACA,WAAYf,EAAe,KAAKiB,CAAU,EAC1C,IAAAJ,EACA,mBAAAS,EACA,oBAAqBN,IAAwBO,EAAkBA,EAAgB,KAAK,EAAI,OAC1F,CAAC,CACH,CACF","names":["AccountAddress","getIssAudAndUidVal","Deserializer","FederatedKeylessPublicKey","AbstractKeylessAccount","FederatedKeylessAccount","args","publicKey","serializer","deserializer","address","proof","ephemeralKeyPair","jwt","uidKey","pepper","verificationKeyHash","jwkAddress","iss","aud","uidVal","bytes","proofFetchCallback","verificationKey"]}
@@ -1,2 +1,2 @@
1
- import{jb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as KeylessAccount};
1
+ import{getIssAudAndUidVal as K,KeylessPublicKey as h}from"../core/crypto";import{Deserializer as m}from"../bcs";import{AbstractKeylessAccount as u}from"./AbstractKeylessAccount";import{Hex as g}from"../core/hex";class c extends u{constructor(e){const r=h.create(e);super({publicKey:r,...e}),this.publicKey=r}serialize(e){super.serialize(e)}static deserialize(e){const{address:r,proof:l,ephemeralKeyPair:o,jwt:t,uidKey:a,pepper:s,verificationKeyHash:p}=u.partialDeserialize(e),{iss:i,aud:n,uidVal:d}=K({jwt:t,uidKey:a});return new c({address:r,proof:l,ephemeralKeyPair:o,iss:i,uidKey:a,uidVal:d,aud:n,pepper:s,jwt:t,verificationKeyHash:p})}static fromBytes(e){return c.deserialize(new m(g.hexInputToUint8Array(e)))}static create(e){const{address:r,proof:l,jwt:o,ephemeralKeyPair:t,pepper:a,uidKey:s="sub",proofFetchCallback:p,verificationKey:i,verificationKeyHash:n}=e;if(n&&i)throw new Error("Cannot provide both verificationKey and verificationKeyHash");const{iss:d,aud:y,uidVal:f}=K({jwt:o,uidKey:s});return new c({address:r,proof:l,ephemeralKeyPair:t,iss:d,uidKey:s,uidVal:f,aud:y,pepper:a,jwt:o,proofFetchCallback:p,verificationKeyHash:n??(i?i.hash():void 0)})}}export{c as KeylessAccount};
2
2
  //# sourceMappingURL=KeylessAccount.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/KeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { HexInput } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport { getIssAudAndUidVal, Groth16VerificationKey, KeylessPublicKey, ZeroKnowledgeSig } from \"../core/crypto\";\n\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Deserializer, Serializer } from \"../bcs\";\nimport { AbstractKeylessAccount, ProofFetchCallback } from \"./AbstractKeylessAccount\";\nimport { Hex } from \"../core/hex\";\n\n/**\n * Account implementation for the Keyless authentication scheme.\n *\n * Used to represent a Keyless based account and sign transactions with it.\n *\n * Use `KeylessAccount.create()` to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.\n *\n * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,\n * EphemeralKeyPair, and corresponding proof.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport class KeylessAccount extends AbstractKeylessAccount {\n /**\n * The KeylessPublicKey associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly publicKey: KeylessPublicKey;\n\n // Use the static constructor 'create' instead.\n\n /**\n * Use the static generator `create(...)` instead.\n * Creates an instance of the KeylessAccount with an optional proof.\n *\n * @param args - The parameters for creating a KeylessAccount.\n * @param args.address - Optional account address associated with the KeylessAccount.\n * @param args.ephemeralKeyPair - The ephemeral key pair used in the account creation.\n * @param args.iss - A JWT issuer.\n * @param args.uidKey - The claim on the JWT to identify a user. This is typically 'sub' or 'email'.\n * @param args.uidVal - The unique id for this user, intended to be a stable user identifier.\n * @param args.aud - The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's\n * OIDC registration with the identity provider.\n * @param args.pepper - A hexadecimal input used for additional security.\n * @param args.proof - A Zero Knowledge Signature or a promise that resolves to one.\n * @param args.proofFetchCallback - Optional callback function for fetching proof.\n * @param args.jwt - A JSON Web Token used for authentication.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n constructor(args: {\n address?: AccountAddress;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n verificationKeyHash?: HexInput;\n }) {\n const publicKey = KeylessPublicKey.create(args);\n super({ publicKey, ...args });\n this.publicKey = publicKey;\n }\n\n /**\n * Serializes the transaction data into a format suitable for transmission or storage.\n * This function ensures that both the transaction bytes and the proof are properly serialized.\n *\n * @param serializer - The serializer instance used to convert the transaction data into bytes.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n serialize(serializer: Serializer): void {\n super.serialize(serializer);\n }\n\n /**\n * Deserializes the provided deserializer to create a KeylessAccount instance.\n * This function extracts necessary components such as the JWT, UID key, pepper, ephemeral key pair, and proof from the deserializer.\n *\n * @param deserializer - The deserializer instance used to retrieve the serialized data.\n * @returns A KeylessAccount instance created from the deserialized data.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static deserialize(deserializer: Deserializer): KeylessAccount {\n const { address, proof, ephemeralKeyPair, jwt, uidKey, pepper, verificationKeyHash } =\n AbstractKeylessAccount.partialDeserialize(deserializer);\n const { iss, aud, uidVal } = getIssAudAndUidVal({ jwt, uidKey });\n return new KeylessAccount({\n address,\n proof,\n ephemeralKeyPair,\n iss,\n uidKey,\n uidVal,\n aud,\n pepper,\n jwt,\n verificationKeyHash,\n });\n }\n\n /**\n * Deserialize bytes using this account's information.\n *\n * @param bytes The bytes being interpreted.\n * @returns\n */\n static fromBytes(bytes: HexInput): KeylessAccount {\n return KeylessAccount.deserialize(new Deserializer(Hex.hexInputToUint8Array(bytes)));\n }\n\n /**\n * Creates a KeylessAccount instance using the provided parameters.\n * This function allows you to set up a KeylessAccount with specific attributes such as address, proof, and JWT.\n * This is used instead of the KeylessAccount constructor.\n *\n * @param args - The parameters for creating a KeylessAccount.\n * @param args.address - Optional account address associated with the KeylessAccount.\n * @param args.proof - A Zero Knowledge Signature or a promise that resolves to one.\n * @param args.jwt - A JSON Web Token used for authentication.\n * @param args.ephemeralKeyPair - The ephemeral key pair used in the account creation.\n * @param args.pepper - A hexadecimal input used for additional security.\n * @param args.uidKey - Optional key for user identification, defaults to \"sub\".\n * @param args.proofFetchCallback - Optional callback function for fetching proof.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static create(args: {\n address?: AccountAddress;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n proofFetchCallback?: ProofFetchCallback;\n verificationKey?: Groth16VerificationKey;\n verificationKeyHash?: Uint8Array;\n }): KeylessAccount {\n const {\n address,\n proof,\n jwt,\n ephemeralKeyPair,\n pepper,\n uidKey = \"sub\",\n proofFetchCallback,\n verificationKey,\n verificationKeyHash,\n } = args;\n\n if (verificationKeyHash && verificationKey) {\n throw new Error(\"Cannot provide both verificationKey and verificationKeyHash\");\n }\n\n const { iss, aud, uidVal } = getIssAudAndUidVal({ jwt, uidKey });\n return new KeylessAccount({\n address,\n proof,\n ephemeralKeyPair,\n iss,\n uidKey,\n uidVal,\n aud,\n pepper,\n jwt,\n proofFetchCallback,\n verificationKeyHash: verificationKeyHash ?? (verificationKey ? verificationKey.hash() : undefined),\n });\n }\n}\n"],"mappings":"AAKA,OAAS,sBAAAA,EAA4C,oBAAAC,MAA0C,iBAG/F,OAAS,gBAAAC,MAAgC,SACzC,OAAS,0BAAAC,MAAkD,2BAC3D,OAAS,OAAAC,MAAW,cAcb,MAAMC,UAAuBF,CAAuB,CA6BzD,YAAYG,EAYT,CACD,MAAMC,EAAYN,EAAiB,OAAOK,CAAI,EAC9C,MAAM,CAAE,UAAAC,EAAW,GAAGD,CAAK,CAAC,EAC5B,KAAK,UAAYC,CACnB,CAUA,UAAUC,EAA8B,CACtC,MAAM,UAAUA,CAAU,CAC5B,CAWA,OAAO,YAAYC,EAA4C,CAC7D,KAAM,CAAE,QAAAC,EAAS,MAAAC,EAAO,iBAAAC,EAAkB,IAAAC,EAAK,OAAAC,EAAQ,OAAAC,EAAQ,oBAAAC,CAAoB,EACjFb,EAAuB,mBAAmBM,CAAY,EAClD,CAAE,IAAAQ,EAAK,IAAAC,EAAK,OAAAC,CAAO,EAAInB,EAAmB,CAAE,IAAAa,EAAK,OAAAC,CAAO,CAAC,EAC/D,OAAO,IAAIT,EAAe,CACxB,QAAAK,EACA,MAAAC,EACA,iBAAAC,EACA,IAAAK,EACA,OAAAH,EACA,OAAAK,EACA,IAAAD,EACA,OAAAH,EACA,IAAAF,EACA,oBAAAG,CACF,CAAC,CACH,CAQA,OAAO,UAAUI,EAAiC,CAChD,OAAOf,EAAe,YAAY,IAAIH,EAAaE,EAAI,qBAAqBgB,CAAK,CAAC,CAAC,CACrF,CAkBA,OAAO,OAAOd,EAUK,CACjB,KAAM,CACJ,QAAAI,EACA,MAAAC,EACA,IAAAE,EACA,iBAAAD,EACA,OAAAG,EACA,OAAAD,EAAS,MACT,mBAAAO,EACA,gBAAAC,EACA,oBAAAN,CACF,EAAIV,EAEJ,GAAIU,GAAuBM,EACzB,MAAM,IAAI,MAAM,6DAA6D,EAG/E,KAAM,CAAE,IAAAL,EAAK,IAAAC,EAAK,OAAAC,CAAO,EAAInB,EAAmB,CAAE,IAAAa,EAAK,OAAAC,CAAO,CAAC,EAC/D,OAAO,IAAIT,EAAe,CACxB,QAAAK,EACA,MAAAC,EACA,iBAAAC,EACA,IAAAK,EACA,OAAAH,EACA,OAAAK,EACA,IAAAD,EACA,OAAAH,EACA,IAAAF,EACA,mBAAAQ,EACA,oBAAqBL,IAAwBM,EAAkBA,EAAgB,KAAK,EAAI,OAC1F,CAAC,CACH,CACF","names":["getIssAudAndUidVal","KeylessPublicKey","Deserializer","AbstractKeylessAccount","Hex","KeylessAccount","args","publicKey","serializer","deserializer","address","proof","ephemeralKeyPair","jwt","uidKey","pepper","verificationKeyHash","iss","aud","uidVal","bytes","proofFetchCallback","verificationKey"]}
@@ -1,2 +1,2 @@
1
- import{mb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as MultiEd25519Account};
1
+ import{AccountAddress as c}from"../core/accountAddress";import{MultiEd25519Signature as g}from"../core/crypto/multiEd25519";import{AccountAuthenticatorMultiEd25519 as a}from"../transactions/authenticator/account";import{generateSigningMessageForTransaction as d}from"../transactions/transactionBuilder/signingMessage";import{SigningScheme as l}from"../types";class T{constructor(t){this.signingScheme=l.MultiEd25519;const{signers:e,publicKey:r,address:u}=t;if(this.publicKey=r,this.accountAddress=u?c.from(u):this.publicKey.authKey().derivedAddress(),r.threshold>e.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${e.length} provided`);if(r.threshold<e.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${e.length} provided`);const n=[];for(const i of e)n.push(this.publicKey.getIndex(i.publicKey()));const s=e.map((i,o)=>[i,n[o]]);s.sort((i,o)=>i[1]-o[1]),this.signers=s.map(i=>i[0]),this.signerIndices=s.map(i=>i[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:n})}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t,signature:t.signature})}signWithAuthenticator(t){return new a(this.publicKey,this.sign(t))}signTransactionWithAuthenticator(t){return new a(this.publicKey,this.signTransaction(t))}sign(t){const e=[];for(const r of this.signers)e.push(r.sign(t));return new g({signatures:e,bitmap:this.signaturesBitmap})}signTransaction(t){return this.sign(d(t))}}export{T as MultiEd25519Account};
2
2
  //# sourceMappingURL=MultiEd25519Account.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/MultiEd25519Account.ts"],"sourcesContent":["import { AptosConfig } from \"../api\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { Ed25519PrivateKey, Signature } from \"../core/crypto\";\nimport { MultiEd25519PublicKey, MultiEd25519Signature } from \"../core/crypto/multiEd25519\";\nimport { AccountAuthenticatorMultiEd25519 } from \"../transactions/authenticator/account\";\nimport { generateSigningMessageForTransaction } from \"../transactions/transactionBuilder/signingMessage\";\nimport { AnyRawTransaction } from \"../transactions/types\";\nimport { HexInput, SigningScheme } from \"../types\";\nimport type { Account } from \"./Account\";\n\nexport interface MultiEd25519SignerConstructorArgs {\n publicKey: MultiEd25519PublicKey;\n signers: Ed25519PrivateKey[];\n address?: AccountAddressInput;\n}\n\nexport interface VerifyMultiEd25519SignatureArgs {\n message: HexInput;\n signature: MultiEd25519Signature;\n}\n\n/**\n * Signer implementation for the Multi-Ed25519 authentication scheme.\n *\n * Note: This authentication scheme is a legacy authentication scheme. Prefer using MultiKeyAccounts as a\n * MultiKeyAccount can support any type of signer, not just Ed25519. Generating a signer instance does not\n * create the account on-chain.\n */\nexport class MultiEd25519Account implements Account {\n readonly publicKey: MultiEd25519PublicKey;\n\n readonly accountAddress: AccountAddress;\n\n readonly signingScheme = SigningScheme.MultiEd25519;\n\n /**\n * The signers used to sign messages. These signers should correspond to public keys in the\n * MultiEd25519Account. The number of signers should be equal to this.publicKey.threshold.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly signers: Ed25519PrivateKey[];\n\n /**\n * An array of indices where for signer[i], signerIndicies[i] is the index of the corresponding public key in\n * publicKey.publicKeys. Used to derive the right public key to use for verification.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly signerIndices: number[];\n\n readonly signaturesBitmap: Uint8Array;\n\n // region Constructors\n\n constructor(args: MultiEd25519SignerConstructorArgs) {\n const { signers, publicKey, address } = args;\n this.publicKey = publicKey;\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n\n if (publicKey.threshold > signers.length) {\n throw new Error(\n // eslint-disable-next-line max-len\n `Not enough signers provided to satisfy the required signatures. Need ${publicKey.threshold} signers, but only ${signers.length} provided`,\n );\n } else if (publicKey.threshold < signers.length) {\n throw new Error(\n // eslint-disable-next-line max-len\n `More signers provided than required. Need ${publicKey.threshold} signers, but ${signers.length} provided`,\n );\n }\n\n // For each signer, find its corresponding position in the public keys array\n const bitPositions: number[] = [];\n for (const signer of signers) {\n bitPositions.push(this.publicKey.getIndex(signer.publicKey()));\n }\n\n // Create pairs of [signer, position] and sort them by position\n // This sorting is critical because:\n // 1. The on-chain verification expects signatures to be in ascending order by bit position\n // 2. The bitmap must match the order of signatures when verifying\n const signersAndBitPosition: [Ed25519PrivateKey, number][] = signers.map((signer, index) => [\n signer,\n bitPositions[index],\n ]);\n signersAndBitPosition.sort((a, b) => a[1] - b[1]);\n\n // Extract the sorted signers and their positions into separate arrays\n this.signers = signersAndBitPosition.map((value) => value[0]);\n this.signerIndices = signersAndBitPosition.map((value) => value[1]);\n\n // Create a bitmap representing which public keys from the MultiEd25519PublicKey are being used\n // This bitmap is used during signature verification to identify which public keys\n // should be used to verify each signature\n this.signaturesBitmap = this.publicKey.createBitmap({ bits: bitPositions });\n }\n\n // endregion\n\n // region Account\n\n /**\n * Verify the given message and signature with the public key.\n *\n * @param args.message raw message data in HexInput format\n * @param args.signature signed message Signature\n * @returns\n */\n verifySignature(args: VerifyMultiEd25519SignatureArgs): boolean {\n return this.publicKey.verifySignature(args);\n }\n\n /**\n * Verify the given message and signature with the public key.\n *\n * MultiEd25519 signatures do not depend on chain state, so this function is\n * equivalent to the synchronous verifySignature method.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network\n * @param args.message - Raw message data in HexInput format.\n * @param args.signature - Signed message signature.\n * @returns A boolean indicating whether the signature is valid.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: Signature;\n options?: { throwErrorWithReason?: boolean };\n }): Promise<boolean> {\n return this.publicKey.verifySignatureAsync({\n ...args,\n signature: args.signature,\n });\n }\n\n /**\n * Sign a message using the account's Ed25519 private key.\n * @param message the signing message, as binary input\n * @return the AccountAuthenticator containing the signature, together with the account's public key\n */\n signWithAuthenticator(message: HexInput): AccountAuthenticatorMultiEd25519 {\n return new AccountAuthenticatorMultiEd25519(this.publicKey, this.sign(message));\n }\n\n /**\n * Sign a transaction using the account's Ed25519 private keys.\n * @param transaction the raw transaction\n * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key\n */\n signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorMultiEd25519 {\n return new AccountAuthenticatorMultiEd25519(this.publicKey, this.signTransaction(transaction));\n }\n\n /**\n * Sign the given message using the account's Ed25519 private keys.\n * @param message in HexInput format\n * @returns MultiEd25519Signature\n */\n sign(message: HexInput): MultiEd25519Signature {\n const signatures = [];\n for (const signer of this.signers) {\n signatures.push(signer.sign(message));\n }\n return new MultiEd25519Signature({ signatures, bitmap: this.signaturesBitmap });\n }\n\n /**\n * Sign the given transaction using the available signing capabilities.\n * @param transaction the transaction to be signed\n * @returns Signature\n */\n signTransaction(transaction: AnyRawTransaction): MultiEd25519Signature {\n return this.sign(generateSigningMessageForTransaction(transaction));\n }\n\n // endregion\n}\n"],"mappings":"AACA,OAAS,kBAAAA,MAA2C,yBAEpD,OAAgC,yBAAAC,MAA6B,8BAC7D,OAAS,oCAAAC,MAAwC,wCACjD,OAAS,wCAAAC,MAA4C,oDAErD,OAAmB,iBAAAC,MAAqB,WAqBjC,MAAMC,CAAuC,CA2BlD,YAAYC,EAAyC,CAtBrD,KAAS,cAAgBF,EAAc,aAuBrC,KAAM,CAAE,QAAAG,EAAS,UAAAC,EAAW,QAAAC,CAAQ,EAAIH,EAIxC,GAHA,KAAK,UAAYE,EACjB,KAAK,eAAiBC,EAAUT,EAAe,KAAKS,CAAO,EAAI,KAAK,UAAU,QAAQ,EAAE,eAAe,EAEnGD,EAAU,UAAYD,EAAQ,OAChC,MAAM,IAAI,MAER,wEAAwEC,EAAU,SAAS,sBAAsBD,EAAQ,MAAM,WACjI,EACK,GAAIC,EAAU,UAAYD,EAAQ,OACvC,MAAM,IAAI,MAER,6CAA6CC,EAAU,S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Scheme","MultiEd25519Account","args","signers","publicKey","address","bitPositions","signer","signersAndBitPosition","index","a","b","value","message","transaction","signatures"]}
@@ -1,2 +1,2 @@
1
- import{lb as a}from"../chunk-L72TIN7T.mjs";import"../chunk-2XQKGWHQ.mjs";import"../chunk-UYVPNUH3.mjs";import"../chunk-XKUIMGKU.mjs";import"../chunk-N6YTF76Q.mjs";import"../chunk-A5L76YP7.mjs";import"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import"../chunk-GOXRBEIJ.mjs";import"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import"../chunk-EF4FA5I6.mjs";import"../chunk-WCMW2L3P.mjs";import"../chunk-WSR5EBJM.mjs";import"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import"../chunk-FGFLPH5K.mjs";import"../chunk-WHSTLR3F.mjs";import"../chunk-M3AO73ZL.mjs";import"../chunk-6OWBKU7N.mjs";import"../chunk-AMXZQPUQ.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-SJDCGNWU.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-4AI7KQQ7.mjs";import"../chunk-7EER7GWV.mjs";import"../chunk-QP2BY4PK.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-RCSJFTST.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{a as MultiKeyAccount};
1
+ import{MultiKey as l,MultiKeySignature as a}from"../core/crypto";import{AccountAddress as d}from"../core/accountAddress";import{SigningScheme as p}from"../types";import{AccountAuthenticatorMultiKey as g}from"../transactions/authenticator/account";import{AbstractKeylessAccount as y}from"./AbstractKeylessAccount";import{SingleKeyAccount as m}from"./SingleKeyAccount";import{Ed25519Account as A}from"./Ed25519Account";class u{constructor(e){this.signingScheme=p.MultiKey;const{multiKey:i,address:t}=e,n=e.signers.map(s=>s instanceof A?m.fromEd25519Account(s):s);if(i.signaturesRequired>n.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${i.signaturesRequired} signers, but only ${n.length} provided`);if(i.signaturesRequired<n.length)throw new Error(`More signers provided than required. Need ${i.signaturesRequired} signers, but ${n.length} provided`);this.publicKey=i,this.accountAddress=t?d.from(t):this.publicKey.authKey().derivedAddress();const r=[];for(const s of n)r.push(this.publicKey.getIndex(s.getAnyPublicKey()));const o=n.map((s,c)=>[s,r[c]]);o.sort((s,c)=>s[1]-c[1]),this.signers=o.map(s=>s[0]),this.signerIndicies=o.map(s=>s[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:r})}static fromPublicKeysAndSigners(e){const{address:i,publicKeys:t,signaturesRequired:n,signers:r}=e,o=new l({publicKeys:t,signaturesRequired:n});return new u({multiKey:o,signers:r,address:i})}static isMultiKeySigner(e){return e instanceof u}signWithAuthenticator(e){return new g(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new g(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){const i=this.signers.filter(t=>t instanceof y).map(async t=>t.waitForProofFetch());await Promise.all(i)}async checkKeylessAccountValidity(e){const t=this.signers.filter(n=>n instanceof y).map(n=>n.checkKeylessAccountValidity(e));await Promise.all(t)}sign(e){const i=[];for(const t of this.signers)i.push(t.sign(e));return new a({signatures:i,bitmap:this.signaturesBitmap})}signTransaction(e){const i=[];for(const t of this.signers)i.push(t.signTransaction(e));return new a({signatures:i,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}}export{u as MultiKeyAccount};
2
2
  //# sourceMappingURL=MultiKeyAccount.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/account/MultiKeyAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Account } from \"./Account\";\nimport { MultiKey, MultiKeySignature, PublicKey } from \"../core/crypto\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { HexInput, SigningScheme } from \"../types\";\nimport { AccountAuthenticatorMultiKey } from \"../transactions/authenticator/account\";\nimport { AnyRawTransaction } from \"../transactions/types\";\nimport { AbstractKeylessAccount, KeylessSigner } from \"./AbstractKeylessAccount\";\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { SingleKeyAccount, SingleKeySigner, SingleKeySignerOrLegacyEd25519Account } from \"./SingleKeyAccount\";\nimport { Ed25519Account } from \"./Ed25519Account\";\n\n/**\n * Arguments required to verify a multi-key signature against a given message.\n *\n * @param message - The original message that was signed.\n * @param signature - The multi-key signature to be verified.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport interface VerifyMultiKeySignatureArgs {\n message: HexInput;\n signature: MultiKeySignature;\n}\n\n/**\n * Signer implementation for the MultiKey authentication scheme.\n *\n * This account utilizes an M of N signing scheme, where M and N are specified in the {@link MultiKey}.\n * It signs messages using an array of M accounts, each corresponding to a public key in the {@link MultiKey}.\n *\n * Note: Generating a signer instance does not create the account on-chain.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport class MultiKeyAccount implements Account, KeylessSigner {\n /**\n * Public key associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly publicKey: MultiKey;\n\n /**\n * Account address associated with the account\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly accountAddress: AccountAddress;\n\n /**\n * Signing scheme used to sign transactions\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly signingScheme: SigningScheme = SigningScheme.MultiKey;\n\n /**\n * The signers used to sign messages. These signers should correspond to public keys in the\n * MultiKeyAccount's public key. The number of signers should be equal to this.publicKey.signaturesRequired.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n readonly signers: Account[];\n\n /**\n * An array of indices where for signer[i], signerIndicies[i] is the index of the corresponding public key in\n * publicKey.publicKeys. Used to derive the right public key to use for verification.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n // TODO: Rename Indicies to Indices\n readonly signerIndicies: number[];\n\n readonly signaturesBitmap: Uint8Array;\n\n /**\n * Constructs a MultiKeyAccount instance, which requires multiple signatures for transactions.\n *\n * @param args - The arguments for creating a MultiKeyAccount.\n * @param args.multiKey - The multikey of the account consisting of N public keys and a number M representing the required signatures.\n * @param args.signers - An array of M signers that will be used to sign the transaction.\n * @param args.address - An optional account address input. If not provided, the derived address from the public key will be used.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n constructor(args: {\n multiKey: MultiKey;\n signers: SingleKeySignerOrLegacyEd25519Account[];\n address?: AccountAddressInput;\n }) {\n const { multiKey, address } = args;\n\n const signers: SingleKeySigner[] = args.signers.map((signer) =>\n signer instanceof Ed25519Account ? SingleKeyAccount.fromEd25519Account(signer) : signer,\n );\n\n if (multiKey.signaturesRequired > signers.length) {\n throw new Error(\n // eslint-disable-next-line max-len\n `Not enough signers provided to satisfy the required signatures. Need ${multiKey.signaturesRequired} signers, but only ${signers.length} provided`,\n );\n } else if (multiKey.signaturesRequired < signers.length) {\n throw new Error(\n // eslint-disable-next-line max-len\n `More signers provided than required. Need ${multiKey.signaturesRequired} signers, but ${signers.length} provided`,\n );\n }\n\n this.publicKey = multiKey;\n\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n\n // For each signer, find its corresponding position in the MultiKey's public keys array\n const bitPositions: number[] = [];\n for (const signer of signers) {\n bitPositions.push(this.publicKey.getIndex(signer.getAnyPublicKey()));\n }\n\n // Create pairs of [signer, position] and sort them by position\n // This sorting is critical because:\n // 1. The on-chain verification expects signatures to be in ascending order by bit position\n // 2. The bitmap must match the order of signatures when verifying\n const signersAndBitPosition: [Account, number][] = signers.map((signer, index) => [signer, bitPositions[index]]);\n signersAndBitPosition.sort((a, b) => a[1] - b[1]);\n\n // Extract the sorted signers and their positions into separate arrays\n this.signers = signersAndBitPosition.map((value) => value[0]);\n this.signerIndicies = signersAndBitPosition.map((value) => value[1]);\n\n // Create a bitmap representing which public keys from the MultiKey are being used\n // This bitmap is used during signature verification to identify which public keys\n // should be used to verify each signature\n this.signaturesBitmap = this.publicKey.createBitmap({ bits: bitPositions });\n }\n\n /**\n * Static constructor to create a MultiKeyAccount using the provided public keys and signers.\n *\n * @param args - The arguments for creating a MultiKeyAccount.\n * @param args.publicKeys - The N public keys of the MultiKeyAccount.\n * @param args.signaturesRequired - The number of signatures required to authorize a transaction.\n * @param args.signers - An array of M signers that will be used to sign the transaction.\n * @returns MultiKeyAccount - The newly created MultiKeyAccount.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static fromPublicKeysAndSigners(args: {\n address?: AccountAddressInput;\n publicKeys: PublicKey[];\n signaturesRequired: number;\n signers: SingleKeySignerOrLegacyEd25519Account[];\n }): MultiKeyAccount {\n const { address, publicKeys, signaturesRequired, signers } = args;\n const multiKey = new MultiKey({ publicKeys, signaturesRequired });\n return new MultiKeyAccount({ multiKey, signers, address });\n }\n\n /**\n * Determines if the provided account is a multi-key account.\n *\n * @param account - The account to check.\n * @returns A boolean indicating whether the account is a multi-key account.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n static isMultiKeySigner(account: Account): account is MultiKeyAccount {\n return account instanceof MultiKeyAccount;\n }\n\n /**\n * Sign a message using the account's signers and return an AccountAuthenticator containing the signature along with the\n * account's public key.\n * @param message - The signing message, represented as binary input in hexadecimal format.\n * @returns An instance of AccountAuthenticatorMultiKey that includes the signature and the public key.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signWithAuthenticator(message: HexInput): AccountAuthenticatorMultiKey {\n return new AccountAuthenticatorMultiKey(this.publicKey, this.sign(message));\n }\n\n /**\n * Sign a transaction using the account's signers, returning an AccountAuthenticator that contains the signature and the\n * account's public key.\n * @param transaction - The raw transaction to be signed.\n * @returns An AccountAuthenticatorMultiKey containing the signature of the transaction along with the account's public key.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorMultiKey {\n return new AccountAuthenticatorMultiKey(this.publicKey, this.signTransaction(transaction));\n }\n\n /**\n * Waits for any proofs on KeylessAccount signers to be fetched. This ensures that signing with the KeylessAccount does not\n * fail due to missing proofs.\n * @return {Promise<void>} A promise that resolves when all proofs have been fetched.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n async waitForProofFetch(): Promise<void> {\n const keylessSigners = this.signers.filter(\n (signer) => signer instanceof AbstractKeylessAccount,\n ) as AbstractKeylessAccount[];\n const promises = keylessSigners.map(async (signer) => signer.waitForProofFetch());\n await Promise.all(promises);\n }\n\n /**\n * Validates that the Keyless Account can be used to sign transactions.\n * @return\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n async checkKeylessAccountValidity(aptosConfig: AptosConfig): Promise<void> {\n const keylessSigners = this.signers.filter(\n (signer) => signer instanceof AbstractKeylessAccount,\n ) as AbstractKeylessAccount[];\n const promises = keylessSigners.map((signer) => signer.checkKeylessAccountValidity(aptosConfig));\n await Promise.all(promises);\n }\n\n /**\n * Sign the given message using the MultiKeyAccount's signers\n * @param data - The data to be signed in HexInput format.\n * @returns MultiKeySignature\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n sign(data: HexInput): MultiKeySignature {\n const signatures = [];\n for (const signer of this.signers) {\n signatures.push(signer.sign(data));\n }\n return new MultiKeySignature({ signatures, bitmap: this.signaturesBitmap });\n }\n\n /**\n * Sign the given transaction using the MultiKeyAccount's signers.\n * This function aggregates signatures from all signers associated with the MultiKeyAccount.\n *\n * @param transaction - The transaction to be signed.\n * @returns MultiKeySignature - An object containing the aggregated signatures and a bitmap of the signatures.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n signTransaction(transaction: AnyRawTransaction): MultiKeySignature {\n const signatures = [];\n for (const signer of this.signers) {\n signatures.push(signer.signTransaction(transaction));\n }\n return new MultiKeySignature({ signatures, bitmap: this.signaturesBitmap });\n }\n\n /**\n * Verify the given message and signature with the public keys.\n *\n * This function checks if the provided signatures are valid for the given message using the corresponding public keys.\n * Note: If you are using KeylessAccounts, you must use `verifySignatureAsync` instead.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The raw message data in HexInput format.\n * @param args.signature - The signed message MultiKeySignature containing multiple signatures.\n * @returns A boolean indicating whether the signatures are valid for the message.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n verifySignature(args: { message: HexInput; signature: MultiKeySignature }): boolean {\n return this.publicKey.verifySignature(args);\n }\n\n /**\n * Verify the given message and signature with the public keys.\n *\n * This function checks if the provided signatures are valid for the given message using the corresponding public keys.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The raw message data in HexInput format.\n * @param args.signature - The signed message MultiKeySignature containing multiple signatures.\n * @param args.options.throwErrorWithReason - Whether to throw an error with the reason for the verification failure.\n * @returns A boolean indicating whether the signatures are valid for the message.\n * @group Implementation\n * @category Account (On-Chain Model)\n */\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: MultiKeySignature;\n options?: { throwErrorWithReason?: boolean };\n }): Promise<boolean> {\n return await this.publicKey.verifySignatureAsync(args);\n }\n}\n"],"mappings":"AAIA,OAAS,YAAAA,EAAU,qBAAAC,MAAoC,iBACvD,OAAS,kBAAAC,MAA2C,yBACpD,OAAmB,iBAAAC,MAAqB,WACxC,OAAS,gCAAAC,MAAoC,wCAE7C,OAAS,0BAAAC,MAA6C,2BAEtD,OAAS,oBAAAC,MAAgF,qBACzF,OAAS,kBAAAC,MAAsB,mBAyBxB,MAAMC,CAAkD,CAmD7D,YAAYC,EAIT,CAnCH,KAAS,cAA+BN,EAAc,SAoCpD,KAAM,CAAE,SAAAO,EAAU,QAAAC,CAAQ,EAAIF,EAExBG,EAA6BH,EAAK,QAAQ,IAAKI,GACnDA,aAAkBN,EAAiBD,EAAiB,mBAAmBO,CAAM,EAAIA,CACnF,EAEA,GAAIH,EAAS,mBAAqBE,EAAQ,OACxC,MAAM,IAAI,MAER,wEAAwEF,EAAS,kBAAkB,sBAAsBE,EAAQ,MAAM,WACzI,EACK,GAAIF,EAAS,mBAAqBE,EAAQ,OAC/C,MAAM,IAAI,MAER,6CAA6CF,EAAS,kBAAkB,iBAAiBE,EAAQ,MAAM,WACzG,EAGF,KAAK,UAAYF,EAEjB,KAAK,eAAiBC,EAAUT,EAAe,KAAKS,CAAO,EAAI,KAAK,UAAU,QAAQ,EAAE,eAAe,EAGvG,MAAMG,EAAyB,CAAC,EAChC,UAAWD,KAAUD,EACnBE,EAAa,KAAK,KAAK,UAAU,SAASD,EAAO,gBAAgB,CAAC,CAAC,EAOrE,MAAME,EAA6CH,EAAQ,IAAI,CAACC,EAAQG,IAAU,CAACH,EAAQC,EAAaE,CAAK,CAAC,CAAC,EAC/GD,EAAsB,KAAK,CAACE,EAAGC,IAAMD,EAAE,CAAC,EAAIC,EAAE,CAAC,CAAC,EAGhD,KAAK,QAAUH,EAAsB,IAAKI,GAAUA,EAAM,CAAC,CAAC,EAC5D,KAAK,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I,EAAa,CAAC,EACpB,UAAWf,KAAU,KAAK,QACxBe,EAAW,KAAKf,EAAO,gBAAgBW,CAAW,CAAC,EAErD,OAAO,IAAIvB,EAAkB,CAAE,WAAA2B,EAAY,OAAQ,KAAK,gBAAiB,CAAC,CAC5E,CAeA,gBAAgBnB,EAAoE,CAClF,OAAO,KAAK,UAAU,gBAAgBA,CAAI,CAC5C,CAeA,MAAM,qBAAqBA,EAKN,CACnB,OAAO,MAAM,KAAK,UAAU,qBAAqBA,CAAI,CACvD,CACF","names":["MultiKey","MultiKeySignature","AccountAddress","SigningScheme","AccountAuthenticatorMultiKey","AbstractKeylessAccount","SingleKeyAccount","Ed25519Account","MultiKeyAccount","args","multiKey","address","signers","signer","bitPositions","signersAndBitPosition","index","a","b","value","publicKeys","signaturesRequired","account","message","transaction","promises","aptosConfig","data","signatures"]}