@aptos-labs/ts-sdk 5.1.0 → 5.1.1-side-effect-free.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) 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 +14 -3
  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.mjs +1 -1
  41. package/dist/esm/api/account.mjs.map +1 -1
  42. package/dist/esm/api/ans.mjs +1 -1
  43. package/dist/esm/api/ans.mjs.map +1 -1
  44. package/dist/esm/api/aptos.mjs +1 -1
  45. package/dist/esm/api/aptos.mjs.map +1 -1
  46. package/dist/esm/api/aptosConfig.mjs +1 -1
  47. package/dist/esm/api/aptosConfig.mjs.map +1 -1
  48. package/dist/esm/api/coin.mjs +1 -1
  49. package/dist/esm/api/coin.mjs.map +1 -1
  50. package/dist/esm/api/digitalAsset.mjs +1 -1
  51. package/dist/esm/api/digitalAsset.mjs.map +1 -1
  52. package/dist/esm/api/faucet.mjs +1 -1
  53. package/dist/esm/api/faucet.mjs.map +1 -1
  54. package/dist/esm/api/fungibleAsset.mjs +1 -1
  55. package/dist/esm/api/fungibleAsset.mjs.map +1 -1
  56. package/dist/esm/api/general.mjs +1 -1
  57. package/dist/esm/api/general.mjs.map +1 -1
  58. package/dist/esm/api/index.mjs +1 -1
  59. package/dist/esm/api/index.mjs.map +1 -1
  60. package/dist/esm/api/keyless.mjs +1 -1
  61. package/dist/esm/api/keyless.mjs.map +1 -1
  62. package/dist/esm/api/object.mjs +1 -1
  63. package/dist/esm/api/object.mjs.map +1 -1
  64. package/dist/esm/api/staking.mjs +1 -1
  65. package/dist/esm/api/staking.mjs.map +1 -1
  66. package/dist/esm/api/table.mjs +1 -1
  67. package/dist/esm/api/table.mjs.map +1 -1
  68. package/dist/esm/api/transaction.mjs +1 -1
  69. package/dist/esm/api/transaction.mjs.map +1 -1
  70. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  71. package/dist/esm/api/transactionSubmission/build.mjs.map +1 -1
  72. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  73. package/dist/esm/api/transactionSubmission/helpers.mjs.map +1 -1
  74. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  75. package/dist/esm/api/transactionSubmission/management.mjs.map +1 -1
  76. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  77. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  78. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  79. package/dist/esm/api/transactionSubmission/simulate.mjs.map +1 -1
  80. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  81. package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -1
  82. package/dist/esm/api/utils.mjs +1 -1
  83. package/dist/esm/api/utils.mjs.map +1 -1
  84. package/dist/esm/bcs/consts.mjs +1 -1
  85. package/dist/esm/bcs/consts.mjs.map +1 -1
  86. package/dist/esm/bcs/deserializer.mjs +1 -1
  87. package/dist/esm/bcs/deserializer.mjs.map +1 -1
  88. package/dist/esm/bcs/index.mjs +1 -1
  89. package/dist/esm/bcs/index.mjs.map +1 -1
  90. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  91. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs.map +1 -1
  92. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  93. package/dist/esm/bcs/serializable/fixedBytes.mjs.map +1 -1
  94. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  95. package/dist/esm/bcs/serializable/movePrimitives.mjs.map +1 -1
  96. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  97. package/dist/esm/bcs/serializable/moveStructs.mjs.map +1 -1
  98. package/dist/esm/bcs/serializer.mjs +1 -1
  99. package/dist/esm/bcs/serializer.mjs.map +1 -1
  100. package/dist/esm/cli/index.mjs +1 -1
  101. package/dist/esm/cli/index.mjs.map +1 -1
  102. package/dist/esm/cli/localNode.mjs +1 -1
  103. package/dist/esm/cli/localNode.mjs.map +1 -1
  104. package/dist/esm/cli/move.mjs +1 -1
  105. package/dist/esm/cli/move.mjs.map +1 -1
  106. package/dist/esm/client/core.mjs +1 -1
  107. package/dist/esm/client/core.mjs.map +1 -1
  108. package/dist/esm/client/get.mjs +1 -1
  109. package/dist/esm/client/get.mjs.map +1 -1
  110. package/dist/esm/client/index.mjs +1 -1
  111. package/dist/esm/client/index.mjs.map +1 -1
  112. package/dist/esm/client/post.mjs +1 -1
  113. package/dist/esm/client/post.mjs.map +1 -1
  114. package/dist/esm/core/account/index.d.mts +1 -1
  115. package/dist/esm/core/account/index.mjs +1 -1
  116. package/dist/esm/core/account/index.mjs.map +1 -1
  117. package/dist/esm/core/account/utils/address.d.mts +12 -1
  118. package/dist/esm/core/account/utils/address.mjs +1 -1
  119. package/dist/esm/core/account/utils/address.mjs.map +1 -1
  120. package/dist/esm/core/account/utils/index.d.mts +1 -1
  121. package/dist/esm/core/account/utils/index.mjs +1 -1
  122. package/dist/esm/core/account/utils/index.mjs.map +1 -1
  123. package/dist/esm/core/accountAddress.mjs +3 -1
  124. package/dist/esm/core/accountAddress.mjs.map +1 -1
  125. package/dist/esm/core/authenticationKey.mjs +1 -1
  126. package/dist/esm/core/authenticationKey.mjs.map +1 -1
  127. package/dist/esm/core/common.mjs +1 -1
  128. package/dist/esm/core/common.mjs.map +1 -1
  129. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  130. package/dist/esm/core/crypto/abstraction.mjs.map +1 -1
  131. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  132. package/dist/esm/core/crypto/deserializationUtils.mjs.map +1 -1
  133. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  134. package/dist/esm/core/crypto/ed25519.mjs.map +1 -1
  135. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  136. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -1
  137. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  138. package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -1
  139. package/dist/esm/core/crypto/hdKey.mjs +1 -1
  140. package/dist/esm/core/crypto/hdKey.mjs.map +1 -1
  141. package/dist/esm/core/crypto/index.mjs +1 -1
  142. package/dist/esm/core/crypto/index.mjs.map +1 -1
  143. package/dist/esm/core/crypto/keyless.mjs +1 -1
  144. package/dist/esm/core/crypto/keyless.mjs.map +1 -1
  145. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  146. package/dist/esm/core/crypto/multiEd25519.mjs.map +1 -1
  147. package/dist/esm/core/crypto/multiKey.mjs +3 -1
  148. package/dist/esm/core/crypto/multiKey.mjs.map +1 -1
  149. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  150. package/dist/esm/core/crypto/poseidon.mjs.map +1 -1
  151. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  152. package/dist/esm/core/crypto/privateKey.mjs.map +1 -1
  153. package/dist/esm/core/crypto/proof.mjs +1 -1
  154. package/dist/esm/core/crypto/proof.mjs.map +1 -1
  155. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  156. package/dist/esm/core/crypto/publicKey.mjs.map +1 -1
  157. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  158. package/dist/esm/core/crypto/secp256k1.mjs.map +1 -1
  159. package/dist/esm/core/crypto/secp256r1.mjs +1 -1
  160. package/dist/esm/core/crypto/secp256r1.mjs.map +1 -1
  161. package/dist/esm/core/crypto/signature.mjs +1 -1
  162. package/dist/esm/core/crypto/signature.mjs.map +1 -1
  163. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  164. package/dist/esm/core/crypto/singleKey.mjs.map +1 -1
  165. package/dist/esm/core/crypto/types.mjs +0 -1
  166. package/dist/esm/core/crypto/utils.mjs +1 -1
  167. package/dist/esm/core/crypto/utils.mjs.map +1 -1
  168. package/dist/esm/core/hex.mjs +1 -1
  169. package/dist/esm/core/hex.mjs.map +1 -1
  170. package/dist/esm/core/index.d.mts +1 -1
  171. package/dist/esm/core/index.mjs +1 -1
  172. package/dist/esm/core/index.mjs.map +1 -1
  173. package/dist/esm/errors/index.mjs +6 -1
  174. package/dist/esm/errors/index.mjs.map +1 -1
  175. package/dist/esm/index.d.mts +1 -1
  176. package/dist/esm/index.mjs +1 -1
  177. package/dist/esm/index.mjs.map +1 -1
  178. package/dist/esm/internal/abstraction.mjs +1 -1
  179. package/dist/esm/internal/abstraction.mjs.map +1 -1
  180. package/dist/esm/internal/account.mjs +1 -1
  181. package/dist/esm/internal/account.mjs.map +1 -1
  182. package/dist/esm/internal/ans.mjs +1 -1
  183. package/dist/esm/internal/ans.mjs.map +1 -1
  184. package/dist/esm/internal/coin.mjs +1 -1
  185. package/dist/esm/internal/coin.mjs.map +1 -1
  186. package/dist/esm/internal/digitalAsset.mjs +1 -1
  187. package/dist/esm/internal/digitalAsset.mjs.map +1 -1
  188. package/dist/esm/internal/faucet.mjs +1 -1
  189. package/dist/esm/internal/faucet.mjs.map +1 -1
  190. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  191. package/dist/esm/internal/fungibleAsset.mjs.map +1 -1
  192. package/dist/esm/internal/general.mjs +1 -1
  193. package/dist/esm/internal/general.mjs.map +1 -1
  194. package/dist/esm/internal/keyless.mjs +1 -1
  195. package/dist/esm/internal/keyless.mjs.map +1 -1
  196. package/dist/esm/internal/object.mjs +1 -1
  197. package/dist/esm/internal/object.mjs.map +1 -1
  198. package/dist/esm/internal/staking.mjs +1 -1
  199. package/dist/esm/internal/staking.mjs.map +1 -1
  200. package/dist/esm/internal/table.mjs +1 -1
  201. package/dist/esm/internal/table.mjs.map +1 -1
  202. package/dist/esm/internal/transaction.mjs +1 -1
  203. package/dist/esm/internal/transaction.mjs.map +1 -1
  204. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  205. package/dist/esm/internal/transactionSubmission.mjs.map +1 -1
  206. package/dist/esm/internal/utils/index.mjs +1 -1
  207. package/dist/esm/internal/utils/index.mjs.map +1 -1
  208. package/dist/esm/internal/utils/utils.mjs +1 -1
  209. package/dist/esm/internal/utils/utils.mjs.map +1 -1
  210. package/dist/esm/internal/view.mjs +1 -1
  211. package/dist/esm/internal/view.mjs.map +1 -1
  212. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  213. package/dist/esm/transactions/authenticator/account.mjs.map +1 -1
  214. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  215. package/dist/esm/transactions/authenticator/index.mjs.map +1 -1
  216. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  217. package/dist/esm/transactions/authenticator/transaction.mjs.map +1 -1
  218. package/dist/esm/transactions/index.mjs +1 -1
  219. package/dist/esm/transactions/index.mjs.map +1 -1
  220. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  221. package/dist/esm/transactions/instances/chainId.mjs.map +1 -1
  222. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  223. package/dist/esm/transactions/instances/identifier.mjs.map +1 -1
  224. package/dist/esm/transactions/instances/index.mjs +1 -1
  225. package/dist/esm/transactions/instances/index.mjs.map +1 -1
  226. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  227. package/dist/esm/transactions/instances/moduleId.mjs.map +1 -1
  228. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  229. package/dist/esm/transactions/instances/multiAgentTransaction.mjs.map +1 -1
  230. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  231. package/dist/esm/transactions/instances/rawTransaction.mjs.map +1 -1
  232. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  233. package/dist/esm/transactions/instances/rotationProofChallenge.mjs.map +1 -1
  234. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  235. package/dist/esm/transactions/instances/signedTransaction.mjs.map +1 -1
  236. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  237. package/dist/esm/transactions/instances/simpleTransaction.mjs.map +1 -1
  238. package/dist/esm/transactions/instances/transactionArgument.mjs +0 -1
  239. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  240. package/dist/esm/transactions/instances/transactionPayload.mjs.map +1 -1
  241. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  242. package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -1
  243. package/dist/esm/transactions/management/asyncQueue.mjs +1 -1
  244. package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -1
  245. package/dist/esm/transactions/management/index.mjs +1 -1
  246. package/dist/esm/transactions/management/index.mjs.map +1 -1
  247. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  248. package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -1
  249. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  250. package/dist/esm/transactions/transactionBuilder/helpers.mjs.map +1 -1
  251. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  252. package/dist/esm/transactions/transactionBuilder/index.mjs.map +1 -1
  253. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  254. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs.map +1 -1
  255. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  256. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -1
  257. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  258. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs.map +1 -1
  259. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  260. package/dist/esm/transactions/typeTag/index.mjs.map +1 -1
  261. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  262. package/dist/esm/transactions/typeTag/parser.mjs.map +1 -1
  263. package/dist/esm/transactions/types.mjs +0 -1
  264. package/dist/esm/types/abstraction.mjs +1 -1
  265. package/dist/esm/types/abstraction.mjs.map +1 -1
  266. package/dist/esm/types/generated/queries.mjs +493 -1
  267. package/dist/esm/types/generated/queries.mjs.map +1 -1
  268. package/dist/esm/types/generated/types.mjs +1 -1
  269. package/dist/esm/types/generated/types.mjs.map +1 -1
  270. package/dist/esm/types/index.mjs +1 -1
  271. package/dist/esm/types/index.mjs.map +1 -1
  272. package/dist/esm/types/indexer.mjs +0 -1
  273. package/dist/esm/types/types.mjs +1 -1
  274. package/dist/esm/types/types.mjs.map +1 -1
  275. package/dist/esm/utils/apiEndpoints.d.mts +1 -0
  276. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  277. package/dist/esm/utils/apiEndpoints.mjs.map +1 -1
  278. package/dist/esm/utils/const.mjs +1 -1
  279. package/dist/esm/utils/const.mjs.map +1 -1
  280. package/dist/esm/utils/helpers.mjs +1 -1
  281. package/dist/esm/utils/helpers.mjs.map +1 -1
  282. package/dist/esm/utils/index.mjs +1 -1
  283. package/dist/esm/utils/index.mjs.map +1 -1
  284. package/dist/esm/utils/memoize.mjs +1 -1
  285. package/dist/esm/utils/memoize.mjs.map +1 -1
  286. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  287. package/dist/esm/utils/normalizeBundle.mjs.map +1 -1
  288. package/dist/esm/version.d.mts +1 -1
  289. package/dist/esm/version.mjs +1 -1
  290. package/dist/esm/version.mjs.map +1 -1
  291. package/package.json +39 -20
  292. package/src/api/aptos.ts +25 -14
  293. package/src/core/account/utils/address.ts +22 -0
  294. package/src/internal/ans.ts +1 -0
  295. package/src/utils/apiEndpoints.ts +7 -0
  296. package/src/version.ts +1 -1
  297. package/dist/common/chunk-A2XB7TVI.js +0 -4
  298. package/dist/esm/chunk-2PASUPUO.mjs +0 -2
  299. package/dist/esm/chunk-2PASUPUO.mjs.map +0 -1
  300. package/dist/esm/chunk-2XQKGWHQ.mjs +0 -2
  301. package/dist/esm/chunk-2XQKGWHQ.mjs.map +0 -1
  302. package/dist/esm/chunk-35DKMW7Q.mjs +0 -2
  303. package/dist/esm/chunk-35DKMW7Q.mjs.map +0 -1
  304. package/dist/esm/chunk-4AI7KQQ7.mjs +0 -2
  305. package/dist/esm/chunk-4AI7KQQ7.mjs.map +0 -1
  306. package/dist/esm/chunk-4QMXOWHP.mjs +0 -1
  307. package/dist/esm/chunk-4QMXOWHP.mjs.map +0 -1
  308. package/dist/esm/chunk-4RXKALLC.mjs +0 -2
  309. package/dist/esm/chunk-4RXKALLC.mjs.map +0 -1
  310. package/dist/esm/chunk-4WPQQPUF.mjs +0 -1
  311. package/dist/esm/chunk-4WPQQPUF.mjs.map +0 -1
  312. package/dist/esm/chunk-56CNRT2K.mjs +0 -2
  313. package/dist/esm/chunk-56CNRT2K.mjs.map +0 -1
  314. package/dist/esm/chunk-5HXLZHDW.mjs +0 -1
  315. package/dist/esm/chunk-5HXLZHDW.mjs.map +0 -1
  316. package/dist/esm/chunk-6OWBKU7N.mjs +0 -2
  317. package/dist/esm/chunk-6OWBKU7N.mjs.map +0 -1
  318. package/dist/esm/chunk-6WDVDEQZ.mjs +0 -7
  319. package/dist/esm/chunk-6WDVDEQZ.mjs.map +0 -1
  320. package/dist/esm/chunk-7DQDJ2SA.mjs +0 -2
  321. package/dist/esm/chunk-7DQDJ2SA.mjs.map +0 -1
  322. package/dist/esm/chunk-7ECCT6PK.mjs +0 -1
  323. package/dist/esm/chunk-7ECCT6PK.mjs.map +0 -1
  324. package/dist/esm/chunk-7EER7GWV.mjs +0 -2
  325. package/dist/esm/chunk-7EER7GWV.mjs.map +0 -1
  326. package/dist/esm/chunk-A5L76YP7.mjs +0 -2
  327. package/dist/esm/chunk-A5L76YP7.mjs.map +0 -1
  328. package/dist/esm/chunk-AMXZQPUQ.mjs +0 -2
  329. package/dist/esm/chunk-AMXZQPUQ.mjs.map +0 -1
  330. package/dist/esm/chunk-B563XRSZ.mjs +0 -2
  331. package/dist/esm/chunk-B563XRSZ.mjs.map +0 -1
  332. package/dist/esm/chunk-C3Q23D22.mjs +0 -2
  333. package/dist/esm/chunk-C3Q23D22.mjs.map +0 -1
  334. package/dist/esm/chunk-CIJA7ONS.mjs +0 -2
  335. package/dist/esm/chunk-CIJA7ONS.mjs.map +0 -1
  336. package/dist/esm/chunk-CW35YAMN.mjs +0 -2
  337. package/dist/esm/chunk-CW35YAMN.mjs.map +0 -1
  338. package/dist/esm/chunk-EBMEXURY.mjs +0 -2
  339. package/dist/esm/chunk-EBMEXURY.mjs.map +0 -1
  340. package/dist/esm/chunk-EF4FA5I6.mjs +0 -2
  341. package/dist/esm/chunk-EF4FA5I6.mjs.map +0 -1
  342. package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
  343. package/dist/esm/chunk-FD6FGKYY.mjs.map +0 -1
  344. package/dist/esm/chunk-FGFLPH5K.mjs +0 -2
  345. package/dist/esm/chunk-FGFLPH5K.mjs.map +0 -1
  346. package/dist/esm/chunk-FLZPUYXQ.mjs +0 -2
  347. package/dist/esm/chunk-FLZPUYXQ.mjs.map +0 -1
  348. package/dist/esm/chunk-FZY4PMEE.mjs +0 -1
  349. package/dist/esm/chunk-FZY4PMEE.mjs.map +0 -1
  350. package/dist/esm/chunk-G3MHXDYA.mjs +0 -1
  351. package/dist/esm/chunk-G3MHXDYA.mjs.map +0 -1
  352. package/dist/esm/chunk-GOXRBEIJ.mjs +0 -2
  353. package/dist/esm/chunk-GOXRBEIJ.mjs.map +0 -1
  354. package/dist/esm/chunk-HGLO5LDS.mjs +0 -1
  355. package/dist/esm/chunk-HGLO5LDS.mjs.map +0 -1
  356. package/dist/esm/chunk-HNBVYE3N.mjs +0 -2
  357. package/dist/esm/chunk-HNBVYE3N.mjs.map +0 -1
  358. package/dist/esm/chunk-I7XT6L7S.mjs +0 -2
  359. package/dist/esm/chunk-I7XT6L7S.mjs.map +0 -1
  360. package/dist/esm/chunk-IF4UU2MT.mjs +0 -2
  361. package/dist/esm/chunk-IF4UU2MT.mjs.map +0 -1
  362. package/dist/esm/chunk-JABP65XD.mjs +0 -2
  363. package/dist/esm/chunk-JABP65XD.mjs.map +0 -1
  364. package/dist/esm/chunk-KDMSOCZY.mjs +0 -2
  365. package/dist/esm/chunk-KDMSOCZY.mjs.map +0 -1
  366. package/dist/esm/chunk-L72TIN7T.mjs +0 -4
  367. package/dist/esm/chunk-L72TIN7T.mjs.map +0 -1
  368. package/dist/esm/chunk-M3AO73ZL.mjs +0 -2
  369. package/dist/esm/chunk-M3AO73ZL.mjs.map +0 -1
  370. package/dist/esm/chunk-MCFQE4GC.mjs +0 -2
  371. package/dist/esm/chunk-MCFQE4GC.mjs.map +0 -1
  372. package/dist/esm/chunk-MT2RJ7H3.mjs +0 -2
  373. package/dist/esm/chunk-MT2RJ7H3.mjs.map +0 -1
  374. package/dist/esm/chunk-N6YTF76Q.mjs +0 -2
  375. package/dist/esm/chunk-N6YTF76Q.mjs.map +0 -1
  376. package/dist/esm/chunk-NECL5FCQ.mjs +0 -1
  377. package/dist/esm/chunk-NECL5FCQ.mjs.map +0 -1
  378. package/dist/esm/chunk-OLILO7VD.mjs +0 -2
  379. package/dist/esm/chunk-OLILO7VD.mjs.map +0 -1
  380. package/dist/esm/chunk-ORMOQWWH.mjs +0 -2
  381. package/dist/esm/chunk-ORMOQWWH.mjs.map +0 -1
  382. package/dist/esm/chunk-Q4W3WJ2U.mjs +0 -2
  383. package/dist/esm/chunk-Q4W3WJ2U.mjs.map +0 -1
  384. package/dist/esm/chunk-QP2BY4PK.mjs +0 -2
  385. package/dist/esm/chunk-QP2BY4PK.mjs.map +0 -1
  386. package/dist/esm/chunk-QREVMGQZ.mjs +0 -2
  387. package/dist/esm/chunk-QREVMGQZ.mjs.map +0 -1
  388. package/dist/esm/chunk-RCSJFTST.mjs +0 -2
  389. package/dist/esm/chunk-RCSJFTST.mjs.map +0 -1
  390. package/dist/esm/chunk-RGKRCZ36.mjs +0 -4
  391. package/dist/esm/chunk-RGKRCZ36.mjs.map +0 -1
  392. package/dist/esm/chunk-SJDCGNWU.mjs +0 -2
  393. package/dist/esm/chunk-SJDCGNWU.mjs.map +0 -1
  394. package/dist/esm/chunk-STY74NUA.mjs +0 -2
  395. package/dist/esm/chunk-STY74NUA.mjs.map +0 -1
  396. package/dist/esm/chunk-TOBQ5UE6.mjs +0 -2
  397. package/dist/esm/chunk-TOBQ5UE6.mjs.map +0 -1
  398. package/dist/esm/chunk-UL777LTI.mjs +0 -494
  399. package/dist/esm/chunk-UL777LTI.mjs.map +0 -1
  400. package/dist/esm/chunk-UYVPNUH3.mjs +0 -1
  401. package/dist/esm/chunk-UYVPNUH3.mjs.map +0 -1
  402. package/dist/esm/chunk-V3MBJJTL.mjs +0 -1
  403. package/dist/esm/chunk-V3MBJJTL.mjs.map +0 -1
  404. package/dist/esm/chunk-WCMW2L3P.mjs +0 -2
  405. package/dist/esm/chunk-WCMW2L3P.mjs.map +0 -1
  406. package/dist/esm/chunk-WHSTLR3F.mjs +0 -2
  407. package/dist/esm/chunk-WHSTLR3F.mjs.map +0 -1
  408. package/dist/esm/chunk-WSR5EBJM.mjs +0 -2
  409. package/dist/esm/chunk-WSR5EBJM.mjs.map +0 -1
  410. package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
  411. package/dist/esm/chunk-XJJVJOX5.mjs.map +0 -1
  412. package/dist/esm/chunk-XKUIMGKU.mjs +0 -2
  413. package/dist/esm/chunk-XKUIMGKU.mjs.map +0 -1
  414. package/dist/esm/chunk-YOZBVVKL.mjs +0 -2
  415. package/dist/esm/chunk-YOZBVVKL.mjs.map +0 -1
  416. package/dist/esm/chunk-ZP4DWSQA.mjs +0 -2
  417. package/dist/esm/chunk-ZP4DWSQA.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-2PASUPUO.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as PrivateKey};
1
+ import{PrivateKeyVariants as p}from"../../types";import{Hex as a}from"../hex";const r=class r{static formatPrivateKey(e,n){const i=r.AIP80_PREFIXES[n];let t=e;return typeof t=="string"&&t.startsWith(i)&&(t=t.split("-")[2]),`${i}${a.fromHexInput(t).toString()}`}static parseHexInput(e,n,i){let t;const s=r.AIP80_PREFIXES[n];if(typeof e=="string")if(!i&&!e.startsWith(s))t=a.fromHexInput(e),i!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(s))t=a.fromHexString(e.split("-")[2]);else throw i?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else t=a.fromHexInput(e);return t}};r.AIP80_PREFIXES={[p.Ed25519]:"ed25519-priv-",[p.Secp256k1]:"secp256k1-priv-",[p.Secp256r1]:"secp256r1-priv-"};let o=r;export{o as PrivateKey};
2
2
  //# sourceMappingURL=privateKey.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/privateKey.ts"],"sourcesContent":["/* eslint-disable max-len */\n\nimport { HexInput, PrivateKeyVariants } from \"../../types\";\nimport { Hex } from \"../hex\";\nimport { PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\n\n/**\n * Represents a private key used for signing messages and deriving the associated public key.\n * @group Implementation\n * @category Serialization\n */\nexport interface PrivateKey {\n /**\n * Sign the given message with the private key to create a signature.\n * @param message - The message to be signed, provided in HexInput format.\n * @returns A Signature object representing the signed message.\n * @group Implementation\n * @category Serialization\n */\n sign(message: HexInput): Signature;\n\n /**\n * Derive the public key associated with the private key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): PublicKey;\n\n /**\n * Get the private key in bytes (Uint8Array).\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array;\n}\n\nexport class PrivateKey {\n /**\n * The AIP-80 compliant prefixes for each private key type. Append this to a private key's hex representation\n * to get an AIP-80 compliant string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n */\n public static readonly AIP80_PREFIXES = {\n [PrivateKeyVariants.Ed25519]: \"ed25519-priv-\",\n [PrivateKeyVariants.Secp256k1]: \"secp256k1-priv-\",\n [PrivateKeyVariants.Secp256r1]: \"secp256r1-priv-\",\n };\n\n /**\n * Format a HexInput to an AIP-80 compliant string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param privateKey - The HexString or Uint8Array format of the private key.\n * @param privateKeyType - The private key type\n */\n public static formatPrivateKey(privateKey: HexInput, type: PrivateKeyVariants): string {\n const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];\n\n // Remove the prefix if it exists\n let formattedPrivateKey = privateKey;\n if (typeof formattedPrivateKey === \"string\" && formattedPrivateKey.startsWith(aip80Prefix)) {\n // eslint-disable-next-line prefer-destructuring\n formattedPrivateKey = formattedPrivateKey.split(\"-\")[2];\n }\n\n return `${aip80Prefix}${Hex.fromHexInput(formattedPrivateKey).toString()}`;\n }\n\n /**\n * Parse a HexInput that may be a HexString, Uint8Array, or a AIP-80 compliant string to a Hex instance.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param value - A HexString, Uint8Array, or a AIP-80 compliant string.\n * @param privateKeyType - The private key type\n * @param strict - If true, the value MUST be compliant with AIP-80.\n */\n public static parseHexInput(value: HexInput, type: PrivateKeyVariants, strict?: boolean): Hex {\n let data: Hex;\n\n const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];\n if (typeof value === \"string\") {\n if (!strict && !value.startsWith(aip80Prefix)) {\n // HexString input\n data = Hex.fromHexInput(value);\n // If the strictness is false, the user has opted into non-AIP-80 compliant private keys.\n if (strict !== false) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.\",\n );\n }\n } else if (value.startsWith(aip80Prefix)) {\n // AIP-80 Compliant String input\n data = Hex.fromHexString(value.split(\"-\")[2]);\n } else {\n if (strict) {\n // The value does not start with the AIP-80 prefix, and strict is true.\n throw new Error(\"Invalid HexString input while parsing private key. Must AIP-80 compliant string.\");\n }\n\n // This condition should never be reached.\n throw new Error(\"Invalid HexString input while parsing private key.\");\n }\n } else {\n // The value is an Uint8Array\n data = Hex.fromHexInput(value);\n }\n\n return data;\n }\n}\n"],"mappings":"AAEA,OAAmB,sBAAAA,MAA0B,cAC7C,OAAS,OAAAC,MAAW,SAkCb,MAAMC,EAAN,MAAMA,CAAW,CAqBtB,OAAc,iBAAiBC,EAAsBC,EAAkC,CACrF,MAAMC,EAAcH,EAAW,eAAeE,CAAI,EAGlD,IAAIE,EAAsBH,EAC1B,OAAI,OAAOG,GAAwB,UAAYA,EAAoB,WAAWD,CAAW,IAEvFC,EAAsBA,EAAoB,MAAM,GAAG,EAAE,CAAC,GAGjD,GAAGD,CAAW,GAAGJ,EAAI,aAAaK,CAAmB,EAAE,SAAS,CAAC,EAC1E,CAWA,OAAc,cAAcC,EAAiBH,EAA0BI,EAAuB,CAC5F,IAAIC,EAEJ,MAAMJ,EAAcH,EAAW,eAAeE,CAAI,EAClD,GAAI,OAAOG,GAAU,SACnB,GAAI,CAACC,GAAU,CAACD,EAAM,WAAWF,CAAW,EAE1CI,EAAOR,EAAI,aAAaM,CAAK,EAEzBC,IAAW,IAEb,QAAQ,KACN,uRACF,UAEOD,EAAM,WAAWF,CAAW,EAErCI,EAAOR,EAAI,cAAcM,EAAM,MAAM,GAAG,EAAE,CAAC,CAAC,MAE5C,OAAIC,EAEI,IAAI,MAAM,kFAAkF,EAI9F,IAAI,MAAM,oDAAoD,OAItEC,EAAOR,EAAI,aAAaM,CAAK,EAG/B,OAAOE,CACT,CACF,EA7EaP,EAOY,eAAiB,CACtC,CAACF,EAAmB,OAAO,EAAG,gBAC9B,CAACA,EAAmB,SAAS,EAAG,kBAChC,CAACA,EAAmB,SAAS,EAAG,iBAClC,EAXK,IAAMU,EAANR","names":["PrivateKeyVariants","Hex","_PrivateKey","privateKey","type","aip80Prefix","formattedPrivateKey","value","strict","data","PrivateKey"]}
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-XJJVJOX5.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-KDMSOCZY.mjs";export{a as Proof};
1
+ import{Serializable as r}from"../../bcs";class o extends r{}export{o as Proof};
2
2
  //# sourceMappingURL=proof.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/proof.ts"],"sourcesContent":["import { Serializable } from \"../../bcs\";\n\n/**\n * An abstract representation of a cryptographic proof associated with specific\n * zero-knowledge proof schemes, such as Groth16 and PLONK.\n * @group Implementation\n * @category Serialization\n */\nexport abstract class Proof extends Serializable {}\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,YAQtB,MAAeC,UAAcD,CAAa,CAAC","names":["Serializable","Proof"]}
@@ -1,2 +1,2 @@
1
- import{a,b}from"../../chunk-WSR5EBJM.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-KDMSOCZY.mjs";export{b as AccountPublicKey,a as PublicKey};
1
+ import{Serializable as e}from"../../bcs";import{Hex as i}from"../hex";class n extends e{async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.bcsToBytes()}toString(){const t=this.toUint8Array();return i.fromHexInput(t).toString()}}class m extends n{}export{m as AccountPublicKey,n as PublicKey};
2
2
  //# sourceMappingURL=publicKey.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/publicKey.ts"],"sourcesContent":["import { AptosConfig } from \"../../api\";\nimport { Serializable } from \"../../bcs\";\nimport { HexInput } from \"../../types\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Hex } from \"../hex\";\nimport { Signature } from \"./signature\";\n\n/**\n * Represents the arguments required to verify a digital signature.\n *\n * @param message - The original message that was signed.\n * @param signature - The signature to be verified against the message.\n * @group Implementation\n * @category Serialization\n */\nexport interface VerifySignatureArgs {\n message: HexInput;\n signature: Signature;\n}\n\n/**\n * Represents the arguments required to verify a digital signature asynchronously.\n *\n * The validity of certain types of signatures are dependent on network state. This is the case for\n * Keyless signatures which need to lookup the verification key and keyless configuration.\n *\n * @param aptosConfig - The Aptos configuration to use\n * @param message - The original message that was signed.\n * @param signature - The signature to be verified against the message.\n * @group Implementation\n * @category Serialization\n */\nexport type VerifySignatureAsyncArgs = VerifySignatureArgs & {\n aptosConfig: AptosConfig;\n options?: any;\n};\n\n/**\n * Represents an abstract public key.\n *\n * This class provides a common interface for verifying signatures associated with the public key.\n * It allows for the retrieval of the raw public key bytes and the public key in a hexadecimal string format.\n * @group Implementation\n * @category Serialization\n */\nexport abstract class PublicKey extends Serializable {\n /**\n * Verifies that the private key associated with this public key signed the message with the given signature.\n * @param args.message The message that was signed\n * @param args.signature The signature to verify\n * @group Implementation\n * @category Serialization\n */\n abstract verifySignature(args: VerifySignatureArgs): boolean;\n\n /**\n * Verifies signature with the public key and makes any network calls required to get state required to verify the signature.\n * @param args.aptosConfig The Aptos configuration\n * @param args.message The message that was signed\n * @param args.signature The signature to verify\n * @group Implementation\n * @category Serialization\n */\n async verifySignatureAsync(args: VerifySignatureAsyncArgs): Promise<boolean> {\n return this.verifySignature(args);\n }\n\n /**\n * Get the raw public key bytes\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n /**\n * Get the public key as a hex string with a 0x prefix.\n *\n * @returns The public key in hex format.\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n const bytes = this.toUint8Array();\n return Hex.fromHexInput(bytes).toString();\n }\n}\n\n/**\n * An abstract representation of an account public key.\n *\n * Provides a common interface for deriving an authentication key.\n *\n * @abstract\n * @group Implementation\n * @category Serialization\n */\nexport abstract class AccountPublicKey extends PublicKey {\n /**\n * Get the authentication key associated with this public key\n * @group Implementation\n * @category Serialization\n */\n abstract authKey(): AuthenticationKey;\n}\n"],"mappings":"AACA,OAAS,gBAAAA,MAAoB,YAG7B,OAAS,OAAAC,MAAW,SAyCb,MAAeC,UAAkBF,CAAa,CAkBnD,MAAM,qBAAqBG,EAAkD,CAC3E,OAAO,KAAK,gBAAgBA,CAAI,CAClC,CAOA,cAA2B,CACzB,OAAO,KAAK,WAAW,CACzB,CASA,UAAmB,CACjB,MAAMC,EAAQ,KAAK,aAAa,EAChC,OAAOH,EAAI,aAAaG,CAAK,EAAE,SAAS,CAC1C,CACF,CAWO,MAAeC,UAAyBH,CAAU,CAOzD","names":["Serializable","Hex","PublicKey","args","bytes","AccountPublicKey"]}
@@ -1,2 +1,2 @@
1
- import{C as a,D as b,E 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 Secp256k1PrivateKey,a as Secp256k1PublicKey,c as Secp256k1Signature};
1
+ import{sha3_256 as p}from"@noble/hashes/sha3";import{secp256k1 as y}from"@noble/curves/secp256k1";import{HDKey as H}from"@scure/bip32";import{Serializable as P}from"../../bcs";import{Hex as l}from"../hex";import{PrivateKeyVariants as m}from"../../types";import{isValidBIP44Path as k,mnemonicToSeed as x}from"./hdKey";import{PrivateKey as g}from"./privateKey";import{PublicKey as A}from"./publicKey";import{Signature as z}from"./signature";import{convertSigningMessage as f}from"./utils";const i=class i extends A{constructor(e){super();this.keyType="secp256k1";const r=l.fromHexInput(e),{length:s}=r.toUint8Array();if(s===i.LENGTH)this.key=r;else if(s===i.COMPRESSED_LENGTH){const o=y.ProjectivePoint.fromHex(r.toUint8Array());this.key=l.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${i.LENGTH} or ${i.COMPRESSED_LENGTH}, received ${s}`)}verifySignature(e){const{message:r,signature:s}=e,o=f(r),d=l.fromHexInput(o).toUint8Array(),S=p(d),v=s.toUint8Array();return y.verify(v,S,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){const r=e.deserializeBytes();return new c(r)}static deserialize(e){const r=e.deserializeBytes();return new i(r)}static isPublicKey(e){return e instanceof i}static isInstance(e){return"key"in e&&e.key?.data?.length===i.LENGTH&&"keyType"in e&&e.keyType==="secp256k1"}};i.LENGTH=65,i.COMPRESSED_LENGTH=33;let u=i;const n=class n extends P{constructor(t,e){super();const r=g.parseHexInput(t,m.Secp256k1,e);if(r.toUint8Array().length!==n.LENGTH)throw new Error(`PrivateKey length should be ${n.LENGTH}`);this.key=r}static generate(){const t=y.utils.randomPrivateKey();return new n(t,!1)}static fromDerivationPath(t,e){if(!k(t))throw new Error(`Invalid derivation path ${t}`);return n.fromDerivationPathInner(t,x(e))}static fromDerivationPathInner(t,e){const{privateKey:r}=H.fromMasterSeed(e).derive(t);if(r===null)throw new Error("Invalid key");return new n(r,!1)}sign(t){const e=f(t),r=l.fromHexInput(e),s=p(r.toUint8Array()),o=y.sign(s,this.key.toUint8Array(),{lowS:!0});return new c(o.toCompactRawBytes())}publicKey(){const t=y.getPublicKey(this.key.toUint8Array(),!1);return new u(t)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return g.formatPrivateKey(this.key.toString(),m.Secp256k1)}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){const e=t.deserializeBytes();return new n(e,!1)}static isPrivateKey(t){return t instanceof n}};n.LENGTH=32;let h=n;const a=class a extends z{constructor(t){super();const e=l.fromHexInput(t);if(e.toUint8Array().length!==a.LENGTH)throw new Error(`Signature length should be ${a.LENGTH}, received ${e.toUint8Array().length}`);this.data=e}toUint8Array(){return this.data.toUint8Array()}serialize(t){t.serializeBytes(this.data.toUint8Array())}static deserialize(t){const e=t.deserializeBytes();return new a(e)}};a.LENGTH=64;let c=a;export{h as Secp256k1PrivateKey,u as Secp256k1PublicKey,c as Secp256k1Signature};
2
2
  //# sourceMappingURL=secp256k1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/secp256k1.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { sha3_256 } from \"@noble/hashes/sha3\";\nimport { secp256k1 } from \"@noble/curves/secp256k1\";\nimport { HDKey } from \"@scure/bip32\";\nimport { Serializable, Deserializer, Serializer } from \"../../bcs\";\nimport { Hex } from \"../hex\";\nimport { HexInput, PrivateKeyVariants } from \"../../types\";\nimport { isValidBIP44Path, mnemonicToSeed } from \"./hdKey\";\nimport { PrivateKey } from \"./privateKey\";\nimport { PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { convertSigningMessage } from \"./utils\";\nimport { AptosConfig } from \"../../api\";\n\n/**\n * Represents a Secp256k1 ECDSA public key.\n *\n * @extends PublicKey\n * @property LENGTH - The length of the Secp256k1 public key in bytes.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256k1PublicKey extends PublicKey {\n // Secp256k1 ecdsa public keys contain a prefix indicating compression and two 32-byte coordinates.\n static readonly LENGTH: number = 65;\n\n // If it's compressed, it is only 33 bytes\n static readonly COMPRESSED_LENGTH: number = 33;\n\n // Hex value of the public key\n private readonly key: Hex;\n\n // Identifier to distinguish from Secp256k1PublicKey\n public readonly keyType: string = \"secp256k1\";\n\n /**\n * Create a new PublicKey instance from a HexInput, which can be a string or Uint8Array.\n * This constructor validates the length of the provided signature data.\n *\n * @param hexInput - A HexInput (string or Uint8Array) representing the signature data.\n * @throws Error if the length of the signature data is not equal to Secp256k1Signature.LENGTH.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n const { length } = hex.toUint8Array();\n if (length === Secp256k1PublicKey.LENGTH) {\n this.key = hex;\n } else if (length === Secp256k1PublicKey.COMPRESSED_LENGTH) {\n const point = secp256k1.ProjectivePoint.fromHex(hex.toUint8Array());\n this.key = Hex.fromHexInput(point.toRawBytes(false));\n } else {\n throw new Error(\n `PublicKey length should be ${Secp256k1PublicKey.LENGTH} or ${Secp256k1PublicKey.COMPRESSED_LENGTH}, received ${length}`,\n );\n }\n }\n\n // region PublicKey\n /**\n * Verifies a Secp256k1 signature against the public key.\n *\n * This function checks the validity of a signature for a given message, ensuring that the signature is canonical as a malleability check.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify against the public key.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: Secp256k1Signature }): boolean {\n const { message, signature } = args;\n const messageToVerify = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToVerify).toUint8Array();\n const messageSha3Bytes = sha3_256(messageBytes);\n const signatureBytes = signature.toUint8Array();\n return secp256k1.verify(signatureBytes, messageSha3Bytes, this.key.toUint8Array(), { lowS: true });\n }\n\n /**\n * Note: Secp256k1Signatures can be verified syncronously.\n *\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.\n *\n * @param args - The arguments for signature verification.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify, which must be an instance of Secp256k1Signature.\n * @returns A boolean indicating whether the signature is valid for the given message.\n * @group Implementation\n * @category Serialization\n */\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: Secp256k1Signature;\n }): Promise<boolean> {\n return this.verifySignature(args);\n }\n\n /**\n * Get the data as a Uint8Array representation.\n *\n * @returns Uint8Array representation of the data.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This function is essential for converting data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to convert the data.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.key.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256k1Signature from the provided deserializer.\n * This function allows you to reconstruct a Secp256k1Signature object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n // eslint-disable-next-line class-methods-use-this\n deserialize(deserializer: Deserializer) {\n const hex = deserializer.deserializeBytes();\n return new Secp256k1Signature(hex);\n }\n\n static deserialize(deserializer: Deserializer): Secp256k1PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256k1PublicKey(bytes);\n }\n\n // endregion\n\n /**\n * Determine if the provided public key is an instance of Secp256k1PublicKey.\n *\n * @deprecated use `instanceof Secp256k1PublicKey` instead\n * @param publicKey - The public key to check.\n * @group Implementation\n * @category Serialization\n */\n static isPublicKey(publicKey: PublicKey): publicKey is Secp256k1PublicKey {\n return publicKey instanceof Secp256k1PublicKey;\n }\n\n /**\n * Determines if the provided public key is a valid instance of a Secp256k1 public key.\n * This function checks for the presence of a \"key\" property and validates the length of the key data.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid Secp256k1 public key.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey): publicKey is Secp256k1PublicKey {\n return (\n \"key\" in publicKey &&\n (publicKey.key as any)?.data?.length === Secp256k1PublicKey.LENGTH &&\n \"keyType\" in publicKey &&\n (publicKey as any).keyType === \"secp256k1\"\n );\n }\n}\n\n/**\n * Represents a Secp256k1 ECDSA private key, providing functionality to create, sign messages,\n * derive public keys, and serialize/deserialize the key.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256k1PrivateKey extends Serializable implements PrivateKey {\n /**\n * Length of Secp256k1 ecdsa private key\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The private key bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly key: Hex;\n\n // region Constructors\n\n /**\n * Create a new PrivateKey instance from a Uint8Array or String.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param hexInput A HexInput (string or Uint8Array)\n * @param strict If true, private key must AIP-80 compliant.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput, strict?: boolean) {\n super();\n\n const privateKeyHex = PrivateKey.parseHexInput(hexInput, PrivateKeyVariants.Secp256k1, strict);\n if (privateKeyHex.toUint8Array().length !== Secp256k1PrivateKey.LENGTH) {\n throw new Error(`PrivateKey length should be ${Secp256k1PrivateKey.LENGTH}`);\n }\n\n this.key = privateKeyHex;\n }\n\n /**\n * Generate a new random private key.\n *\n * @returns Secp256k1PrivateKey - A newly generated Secp256k1 private key.\n * @group Implementation\n * @category Serialization\n */\n static generate(): Secp256k1PrivateKey {\n const hexInput = secp256k1.utils.randomPrivateKey();\n return new Secp256k1PrivateKey(hexInput, false);\n }\n\n /**\n * Derives a private key from a mnemonic seed phrase using a specified BIP44 path.\n *\n * @param path - The BIP44 path to derive the key from.\n * @param mnemonics - The mnemonic seed phrase used for key generation.\n *\n * @returns The generated private key.\n *\n * @throws Error if the provided path is not a valid BIP44 path.\n * @group Implementation\n * @category Serialization\n */\n static fromDerivationPath(path: string, mnemonics: string): Secp256k1PrivateKey {\n if (!isValidBIP44Path(path)) {\n throw new Error(`Invalid derivation path ${path}`);\n }\n return Secp256k1PrivateKey.fromDerivationPathInner(path, mnemonicToSeed(mnemonics));\n }\n\n /**\n * Derives a private key from a specified BIP44 path using a given seed.\n * This function is essential for generating keys that follow the hierarchical deterministic (HD) wallet structure.\n *\n * @param path - The BIP44 path used for key derivation.\n * @param seed - The seed phrase created by the mnemonics, represented as a Uint8Array.\n * @returns The generated private key as an instance of Secp256k1PrivateKey.\n * @throws Error if the derived private key is invalid.\n * @group Implementation\n * @category Serialization\n */\n private static fromDerivationPathInner(path: string, seed: Uint8Array): Secp256k1PrivateKey {\n const { privateKey } = HDKey.fromMasterSeed(seed).derive(path);\n // library returns privateKey as Uint8Array | null\n if (privateKey === null) {\n throw new Error(\"Invalid key\");\n }\n\n return new Secp256k1PrivateKey(privateKey, false);\n }\n\n // endregion\n\n // region PrivateKey\n\n /**\n * Sign the given message with the private key.\n * This function generates a cryptographic signature for the provided message, ensuring the signature is canonical and non-malleable.\n *\n * @param message - A message in HexInput format to be signed.\n * @returns Signature - The generated signature for the provided message.\n * @group Implementation\n * @category Serialization\n */\n sign(message: HexInput): Secp256k1Signature {\n const messageToSign = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToSign);\n const messageHashBytes = sha3_256(messageBytes.toUint8Array());\n const signature = secp256k1.sign(messageHashBytes, this.key.toUint8Array(), { lowS: true });\n return new Secp256k1Signature(signature.toCompactRawBytes());\n }\n\n /**\n * Derive the Secp256k1PublicKey from this private key.\n *\n * @returns Secp256k1PublicKey The derived public key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): Secp256k1PublicKey {\n const bytes = secp256k1.getPublicKey(this.key.toUint8Array(), false);\n return new Secp256k1PublicKey(bytes);\n }\n\n /**\n * Get the private key in bytes (Uint8Array).\n *\n * @returns\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n /**\n * Get the private key as a string representation.\n *\n * @returns string representation of the private key\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.toAIP80String();\n }\n\n /**\n * Get the private key as a hex string with the 0x prefix.\n *\n * @returns string representation of the private key.\n */\n toHexString(): string {\n return this.key.toString();\n }\n\n /**\n * Get the private key as a AIP-80 compliant hex string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @returns AIP-80 compliant string representation of the private key.\n */\n toAIP80String(): string {\n return PrivateKey.formatPrivateKey(this.key.toString(), PrivateKeyVariants.Secp256k1);\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Secp256k1PrivateKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256k1PrivateKey(bytes, false);\n }\n\n // endregion\n\n /**\n * Determines if the provided private key is an instance of Secp256k1PrivateKey.\n *\n * @param privateKey - The private key to be checked.\n *\n * @deprecated use `instanceof Secp256k1PrivateKey` instead\n * @group Implementation\n * @category Serialization\n */\n static isPrivateKey(privateKey: PrivateKey): privateKey is Secp256k1PrivateKey {\n return privateKey instanceof Secp256k1PrivateKey;\n }\n}\n\n/**\n * Represents a signature of a message signed using a Secp256k1 ECDSA private key.\n *\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256k1Signature extends Signature {\n /**\n * Secp256k1 ecdsa signatures are 256-bit.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH = 64;\n\n /**\n * The signature bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly data: Hex;\n\n // region Constructors\n\n /**\n * Create a new Signature instance from a Uint8Array or String.\n *\n * @param hexInput A HexInput (string or Uint8Array)\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n const data = Hex.fromHexInput(hexInput);\n if (data.toUint8Array().length !== Secp256k1Signature.LENGTH) {\n throw new Error(\n `Signature length should be ${Secp256k1Signature.LENGTH}, received ${data.toUint8Array().length}`,\n );\n }\n this.data = data;\n }\n\n // endregion\n\n // region Signature\n\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.data.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Secp256k1Signature {\n const hex = deserializer.deserializeBytes();\n return new Secp256k1Signature(hex);\n }\n\n // endregion\n}\n"],"mappings":"AAGA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,aAAAC,MAAiB,0BAC1B,OAAS,SAAAC,MAAa,eACtB,OAAS,gBAAAC,MAA8C,YACvD,OAAS,OAAAC,MAAW,SACpB,OAAmB,sBAAAC,MAA0B,cAC7C,OAAS,oBAAAC,EAAkB,kBAAAC,MAAsB,UACjD,OAAS,cAAAC,MAAkB,eAC3B,OAAS,aAAAC,MAAiB,cAC1B,OAAS,aAAAC,MAAiB,cAC1B,OAAS,yBAAAC,MAA6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HDKey","Serializable","Hex","PrivateKeyVariants","isValidBIP44Path","mnemonicToSeed","PrivateKey","PublicKey","Signature","convertSigningMessage","_Secp256k1PublicKey","hexInput","hex","length","point","args","message","signature","messageToVerify","messageBytes","messageSha3Bytes","signatureBytes","serializer","deserializer","Secp256k1Signature","bytes","publicKey","Secp256k1PublicKey","_Secp256k1PrivateKey","strict","privateKeyHex","path","mnemonics","seed","privateKey","messageToSign","messageHashBytes","Secp256k1PrivateKey","_Secp256k1Signature","data"]}
@@ -1,2 +1,2 @@
1
- import{a,b,c,d}from"../../chunk-I7XT6L7S.mjs";import"../../chunk-2PASUPUO.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-FGFLPH5K.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-KDMSOCZY.mjs";export{b as Secp256r1PrivateKey,a as Secp256r1PublicKey,d as Secp256r1Signature,c as WebAuthnSignature};
1
+ import{sha3_256 as p}from"@noble/hashes/sha3";import{p256 as o}from"@noble/curves/nist.js";import{Serializer as c}from"../../bcs";import{Hex as s}from"../hex";import{PrivateKeyVariants as m,SigningScheme as f,AnyPublicKeyVariant as U}from"../../types";import{PublicKey as z}from"./publicKey";import{PrivateKey as l}from"./privateKey";import{Signature as x}from"./signature";import{AuthenticationKey as b}from"../authenticationKey";const n=class n extends z{constructor(e){super();this.keyType="secp256r1";const r=s.fromHexInput(e),i=r.toUint8Array().length;if(i!==n.LENGTH&&i!==n.COMPRESSED_LENGTH)throw new Error(`PublicKey length should be ${n.LENGTH} or ${n.COMPRESSED_LENGTH}, received ${i}`);if(i===n.COMPRESSED_LENGTH){const u=o.ProjectivePoint.fromHex(r.toUint8Array());this.key=s.fromHexInput(u.toRawBytes(!1))}else this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}bcsToBytes(){const e=new c;return this.serialize(e),e.toUint8Array()}verifySignature(e){const{message:r,signature:i}=e,u=s.fromHexInput(r).toUint8Array(),A=p(u),d=i.toUint8Array();return o.verify(d,A,this.toUint8Array())}async verifySignatureAsync(e){return this.verifySignature({message:e.message,signature:e.signature})}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){const r=e.deserializeBytes();return new n(r)}static load(e){const r=e.deserializeBytes();return new n(r)}static isInstance(e){return"key"in e&&e.key?.data?.length===n.LENGTH&&"keyType"in e&&e.keyType==="secp256r1"}authKey(){const e=new c;return e.serializeU32AsUleb128(U.Secp256r1),e.serializeFixedBytes(this.bcsToBytes()),b.fromSchemeAndBytes({scheme:f.SingleKey,input:e.toUint8Array()})}};n.LENGTH=65,n.COMPRESSED_LENGTH=33;let h=n;const a=class a extends l{constructor(t,e){super();const r=l.parseHexInput(t,m.Secp256r1,e),i=r.toUint8Array().length;if(i!==a.LENGTH)throw new Error(`PrivateKey length should be ${a.LENGTH}, received ${i}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return l.formatPrivateKey(this.key.toString(),m.Secp256r1)}toHexString(){return this.key.toString()}sign(t){const e=s.fromHexInput(t),r=p(e.toUint8Array()),i=o.sign(r,this.key.toUint8Array());return new g(i.toCompactRawBytes())}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){const e=t.deserializeBytes();return new a(e)}static generate(){const t=o.utils.randomPrivateKey();return new a(t)}publicKey(){const t=o.getPublicKey(this.key.toUint8Array(),!1);return new h(t)}};a.LENGTH=32;let H=a;class S extends x{constructor(t,e,r){super(),this.signature=s.fromHexInput(t),this.authenticatorData=s.fromHexInput(e),this.clientDataJSON=s.fromHexInput(r)}toUint8Array(){return this.signature.toUint8Array()}serialize(t){t.serializeU32AsUleb128(0),t.serializeBytes(this.signature.toUint8Array()),t.serializeBytes(this.authenticatorData.toUint8Array()),t.serializeBytes(this.clientDataJSON.toUint8Array())}bcsToBytes(){const t=new c;return this.serialize(t),t.toUint8Array()}bcsToHex(){return s.fromHexInput(this.bcsToBytes())}toStringWithoutPrefix(){return s.fromHexInput(this.bcsToBytes()).toString()}static deserialize(t){const e=t.deserializeUleb128AsU32();if(e!==0)throw new Error(`Invalid id for WebAuthnSignature: ${e}`);const r=t.deserializeBytes(),i=t.deserializeBytes(),u=t.deserializeBytes();return new S(r,i,u)}}const y=class y extends x{constructor(t){super();const e=s.fromHexInput(t),r=e.toUint8Array().length;if(r!==y.LENGTH)throw new Error(`Signature length should be ${y.LENGTH}, received ${r}`);const i=o.Signature.fromCompact(e.toUint8Array()).normalizeS().toCompactRawBytes();this.data=s.fromHexInput(i)}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(t){t.serializeBytes(this.data.toUint8Array())}static deserialize(t){const e=t.deserializeBytes();return new y(e)}};y.LENGTH=64;let g=y;export{H as Secp256r1PrivateKey,h as Secp256r1PublicKey,g as Secp256r1Signature,S as WebAuthnSignature};
2
2
  //# sourceMappingURL=secp256r1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/secp256r1.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { sha3_256 } from \"@noble/hashes/sha3\";\nimport { p256 } from \"@noble/curves/nist.js\";\nimport { Deserializer, Serializer } from \"../../bcs\";\nimport { Hex } from \"../hex\";\nimport {\n HexInput,\n PrivateKeyVariants,\n SigningScheme as AuthenticationKeyScheme,\n AnyPublicKeyVariant,\n} from \"../../types\";\nimport { PublicKey, VerifySignatureAsyncArgs } from \"./publicKey\";\nimport { PrivateKey } from \"./privateKey\";\nimport { Signature } from \"./signature\";\nimport { AuthenticationKey } from \"../authenticationKey\";\n\n/**\n * Represents a Secp256r1 ECDSA public key.\n *\n * @extends PublicKey\n * @property LENGTH - The length of the Secp256r1 public key in bytes.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256r1PublicKey extends PublicKey {\n // Secp256r1 ecdsa public keys contain a prefix indicating compression and two 32-byte coordinates.\n static readonly LENGTH: number = 65;\n\n // If it's compressed, it is only 33 bytes\n static readonly COMPRESSED_LENGTH: number = 33;\n\n // Hex value of the public key\n private readonly key: Hex;\n\n // Identifier to distinguish from Secp256k1PublicKey\n public readonly keyType: string = \"secp256r1\";\n\n /**\n * Create a new PublicKey instance from a HexInput, which can be a string or Uint8Array.\n * This constructor validates the length of the provided public key data.\n *\n * @param hexInput - A HexInput (string or Uint8Array) representing the public key data.\n * @throws Error if the length of the public key data is not equal to Secp256r1PublicKey.LENGTH or COMPRESSED_LENGTH.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n const keyLength = hex.toUint8Array().length;\n if (keyLength !== Secp256r1PublicKey.LENGTH && keyLength !== Secp256r1PublicKey.COMPRESSED_LENGTH) {\n throw new Error(\n `PublicKey length should be ${Secp256r1PublicKey.LENGTH} or ${Secp256r1PublicKey.COMPRESSED_LENGTH}, received ${keyLength}`,\n );\n }\n\n if (keyLength === Secp256r1PublicKey.COMPRESSED_LENGTH) {\n const point = p256.ProjectivePoint.fromHex(hex.toUint8Array());\n this.key = Hex.fromHexInput(point.toRawBytes(false));\n } else {\n this.key = hex;\n }\n }\n\n /**\n * Get the data as a Uint8Array representation.\n *\n * @returns Uint8Array representation of the data.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n /**\n * Get the public key as a hex string with the 0x prefix.\n *\n * @returns string representation of the public key.\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.key.toString();\n }\n\n /**\n * Converts the public key to BCS (Binary Canonical Serialization) bytes.\n * This function serializes the public key data into a byte array format suitable for transmission or storage.\n *\n * @returns Uint8Array representation of the serialized public key.\n * @group Implementation\n * @category Serialization\n */\n bcsToBytes() {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n /**\n * Verifies a Secp256r1 signature against the public key.\n *\n * This function checks the validity of a signature for a given message.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify against the public key.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: Signature }): boolean {\n const { message, signature } = args;\n\n const msgHex = Hex.fromHexInput(message).toUint8Array();\n const sha3Message = sha3_256(msgHex);\n const rawSignature = signature.toUint8Array();\n\n return p256.verify(rawSignature, sha3Message, this.toUint8Array());\n }\n\n /**\n * Note: Secp256r1Signatures can be verified synchronously.\n *\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.\n *\n * @param args - The arguments for signature verification.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify, which must be an instance of Secp256r1Signature.\n * @returns A boolean indicating whether the signature is valid for the given message.\n * @group Implementation\n * @category Serialization\n */\n async verifySignatureAsync(args: VerifySignatureAsyncArgs): Promise<boolean> {\n return this.verifySignature({ message: args.message, signature: args.signature });\n }\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This function is essential for converting data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to convert the data.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.key.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256r1PublicKey from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1PublicKey object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): Secp256r1PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PublicKey(bytes);\n }\n\n /**\n * Loads a Secp256r1PublicKey from the provided deserializer.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static load(deserializer: Deserializer): Secp256r1PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PublicKey(bytes);\n }\n\n /**\n * Determines if the provided public key is a valid instance of a Secp256r1 public key.\n * This function checks for the presence of a \"key\" property and validates the length of the key data.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid Secp256r1 public key.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey): publicKey is Secp256r1PublicKey {\n return (\n \"key\" in publicKey &&\n (publicKey.key as any)?.data?.length === Secp256r1PublicKey.LENGTH &&\n \"keyType\" in publicKey &&\n (publicKey as any).keyType === \"secp256r1\"\n );\n }\n\n /**\n * Generates an authentication key from the public key using the Secp256r1 scheme.\n * This function is essential for creating a secure authentication key that can be used for further cryptographic operations.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(AnyPublicKeyVariant.Secp256r1);\n serializer.serializeFixedBytes(this.bcsToBytes());\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.SingleKey,\n input: serializer.toUint8Array(),\n });\n }\n}\n\n/**\n * Represents a Secp256r1 ECDSA private key, providing functionality to create, sign messages,\n * derive public keys, and serialize/deserialize the key.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256r1PrivateKey extends PrivateKey {\n /**\n * Length of Secp256r1 ecdsa private key\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The private key bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly key: Hex;\n\n /**\n * Create a new PrivateKey instance from a Uint8Array or String.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param hexInput A HexInput (string or Uint8Array)\n * @param strict If true, private key must AIP-80 compliant.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput, strict?: boolean) {\n super();\n\n const privateKeyHex = PrivateKey.parseHexInput(hexInput, PrivateKeyVariants.Secp256r1, strict);\n const keyLength = privateKeyHex.toUint8Array().length;\n if (keyLength !== Secp256r1PrivateKey.LENGTH) {\n throw new Error(`PrivateKey length should be ${Secp256r1PrivateKey.LENGTH}, received ${keyLength}`);\n }\n\n this.key = privateKeyHex;\n }\n\n /**\n * Get the private key in bytes (Uint8Array).\n *\n * @returns\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n /**\n * Get the private key as a string representation.\n *\n * @returns string representation of the private key\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return PrivateKey.formatPrivateKey(this.key.toString(), PrivateKeyVariants.Secp256r1);\n }\n\n /**\n * Get the private key as a hex string with the 0x prefix.\n *\n * @returns string representation of the private key.\n */\n toHexString(): string {\n return this.key.toString();\n }\n\n /**\n * Sign the given message with the private key.\n * This function generates a cryptographic signature for the provided message.\n *\n * @param message - A message in HexInput format to be signed.\n * @returns Signature - The generated signature for the provided message.\n * @group Implementation\n * @category Serialization\n */\n sign(message: HexInput): Secp256r1Signature {\n const msgHex = Hex.fromHexInput(message);\n const sha3Message = sha3_256(msgHex.toUint8Array());\n const signature = p256.sign(sha3Message, this.key.toUint8Array());\n return new Secp256r1Signature(signature.toCompactRawBytes());\n }\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This function is essential for converting data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to convert the data.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256r1PrivateKey from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1PrivateKey object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): Secp256r1PrivateKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PrivateKey(bytes);\n }\n\n /**\n * Generate a new random private key.\n *\n * @returns Secp256r1PrivateKey - A newly generated Secp256r1 private key.\n * @group Implementation\n * @category Serialization\n */\n static generate(): Secp256r1PrivateKey {\n const hexInput = p256.utils.randomPrivateKey();\n return new Secp256r1PrivateKey(hexInput);\n }\n\n /**\n * Derive the Secp256r1PublicKey from this private key.\n *\n * @returns Secp256r1PublicKey The derived public key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): Secp256r1PublicKey {\n const bytes = p256.getPublicKey(this.key.toUint8Array(), false);\n return new Secp256r1PublicKey(bytes);\n }\n}\n\nexport class WebAuthnSignature extends Signature {\n signature: Hex;\n\n authenticatorData: Hex;\n\n clientDataJSON: Hex;\n\n constructor(signature: HexInput, authenticatorData: HexInput, clientDataJSON: HexInput) {\n super();\n this.signature = Hex.fromHexInput(signature);\n this.authenticatorData = Hex.fromHexInput(authenticatorData);\n this.clientDataJSON = Hex.fromHexInput(clientDataJSON);\n }\n\n toUint8Array() {\n return this.signature.toUint8Array();\n }\n\n serialize(serializer: Serializer) {\n serializer.serializeU32AsUleb128(0);\n serializer.serializeBytes(this.signature.toUint8Array());\n serializer.serializeBytes(this.authenticatorData.toUint8Array());\n serializer.serializeBytes(this.clientDataJSON.toUint8Array());\n }\n\n bcsToBytes() {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n bcsToHex() {\n return Hex.fromHexInput(this.bcsToBytes());\n }\n\n toStringWithoutPrefix() {\n return Hex.fromHexInput(this.bcsToBytes()).toString();\n }\n\n static deserialize(deserializer: Deserializer) {\n const id = deserializer.deserializeUleb128AsU32();\n if (id !== 0) {\n throw new Error(`Invalid id for WebAuthnSignature: ${id}`);\n }\n const signature = deserializer.deserializeBytes();\n const authenticatorData = deserializer.deserializeBytes();\n const clientDataJSON = deserializer.deserializeBytes();\n return new WebAuthnSignature(signature, authenticatorData, clientDataJSON);\n }\n}\n\n/**\n * Represents a signature of a message signed using a Secp256r1 ECDSA private key.\n *\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256r1Signature extends Signature {\n /**\n * Secp256r1 ecdsa signatures are 256-bit.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH = 64;\n\n /**\n * The signature bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly data: Hex;\n\n /**\n * Create a new Signature instance from a Uint8Array or String.\n *\n * @param hexInput A HexInput (string or Uint8Array)\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n const signatureLength = hex.toUint8Array().length;\n if (signatureLength !== Secp256r1Signature.LENGTH) {\n throw new Error(`Signature length should be ${Secp256r1Signature.LENGTH}, received ${signatureLength}`);\n }\n const signature = p256.Signature.fromCompact(hex.toUint8Array()).normalizeS().toCompactRawBytes();\n this.data = Hex.fromHexInput(signature);\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the signature\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n /**\n * Get the signature as a hex string with the 0x prefix.\n *\n * @returns string representation of the signature\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.data.toString();\n }\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This function is essential for converting data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to convert the data.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.data.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256r1Signature from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1Signature object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): Secp256r1Signature {\n const hex = deserializer.deserializeBytes();\n return new Secp256r1Signature(hex);\n }\n}\n"],"mappings":"AAGA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,QAAAC,MAAY,wBACrB,OAAuB,cAAAC,MAAkB,YACzC,OAAS,OAAAC,MAAW,SACpB,OAEE,sBAAAC,EACA,iBAAiBC,EACjB,uBAAAC,MACK,cACP,OAAS,aAAAC,MAA2C,cACpD,OAAS,cAAAC,MAAkB,eAC3B,OAAS,aAAAC,MAAiB,cAC1B,OAAS,qBAAAC,MAAyB,uBAU3B,MAAMC,EAAN,MAAMA,UAA2BJ,CAAU,CAsBhD,YAAYK,EAAoB,CAC9B,MAAM,EAZR,KAAgB,QAAkB,YAchC,MAAMC,EAAMV,EAAI,aAAaS,CAAQ,EAC/BE,EAAYD,EAAI,aAAa,EAAE,OACrC,GAAIC,IAAcH,EAAmB,QAAUG,IAAcH,EAAmB,kBAC9E,MAAM,IAAI,MACR,8BAA8BA,EAAmB,MAAM,OAAOA,EAAmB,iBAAiB,cAAcG,CAAS,EAC3H,EAGF,GAAIA,IAAcH,EAAmB,kBAAmB,CACtD,MAAMI,EAAQd,EAAK,gBAAgB,QAAQY,EAAI,aAAa,CAAC,EAC7D,KAAK,IAAMV,EAAI,aAAaY,EAAM,WAAW,EAAK,CAAC,CACrD,MACE,KAAK,IAAMF,CAEf,CASA,cAA2B,CACzB,OAAO,KAAK,IAAI,aAAa,CAC/B,CASA,UAAmB,CACjB,OAAO,KAAK,IAAI,SAAS,CAC3B,CAUA,YAAa,CACX,MAAMG,EAAa,IAAId,EACvB,YAAK,UAAUc,CAAU,EAClBA,EAAW,aAAa,CACjC,CAaA,gBAAgBC,EAA4D,CAC1E,KAAM,CAAE,QAAAC,EAAS,UAAAC,CAAU,EAAIF,EAEzBG,EAASjB,EAAI,aAAae,CAAO,EAAE,aAAa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OAAS,GANpB,IAAMN,EAANM","names":["sha3_256","p256","Serializer","Hex","PrivateKeyVariants","AuthenticationKeyScheme","AnyPublicKeyVariant","PublicKey","PrivateKey","Signature","AuthenticationKey","_Secp256r1PublicKey","hexInput","hex","keyLength","point","serializer","args","message","signature","msgHex","sha3Message","rawSignature","deserializer","bytes","publicKey","Secp256r1PublicKey","_Secp256r1PrivateKey","strict","privateKeyHex","Secp256r1Signature","Secp256r1PrivateKey","WebAuthnSignature","authenticatorData","clientDataJSON","id","_Secp256r1Signature","signatureLength"]}
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-WCMW2L3P.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-KDMSOCZY.mjs";export{a as Signature};
1
+ import{Serializable as r}from"../../bcs";import{Hex as i}from"../hex";class s extends r{toUint8Array(){return this.bcsToBytes()}toString(){const t=this.toUint8Array();return i.fromHexInput(t).toString()}}export{s as Signature};
2
2
  //# sourceMappingURL=signature.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/signature.ts"],"sourcesContent":["import { Serializable } from \"../../bcs\";\nimport { Hex } from \"../hex\";\n\n/**\n * An abstract representation of a crypto signature,\n * associated with a specific signature scheme, e.g., Ed25519 or Secp256k1.\n *\n * This class represents the product of signing a message directly from a\n * PrivateKey and can be verified against a CryptoPublicKey.\n * @group Implementation\n * @category Serialization\n */\nexport abstract class Signature extends Serializable {\n /**\n * Get the raw signature bytes\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n /**\n * Get the signature as a hex string with a 0x prefix e.g. 0x123456...\n * @returns The hex string representation of the signature.\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n const bytes = this.toUint8Array();\n return Hex.fromHexInput(bytes).toString();\n }\n}\n\n/**\n * An abstract representation of an account signature,\n * associated to a specific authentication scheme e.g. Ed25519 or SingleKey\n *\n * This is the product of signing a message through an account,\n * and can be verified against an AccountPublicKey.\n * @group Implementation\n * @category Serialization\n */\n// export abstract class AccountSignature extends Serializable {\n// /**\n// * Get the raw signature bytes\n// */\n// abstract toUint8Array(): Uint8Array;\n//\n// /**\n// * Get the signature as a hex string with a 0x prefix e.g. 0x123456...\n// */\n// toString(): string {\n// const bytes = this.toUint8Array();\n// return Hex.fromHexInput(bytes).toString();\n// }\n// }\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,YAC7B,OAAS,OAAAC,MAAW,SAWb,MAAeC,UAAkBF,CAAa,CAMnD,cAA2B,CACzB,OAAO,KAAK,WAAW,CACzB,CAQA,UAAmB,CACjB,MAAMG,EAAQ,KAAK,aAAa,EAChC,OAAOF,EAAI,aAAaE,CAAK,EAAE,SAAS,CAC1C,CACF","names":["Serializable","Hex","Signature","bytes"]}
@@ -1,2 +1,2 @@
1
- import{F as a,G as b}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 AnyPublicKey,b as AnySignature};
1
+ import{AnyPublicKeyVariant as t,AnySignatureVariant as r,SigningScheme as g}from"../../types";import{AuthenticationKey as K}from"../authenticationKey";import{Ed25519PublicKey as a,Ed25519Signature as l}from"./ed25519";import{AccountPublicKey as S}from"./publicKey";import{Secp256k1PublicKey as s,Secp256k1Signature as y}from"./secp256k1";import{KeylessPublicKey as o,KeylessSignature as p}from"./keyless";import{Signature as A}from"./signature";import{FederatedKeylessPublicKey as b}from"./federatedKeyless";import{Secp256r1PublicKey as f,WebAuthnSignature as h}from"./secp256r1";class u extends S{constructor(e){if(super(),this.publicKey=e,e instanceof a)this.variant=t.Ed25519;else if(e instanceof s)this.variant=t.Secp256k1;else if(e instanceof f)this.variant=t.Secp256r1;else if(e instanceof o)this.variant=t.Keyless;else if(e instanceof b)this.variant=t.FederatedKeyless;else throw new Error("Unsupported public key type")}verifySignature(e){const{message:n,signature:i}=e;if(this.publicKey instanceof o)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:n,signature:i.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof c)){if(e.options?.throwErrorWithReason)throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return K.fromSchemeAndBytes({scheme:g.SingleKey,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){const n=e.deserializeUleb128AsU32();let i;switch(n){case t.Ed25519:i=a.deserialize(e);break;case t.Secp256k1:i=s.deserialize(e);break;case t.Secp256r1:i=f.deserialize(e);break;case t.Keyless:i=o.deserialize(e);break;case t.FederatedKeyless:i=b.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${n}`)}return new u(i)}static isPublicKey(e){return e instanceof u}isEd25519(){return this.publicKey instanceof a}isSecp256k1PublicKey(){return this.publicKey instanceof s}static isInstance(e){return"publicKey"in e&&"variant"in e}}class c extends A{constructor(e){if(super(),this.signature=e,e instanceof l)this.variant=r.Ed25519;else if(e instanceof y)this.variant=r.Secp256k1;else if(e instanceof h)this.variant=r.WebAuthn;else if(e instanceof p)this.variant=r.Keyless;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){const n=e.deserializeUleb128AsU32();let i;switch(n){case r.Ed25519:i=l.deserialize(e);break;case r.Secp256k1:i=y.deserialize(e);break;case r.WebAuthn:i=h.deserialize(e);break;case r.Keyless:i=p.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${n}`)}return new c(i)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}}export{u as AnyPublicKey,c as AnySignature};
2
2
  //# sourceMappingURL=singleKey.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/singleKey.ts"],"sourcesContent":["import { Deserializer, Serializer } from \"../../bcs\";\nimport {\n AnyPublicKeyVariant,\n AnySignatureVariant,\n SigningScheme as AuthenticationKeyScheme,\n HexInput,\n} from \"../../types\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Ed25519PrivateKey, Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport { AccountPublicKey, PublicKey } from \"./publicKey\";\nimport { Secp256k1PrivateKey, Secp256k1PublicKey, Secp256k1Signature } from \"./secp256k1\";\nimport { KeylessPublicKey, KeylessSignature } from \"./keyless\";\nimport { Signature } from \"./signature\";\nimport { FederatedKeylessPublicKey } from \"./federatedKeyless\";\nimport { AptosConfig } from \"../../api\";\nimport { Secp256r1PublicKey, WebAuthnSignature } from \"./secp256r1\";\n\nexport type PrivateKeyInput = Ed25519PrivateKey | Secp256k1PrivateKey;\n\n/**\n * Represents any public key supported by Aptos.\n *\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports\n * `Legacy` and `Unified` authentication keys.\n *\n * Any unified authentication key is represented in the SDK as `AnyPublicKey`.\n * @group Implementation\n * @category Serialization\n */\nexport class AnyPublicKey extends AccountPublicKey {\n /**\n * Reference to the inner public key\n * @group Implementation\n * @category Serialization\n */\n public readonly publicKey: PublicKey;\n\n /**\n * Index of the underlying enum variant\n * @group Implementation\n * @category Serialization\n */\n public readonly variant: AnyPublicKeyVariant;\n\n // region Constructors\n\n /**\n * Creates an instance of the signature class based on the provided signature type.\n * This allows for the handling of different signature variants such as Ed25519, Secp256k1, and Keyless.\n *\n * @param publicKey - The publicKey object which determines the variant to be used.\n * @throws Error if the provided signature type is unsupported.\n * @group Implementation\n * @category Serialization\n */\n constructor(publicKey: PublicKey) {\n super();\n this.publicKey = publicKey;\n if (publicKey instanceof Ed25519PublicKey) {\n this.variant = AnyPublicKeyVariant.Ed25519;\n } else if (publicKey instanceof Secp256k1PublicKey) {\n this.variant = AnyPublicKeyVariant.Secp256k1;\n } else if (publicKey instanceof Secp256r1PublicKey) {\n this.variant = AnyPublicKeyVariant.Secp256r1;\n } else if (publicKey instanceof KeylessPublicKey) {\n this.variant = AnyPublicKeyVariant.Keyless;\n } else if (publicKey instanceof FederatedKeylessPublicKey) {\n this.variant = AnyPublicKeyVariant.FederatedKeyless;\n } else {\n throw new Error(\"Unsupported public key type\");\n }\n }\n\n // endregion\n\n // region AccountPublicKey\n\n /**\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.\n *\n * @param args - The arguments for signature verification.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify, which must be an instance of AnySignature.\n * @returns A boolean indicating whether the signature is valid for the given message.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: AnySignature }): boolean {\n const { message, signature } = args;\n if (this.publicKey instanceof KeylessPublicKey) {\n throw new Error(\"Use verifySignatureAsync to verify Keyless signatures\");\n }\n return this.publicKey.verifySignature({\n message,\n signature: signature.signature,\n });\n }\n\n /**\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.\n *\n * @param args - The arguments for signature verification.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify, which must be an instance of AnySignature.\n * @returns A boolean indicating whether the signature is valid for the given message.\n * @group Implementation\n * @category Serialization\n */\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: Signature;\n options?: { throwErrorWithReason?: boolean };\n }): Promise<boolean> {\n if (!(args.signature instanceof AnySignature)) {\n if (args.options?.throwErrorWithReason) {\n throw new Error(\"Signature must be an instance of AnySignature\");\n }\n return false;\n }\n return await this.publicKey.verifySignatureAsync({\n ...args,\n signature: args.signature.signature,\n });\n }\n\n /**\n * Generates an authentication key from the current instance's byte representation.\n * This function is essential for creating a unique identifier for authentication purposes.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.SingleKey,\n input: this.toUint8Array(),\n });\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * This function is a warning that it will soon return the underlying signature bytes directly.\n * Use AnySignature.bcsToBytes() instead.\n *\n * @returns Uint8Array representation of the signature.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the current object using the provided serializer.\n * This function helps in converting the object into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.publicKey.serialize(serializer);\n }\n\n /**\n * Deserializes an AnySignature from the provided deserializer.\n * This function helps in reconstructing the AnySignature object from its serialized form, allowing for further processing or validation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AnyPublicKey {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let publicKey: PublicKey;\n switch (variantIndex) {\n case AnyPublicKeyVariant.Ed25519:\n publicKey = Ed25519PublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.Secp256k1:\n publicKey = Secp256k1PublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.Secp256r1:\n publicKey = Secp256r1PublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.Keyless:\n publicKey = KeylessPublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.FederatedKeyless:\n publicKey = FederatedKeylessPublicKey.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);\n }\n return new AnyPublicKey(publicKey);\n }\n // endregion\n\n /**\n * Determines if the provided public key is an instance of AnyPublicKey.\n *\n * @param publicKey - The public key to check.\n * @deprecated Use `instanceof AnyPublicKey` instead.\n * @group Implementation\n * @category Serialization\n */\n static isPublicKey(publicKey: AccountPublicKey): publicKey is AnyPublicKey {\n return publicKey instanceof AnyPublicKey;\n }\n\n /**\n * Determines if the current public key is an instance of Ed25519PublicKey.\n *\n * @deprecated use `publicKey instanceof Ed25519PublicKey` instead.\n * @group Implementation\n * @category Serialization\n */\n isEd25519(): boolean {\n return this.publicKey instanceof Ed25519PublicKey;\n }\n\n /**\n * Checks if the public key is an instance of Secp256k1PublicKey.\n *\n * @deprecated use `publicKey instanceof Secp256k1PublicKey` instead.\n * @group Implementation\n * @category Serialization\n */\n isSecp256k1PublicKey(): boolean {\n return this.publicKey instanceof Secp256k1PublicKey;\n }\n\n /**\n * Determines if the provided publicKey is an instance of a valid PublicKey object.\n *\n * @param publicKey - The publicKey to be checked for validity.\n * @param publicKey.publicKey - The actual publicKey object that needs to be validated.\n * @returns True if the signature is a valid instance; otherwise, false.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey): publicKey is AnyPublicKey {\n return \"publicKey\" in publicKey && \"variant\" in publicKey;\n }\n}\n\n/**\n * Represents a signature that utilizes the SingleKey authentication scheme.\n * This class is designed to encapsulate various types of signatures, which can\n * only be generated by a `SingleKeySigner` due to the shared authentication mechanism.\n *\n * @extends Signature\n * @group Implementation\n * @category Serialization\n */\nexport class AnySignature extends Signature {\n public readonly signature: Signature;\n\n /**\n * Index of the underlying enum variant\n * @group Implementation\n * @category Serialization\n */\n private readonly variant: AnySignatureVariant;\n\n // region Constructors\n\n constructor(signature: Signature) {\n super();\n this.signature = signature;\n\n if (signature instanceof Ed25519Signature) {\n this.variant = AnySignatureVariant.Ed25519;\n } else if (signature instanceof Secp256k1Signature) {\n this.variant = AnySignatureVariant.Secp256k1;\n } else if (signature instanceof WebAuthnSignature) {\n this.variant = AnySignatureVariant.WebAuthn;\n } else if (signature instanceof KeylessSignature) {\n this.variant = AnySignatureVariant.Keyless;\n } else {\n throw new Error(\"Unsupported signature type\");\n }\n }\n\n // endregion\n\n // region AccountSignature\n\n toUint8Array(): Uint8Array {\n // TODO: keep this warning around for a bit, and eventually change this to return `this.signature.toUint8Array()`.\n // eslint-disable-next-line no-console\n console.warn(\n \"[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. \" +\n \"Use AnySignature.bcsToBytes() instead.\",\n );\n return this.bcsToBytes();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.signature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): AnySignature {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let signature: Signature;\n switch (variantIndex) {\n case AnySignatureVariant.Ed25519:\n signature = Ed25519Signature.deserialize(deserializer);\n break;\n case AnySignatureVariant.Secp256k1:\n signature = Secp256k1Signature.deserialize(deserializer);\n break;\n case AnySignatureVariant.WebAuthn:\n signature = WebAuthnSignature.deserialize(deserializer);\n break;\n case AnySignatureVariant.Keyless:\n signature = KeylessSignature.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for AnySignature: ${variantIndex}`);\n }\n return new AnySignature(signature);\n }\n\n // endregion\n\n static isInstance(signature: Signature): signature is AnySignature {\n return (\n \"signature\" in signature &&\n typeof signature.signature === \"object\" &&\n signature.signature !== null &&\n \"toUint8Array\" in signature.signature\n );\n }\n}\n"],"mappings":"AACA,OACE,uBAAAA,EACA,uBAAAC,EACA,iBAAiBC,MAEZ,cACP,OAAS,qBAAAC,MAAyB,uBAClC,OAA4B,oBAAAC,EAAkB,oBAAAC,MAAwB,YACtE,OAAS,oBAAAC,MAAmC,cAC5C,OAA8B,sBAAAC,EAAoB,sBAAAC,MAA0B,cAC5E,OAAS,oBAAAC,EAAkB,oBAAAC,MAAwB,YACnD,OAAS,aAAAC,MAAiB,cAC1B,OAAS,6BAAAC,MAAiC,qBAE1C,OAAS,sBAAAC,EAAoB,qBAAAC,MAAyB,cAc/C,MAAMC,UAAqBT,CAAiB,CA0BjD,YAAYU,EAAsB,CAGhC,GAFA,MAAM,EACN,KAAK,UAAYA,EACbA,aAAqBZ,EACvB,KAAK,QAAUJ,EAAoB,gBAC1BgB,aAAqBT,EAC9B,KAAK,QAAUP,EAAoB,kBAC1BgB,aAAqBH,EAC9B,KAAK,QAAUb,EAAoB,kBAC1BgB,aAAqBP,EAC9B,KAAK,QAAUT,EAAoB,gBAC1BgB,aAAqBJ,EAC9B,KAAK,QAAUZ,EAAoB,qBAEnC,OAAM,IAAI,MAAM,6BAA6B,CAEjD,CAiBA,gBAAgBiB,EAA+D,CAC7E,KAAM,CAAE,QAAAC,EAAS,UAAAC,CAAU,EAAIF,EAC/B,GAAI,KAAK,qBAAqBR,EAC5B,MAAM,IAAI,MAAM,uDAAuD,EAEzE,OAAO,KAAK,UAAU,gBAAgB,CACpC,QAAAS,EACA,UAAWC,EAAU,SACvB,CAAC,CACH,CAcA,MAAM,qBAAqBF,EAKN,CACnB,GAAI,EAAEA,EAAK,qBA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KAAK,UAAYA,EAEbA,aAAqBd,EACvB,KAAK,QAAUJ,EAAoB,gBAC1BkB,aAAqBX,EAC9B,KAAK,QAAUP,EAAoB,kBAC1BkB,aAAqBL,EAC9B,KAAK,QAAUb,EAAoB,iBAC1BkB,aAAqBT,EAC9B,KAAK,QAAUT,EAAoB,YAEnC,OAAM,IAAI,MAAM,4BAA4B,CAEhD,CAMA,cAA2B,CAGzB,eAAQ,KACN,0IAEF,EACO,KAAK,WAAW,CACzB,CAMA,UAAUoB,EAA8B,CACtCA,EAAW,sBAAsB,KAAK,OAAO,EAC7C,KAAK,UAAU,UAAUA,CAAU,CACrC,CAEA,OAAO,YAAYC,EAA0C,CAC3D,MAAMC,EAAeD,EAAa,wBAAwB,EAC1D,IAAIH,EACJ,OAAQI,EAAc,CACpB,KAAKtB,EAAoB,QACvBkB,EAAYd,EAAiB,YAAYiB,CAAY,EACrD,MACF,KAAKrB,EAAoB,UACvBkB,EAAYX,EAAmB,YAAYc,CAAY,EACvD,MACF,KAAKrB,EAAoB,SACvBkB,EAAYL,EAAkB,YAAYQ,CAAY,EACtD,MACF,KAAKrB,EAAoB,QACvBkB,EAAYT,EAAiB,YAAYY,CAAY,EACrD,MACF,QACE,MAAM,IAAI,MAAM,2CAA2CC,CAAY,EAAE,CAC7E,CACA,OAAO,IAAIH,EAAaD,CAAS,CACnC,CAIA,OAAO,WAAWA,EAAiD,CACjE,MACE,cAAeA,GACf,OAAOA,EAAU,WAAc,UAC/BA,EAAU,YAAc,MACxB,iBAAkBA,EAAU,SAEhC,CACF","names":["AnyPublicKeyVariant","AnySignatureVariant","AuthenticationKeyScheme","AuthenticationKey","Ed25519PublicKey","Ed25519Signature","AccountPublicKey","Secp256k1PublicKey","Secp256k1Signature","KeylessPublicKey","KeylessSignature","Signature","FederatedKeylessPublicKey","Secp256r1PublicKey","WebAuthnSignature","AnyPublicKey","publicKey","args","message","signature","AnySignature","serializer","deserializer","variantIndex"]}
@@ -1,2 +1 @@
1
- import"../../chunk-5HXLZHDW.mjs";
2
1
  //# sourceMappingURL=types.mjs.map
@@ -1,2 +1,2 @@
1
- import{M as a,N as b,O 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 accountPublicKeyToBaseAccountPublicKey,c as accountPublicKeyToSigningScheme,a as convertSigningMessage};
1
+ import{SigningScheme as t}from"../../types";import{Hex as u}from"../hex";import{Ed25519PublicKey as i}from"./ed25519";import{FederatedKeylessPublicKey as f}from"./federatedKeyless";import{KeylessPublicKey as s}from"./keyless";import{MultiEd25519PublicKey as r}from"./multiEd25519";import{MultiKey as c}from"./multiKey";import{AnyPublicKey as o}from"./singleKey";const E=n=>typeof n=="string"?u.isValid(n).valid?n:new TextEncoder().encode(n):n,l=n=>{if(n instanceof i||n instanceof o||n instanceof r||n instanceof c)return n;if(n instanceof s||n instanceof f)return new o(n);throw new Error(`Unknown account public key: ${n}`)},h=n=>{const e=l(n);if(e instanceof i)return t.Ed25519;if(e instanceof o)return t.SingleKey;if(e instanceof r)return t.MultiEd25519;if(e instanceof c)return t.MultiKey;throw new Error(`Unknown signing scheme: ${e}`)};export{l as accountPublicKeyToBaseAccountPublicKey,h as accountPublicKeyToSigningScheme,E as convertSigningMessage};
2
2
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/utils.ts"],"sourcesContent":["import { HexInput, SigningScheme } from \"../../types\";\nimport { Hex } from \"../hex\";\nimport { Ed25519PublicKey } from \"./ed25519\";\nimport { FederatedKeylessPublicKey } from \"./federatedKeyless\";\nimport { KeylessPublicKey } from \"./keyless\";\nimport { MultiEd25519PublicKey } from \"./multiEd25519\";\nimport { MultiKey } from \"./multiKey\";\nimport { AccountPublicKey } from \"./publicKey\";\nimport { AnyPublicKey } from \"./singleKey\";\nimport { BaseAccountPublicKey } from \"./types\";\n\n/**\n * Helper function to convert a message to sign or to verify to a valid message input\n *\n * @param message a message as a string or Uint8Array\n *\n * @returns a valid HexInput - string or Uint8Array\n * @group Implementation\n * @category Serialization\n */\nexport const convertSigningMessage = (message: HexInput): HexInput => {\n // if message is of type string, verify it is a valid Hex string\n if (typeof message === \"string\") {\n const isValid = Hex.isValid(message);\n // If message is not a valid Hex string, convert it\n if (!isValid.valid) {\n return new TextEncoder().encode(message);\n }\n // If message is a valid Hex string, return it\n return message;\n }\n // message is a Uint8Array\n return message;\n};\n\nexport const accountPublicKeyToBaseAccountPublicKey = (publicKey: AccountPublicKey): BaseAccountPublicKey => {\n if (\n publicKey instanceof Ed25519PublicKey ||\n publicKey instanceof AnyPublicKey ||\n publicKey instanceof MultiEd25519PublicKey ||\n publicKey instanceof MultiKey\n ) {\n return publicKey;\n }\n if (publicKey instanceof KeylessPublicKey || publicKey instanceof FederatedKeylessPublicKey) {\n return new AnyPublicKey(publicKey);\n }\n throw new Error(`Unknown account public key: ${publicKey}`);\n};\n\nexport const accountPublicKeyToSigningScheme = (publicKey: AccountPublicKey): SigningScheme => {\n const baseAccountPublicKey = accountPublicKeyToBaseAccountPublicKey(publicKey);\n if (baseAccountPublicKey instanceof Ed25519PublicKey) {\n return SigningScheme.Ed25519;\n } else if (baseAccountPublicKey instanceof AnyPublicKey) {\n return SigningScheme.SingleKey;\n } else if (baseAccountPublicKey instanceof MultiEd25519PublicKey) {\n return SigningScheme.MultiEd25519;\n } else if (baseAccountPublicKey instanceof MultiKey) {\n return SigningScheme.MultiKey;\n }\n throw new Error(`Unknown signing scheme: ${baseAccountPublicKey}`);\n};\n"],"mappings":"AAAA,OAAmB,iBAAAA,MAAqB,cACxC,OAAS,OAAAC,MAAW,SACpB,OAAS,oBAAAC,MAAwB,YACjC,OAAS,6BAAAC,MAAiC,qBAC1C,OAAS,oBAAAC,MAAwB,YACjC,OAAS,yBAAAC,MAA6B,iBACtC,OAAS,YAAAC,MAAgB,aAEzB,OAAS,gBAAAC,MAAoB,cAYtB,MAAMC,EAAyBC,GAEhC,OAAOA,GAAY,SACLR,EAAI,QAAQQ,CAAO,EAEtB,MAINA,EAHE,IAAI,YAAY,EAAE,OAAOA,CAAO,EAMpCA,EAGIC,EAA0CC,GAAsD,CAC3G,GACEA,aAAqBT,GACrBS,aAAqBJ,GACrBI,aAAqBN,GACrBM,aAAqBL,EAErB,OAAOK,EAET,GAAIA,aAAqBP,GAAoBO,aAAqBR,EAChE,OAAO,IAAII,EAAaI,CAAS,EAEnC,MAAM,IAAI,MAAM,+BAA+BA,CAAS,EAAE,CAC5D,EAEaC,EAAmCD,GAA+C,CAC7F,MAAME,EAAuBH,EAAuCC,CAAS,EAC7E,GAAIE,aAAgCX,EAClC,OAAOF,EAAc,QAChB,GAAIa,aAAgCN,EACzC,OAAOP,EAAc,UAChB,GAAIa,aAAgCR,EACzC,OAAOL,EAAc,aAChB,GAAIa,aAAgCP,EACzC,OAAON,EAAc,SAEvB,MAAM,IAAI,MAAM,2BAA2Ba,CAAoB,EAAE,CACnE","names":["SigningScheme","Hex","Ed25519PublicKey","FederatedKeylessPublicKey","KeylessPublicKey","MultiEd25519PublicKey","MultiKey","AnyPublicKey","convertSigningMessage","message","accountPublicKeyToBaseAccountPublicKey","publicKey","accountPublicKeyToSigningScheme","baseAccountPublicKey"]}
@@ -1,2 +1,2 @@
1
- import{a,b,c}from"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-KDMSOCZY.mjs";export{b as Hex,a as HexInvalidReason,c as hexToAsciiString};
1
+ import{bytesToHex as o,hexToBytes as s}from"@noble/hashes/utils";import{ParsingError as i}from"./common";var u=(e=>(e.TOO_SHORT="too_short",e.INVALID_LENGTH="invalid_length",e.INVALID_HEX_CHARS="invalid_hex_chars",e))(u||{});class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return o(this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let r=t;if(r.startsWith("0x")&&(r=r.slice(2)),r.length===0)throw new i("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(r.length%2!==0)throw new i("Hex string must be an even number of hex characters.","invalid_length");try{return new n(s(r))}catch(e){throw new i(`Hex string contains invalid hex characters: ${e?.message}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static hexInputToUint8Array(t){return t instanceof Uint8Array?t:n.fromHexString(t).toUint8Array()}static hexInputToString(t){return n.fromHexInput(t).toString()}static hexInputToStringWithoutPrefix(t){return n.fromHexInput(t).toStringWithoutPrefix()}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(r){return{valid:!1,invalidReason:r?.invalidReason,invalidReasonMessage:r?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((r,e)=>r===t.data[e])}}const f=a=>new TextDecoder().decode(n.fromHexInput(a).toUint8Array());export{n as Hex,u as HexInvalidReason,f as hexToAsciiString};
2
2
  //# sourceMappingURL=hex.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/core/hex.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { HexInput } from \"../types\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n * @group Implementation\n * @category Serialization\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n * @group Implementation\n * @category Serialization\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n * @group Implementation\n * @category Serialization\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n * @group Implementation\n * @category Serialization\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n * @group Implementation\n * @category Serialization\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n return Hex.fromHexString(hexInput);\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n * @group Implementation\n * @category Serialization\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n"],"mappings":"AAGA,OAAS,cAAAA,EAAY,cAAAC,MAAkB,sBACvC,OAAS,gBAAAC,MAAmC,WAQrC,IAAKC,OACVA,EAAA,UAAY,YACZA,EAAA,eAAiB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,CAC1B,OAAI,KAAK,KAAK,SAAWA,EAAM,KAAK,OAAe,GAC5C,KAAK,KAAK,MAAM,CAACC,EAAOC,IAAUD,IAAUD,EAAM,KAAKE,CAAK,CAAC,CACtE,CACF,CAEO,MAAMC,EAAoBC,GAAgB,IAAI,YAAY,EAAE,OAAOV,EAAI,aAAaU,CAAG,EAAE,aAAa,CAAC","names":["bytesToHex","hexToBytes","ParsingError","HexInvalidReason","Hex","data","str","input","error","hexInput","other","value","index","hexToAsciiString","hex"]}
@@ -1,4 +1,4 @@
1
- export { createObjectAddress, createResourceAddress, createTokenAddress } from './account/utils/address.mjs';
1
+ export { createObjectAddress, createResourceAddress, createTokenAddress, createUserDerivedObjectAddress } from './account/utils/address.mjs';
2
2
  export { w as AbstractMultiKey, n as AccountAddress, m as AccountAddressInput, G as AccountPublicKey, l as AddressInvalidReason, N as AnyPublicKey, O as AnySignature, p as AuthenticationKey, r as Ed25519PrivateKey, E as Ed25519PublicKey, s as Ed25519Signature, R as Hex, Q as HexInvalidReason, t as MultiEd25519PublicKey, u as MultiEd25519Signature, x as MultiKey, y as MultiKeySignature, P as PrivateKey, L as PrivateKeyInput, C as PublicKey, I as Secp256k1PrivateKey, H as Secp256k1PublicKey, J as Secp256k1Signature, K as Signature, V as VerifySignatureArgs, z as VerifySignatureAsyncArgs, T as hexToAsciiString, q as isCanonicalEd25519Signature } from '../account-BortO8g2.mjs';
3
3
  export { ParsingError, ParsingResult } from './common.mjs';
4
4
  export { AbstractPublicKey, AbstractSignature } from './crypto/abstraction.mjs';
@@ -1,2 +1,2 @@
1
- import{A as da,B as ea,C as fa,D as ga,E as ha,F as ma,G as na,H as oa,I as pa,J as qa,K as ra,L as sa,P as ta,Q as ua,R as va,S as wa,T as xa,U as ya,a as x,b as y,c as H,d as I,e as J,f as K,g as L,h as M,i as N,j as O,k as P,l as Q,m as R,n as S,o as T,p as U,q as V,r as W,s as X,t as Y,u as Z,v as _,w as $,x as aa,y as ba,z as ca}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{a as ia,b as ja,c as ka,d as la}from"../chunk-I7XT6L7S.mjs";import"../chunk-5HXLZHDW.mjs";import"../chunk-G3MHXDYA.mjs";import"../chunk-JABP65XD.mjs";import{a as z,b as A,c as B,d as C,e as D}from"../chunk-GOXRBEIJ.mjs";import{a as w}from"../chunk-2PASUPUO.mjs";import"../chunk-XJJVJOX5.mjs";import"../chunk-NECL5FCQ.mjs";import"../chunk-4QMXOWHP.mjs";import{a as k,b as l}from"../chunk-EF4FA5I6.mjs";import{a as j}from"../chunk-WCMW2L3P.mjs";import{a as h,b as i}from"../chunk-WSR5EBJM.mjs";import{a as m,b as n,c as o,d as p,e as q,f as r,g as s,h as t,i as u,j as v}from"../chunk-C3Q23D22.mjs";import"../chunk-QREVMGQZ.mjs";import"../chunk-V3MBJJTL.mjs";import"../chunk-ZP4DWSQA.mjs";import{a as g}from"../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{a as E,b as F,c as G}from"../chunk-HNBVYE3N.mjs";import{a as e,b as f}from"../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{a as b,b as c,c as d}from"../chunk-STY74NUA.mjs";import{a}from"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-CIJA7ONS.mjs";import"../chunk-KDMSOCZY.mjs";export{n as APTOS_BIP44_REGEX,m as APTOS_HARDENED_REGEX,oa as AbstractMultiKey,l as AbstractPublicKey,k as AbstractSignature,f as AccountAddress,i as AccountPublicKey,e as AddressInvalidReason,ma as AnyPublicKey,na as AnySignature,g as AuthenticationKey,t as CKDPriv,H as EPK_HORIZON_SECS,va as Ed25519PrivateKey,ua as Ed25519PublicKey,wa as Ed25519Signature,U as EphemeralCertificate,x as EphemeralPublicKey,y as EphemeralSignature,ea as FederatedKeylessPublicKey,W as Groth16ProofAndStatement,_ as Groth16VerificationKey,V as Groth16Zkp,p as HARDENED_OFFSET,c as Hex,b as HexInvalidReason,o as KeyType,Z as KeylessConfiguration,P as KeylessPublicKey,T as KeylessSignature,I as MAX_AUD_VAL_BYTES,O as MAX_COMMITED_EPK_BYTES,M as MAX_EXTRA_FIELD_BYTES,L as MAX_ISS_VAL_BYTES,N as MAX_JWT_HEADER_B64_BYTES,J as MAX_UID_KEY_BYTES,K as MAX_UID_VAL_BYTES,ca as MoveJWK,ra as MultiEd25519PublicKey,sa as MultiEd25519Signature,pa as MultiKey,qa as MultiKeySignature,a as ParsingError,w as PrivateKey,h as PublicKey,ga as Secp256k1PrivateKey,fa as Secp256k1PublicKey,ha as Secp256k1Signature,ja as Secp256r1PrivateKey,ia as Secp256r1PublicKey,la as Secp256r1Signature,j as Signature,ka as WebAuthnSignature,Y as ZeroKnowledgeSig,X as ZkProof,C as bigIntToBytesLE,B as bytesToBigIntLE,E as createObjectAddress,F as createResourceAddress,G as createTokenAddress,s as deriveKey,xa as deserializePublicKey,ya as deserializeSignature,S as fetchJWK,aa as getIssAudAndUidVal,$ as getKeylessConfig,ba as getKeylessJWKs,z as hashStrToField,d as hexToAsciiString,ta as isCanonicalEd25519Signature,q as isValidBIP44Path,r as isValidHardenedPath,v as mnemonicToSeed,A as padAndPackBytesWithLen,da as parseJwtHeader,D as poseidonHash,u as splitPath,Q as verifyKeylessSignature,R as verifyKeylessSignatureWithJwkAndConfig};
1
+ export*from"./account";export*from"./accountAddress";export*from"./authenticationKey";export*from"./common";export*from"./crypto";export*from"./hex";
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/core/index.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from \"./account\";\nexport * from \"./accountAddress\";\nexport * from \"./authenticationKey\";\nexport * from \"./common\";\nexport * from \"./crypto\";\nexport * from \"./hex\";\n"],"mappings":"AAGA,WAAc,YACd,WAAc,mBACd,WAAc,sBACd,WAAc,WACd,WAAc,WACd,WAAc","names":[]}
@@ -1,2 +1,7 @@
1
- import{a,b,c,d,e}from"../chunk-6WDVDEQZ.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-MCFQE4GC.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-KDMSOCZY.mjs";export{e as AptosApiError,d as KeylessError,a as KeylessErrorCategory,b as KeylessErrorResolutionTip,c as KeylessErrorType};
1
+ import{AptosApiType as A}from"../utils/const";import{getErrorMessage as N}from"../utils/helpers";var l=(t=>(t[t.API_ERROR=0]="API_ERROR",t[t.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",t[t.SESSION_EXPIRED=2]="SESSION_EXPIRED",t[t.INVALID_STATE=3]="INVALID_STATE",t[t.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",t[t.UNKNOWN=5]="UNKNOWN",t))(l||{}),O=(s=>(s.REAUTHENTICATE="Re-authentiate to continue using your keyless account",s.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",s.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",s.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",s.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",s.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",s.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",s))(O||{}),u=(e=>(e[e.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",e[e.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",e[e.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",e[e.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",e[e.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",e[e.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",e[e.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",e[e.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",e[e.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",e[e.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",e[e.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",e[e.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",e[e.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",e[e.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",e[e.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",e[e.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",e[e.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",e[e.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",e[e.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",e[e.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",e[e.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",e[e.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",e[e.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",e[e.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",e[e.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",e[e.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",e[e.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",e[e.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",e[e.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",e[e.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",e[e.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",e[e.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",e[e.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",e[e.UNKNOWN=33]="UNKNOWN",e))(u||{});const a={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]};class T extends Error{constructor(o){const{innerError:r,category:E,resolutionTip:i,type:R,message:t=a[R][0],details:I}=o;super(t),this.name="KeylessError",this.innerError=r,this.category=E,this.resolutionTip=i,this.type=R,this.details=I,this.message=T.constructMessage(t,i,r,I)}static constructMessage(o,r,E,i){let R=`
2
+ Message: ${o}`;return i&&(R+=`
3
+ Details: ${i}`),E instanceof S?R+=`
4
+ AptosApiError: ${E.message}`:E!==void 0&&(R+=`
5
+ Error: ${N(E)}`),R+=`
6
+ KeylessErrorResolutionTip: ${r}`,R}static fromErrorType(o){const{error:r,type:E,details:i}=o,[R,t,I]=a[E];return new T({message:R,details:i,innerError:r,category:t,resolutionTip:I,type:E})}}class S extends Error{constructor({apiType:o,aptosRequest:r,aptosResponse:E}){super(P({apiType:o,aptosRequest:r,aptosResponse:E})),this.name="AptosApiError",this.url=E.url,this.status=E.status,this.statusText=E.statusText,this.data=E.data,this.request=r}}function P({apiType:_,aptosRequest:o,aptosResponse:r}){const E=r.headers?.traceparent?.split("-")[1],i=E?`(trace_id:${E}) `:"",R=`Request to [${_}]: ${o.method} ${r.url??o.url} ${i}failed with`;return _===A.INDEXER&&r.data?.errors?.[0]?.message!=null?`${R}: ${r.data.errors[0].message}`:r.data?.message!=null&&r.data?.error_code!=null?`${R}: ${JSON.stringify(r.data)}`:`${R} status: ${r.statusText}(code:${r.status}) and response body: ${h(r.data)}`}const n=400;function h(_){const o=JSON.stringify(_);return o.length<=n?o:`truncated(original_size:${o.length}): ${o.slice(0,n/2)}...${o.slice(-n/2)}`}export{S as AptosApiError,T as KeylessError,l as KeylessErrorCategory,O as KeylessErrorResolutionTip,u as KeylessErrorType};
2
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/errors/index.ts"],"sourcesContent":["import { AptosApiType } from \"../utils/const\";\nimport { getErrorMessage } from \"../utils/helpers\";\nimport { AptosRequest, AptosResponse } from \"../types\";\n\nexport enum KeylessErrorCategory {\n API_ERROR,\n EXTERNAL_API_ERROR,\n SESSION_EXPIRED,\n INVALID_STATE,\n INVALID_SIGNATURE,\n UNKNOWN,\n}\n\nexport enum KeylessErrorResolutionTip {\n REAUTHENTICATE = \"Re-authentiate to continue using your keyless account\",\n // eslint-disable-next-line max-len\n REAUTHENTICATE_UNSURE = \"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support\",\n UPDATE_REQUEST_PARAMS = \"Update the invalid request parameters and reauthenticate.\",\n // eslint-disable-next-line max-len\n RATE_LIMIT_EXCEEDED = \"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.\",\n // eslint-disable-next-line max-len\n SERVER_ERROR = \"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n // eslint-disable-next-line max-len\n CALL_PRECHECK = \"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.\",\n REINSTANTIATE = \"Try instantiating the account again. Avoid manipulating the account object directly\",\n JOIN_SUPPORT_GROUP = \"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n UNKNOWN = \"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n}\n\nexport enum KeylessErrorType {\n EPHEMERAL_KEY_PAIR_EXPIRED,\n\n PROOF_NOT_FOUND,\n\n ASYNC_PROOF_FETCH_FAILED,\n\n INVALID_PROOF_VERIFICATION_FAILED,\n\n INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND,\n\n INVALID_JWT_SIG,\n\n INVALID_JWT_JWK_NOT_FOUND,\n\n INVALID_JWT_ISS_NOT_RECOGNIZED,\n\n INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED,\n\n INVALID_TW_SIG_VERIFICATION_FAILED,\n\n INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND,\n\n INVALID_EXPIRY_HORIZON,\n\n JWT_PARSING_ERROR,\n\n JWK_FETCH_FAILED,\n\n JWK_FETCH_FAILED_FEDERATED,\n\n RATE_LIMIT_EXCEEDED,\n\n PEPPER_SERVICE_INTERNAL_ERROR,\n\n PEPPER_SERVICE_BAD_REQUEST,\n\n PEPPER_SERVICE_OTHER,\n\n PROVER_SERVICE_INTERNAL_ERROR,\n\n PROVER_SERVICE_BAD_REQUEST,\n\n PROVER_SERVICE_OTHER,\n\n FULL_NODE_CONFIG_LOOKUP_ERROR,\n\n FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR,\n\n FULL_NODE_JWKS_LOOKUP_ERROR,\n\n FULL_NODE_OTHER,\n\n SIGNATURE_TYPE_INVALID,\n\n SIGNATURE_EXPIRED,\n\n MAX_EXPIRY_HORIZON_EXCEEDED,\n\n EPHEMERAL_SIGNATURE_VERIFICATION_FAILED,\n\n TRAINING_WHEELS_SIGNATURE_MISSING,\n\n TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED,\n\n PROOF_VERIFICATION_FAILED,\n\n UNKNOWN,\n}\n\nconst KeylessErrors: { [key in KeylessErrorType]: [string, KeylessErrorCategory, KeylessErrorResolutionTip] } = {\n [KeylessErrorType.EPHEMERAL_KEY_PAIR_EXPIRED]: [\n \"The ephemeral keypair has expired.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.PROOF_NOT_FOUND]: [\n \"The required proof could not be found.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.CALL_PRECHECK,\n ],\n [KeylessErrorType.ASYNC_PROOF_FETCH_FAILED]: [\n \"The required proof failed to fetch.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_PROOF_VERIFICATION_FAILED]: [\n \"The provided proof is invalid.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND]: [\n \"The verification key used to authenticate was updated.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_JWT_SIG]: [\n \"The JWK was found, but JWT failed verification\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_JWT_JWK_NOT_FOUND]: [\n \"The JWK required to verify the JWT could not be found. The JWK may have been rotated out.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_JWT_ISS_NOT_RECOGNIZED]: [\n \"The JWT issuer is not recognized.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED]: [\n \"The JWT issuer is not supported by the Federated Keyless \",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_TW_SIG_VERIFICATION_FAILED]: [\n \"The training wheels signature is invalid.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND]: [\n \"The public key used to verify the training wheels signature was not found.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_EXPIRY_HORIZON]: [\n \"The expiry horizon is invalid.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.JWK_FETCH_FAILED]: [\n \"Failed to fetch JWKS.\",\n KeylessErrorCategory.EXTERNAL_API_ERROR,\n KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,\n ],\n [KeylessErrorType.JWK_FETCH_FAILED_FEDERATED]: [\n \"Failed to fetch JWKS for Federated Keyless provider.\",\n KeylessErrorCategory.EXTERNAL_API_ERROR,\n KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,\n ],\n [KeylessErrorType.RATE_LIMIT_EXCEEDED]: [\n \"Rate limit exceeded. Too many requests in a short period.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.RATE_LIMIT_EXCEEDED,\n ],\n [KeylessErrorType.PEPPER_SERVICE_INTERNAL_ERROR]: [\n \"Internal error from Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PEPPER_SERVICE_BAD_REQUEST]: [\n \"Bad request sent to Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.PEPPER_SERVICE_OTHER]: [\n \"Unknown error from Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PROVER_SERVICE_INTERNAL_ERROR]: [\n \"Internal error from Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PROVER_SERVICE_BAD_REQUEST]: [\n \"Bad request sent to Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.PROVER_SERVICE_OTHER]: [\n \"Unknown error from Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.JWT_PARSING_ERROR]: [\n \"Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REINSTANTIATE,\n ],\n [KeylessErrorType.FULL_NODE_CONFIG_LOOKUP_ERROR]: [\n \"Error when looking up on-chain keyless configuration.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR]: [\n \"Error when looking up on-chain verification key.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_JWKS_LOOKUP_ERROR]: [\n \"Error when looking up on-chain JWKS.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_OTHER]: [\n \"Unknown error from full node.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.SIGNATURE_TYPE_INVALID]: [\n \"The signature is not a valid Keyless signature.\",\n KeylessErrorCategory.INVALID_SIGNATURE,\n KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,\n ],\n [KeylessErrorType.SIGNATURE_EXPIRED]: [\n \"The ephemeral key pair used to sign the message has expired.\",\n KeylessErrorCategory.INVALID_SIGNATURE,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.MAX_EXPIRY_HORIZON_EXCEEDED]: [\n \"The expiry horizon on the signature exceeds the maximum allowed value.\",\n KeylessErrorCategory.INVALID_SIGNATURE,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED]: [\n \"Failed to verify the ephemeral signature with the ephemeral public key.\",\n KeylessErrorCategory.INVALID_SIGNATURE,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.TRAINING_WHEELS_SIGNATURE_MISSING]: [\n \"The training wheels signature is missing but is required by the Keyless configuration.\",\n KeylessErrorCategory.INVALID_SIGNATURE,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED]: [\n \"Failed to verify the training wheels signature with the training wheels public key.\",\n KeylessErrorCategory.INVALID_SIGNATURE,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.PROOF_VERIFICATION_FAILED]: [\n \"The proof verification failed.\",\n KeylessErrorCategory.INVALID_SIGNATURE,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.UNKNOWN]: [\n \"An unknown error has occurred.\",\n KeylessErrorCategory.UNKNOWN,\n KeylessErrorResolutionTip.UNKNOWN,\n ],\n};\n\nexport class KeylessError extends Error {\n readonly innerError?: unknown;\n\n readonly category: KeylessErrorCategory;\n\n readonly resolutionTip: KeylessErrorResolutionTip;\n\n readonly type: KeylessErrorType;\n\n readonly details?: string;\n\n /** @internal this constructor is for sdk internal use - do not instantiate outside of the SDK codebase */\n constructor(args: {\n innerError?: unknown;\n category: KeylessErrorCategory;\n resolutionTip: KeylessErrorResolutionTip;\n type: KeylessErrorType;\n message?: string;\n details?: string;\n }) {\n const { innerError, category, resolutionTip, type, message = KeylessErrors[type][0], details } = args;\n super(message);\n this.name = \"KeylessError\";\n this.innerError = innerError;\n this.category = category;\n this.resolutionTip = resolutionTip;\n this.type = type;\n this.details = details;\n this.message = KeylessError.constructMessage(message, resolutionTip, innerError, details);\n }\n\n static constructMessage(\n message: string,\n tip: KeylessErrorResolutionTip,\n innerError?: unknown,\n details?: string,\n ): string {\n let result = `\\nMessage: ${message}`;\n if (details) {\n result += `\\nDetails: ${details}`;\n }\n if (innerError instanceof AptosApiError) {\n result += `\\nAptosApiError: ${innerError.message}`;\n } else if (innerError !== undefined) {\n result += `\\nError: ${getErrorMessage(innerError)}`;\n }\n result += `\\nKeylessErrorResolutionTip: ${tip}`;\n return result;\n }\n\n /**\n * Static constructor that creates a KeylessError instance using the KeylessErrors constant\n * @param args.type The type of KeylessError\n * @param args.aptosApiError optional AptosApiError supplied for api errors\n * @param args.details optional details to include in the error message\n * @returns A new KeylessError instance\n */\n static fromErrorType(args: { type: KeylessErrorType; error?: unknown; details?: string }): KeylessError {\n const { error, type, details } = args;\n\n const [message, category, resolutionTip] = KeylessErrors[type];\n return new KeylessError({\n message,\n details,\n innerError: error,\n category,\n resolutionTip,\n type,\n });\n }\n}\n\n/**\n * Options for handling errors in the Aptos API.\n */\ntype AptosApiErrorOpts = {\n apiType: AptosApiType;\n aptosRequest: AptosRequest;\n aptosResponse: AptosResponse<any, any>;\n};\n\n/**\n * Represents an error returned from the Aptos API.\n * This class encapsulates the details of the error, including the request URL, response status, and additional data.\n *\n * @param name - The name of the error, which is always \"AptosApiError\".\n * @param url - The URL to which the request was made.\n * @param status - The HTTP response status code (e.g., 400).\n * @param statusText - The message associated with the response status.\n * @param data - The response data returned from the API.\n * @param request - The original AptosRequest that triggered the error.\n */\nexport class AptosApiError extends Error {\n readonly url: string;\n\n readonly status: number;\n\n readonly statusText: string;\n\n readonly data: any;\n\n readonly request: AptosRequest;\n\n /**\n * Constructs an instance of AptosApiError with relevant error details.\n *\n * @param opts - The options for creating the AptosApiError.\n * @param opts.apiType - The type of API that generated the error.\n * @param opts.aptosRequest - The request object that caused the error.\n * @param opts.aptosResponse - The response object containing error details.\n *\n * @internal This constructor is for SDK internal use - do not instantiate outside the SDK codebase.\n */\n constructor({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts) {\n super(deriveErrorMessage({ apiType, aptosRequest, aptosResponse }));\n\n this.name = \"AptosApiError\";\n this.url = aptosResponse.url;\n this.status = aptosResponse.status;\n this.statusText = aptosResponse.statusText;\n this.data = aptosResponse.data;\n this.request = aptosRequest;\n }\n}\n\n/**\n * Derives an error message from the Aptos API response, providing context for debugging.\n * This function helps in understanding the nature of the error encountered during an API request.\n *\n * @param {AptosApiErrorOpts} opts - The options for deriving the error message.\n * @param {AptosApiType} opts.apiType - The type of API being called.\n * @param {AptosRequest} opts.aptosRequest - The original request made to the Aptos API.\n * @param {AptosResponse} opts.aptosResponse - The response received from the Aptos API.\n */\nfunction deriveErrorMessage({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts): string {\n // eslint-disable-next-line max-len\n // extract the W3C trace_id from the response headers if it exists. Some services set this in the response, and it's useful for debugging.\n // See https://www.w3.org/TR/trace-context/#relationship-between-the-headers .\n const traceId = aptosResponse.headers?.traceparent?.split(\"-\")[1];\n const traceIdString = traceId ? `(trace_id:${traceId}) ` : \"\";\n\n const errorPrelude: string = `Request to [${apiType}]: ${aptosRequest.method} ${\n aptosResponse.url ?? aptosRequest.url\n } ${traceIdString}failed with`;\n\n // handle graphql responses from indexer api and extract the error message of the first error\n if (apiType === AptosApiType.INDEXER && aptosResponse.data?.errors?.[0]?.message != null) {\n return `${errorPrelude}: ${aptosResponse.data.errors[0].message}`;\n }\n\n // Received well-known structured error response body - simply serialize and return it.\n // We don't need http status codes etc. in this case.\n if (aptosResponse.data?.message != null && aptosResponse.data?.error_code != null) {\n return `${errorPrelude}: ${JSON.stringify(aptosResponse.data)}`;\n }\n\n // This is the generic/catch-all case. We received some response from the API, but it doesn't appear to be a well-known structure.\n // We print http status codes and the response body (after some trimming),\n // in the hope that this gives enough context what went wrong without printing overly huge messages.\n return `${errorPrelude} status: ${aptosResponse.statusText}(code:${\n aptosResponse.status\n }) and response body: ${serializeAnyPayloadForErrorMessage(aptosResponse.data)}`;\n}\n\nconst SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH = 400;\n\n/**\n * This function accepts a payload of any type (probably an object) and serializes it to a string\n * Since we don't know the type or size of the payload, and we don't want to add a huge object in full to the error message\n * we limit the to the first 200 and last 200 characters of the serialized payload and put a \"...\" in the middle.\n * @param payload - The payload to serialize, which can be of any type.\n *\n * @returns A string representation of the serialized payload, potentially truncated.\n */\nfunction serializeAnyPayloadForErrorMessage(payload: any): string {\n const serializedPayload = JSON.stringify(payload);\n if (serializedPayload.length <= SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH) {\n return serializedPayload;\n }\n return `truncated(original_size:${serializedPayload.length}): ${serializedPayload.slice(\n 0,\n SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2,\n )}...${serializedPayload.slice(-SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2)}`;\n}\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,iBAC7B,OAAS,mBAAAC,MAAuB,mBAGzB,IAAKC,OACVA,IAAA,yBACAA,IAAA,2CACAA,IAAA,qCACAA,IAAA,iCACAA,IAAA,yCACAA,IAAA,qBANUA,OAAA,IASAC,OACVA,EAAA,eAAiB,wDAEjBA,EAAA,sBAAwB,4HACxBA,EAAA,sBAAwB,4DAExBA,EAAA,oBAAsB,iPAEtBA,EAAA,aAAe,+IAEfA,EAAA,cAAgB,mJAChBA,EAAA,cAAgB,uFAChBA,EAAA,mBAAqB,wEACrBA,EAAA,QAAU,uFAbAA,OAAA,IAgBAC,OACVA,IAAA,2DAEAA,IAAA,qCAEAA,IAAA,uDAEAA,IAAA,yEAEAA,IAAA,uFAEAA,IAAA,qCAEAA,IAAA,yDAEAA,IAAA,mEAEAA,IAAA,qFAEAA,IAAA,2EAEAA,IAAA,8EAEAA,IAAA,oDAEAA,IAAA,0CAEAA,IAAA,wCAEAA,IAAA,4DAEAA,IAAA,8CAEAA,IAAA,kEAEAA,IAAA,4DAEAA,IAAA,gDAEAA,IAAA,kEAEAA,IAAA,4DAEAA,IAAA,gDAEAA,IAAA,kEAEAA,IAAA,sFAEAA,IAAA,8DAEAA,IAAA,sCAEAA,IAAA,oDAEAA,IAAA,0CAEAA,IAAA,8DAEAA,IAAA,sFAEAA,IAAA,0EAEAA,IAAA,kGAEAA,IAAA,0DAEAA,IAAA,sBAnEUA,OAAA,IAsEZ,MAAMC,EAA0G,CAC7G,EAA8C,CAC7C,qCACA,EACA,uDACF,EACC,EAAmC,CAClC,yCACA,EACA,kJACF,EACC,EAA4C,CAC3C,sCACA,EACA,2HACF,EACC,EAAqD,CACpD,iCACA,EACA,2HACF,EACC,EAA4D,CAC3D,yDACA,EACA,uDACF,EACC,EAAmC,CAClC,iDACA,EACA,2HACF,EACC,EAA6C,CAC5C,4FACA,EACA,uDACF,EACC,EAAkD,CACjD,oCACA,EACA,2DACF,EACC,EAA2D,CAC1D,4DACA,EACA,2HACF,EACC,EAAsD,CACrD,4CACA,EACA,2HACF,EACC,GAAuD,CACtD,6EACA,EACA,uDACF,EACC,GAA0C,CACzC,iCACA,EACA,uDACF,EACC,GAAoC,CACnC,wBACA,EACA,uEACF,EACC,GAA8C,CAC7C,uDACA,EACA,uEACF,EACC,GAAuC,CACtC,4DACA,EACA,gPACF,EACC,GAAiD,CAChD,sCACA,EACA,8IACF,EACC,GAA8C,CAC7C,sCACA,EACA,2DACF,EACC,GAAwC,CACvC,qCACA,EACA,8IACF,EACC,GAAiD,CAChD,sCACA,EACA,8IACF,EACC,GAA8C,CAC7C,sCACA,EACA,2DACF,EACC,GAAwC,CACvC,qCACA,EACA,8IACF,EACC,GAAqC,CACpC,oGACA,EACA,sFACF,EACC,GAAiD,CAChD,wDACA,EACA,8IACF,EACC,GAA2D,CAC1D,mDACA,EACA,8IACF,EACC,GAA+C,CAC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,CAAC,CAAC,EAC5E","names":["AptosApiType","getErrorMessage","KeylessErrorCategory","KeylessErrorResolutionTip","KeylessErrorType","KeylessErrors","KeylessError","args","innerError","category","resolutionTip","type","message","details","tip","result","AptosApiError","error","apiType","aptosRequest","aptosResponse","deriveErrorMessage","traceId","traceIdString","errorPrelude","serializeAnyPayloadForErrorMessage","SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH","payload","serializedPayload"]}
@@ -14,7 +14,7 @@ export { EntryFunctionBytes } from './bcs/serializable/entryFunctionBytes.mjs';
14
14
  export { aptosRequest, request } from './client/core.mjs';
15
15
  export { GetAptosRequestOptions, GetRequestOptions, get, getAptosFullNode, getAptosPepperService, getPageWithObfuscatedCursor, paginateWithCursor, paginateWithObfuscatedCursor } from './client/get.mjs';
16
16
  export { PostAptosRequestOptions, PostRequestOptions, post, postAptosFaucet, postAptosFullNode, postAptosIndexer, postAptosPepperService, postAptosProvingService } from './client/post.mjs';
17
- export { createObjectAddress, createResourceAddress, createTokenAddress } from './core/account/utils/address.mjs';
17
+ export { createObjectAddress, createResourceAddress, createTokenAddress, createUserDerivedObjectAddress } from './core/account/utils/address.mjs';
18
18
  export { ParsingError, ParsingResult } from './core/common.mjs';
19
19
  export { AbstractPublicKey, AbstractSignature } from './core/crypto/abstraction.mjs';
20
20
  export { EphemeralPublicKey, EphemeralSignature } from './core/crypto/ephemeral.mjs';
@@ -1,2 +1,2 @@
1
- import{$ as Hc,$a as Kd,$b as Je,A as fc,Aa as id,Ab as ie,B as gc,Ba as jd,Bb as je,C as hc,Ca as kd,Cb as ke,D as ic,Da as ld,Db as le,E as jc,Ea as md,Eb as me,F as oc,Fa as nd,Fb as ne,G as pc,Ga as od,Gb as oe,H as qc,Ha as pd,Hb as pe,I as rc,Ia as qd,Ib as qe,J as sc,Ja as rd,Jb as re,K as tc,Ka as sd,Kb as se,L as uc,La as td,Lb as te,Ma as ud,Mb as ue,Na as vd,Nb as ve,Oa as wd,Ob as we,P as vc,Pa as xd,Pb as xe,Q as wc,Qa as zd,Qb as ye,R as xc,Ra as Ad,Rb as ze,S as yc,Sa as Bd,Sb as Ae,T as zc,Ta as Cd,Tb as Be,U as Ac,Ua as Dd,Ub as Ce,V as Bc,Va as Ed,Vb as De,W as Cc,Wa as Fd,Wb as Ee,X as Dc,Xa as Gd,Xb as Fe,Y as Ec,Ya as Hd,Yb as Ge,Z as Fc,Za as Id,Zb as He,_ as Gc,_a as Jd,_b as Ie,a as Aa,aa as Ic,ab as Ld,ac as Ke,b as Ba,ba as Lc,bb as Md,bc as Le,c as Jb,ca as Mc,cb as Nd,cc as Me,d as Kb,da as Nc,db as Od,dc as Ne,e as Lb,ea as Oc,eb as Pd,ec as Oe,f as Mb,fa as Pc,fb as Qd,fc as Pe,fe as Re,g as Nb,ga as Qc,gb as Rd,ge as Se,h as Ob,ha as Rc,hb as Sd,he as Te,i as Pb,ia as Sc,ib as Td,ie as Ue,j as Qb,ja as Tc,jb as Ud,k as Rb,ka as Uc,kb as Vd,l as Sb,la as Vc,lb as Wd,m as Tb,ma as Wc,mb as Xd,n as Ub,na as Xc,o as Vb,oa as Yc,ob as Yd,p as Wb,pa as Zc,pb as Zd,q as Xb,qa as _c,qb as _d,r as Yb,ra as $c,rb as $d,s as Zb,sa as ad,sb as ae,t as _b,ta as bd,tb as be,te as Ve,u as $b,ua as cd,ub as ce,v as ac,va as dd,vb as de,w as bc,wa as ed,wb as ee,x as cc,xa as fd,xb as fe,y as dc,ya as gd,yb as ge,z as ec,za as hd,zb as he}from"./chunk-L72TIN7T.mjs";import{a as yd}from"./chunk-2XQKGWHQ.mjs";import"./chunk-UYVPNUH3.mjs";import{a as Jc}from"./chunk-XKUIMGKU.mjs";import{a as Kc}from"./chunk-N6YTF76Q.mjs";import"./chunk-A5L76YP7.mjs";import{a as kc,b as lc,c as mc,d as nc}from"./chunk-I7XT6L7S.mjs";import"./chunk-5HXLZHDW.mjs";import"./chunk-G3MHXDYA.mjs";import"./chunk-JABP65XD.mjs";import{a as Ca,b as Da,c as Ea,d as Fa,e as Ga}from"./chunk-GOXRBEIJ.mjs";import{a as za}from"./chunk-2PASUPUO.mjs";import"./chunk-XJJVJOX5.mjs";import"./chunk-NECL5FCQ.mjs";import"./chunk-4QMXOWHP.mjs";import{a as na,b as oa}from"./chunk-EF4FA5I6.mjs";import{a as ma}from"./chunk-WCMW2L3P.mjs";import{a as ka,b as la}from"./chunk-WSR5EBJM.mjs";import{a as pa,b as qa,c as ra,d as sa,e as ta,f as ua,g as va,h as wa,i as xa,j as ya}from"./chunk-C3Q23D22.mjs";import"./chunk-QREVMGQZ.mjs";import"./chunk-V3MBJJTL.mjs";import"./chunk-ZP4DWSQA.mjs";import{a as ja}from"./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{a as Db,b as Eb,c as Fb,d as Gb,e as Hb,f as Ib}from"./chunk-4AI7KQQ7.mjs";import{a as xb,b as yb,c as zb,d as Ab,e as Bb,f as Cb}from"./chunk-7EER7GWV.mjs";import{a as vb,b as wb}from"./chunk-QP2BY4PK.mjs";import"./chunk-HGLO5LDS.mjs";import{a as _a}from"./chunk-CW35YAMN.mjs";import{a as qb,b as rb,c as sb,d as tb,e as ub}from"./chunk-6WDVDEQZ.mjs";import{a as Qe}from"./chunk-RCSJFTST.mjs";import{a as Ha,b as Ia,c as Ja,d as Ka,e as La,f as Ma,g as Na,h as Oa}from"./chunk-4RXKALLC.mjs";import{a as Pa,b as Qa,c as Ra,d as Sa,e as Ta,f as Ua,g as Va,h as Wa,i as Xa,j as Ya,k as Za}from"./chunk-OLILO7VD.mjs";import{a as cb,b as db,c as eb,d as fb,e as gb,f as hb,g as ib,h as jb,i as kb,j as lb,k as mb,l as nb,m as ob,n as pb}from"./chunk-7DQDJ2SA.mjs";import{a as $a,b as ab,c as bb}from"./chunk-HNBVYE3N.mjs";import{a as ha,b as ia}from"./chunk-RGKRCZ36.mjs";import"./chunk-FZY4PMEE.mjs";import{a as da,b as ea,c as fa,d as ga}from"./chunk-Q4W3WJ2U.mjs";import{a as l}from"./chunk-TOBQ5UE6.mjs";import{a as k}from"./chunk-MT2RJ7H3.mjs";import{a as Y,b as Z,c as _,d as $,e as aa,f as ba,g as ca}from"./chunk-ORMOQWWH.mjs";import"./chunk-FD6FGKYY.mjs";import"./chunk-4WPQQPUF.mjs";import{A as M,B as N,C as O,D as P,E as Q,F as R,G as S,H as T,I as U,J as V,K as W,L as X,a as m,b as n,c as o,d as p,e as q,f as r,g as s,h as t,i as u,j as v,k as w,l as x,m as y,n as z,o as A,p as B,q as C,r as D,s as E,t as F,u as G,v as H,w as I,x as J,y as K,z as L}from"./chunk-MCFQE4GC.mjs";import{a as e}from"./chunk-FLZPUYXQ.mjs";import{a as f,b as g,c as h,d as i,e as j}from"./chunk-EBMEXURY.mjs";import{a as b,b as c,c as d}from"./chunk-STY74NUA.mjs";import{a}from"./chunk-IF4UU2MT.mjs";import"./chunk-56CNRT2K.mjs";import"./chunk-CIJA7ONS.mjs";import"./chunk-KDMSOCZY.mjs";export{Xa as ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT,qa as APTOS_BIP44_REGEX,Ta as APTOS_COIN,Ua as APTOS_FA,pa as APTOS_HARDENED_REGEX,Sd as AbstractKeylessAccount,qc as AbstractMultiKey,oa as AbstractPublicKey,na as AbstractSignature,Zd as AbstractedAccount,Pd as Account,Ic as AccountAbstractionMessage,ia as AccountAddress,Bc as AccountAuthenticator,Hc as AccountAuthenticatorAbstraction,Cc as AccountAuthenticatorEd25519,Dc as AccountAuthenticatorMultiEd25519,Fc as AccountAuthenticatorMultiKey,Gc as AccountAuthenticatorNoAccountAuthenticator,Ec as AccountAuthenticatorSingleKey,v as AccountAuthenticatorVariant,la as AccountPublicKey,Re as AccountSequenceNumber,Yd as AccountUtils,ha as AddressInvalidReason,oc as AnyPublicKey,x as AnyPublicKeyVariant,pc as AnySignature,z as AnySignatureVariant,Ve as Aptos,ub as AptosApiError,Pa as AptosApiType,Qe as AptosConfig,ja as AuthenticationKey,Y as Bool,wa as CKDPriv,Jc as ChainId,Qa as DEFAULT_MAX_GAS_AMOUNT,Ra as DEFAULT_TXN_EXP_SEC_FROM_NOW,Sa as DEFAULT_TXN_TIMEOUT_SEC,_d as DerivableAbstractedAccount,X as DeriveScheme,e as Deserializer,Jb as EPK_HORIZON_SECS,Md as Ed25519Account,xc as Ed25519PrivateKey,wc as Ed25519PublicKey,yc as Ed25519Signature,id as EntryFunction,l as EntryFunctionBytes,Wb as EphemeralCertificate,C as EphemeralCertificateVariant,Qd as EphemeralKeyPair,Aa as EphemeralPublicKey,A as EphemeralPublicKeyVariant,Ba as EphemeralSignature,B as EphemeralSignatureVariant,Za as FIREBASE_AUTH_ISS_PATTERN,Vd as FederatedKeylessAccount,gc as FederatedKeylessPublicKey,xd as FeePayerRawTransaction,k as FixedBytes,Yb as Groth16ProofAndStatement,ac as Groth16VerificationKey,Xb as Groth16Zkp,sa as HARDENED_OFFSET,c as Hex,b as HexInvalidReason,Kc as Identifier,ra as KeyType,Ud as KeylessAccount,$b as KeylessConfiguration,tb as KeylessError,qb as KeylessErrorCategory,rb as KeylessErrorResolutionTip,sb as KeylessErrorType,Rb as KeylessPublicKey,Vb as KeylessSignature,Kb as MAX_AUD_VAL_BYTES,Qb as MAX_COMMITED_EPK_BYTES,Ob as MAX_EXTRA_FIELD_BYTES,Nb as MAX_ISS_VAL_BYTES,Pb as MAX_JWT_HEADER_B64_BYTES,Lb as MAX_UID_KEY_BYTES,Mb as MAX_UID_VAL_BYTES,m as MimeType,Lc as ModuleId,T as MoveAbility,S as MoveFunctionVisibility,ec as MoveJWK,ga as MoveOption,fa as MoveString,da as MoveVector,wd as MultiAgentRawTransaction,Hd as MultiAgentTransaction,Xd as MultiEd25519Account,tc as MultiEd25519PublicKey,uc as MultiEd25519Signature,rc as MultiKey,Wd as MultiKeyAccount,sc as MultiKeySignature,kd as MultiSig,ld as MultiSigTransactionPayload,Ma as Network,Na as NetworkToChainId,Ja as NetworkToFaucetAPI,Ha as NetworkToIndexerAPI,Oa as NetworkToNetworkName,Ia as NetworkToNodeAPI,Ka as NetworkToPepperAPI,La as NetworkToProverAPI,a as ParsingError,za as PrivateKey,w as PrivateKeyVariants,Ya as ProcessorType,ka as PublicKey,Va as RAW_TRANSACTION_SALT,Wa as RAW_TRANSACTION_WITH_DATA_SALT,ud as RawTransaction,vd as RawTransactionWithData,U as RoleType,yd as RotationProofChallenge,jd as Script,o as ScriptTransactionArgumentVariants,ic as Secp256k1PrivateKey,hc as Secp256k1PublicKey,jc as Secp256k1Signature,lc as Secp256r1PrivateKey,kc as Secp256r1PublicKey,nc as Secp256r1Signature,f as Serializable,ea as Serialized,g as Serializer,ma as Signature,Fd as SignedTransaction,V as SigningScheme,W as SigningSchemeInput,Gd as SimpleTransaction,Od as SingleKeyAccount,_c as StructTag,Td as TransactionAndProof,zd as TransactionAuthenticator,Ad as TransactionAuthenticatorEd25519,Dd as TransactionAuthenticatorFeePayer,Cd as TransactionAuthenticatorMultiAgent,Bd as TransactionAuthenticatorMultiEd25519,Ed as TransactionAuthenticatorSingleSender,u as TransactionAuthenticatorVariant,od as TransactionExecutable,rd as TransactionExecutableEmpty,qd as TransactionExecutableEntryFunction,pd as TransactionExecutableScript,r as TransactionExecutableVariants,sd as TransactionExtraConfig,td as TransactionExtraConfigV1,s as TransactionExtraConfigVariants,md as TransactionInnerPayload,nd as TransactionInnerPayloadV1,q as TransactionInnerPayloadVariants,ed as TransactionPayload,gd as TransactionPayloadEntryFunction,hd as TransactionPayloadMultiSig,fd as TransactionPayloadScript,p as TransactionPayloadVariants,E as TransactionResponseType,t as TransactionVariants,Ue as TransactionWorker,Te as TransactionWorkerEventsEnum,Mc as TypeTag,Uc as TypeTagAddress,Nc as TypeTagBool,Xc as TypeTagGeneric,ae as TypeTagParserError,$d as TypeTagParserErrorType,Wc as TypeTagReference,Vc as TypeTagSigner,Zc as TypeTagStruct,Sc as TypeTagU128,Pc as TypeTagU16,Tc as TypeTagU256,Qc as TypeTagU32,Rc as TypeTagU64,Oc as TypeTagU8,n as TypeTagVariants,Yc as TypeTagVector,ba as U128,_ as U16,ca as U256,$ as U32,aa as U64,Z as U8,mc as WebAuthnSignature,_b as ZeroKnowledgeSig,Zb as ZkProof,D as ZkpVariant,y as anyPublicKeyVariantToString,$c as aptosCoinStructTag,wb as aptosRequest,gb as base64UrlDecode,hb as base64UrlToBytes,Fa as bigIntToBytesLE,Ke as buildTransaction,Ea as bytesToBigIntLE,De as checkOrConvertArgument,ib as convertAmountFromHumanReadableToOnChain,jb as convertAmountFromOnChainToHumanReadable,Ce as convertArgument,fe as convertNumber,Je as convertPayloadToInnerPayload,$a as createObjectAddress,ab as createResourceAddress,bb as createTokenAddress,va as deriveKey,Id as deriveTransactionType,dd as deserializeFromScriptArgument,zc as deserializePublicKey,Ac as deserializeSignature,h as ensureBoolean,Ae as fetchEntryFunctionAbi,ye as fetchFunctionAbi,Ub as fetchJWK,xe as fetchModuleAbi,ze as fetchMoveFunctionAbi,Be as fetchViewFunctionAbi,ve as findFirstNonSignerArg,fb as floorToWholeHour,Ie as generateRawTransaction,Ne as generateSignedTransaction,Le as generateSignedTransactionForSimulation,Jd as generateSigningMessage,Kd as generateSigningMessageForSerializable,Ld as generateSigningMessageForTransaction,Ee as generateTransactionPayload,Fe as generateTransactionPayloadWithABI,Pe as generateUserTransactionHash,Ge as generateViewFunctionPayload,He as generateViewFunctionPayloadWithABI,xb as get,yb as getAptosFullNode,zb as getAptosPepperService,Me as getAuthenticatorForSimulation,db as getErrorMessage,mb as getFunctionParts,cc as getIssAudAndUidVal,bc as getKeylessConfig,dc as getKeylessJWKs,Cb as getPageWithObfuscatedCursor,Ca as hashStrToField,Oe as hashValues,d as hexToAsciiString,ke as isBcsAddress,je as isBcsBool,me as isBcsFixedBytes,le as isBcsString,re as isBcsU128,oe as isBcsU16,se as isBcsU256,pe as isBcsU32,qe as isBcsU64,ne as isBcsU8,L as isBlockEpilogueTransactionResponse,I as isBlockMetadataTransactionResponse,ce as isBool,vc as isCanonicalEd25519Signature,M as isEd25519Signature,he as isEmptyOption,ie as isEncodedEntryFunctionArgument,lb as isEncodedStruct,P as isFeePayerSignature,H as isGenesisTransactionResponse,Rd as isKeylessSigner,ge as isLargeNumber,O as isMultiAgentSignature,Q as isMultiEd25519Signature,ee as isNumber,F as isPendingTransactionResponse,te as isScriptDataInput,N as isSecp256k1Signature,Nd as isSingleKeySigner,R as isSingleSenderSignature,J as isStateCheckpointTransactionResponse,de as isString,G as isUserTransactionResponse,ta as isValidBIP44Path,nb as isValidFunctionInfo,ua as isValidHardenedPath,K as isValidatorTransactionResponse,ya as mnemonicToSeed,_a as normalizeBundle,eb as nowInSeconds,cd as objectStructTag,bd as optionStructTag,i as outOfRangeErrorMessage,Da as padAndPackBytesWithLen,Ab as paginateWithCursor,Bb as paginateWithObfuscatedCursor,pb as pairedFaMetadataAddress,kb as parseEncodedStruct,fc as parseJwtHeader,be as parseTypeTag,Ga as poseidonHash,Db as post,Gb as postAptosFaucet,Eb as postAptosFullNode,Fb as postAptosIndexer,Hb as postAptosPepperService,Ib as postAptosProvingService,Se as promiseFulfilledStatus,vb as request,cb as sleep,xa as splitPath,we as standardizeTypeTags,ad as stringStructTag,ue as throwTypeMismatch,ob as truncateAddress,j as validateNumberInRange,Sb as verifyKeylessSignature,Tb as verifyKeylessSignatureWithJwkAndConfig};
1
+ export*from"./account";export*from"./api";export*from"./bcs";export*from"./client";export*from"./core";export*from"./errors";export*from"./transactions";export*from"./transactions/management";export*from"./types";export*from"./utils";
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from \"./account\";\nexport * from \"./api\";\nexport * from \"./bcs\";\nexport * from \"./client\";\nexport * from \"./core\";\nexport * from \"./errors\";\nexport * from \"./transactions\";\nexport * from \"./transactions/management\";\nexport * from \"./types\";\nexport * from \"./utils\";\n"],"mappings":"AAGA,WAAc,YACd,WAAc,QACd,WAAc,QACd,WAAc,WACd,WAAc,SACd,WAAc,WACd,WAAc,iBACd,WAAc,4BACd,WAAc,UACd,WAAc","names":[]}
@@ -1,2 +1,2 @@
1
- import{Sc as a,Tc as b,Uc 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{a as addAuthenticationFunctionTransaction,b as removeAuthenticationFunctionTransaction,c as removeDispatchableAuthenticatorTransaction};
1
+ import{TypeTagAddress as m,TypeTagStruct as a,stringStructTag as i}from"../transactions";import{generateTransaction as p}from"./transactionSubmission";import{getFunctionParts as d}from"../utils/helpers";async function l(n){const{aptosConfig:t,sender:o,authenticationFunction:e,options:r}=n,{moduleAddress:s,moduleName:c,functionName:u}=d(e);return p({aptosConfig:t,sender:o,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[s,c,u],abi:{typeParameters:[],parameters:[new m,new a(i()),new a(i())]}},options:r})}async function v(n){const{aptosConfig:t,sender:o,authenticationFunction:e,options:r}=n,{moduleAddress:s,moduleName:c,functionName:u}=d(e);return p({aptosConfig:t,sender:o,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[s,c,u],abi:{typeParameters:[],parameters:[new m,new a(i()),new a(i())]}},options:r})}async function w(n){const{aptosConfig:t,sender:o,options:e}=n;return p({aptosConfig:t,sender:o,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:e})}export{l as addAuthenticationFunctionTransaction,v as removeAuthenticationFunctionTransaction,w as removeDispatchableAuthenticatorTransaction};
2
2
  //# sourceMappingURL=abstraction.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/internal/abstraction.ts"],"sourcesContent":["import {\n SimpleTransaction,\n InputGenerateTransactionOptions,\n TypeTagAddress,\n TypeTagStruct,\n stringStructTag,\n} from \"../transactions\";\nimport { AccountAddressInput } from \"../core\";\nimport { generateTransaction } from \"./transactionSubmission\";\nimport { MoveFunctionId } from \"../types\";\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { getFunctionParts } from \"../utils/helpers\";\n\nexport async function addAuthenticationFunctionTransaction(args: {\n aptosConfig: AptosConfig;\n sender: AccountAddressInput;\n authenticationFunction: string;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, sender, authenticationFunction, options } = args;\n const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction as MoveFunctionId);\n return generateTransaction({\n aptosConfig,\n sender,\n data: {\n function: \"0x1::account_abstraction::add_authentication_function\",\n typeArguments: [],\n functionArguments: [moduleAddress, moduleName, functionName],\n abi: {\n typeParameters: [],\n parameters: [new TypeTagAddress(), new TypeTagStruct(stringStructTag()), new TypeTagStruct(stringStructTag())],\n },\n },\n options,\n });\n}\n\nexport async function removeAuthenticationFunctionTransaction(args: {\n aptosConfig: AptosConfig;\n sender: AccountAddressInput;\n authenticationFunction: string;\n options?: InputGenerateTransactionOptions;\n}) {\n const { aptosConfig, sender, authenticationFunction, options } = args;\n const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction as MoveFunctionId);\n return generateTransaction({\n aptosConfig,\n sender,\n data: {\n function: \"0x1::account_abstraction::remove_authentication_function\",\n typeArguments: [],\n functionArguments: [moduleAddress, moduleName, functionName],\n abi: {\n typeParameters: [],\n parameters: [new TypeTagAddress(), new TypeTagStruct(stringStructTag()), new TypeTagStruct(stringStructTag())],\n },\n },\n options,\n });\n}\n\nexport async function removeDispatchableAuthenticatorTransaction(args: {\n aptosConfig: AptosConfig;\n sender: AccountAddressInput;\n options?: InputGenerateTransactionOptions;\n}) {\n const { aptosConfig, sender, options } = args;\n return generateTransaction({\n aptosConfig,\n sender,\n data: {\n function: \"0x1::account_abstraction::remove_authenticator\",\n typeArguments: [],\n functionArguments: [],\n abi: { typeParameters: [], parameters: [] },\n },\n options,\n });\n}\n"],"mappings":"AAAA,OAGE,kBAAAA,EACA,iBAAAC,EACA,mBAAAC,MACK,kBAEP,OAAS,uBAAAC,MAA2B,0BAGpC,OAAS,oBAAAC,MAAwB,mBAEjC,eAAsBC,EAAqCC,EAK5B,CAC7B,KAAM,CAAE,YAAAC,EAAa,OAAAC,EAAQ,uBAAAC,EAAwB,QAAAC,CAAQ,EAAIJ,EAC3D,CAAE,cAAAK,EAAe,WAAAC,EAAY,aAAAC,CAAa,EAAIT,EAAiBK,CAAwC,EAC7G,OAAON,EAAoB,CACzB,YAAAI,EACA,OAAAC,EACA,KAAM,CACJ,SAAU,wDACV,cAAe,CAAC,EAChB,kBAAmB,CAACG,EAAeC,EAAYC,CAAY,EAC3D,IAAK,CACH,eAAgB,CAAC,EACjB,WAAY,CAAC,IAAIb,EAAkB,IAAIC,EAAcC,EAAgB,CAAC,EAAG,IAAID,EAAcC,EAAgB,CAAC,CAAC,CAC/G,CACF,EACA,QAAAQ,CACF,CAAC,CACH,CAEA,eAAsBI,EAAwCR,EAK3D,CACD,KAAM,CAAE,YAAAC,EAAa,OAAAC,EAAQ,uBAAAC,EAAwB,QAAAC,CAAQ,EAAIJ,EAC3D,CAAE,cAAAK,EAAe,WAAAC,EAAY,aAAAC,CAAa,EAAIT,EAAiBK,CAAwC,EAC7G,OAAON,EAAoB,CACzB,YAAAI,EACA,OAAAC,EACA,KAAM,CACJ,SAAU,2DACV,cAAe,CAAC,EAChB,kBAAmB,CAACG,EAAeC,EAAYC,CAAY,EAC3D,IAAK,CACH,eAAgB,CAAC,EACjB,WAAY,CAAC,IAAIb,EAAkB,IAAIC,EAAcC,EAAgB,CAAC,EAAG,IAAID,EAAcC,EAAgB,CAAC,CAAC,CAC/G,CACF,EACA,QAAAQ,CACF,CAAC,CACH,CAEA,eAAsBK,EAA2CT,EAI9D,CACD,KAAM,CAAE,YAAAC,EAAa,OAAAC,EAAQ,QAAAE,CAAQ,EAAIJ,EACzC,OAAOH,EAAoB,CACzB,YAAAI,EACA,OAAAC,EACA,KAAM,CACJ,SAAU,iDACV,cAAe,CAAC,EAChB,kBAAmB,CAAC,EACpB,IAAK,CAAE,eAAgB,CAAC,EAAG,WAAY,CAAC,CAAE,CAC5C,EACA,QAAAE,CACF,CAAC,CACH","names":["TypeTagAddress","TypeTagStruct","stringStructTag","generateTransaction","getFunctionParts","addAuthenticationFunctionTransaction","args","aptosConfig","sender","authenticationFunction","options","moduleAddress","moduleName","functionName","removeAuthenticationFunctionTransaction","removeDispatchableAuthenticatorTransaction"]}