@aptos-labs/ts-sdk 1.16.0-zeta.2 → 1.16.0-zeta.3

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 (229) hide show
  1. package/dist/common/index.d.ts +36 -15
  2. package/dist/common/index.js +27 -27
  3. package/dist/common/index.js.map +1 -1
  4. package/dist/esm/account/Account.mjs +1 -1
  5. package/dist/esm/account/Ed25519Account.mjs +1 -1
  6. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  7. package/dist/esm/account/KeylessAccount.d.mts +1 -1
  8. package/dist/esm/account/KeylessAccount.mjs +1 -1
  9. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  10. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  11. package/dist/esm/account/index.mjs +1 -1
  12. package/dist/esm/api/account.mjs +1 -1
  13. package/dist/esm/api/ans.mjs +1 -1
  14. package/dist/esm/api/aptos.d.mts +3 -3
  15. package/dist/esm/api/aptos.mjs +1 -1
  16. package/dist/esm/api/aptosConfig.mjs +1 -1
  17. package/dist/esm/api/coin.mjs +1 -1
  18. package/dist/esm/api/digitalAsset.mjs +1 -1
  19. package/dist/esm/api/event.mjs +1 -1
  20. package/dist/esm/api/faucet.mjs +1 -1
  21. package/dist/esm/api/fungibleAsset.mjs +1 -1
  22. package/dist/esm/api/general.mjs +1 -1
  23. package/dist/esm/api/index.d.mts +3 -3
  24. package/dist/esm/api/index.mjs +1 -1
  25. package/dist/esm/api/keyless.d.mts +6 -13
  26. package/dist/esm/api/keyless.mjs +1 -1
  27. package/dist/esm/api/staking.mjs +1 -1
  28. package/dist/esm/api/table.mjs +1 -1
  29. package/dist/esm/api/transaction.mjs +1 -1
  30. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  31. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  32. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  33. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  34. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  35. package/dist/esm/api/utils.mjs +1 -1
  36. package/dist/esm/{chunk-JKRWCFUQ.mjs → chunk-2BDKITTE.mjs} +2 -2
  37. package/dist/esm/{chunk-JWGG6XFS.mjs → chunk-2DESIV2P.mjs} +2 -2
  38. package/dist/esm/{chunk-CVCM46UN.mjs → chunk-2SJENNM4.mjs} +2 -2
  39. package/dist/esm/{chunk-I7GRECEJ.mjs → chunk-2Y7GVUQQ.mjs} +2 -2
  40. package/dist/esm/{chunk-OJUFU5TJ.mjs → chunk-3TIXNBXM.mjs} +2 -2
  41. package/dist/esm/{chunk-PWYL5QZP.mjs → chunk-4AWM7GGV.mjs} +2 -2
  42. package/dist/esm/{chunk-VJ3OBIFQ.mjs → chunk-572AE4D7.mjs} +2 -2
  43. package/dist/esm/{chunk-H4AGIUGI.mjs → chunk-5SGAX4VT.mjs} +2 -2
  44. package/dist/esm/{chunk-E4XMEVB7.mjs → chunk-66G6MKI6.mjs} +2 -2
  45. package/dist/esm/{chunk-RKHPXZM6.mjs → chunk-6FBKUTGF.mjs} +2 -2
  46. package/dist/esm/{chunk-RKHPXZM6.mjs.map → chunk-6FBKUTGF.mjs.map} +1 -1
  47. package/dist/esm/{chunk-PUP6XMAV.mjs → chunk-6OQBDCDK.mjs} +2 -2
  48. package/dist/esm/chunk-7FUZE7F4.mjs +2 -0
  49. package/dist/esm/chunk-7FUZE7F4.mjs.map +1 -0
  50. package/dist/esm/chunk-7GU3E2FJ.mjs +2 -0
  51. package/dist/esm/chunk-7GU3E2FJ.mjs.map +1 -0
  52. package/dist/esm/{chunk-PHEA3NOJ.mjs → chunk-7SOLAI6Q.mjs} +2 -2
  53. package/dist/esm/{chunk-PAY7N36H.mjs → chunk-AEWSL7BS.mjs} +2 -2
  54. package/dist/esm/{chunk-J6VDYVNB.mjs → chunk-ARHEUGVT.mjs} +2 -2
  55. package/dist/esm/{chunk-B76XCRLH.mjs → chunk-AXR47GFL.mjs} +2 -2
  56. package/dist/esm/{chunk-6DFVM2W6.mjs → chunk-B74ZAMWR.mjs} +2 -2
  57. package/dist/esm/{chunk-IPSITJFX.mjs → chunk-CCIY5VLR.mjs} +2 -2
  58. package/dist/esm/{chunk-EQN6FVO7.mjs → chunk-CI64RKDE.mjs} +2 -2
  59. package/dist/esm/{chunk-IGMXAPHY.mjs → chunk-E62NBNHE.mjs} +2 -2
  60. package/dist/esm/{chunk-FUKWM4HL.mjs → chunk-EJA532W4.mjs} +2 -2
  61. package/dist/esm/{chunk-GTUBZWAF.mjs → chunk-EJQ2EYJ7.mjs} +2 -2
  62. package/dist/esm/{chunk-6FK6OA37.mjs → chunk-ERPUZQVK.mjs} +2 -2
  63. package/dist/esm/chunk-F7XWXQHU.mjs +2 -0
  64. package/dist/esm/{chunk-FLALKQIK.mjs.map → chunk-F7XWXQHU.mjs.map} +1 -1
  65. package/dist/esm/{chunk-LMEJ5K6B.mjs → chunk-GTXZNAYI.mjs} +2 -2
  66. package/dist/esm/{chunk-7XRUPEQ4.mjs → chunk-IPI3VB62.mjs} +2 -2
  67. package/dist/esm/{chunk-RYRID5HT.mjs → chunk-J63BIFB7.mjs} +2 -2
  68. package/dist/esm/{chunk-K2KJX32L.mjs → chunk-JBX3JBIW.mjs} +2 -2
  69. package/dist/esm/{chunk-7JLHN655.mjs → chunk-JEE2OXOZ.mjs} +2 -2
  70. package/dist/esm/{chunk-6GGHUBUA.mjs → chunk-JV6JCXCH.mjs} +2 -2
  71. package/dist/esm/chunk-LA67NWMV.mjs +2 -0
  72. package/dist/esm/chunk-LA67NWMV.mjs.map +1 -0
  73. package/dist/esm/{chunk-2NGHKNUS.mjs → chunk-MMM5NTKW.mjs} +2 -2
  74. package/dist/esm/{chunk-MX5Z3EHG.mjs → chunk-MPTKOK27.mjs} +2 -2
  75. package/dist/esm/{chunk-OJL36Q4H.mjs → chunk-NMD45OTM.mjs} +2 -2
  76. package/dist/esm/chunk-NTQLNAKS.mjs +2 -0
  77. package/dist/esm/chunk-NTQLNAKS.mjs.map +1 -0
  78. package/dist/esm/{chunk-RTO3YBWQ.mjs → chunk-NZBZV7RP.mjs} +2 -2
  79. package/dist/esm/{chunk-XGDLSWBF.mjs → chunk-O3BRX56F.mjs} +2 -2
  80. package/dist/esm/{chunk-VCAURUJ3.mjs → chunk-OAX7LYUZ.mjs} +2 -2
  81. package/dist/esm/{chunk-NW6LGHE7.mjs → chunk-OJ6AF4YT.mjs} +2 -2
  82. package/dist/esm/{chunk-KMVSI4PC.mjs → chunk-OR27VDOE.mjs} +2 -2
  83. package/dist/esm/{chunk-JOXU5RWH.mjs → chunk-PAJXNH6J.mjs} +2 -2
  84. package/dist/esm/{chunk-FF4L66LJ.mjs → chunk-QMYYNCC2.mjs} +2 -2
  85. package/dist/esm/chunk-QNDR3S5U.mjs +2 -0
  86. package/dist/esm/chunk-QNDR3S5U.mjs.map +1 -0
  87. package/dist/esm/{chunk-GY6LFCB2.mjs → chunk-SCHZ67F3.mjs} +2 -2
  88. package/dist/esm/{chunk-GY6LFCB2.mjs.map → chunk-SCHZ67F3.mjs.map} +1 -1
  89. package/dist/esm/{chunk-RURI53PG.mjs → chunk-TDDJZLWB.mjs} +2 -2
  90. package/dist/esm/{chunk-YBXQVY7N.mjs → chunk-TEGJAM44.mjs} +2 -2
  91. package/dist/esm/{chunk-YBXQVY7N.mjs.map → chunk-TEGJAM44.mjs.map} +1 -1
  92. package/dist/esm/{chunk-MEOGVBMZ.mjs → chunk-TV7RXL3V.mjs} +2 -2
  93. package/dist/esm/chunk-UKKHWC4Y.mjs +2 -0
  94. package/dist/esm/chunk-UKKHWC4Y.mjs.map +1 -0
  95. package/dist/esm/chunk-VRO3J43Z.mjs +2 -0
  96. package/dist/esm/chunk-VRO3J43Z.mjs.map +1 -0
  97. package/dist/esm/{chunk-SBEZ64HG.mjs → chunk-WT5HOIK6.mjs} +2 -2
  98. package/dist/esm/{chunk-27PC47S7.mjs → chunk-X2VUS374.mjs} +2 -2
  99. package/dist/esm/{chunk-R4KIZ2FK.mjs → chunk-YDSBZMZB.mjs} +2 -2
  100. package/dist/esm/{chunk-HZOBRRQP.mjs → chunk-Z6FMMNAL.mjs} +2 -2
  101. package/dist/esm/{chunk-RX5SPT5S.mjs → chunk-ZNPEUH4I.mjs} +2 -2
  102. package/dist/esm/client/core.mjs +1 -1
  103. package/dist/esm/client/get.mjs +1 -1
  104. package/dist/esm/client/index.mjs +1 -1
  105. package/dist/esm/client/post.mjs +1 -1
  106. package/dist/esm/client/types.d.mts +1 -5
  107. package/dist/esm/client/types.mjs +1 -1
  108. package/dist/esm/core/crypto/cryptoHasher.mjs +1 -1
  109. package/dist/esm/core/crypto/index.mjs +1 -1
  110. package/dist/esm/core/crypto/keyless.d.mts +34 -2
  111. package/dist/esm/core/crypto/keyless.mjs +1 -1
  112. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  113. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  114. package/dist/esm/core/index.mjs +1 -1
  115. package/dist/esm/index.mjs +1 -1
  116. package/dist/esm/internal/account.mjs +1 -1
  117. package/dist/esm/internal/ans.mjs +1 -1
  118. package/dist/esm/internal/coin.mjs +1 -1
  119. package/dist/esm/internal/digitalAsset.mjs +1 -1
  120. package/dist/esm/internal/event.mjs +1 -1
  121. package/dist/esm/internal/faucet.mjs +1 -1
  122. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  123. package/dist/esm/internal/general.d.mts +2 -16
  124. package/dist/esm/internal/general.mjs +1 -1
  125. package/dist/esm/internal/keyless.d.mts +3 -7
  126. package/dist/esm/internal/keyless.mjs +1 -1
  127. package/dist/esm/internal/staking.mjs +1 -1
  128. package/dist/esm/internal/table.mjs +1 -1
  129. package/dist/esm/internal/transaction.d.mts +16 -2
  130. package/dist/esm/internal/transaction.mjs +1 -1
  131. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  132. package/dist/esm/internal/view.mjs +1 -1
  133. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  134. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  135. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  136. package/dist/esm/transactions/index.mjs +1 -1
  137. package/dist/esm/transactions/instances/index.mjs +1 -1
  138. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  139. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  140. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  141. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  142. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  143. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  144. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  145. package/dist/esm/transactions/management/index.mjs +1 -1
  146. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  147. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  148. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  149. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  150. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  151. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  152. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  153. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  154. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  155. package/dist/esm/utils/index.mjs +1 -1
  156. package/dist/esm/version.d.mts +1 -1
  157. package/dist/esm/version.mjs +1 -1
  158. package/package.json +1 -1
  159. package/src/account/KeylessAccount.ts +3 -4
  160. package/src/api/general.ts +1 -2
  161. package/src/api/keyless.ts +2 -13
  162. package/src/client/core.ts +1 -1
  163. package/src/client/types.ts +1 -1
  164. package/src/core/crypto/keyless.ts +48 -11
  165. package/src/internal/general.ts +1 -38
  166. package/src/internal/keyless.ts +31 -14
  167. package/src/internal/transaction.ts +92 -0
  168. package/src/utils/apiEndpoints.ts +1 -1
  169. package/src/utils/helpers.ts +6 -0
  170. package/src/version.ts +1 -1
  171. package/dist/esm/chunk-4TDMJQOJ.mjs +0 -2
  172. package/dist/esm/chunk-4TDMJQOJ.mjs.map +0 -1
  173. package/dist/esm/chunk-5YH2YL3L.mjs +0 -2
  174. package/dist/esm/chunk-5YH2YL3L.mjs.map +0 -1
  175. package/dist/esm/chunk-FLALKQIK.mjs +0 -2
  176. package/dist/esm/chunk-KCRCX6BL.mjs +0 -2
  177. package/dist/esm/chunk-KCRCX6BL.mjs.map +0 -1
  178. package/dist/esm/chunk-KNMQU2TA.mjs +0 -2
  179. package/dist/esm/chunk-KNMQU2TA.mjs.map +0 -1
  180. package/dist/esm/chunk-KSSJ3CT5.mjs +0 -2
  181. package/dist/esm/chunk-KSSJ3CT5.mjs.map +0 -1
  182. package/dist/esm/chunk-KUMZXNMD.mjs +0 -2
  183. package/dist/esm/chunk-KUMZXNMD.mjs.map +0 -1
  184. package/dist/esm/chunk-T4HO5JMQ.mjs +0 -2
  185. package/dist/esm/chunk-T4HO5JMQ.mjs.map +0 -1
  186. /package/dist/esm/{chunk-JKRWCFUQ.mjs.map → chunk-2BDKITTE.mjs.map} +0 -0
  187. /package/dist/esm/{chunk-JWGG6XFS.mjs.map → chunk-2DESIV2P.mjs.map} +0 -0
  188. /package/dist/esm/{chunk-CVCM46UN.mjs.map → chunk-2SJENNM4.mjs.map} +0 -0
  189. /package/dist/esm/{chunk-I7GRECEJ.mjs.map → chunk-2Y7GVUQQ.mjs.map} +0 -0
  190. /package/dist/esm/{chunk-OJUFU5TJ.mjs.map → chunk-3TIXNBXM.mjs.map} +0 -0
  191. /package/dist/esm/{chunk-PWYL5QZP.mjs.map → chunk-4AWM7GGV.mjs.map} +0 -0
  192. /package/dist/esm/{chunk-VJ3OBIFQ.mjs.map → chunk-572AE4D7.mjs.map} +0 -0
  193. /package/dist/esm/{chunk-H4AGIUGI.mjs.map → chunk-5SGAX4VT.mjs.map} +0 -0
  194. /package/dist/esm/{chunk-E4XMEVB7.mjs.map → chunk-66G6MKI6.mjs.map} +0 -0
  195. /package/dist/esm/{chunk-PUP6XMAV.mjs.map → chunk-6OQBDCDK.mjs.map} +0 -0
  196. /package/dist/esm/{chunk-PHEA3NOJ.mjs.map → chunk-7SOLAI6Q.mjs.map} +0 -0
  197. /package/dist/esm/{chunk-PAY7N36H.mjs.map → chunk-AEWSL7BS.mjs.map} +0 -0
  198. /package/dist/esm/{chunk-J6VDYVNB.mjs.map → chunk-ARHEUGVT.mjs.map} +0 -0
  199. /package/dist/esm/{chunk-B76XCRLH.mjs.map → chunk-AXR47GFL.mjs.map} +0 -0
  200. /package/dist/esm/{chunk-6DFVM2W6.mjs.map → chunk-B74ZAMWR.mjs.map} +0 -0
  201. /package/dist/esm/{chunk-IPSITJFX.mjs.map → chunk-CCIY5VLR.mjs.map} +0 -0
  202. /package/dist/esm/{chunk-EQN6FVO7.mjs.map → chunk-CI64RKDE.mjs.map} +0 -0
  203. /package/dist/esm/{chunk-IGMXAPHY.mjs.map → chunk-E62NBNHE.mjs.map} +0 -0
  204. /package/dist/esm/{chunk-FUKWM4HL.mjs.map → chunk-EJA532W4.mjs.map} +0 -0
  205. /package/dist/esm/{chunk-GTUBZWAF.mjs.map → chunk-EJQ2EYJ7.mjs.map} +0 -0
  206. /package/dist/esm/{chunk-6FK6OA37.mjs.map → chunk-ERPUZQVK.mjs.map} +0 -0
  207. /package/dist/esm/{chunk-LMEJ5K6B.mjs.map → chunk-GTXZNAYI.mjs.map} +0 -0
  208. /package/dist/esm/{chunk-7XRUPEQ4.mjs.map → chunk-IPI3VB62.mjs.map} +0 -0
  209. /package/dist/esm/{chunk-RYRID5HT.mjs.map → chunk-J63BIFB7.mjs.map} +0 -0
  210. /package/dist/esm/{chunk-K2KJX32L.mjs.map → chunk-JBX3JBIW.mjs.map} +0 -0
  211. /package/dist/esm/{chunk-7JLHN655.mjs.map → chunk-JEE2OXOZ.mjs.map} +0 -0
  212. /package/dist/esm/{chunk-6GGHUBUA.mjs.map → chunk-JV6JCXCH.mjs.map} +0 -0
  213. /package/dist/esm/{chunk-2NGHKNUS.mjs.map → chunk-MMM5NTKW.mjs.map} +0 -0
  214. /package/dist/esm/{chunk-MX5Z3EHG.mjs.map → chunk-MPTKOK27.mjs.map} +0 -0
  215. /package/dist/esm/{chunk-OJL36Q4H.mjs.map → chunk-NMD45OTM.mjs.map} +0 -0
  216. /package/dist/esm/{chunk-RTO3YBWQ.mjs.map → chunk-NZBZV7RP.mjs.map} +0 -0
  217. /package/dist/esm/{chunk-XGDLSWBF.mjs.map → chunk-O3BRX56F.mjs.map} +0 -0
  218. /package/dist/esm/{chunk-VCAURUJ3.mjs.map → chunk-OAX7LYUZ.mjs.map} +0 -0
  219. /package/dist/esm/{chunk-NW6LGHE7.mjs.map → chunk-OJ6AF4YT.mjs.map} +0 -0
  220. /package/dist/esm/{chunk-KMVSI4PC.mjs.map → chunk-OR27VDOE.mjs.map} +0 -0
  221. /package/dist/esm/{chunk-JOXU5RWH.mjs.map → chunk-PAJXNH6J.mjs.map} +0 -0
  222. /package/dist/esm/{chunk-FF4L66LJ.mjs.map → chunk-QMYYNCC2.mjs.map} +0 -0
  223. /package/dist/esm/{chunk-RURI53PG.mjs.map → chunk-TDDJZLWB.mjs.map} +0 -0
  224. /package/dist/esm/{chunk-MEOGVBMZ.mjs.map → chunk-TV7RXL3V.mjs.map} +0 -0
  225. /package/dist/esm/{chunk-SBEZ64HG.mjs.map → chunk-WT5HOIK6.mjs.map} +0 -0
  226. /package/dist/esm/{chunk-27PC47S7.mjs.map → chunk-X2VUS374.mjs.map} +0 -0
  227. /package/dist/esm/{chunk-R4KIZ2FK.mjs.map → chunk-YDSBZMZB.mjs.map} +0 -0
  228. /package/dist/esm/{chunk-HZOBRRQP.mjs.map → chunk-Z6FMMNAL.mjs.map} +0 -0
  229. /package/dist/esm/{chunk-RX5SPT5S.mjs.map → chunk-ZNPEUH4I.mjs.map} +0 -0
@@ -3,14 +3,13 @@
3
3
 
4
4
  import { AptosConfig } from "./aptosConfig";
5
5
  import {
6
- getBlockByHeight,
7
- getBlockByVersion,
8
6
  getChainTopUserTransactions,
9
7
  getIndexerLastSuccessVersion,
10
8
  getLedgerInfo,
11
9
  getProcessorStatus,
12
10
  queryIndexer,
13
11
  } from "../internal/general";
12
+ import { getBlockByHeight, getBlockByVersion } from "../internal/transaction";
14
13
  import { view } from "../internal/view";
15
14
  import {
16
15
  AnyNumber,
@@ -2,9 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
5
- import { KeylessConfiguration } from "../core";
6
- import { deriveKeylessAccount, getKeylessConfig, getPepper } from "../internal/keyless";
7
- import { HexInput, LedgerVersionArg } from "../types";
5
+ import { deriveKeylessAccount, getPepper } from "../internal/keyless";
6
+ import { HexInput } from "../types";
8
7
  import { AptosConfig } from "./aptosConfig";
9
8
 
10
9
  /**
@@ -13,16 +12,6 @@ import { AptosConfig } from "./aptosConfig";
13
12
  export class Keyless {
14
13
  constructor(readonly config: AptosConfig) {}
15
14
 
16
- /**
17
- * Gets the parameters of how Keyless Accounts are configured on chain.
18
- *
19
- * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
20
- * @returns KeylessConfiguration
21
- */
22
- async getKeylessConfig(options?: LedgerVersionArg): Promise<KeylessConfiguration> {
23
- return getKeylessConfig({ aptosConfig: this.config, options });
24
- }
25
-
26
15
  /**
27
16
  * Fetches the pepper from the Aptos pepper service API.
28
17
  *
@@ -101,7 +101,7 @@ export async function aptosRequest<Req extends {}, Res extends {}>(
101
101
  }
102
102
  result.data = indexerResponse.data as Res;
103
103
  } else if (apiType === AptosApiType.PEPPER || apiType === AptosApiType.PROVER) {
104
- if (result.status >= 500) {
104
+ if (result.status >= 400) {
105
105
  throw new AptosApiError(options, result, `${response.data}`);
106
106
  }
107
107
  }
@@ -41,7 +41,7 @@ export class AptosApiError extends Error {
41
41
 
42
42
  readonly statusText: string;
43
43
 
44
- readonly data: { message: string; error_code?: string; vm_error_code?: number };
44
+ readonly data: any;
45
45
 
46
46
  readonly request: AptosRequest;
47
47
 
@@ -1,6 +1,7 @@
1
1
  // Copyright © Aptos Foundation
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { JwtPayload, jwtDecode } from "jwt-decode";
4
5
  import { AccountPublicKey, PublicKey } from "./publicKey";
5
6
  import { Signature } from "./signature";
6
7
  import { Deserializer, Serializable, Serializer } from "../../bcs";
@@ -138,6 +139,18 @@ export class KeylessPublicKey extends AccountPublicKey {
138
139
  computeIdCommitment(args);
139
140
  return new KeylessPublicKey(args.iss, computeIdCommitment(args));
140
141
  }
142
+
143
+ static fromJWTAndPepper(args: { jwt: string; pepper: HexInput; uidKey?: string }): KeylessPublicKey {
144
+ const { jwt, pepper, uidKey = "sub" } = args;
145
+ const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);
146
+ const iss = jwtPayload.iss!;
147
+ if (typeof jwtPayload.aud !== "string") {
148
+ throw new Error("aud was not found or an array of values");
149
+ }
150
+ const aud = jwtPayload.aud!;
151
+ const uidVal = jwtPayload[uidKey];
152
+ return KeylessPublicKey.create({ iss, uidKey, uidVal, aud, pepper });
153
+ }
141
154
  }
142
155
 
143
156
  function computeIdCommitment(args: { uidKey: string; uidVal: string; aud: string; pepper: HexInput }): Uint8Array {
@@ -254,6 +267,7 @@ export class KeylessSignature extends Signature {
254
267
  new Groth16Zkp({ a: new Uint8Array(32), b: new Uint8Array(64), c: new Uint8Array(32) }),
255
268
  ZkpVariant.Groth16,
256
269
  ),
270
+ expHorizonSecs: 0,
257
271
  }),
258
272
  EphemeralCertificateVariant.ZkProof,
259
273
  ),
@@ -438,7 +452,7 @@ export class ZeroKnowledgeSig extends Signature {
438
452
  /**
439
453
  * The max lifespan of the proof
440
454
  */
441
- readonly expHorizonSecs: bigint;
455
+ readonly expHorizonSecs: number;
442
456
 
443
457
  /**
444
458
  * A key value pair on the JWT token that can be specified on the signature which would reveal the value on chain.
@@ -458,19 +472,13 @@ export class ZeroKnowledgeSig extends Signature {
458
472
 
459
473
  constructor(args: {
460
474
  proof: ZkProof;
461
- expHorizonSecs?: bigint;
475
+ expHorizonSecs: number;
462
476
  extraField?: string;
463
477
  overrideAudVal?: string;
464
478
  trainingWheelsSignature?: EphemeralSignature;
465
479
  }) {
466
480
  super();
467
- const {
468
- proof,
469
- expHorizonSecs = BigInt(EPK_HORIZON_SECS),
470
- trainingWheelsSignature,
471
- extraField,
472
- overrideAudVal,
473
- } = args;
481
+ const { proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal } = args;
474
482
  this.proof = proof;
475
483
  this.expHorizonSecs = expHorizonSecs;
476
484
  this.trainingWheelsSignature = trainingWheelsSignature;
@@ -506,7 +514,7 @@ export class ZeroKnowledgeSig extends Signature {
506
514
 
507
515
  static deserialize(deserializer: Deserializer): ZeroKnowledgeSig {
508
516
  const proof = ZkProof.deserialize(deserializer);
509
- const expHorizonSecs = deserializer.deserializeU64();
517
+ const expHorizonSecs = Number(deserializer.deserializeU64());
510
518
  const extraField = deserializer.deserializeOptionStr();
511
519
  const overrideAudVal = deserializer.deserializeOptionStr();
512
520
  const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);
@@ -515,7 +523,7 @@ export class ZeroKnowledgeSig extends Signature {
515
523
 
516
524
  static load(deserializer: Deserializer): ZeroKnowledgeSig {
517
525
  const proof = ZkProof.deserialize(deserializer);
518
- const expHorizonSecs = deserializer.deserializeU64();
526
+ const expHorizonSecs = Number(deserializer.deserializeU64());
519
527
  const extraField = deserializer.deserializeOptionStr();
520
528
  const overrideAudVal = deserializer.deserializeOptionStr();
521
529
  const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);
@@ -523,9 +531,18 @@ export class ZeroKnowledgeSig extends Signature {
523
531
  }
524
532
  }
525
533
 
534
+ /**
535
+ * A class which represents the on-chain configuration for how Keyless accounts work
536
+ */
526
537
  export class KeylessConfiguration {
538
+ /**
539
+ * The verification key used to verify Groth16 proofs on chain
540
+ */
527
541
  readonly verficationKey: Groth16VerificationKey;
528
542
 
543
+ /**
544
+ * The maximum lifespan of an ephemeral key pair. This is configured on chain.
545
+ */
529
546
  readonly maxExpHorizonSecs: number;
530
547
 
531
548
  constructor(verficationKey: Groth16VerificationKey, maxExpHorizonSecs: number) {
@@ -547,15 +564,35 @@ export class KeylessConfiguration {
547
564
  }
548
565
  }
549
566
 
567
+ /**
568
+ * A representation of the verification key stored on chain used to verify Groth16 proofs
569
+ */
550
570
  class Groth16VerificationKey {
571
+ // The docstrings below are borrowed from ark-groth16
572
+
573
+ /**
574
+ * The `alpha * G`, where `G` is the generator of G1
575
+ */
551
576
  readonly alphaG1: G1Bytes;
552
577
 
578
+ /**
579
+ * The `alpha * H`, where `H` is the generator of G2
580
+ */
553
581
  readonly betaG2: G2Bytes;
554
582
 
583
+ /**
584
+ * The `delta * H`, where `H` is the generator of G2
585
+ */
555
586
  readonly deltaG2: G2Bytes;
556
587
 
588
+ /**
589
+ * The `gamma^{-1} * (beta * a_i + alpha * b_i + c_i) * H`, where H is the generator of G1
590
+ */
557
591
  readonly gammaAbcG1: G1Bytes[];
558
592
 
593
+ /**
594
+ * The `gamma * H`, where `H` is the generator of G2
595
+ */
559
596
  readonly gammaG2: G2Bytes;
560
597
 
561
598
  constructor(args: {
@@ -10,14 +10,7 @@
10
10
 
11
11
  import { AptosConfig } from "../api/aptosConfig";
12
12
  import { getAptosFullNode, postAptosIndexer } from "../client";
13
- import {
14
- AnyNumber,
15
- Block,
16
- GetChainTopUserTransactionsResponse,
17
- GetProcessorStatusResponse,
18
- GraphqlQuery,
19
- LedgerInfo,
20
- } from "../types";
13
+ import { GetChainTopUserTransactionsResponse, GetProcessorStatusResponse, GraphqlQuery, LedgerInfo } from "../types";
21
14
  import { GetChainTopUserTransactionsQuery, GetProcessorStatusQuery } from "../types/generated/operations";
22
15
  import { GetChainTopUserTransactions, GetProcessorStatus } from "../types/generated/queries";
23
16
  import { ProcessorType } from "../utils/const";
@@ -32,36 +25,6 @@ export async function getLedgerInfo(args: { aptosConfig: AptosConfig }): Promise
32
25
  return data;
33
26
  }
34
27
 
35
- export async function getBlockByVersion(args: {
36
- aptosConfig: AptosConfig;
37
- ledgerVersion: AnyNumber;
38
- options?: { withTransactions?: boolean };
39
- }): Promise<Block> {
40
- const { aptosConfig, ledgerVersion, options } = args;
41
- const { data } = await getAptosFullNode<{}, Block>({
42
- aptosConfig,
43
- originMethod: "getBlockByVersion",
44
- path: `blocks/by_version/${ledgerVersion}`,
45
- params: { with_transactions: options?.withTransactions },
46
- });
47
- return data;
48
- }
49
-
50
- export async function getBlockByHeight(args: {
51
- aptosConfig: AptosConfig;
52
- blockHeight: AnyNumber;
53
- options?: { withTransactions?: boolean };
54
- }): Promise<Block> {
55
- const { aptosConfig, blockHeight, options } = args;
56
- const { data } = await getAptosFullNode<{}, Block>({
57
- aptosConfig,
58
- originMethod: "getBlockByHeight",
59
- path: `blocks/by_height/${blockHeight}`,
60
- params: { with_transactions: options?.withTransactions },
61
- });
62
- return data;
63
- }
64
-
65
28
  export async function getChainTopUserTransactions(args: {
66
29
  aptosConfig: AptosConfig;
67
30
  limit: number;
@@ -11,7 +11,6 @@ import { AptosConfig } from "../api/aptosConfig";
11
11
  import { getAptosFullNode, postAptosPepperService, postAptosProvingService } from "../client";
12
12
  import {
13
13
  AccountAddress,
14
- EPK_HORIZON_SECS,
15
14
  EphemeralSignature,
16
15
  Groth16Zkp,
17
16
  Hex,
@@ -31,15 +30,21 @@ import {
31
30
  } from "../types/keyless";
32
31
  import { memoizeAsync } from "../utils/memoize";
33
32
 
34
- export async function getKeylessConfig(args: {
33
+ /**
34
+ * Gets the parameters of how Keyless Accounts are configured on chain including the verifying key and the max expiry horizon
35
+ *
36
+ * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
37
+ * @returns KeylessConfiguration
38
+ */
39
+ async function getKeylessConfig(args: {
35
40
  aptosConfig: AptosConfig;
36
41
  options?: LedgerVersionArg;
37
42
  }): Promise<KeylessConfiguration> {
38
43
  const { aptosConfig } = args;
39
44
  return memoizeAsync(
40
45
  async () => {
41
- const config = await getKeylessConfiguration(args);
42
- const vk = await getGroth16VerificationKey(args);
46
+ const config = await getKeylessConfigurationResource(args);
47
+ const vk = await getGroth16VerificationKeyResource(args);
43
48
  return KeylessConfiguration.create(vk, Number(config.max_exp_horizon_secs));
44
49
  },
45
50
  `keyless-configuration-${aptosConfig.network}`,
@@ -47,7 +52,13 @@ export async function getKeylessConfig(args: {
47
52
  )();
48
53
  }
49
54
 
50
- async function getKeylessConfiguration(args: {
55
+ /**
56
+ * Gets the KeylessConfiguration set on chain
57
+ *
58
+ * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
59
+ * @returns KeylessConfigurationResponse
60
+ */
61
+ async function getKeylessConfigurationResource(args: {
51
62
  aptosConfig: AptosConfig;
52
63
  options?: LedgerVersionArg;
53
64
  }): Promise<KeylessConfigurationResponse> {
@@ -63,7 +74,13 @@ async function getKeylessConfiguration(args: {
63
74
  return data.data;
64
75
  }
65
76
 
66
- async function getGroth16VerificationKey(args: {
77
+ /**
78
+ * Gets the Groth16VerificationKey set on chain
79
+ *
80
+ * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
81
+ * @returns Groth16VerificationKeyResponse
82
+ */
83
+ async function getGroth16VerificationKeyResource(args: {
67
84
  aptosConfig: AptosConfig;
68
85
  options?: LedgerVersionArg;
69
86
  }): Promise<Groth16VerificationKeyResponse> {
@@ -86,14 +103,14 @@ export async function getPepper(args: {
86
103
  uidKey?: string;
87
104
  derivationPath?: string;
88
105
  }): Promise<Uint8Array> {
89
- const { aptosConfig, jwt, ephemeralKeyPair, uidKey, derivationPath } = args;
106
+ const { aptosConfig, jwt, ephemeralKeyPair, uidKey = "sub", derivationPath } = args;
90
107
 
91
108
  const body = {
92
109
  jwt_b64: jwt,
93
110
  epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),
94
111
  exp_date_secs: ephemeralKeyPair.expiryDateSecs,
95
112
  epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
96
- uid_key: uidKey || "sub",
113
+ uid_key: uidKey,
97
114
  derivation_path: derivationPath,
98
115
  };
99
116
  const { data } = await postAptosPepperService<PepperFetchRequest, PepperFetchResponse>({
@@ -113,19 +130,18 @@ export async function getProof(args: {
113
130
  pepper: HexInput;
114
131
  uidKey?: string;
115
132
  }): Promise<ZeroKnowledgeSig> {
116
- const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey } = args;
133
+ const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey = "sub" } = args;
134
+ const { maxExpHorizonSecs } = await getKeylessConfig({ aptosConfig });
117
135
  const json = {
118
136
  jwt_b64: jwt,
119
137
  epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),
120
138
  epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
121
139
  exp_date_secs: ephemeralKeyPair.expiryDateSecs,
122
- exp_horizon_secs: EPK_HORIZON_SECS,
140
+ exp_horizon_secs: maxExpHorizonSecs,
123
141
  pepper: Hex.fromHexInput(pepper).toStringWithoutPrefix(),
124
- uid_key: uidKey || "sub",
142
+ uid_key: uidKey,
125
143
  };
126
144
 
127
- console.log(JSON.stringify(json))
128
-
129
145
  const { data } = await postAptosProvingService<ProverRequest, ProverResponse>({
130
146
  aptosConfig,
131
147
  path: "prove",
@@ -144,6 +160,7 @@ export async function getProof(args: {
144
160
  const signedProof = new ZeroKnowledgeSig({
145
161
  proof: new ZkProof(groth16Zkp, ZkpVariant.Groth16),
146
162
  trainingWheelsSignature: EphemeralSignature.fromHex(data.training_wheels_signature),
163
+ expHorizonSecs: maxExpHorizonSecs,
147
164
  });
148
165
  return signedProof;
149
166
  }
@@ -171,7 +188,7 @@ export async function deriveKeylessAccount(args: {
171
188
  const proofPromise = getProof({ ...args, pepper });
172
189
  const proof = proofFetchCallback ? proofPromise : await proofPromise;
173
190
 
174
- const keylessAccount = KeylessAccount.fromJWTAndProof({ ...args, proof, pepper, proofFetchCallback });
191
+ const keylessAccount = KeylessAccount.create({ ...args, proof, pepper, proofFetchCallback });
175
192
 
176
193
  return keylessAccount;
177
194
  }
@@ -19,6 +19,7 @@ import {
19
19
  type TransactionResponse,
20
20
  WaitForTransactionOptions,
21
21
  CommittedTransactionResponse,
22
+ Block,
22
23
  } from "../types";
23
24
  import { DEFAULT_TXN_TIMEOUT_SEC, ProcessorType } from "../utils/const";
24
25
  import { sleep } from "../utils/helpers";
@@ -279,3 +280,94 @@ export class FailedTransactionError extends Error {
279
280
  this.transaction = transaction;
280
281
  }
281
282
  }
283
+
284
+ export async function getBlockByVersion(args: {
285
+ aptosConfig: AptosConfig;
286
+ ledgerVersion: AnyNumber;
287
+ options?: { withTransactions?: boolean };
288
+ }): Promise<Block> {
289
+ const { aptosConfig, ledgerVersion, options } = args;
290
+ const { data: block } = await getAptosFullNode<{}, Block>({
291
+ aptosConfig,
292
+ originMethod: "getBlockByVersion",
293
+ path: `blocks/by_version/${ledgerVersion}`,
294
+ params: { with_transactions: options?.withTransactions },
295
+ });
296
+
297
+ return fillBlockTransactions({ block, ...args });
298
+ }
299
+
300
+ export async function getBlockByHeight(args: {
301
+ aptosConfig: AptosConfig;
302
+ blockHeight: AnyNumber;
303
+ options?: { withTransactions?: boolean };
304
+ }): Promise<Block> {
305
+ const { aptosConfig, blockHeight, options } = args;
306
+ const { data: block } = await getAptosFullNode<{}, Block>({
307
+ aptosConfig,
308
+ originMethod: "getBlockByHeight",
309
+ path: `blocks/by_height/${blockHeight}`,
310
+ params: { with_transactions: options?.withTransactions },
311
+ });
312
+ return fillBlockTransactions({ block, ...args });
313
+ }
314
+
315
+ /**
316
+ * Fills in the block with transactions if not enough were returned
317
+ * @param args
318
+ */
319
+ async function fillBlockTransactions(args: {
320
+ aptosConfig: AptosConfig;
321
+ block: Block;
322
+ options?: { withTransactions?: boolean };
323
+ }) {
324
+ const { aptosConfig, block, options } = args;
325
+ if (options?.withTransactions) {
326
+ // Transactions should be filled, but this ensures it
327
+ block.transactions = block.transactions ?? [];
328
+
329
+ const lastTxn = block.transactions[block.transactions.length - 1];
330
+ const firstVersion = BigInt(block.first_version);
331
+ const lastVersion = BigInt(block.last_version);
332
+
333
+ // Convert the transaction to the type
334
+ const curVersion: string | undefined = (lastTxn as any)?.version;
335
+ let latestVersion;
336
+
337
+ // This time, if we don't have any transactions, we will try once with the start of the block
338
+ if (curVersion === undefined) {
339
+ latestVersion = firstVersion - 1n;
340
+ } else {
341
+ latestVersion = BigInt(curVersion);
342
+ }
343
+
344
+ // If we have all the transactions in the block, we can skip out, otherwise we need to fill the transactions
345
+ if (latestVersion === lastVersion) {
346
+ return block;
347
+ }
348
+
349
+ // For now, we will grab all the transactions in groups of 100, but we can make this more efficient by trying larger
350
+ // amounts
351
+ const fetchFutures = [];
352
+ const pageSize = 100n;
353
+ for (let i = latestVersion + 1n; i < lastVersion; i += BigInt(100)) {
354
+ fetchFutures.push(
355
+ getTransactions({
356
+ aptosConfig,
357
+ options: {
358
+ offset: i,
359
+ limit: Math.min(Number(pageSize), Number(lastVersion - i + 1n)),
360
+ },
361
+ }),
362
+ );
363
+ }
364
+
365
+ // Combine all the futures
366
+ const responses = await Promise.all(fetchFutures);
367
+ for (const txns of responses) {
368
+ block.transactions.push(...txns);
369
+ }
370
+ }
371
+
372
+ return block;
373
+ }
@@ -33,7 +33,7 @@ export const NetworkToPepperAPI: Record<string, string> = {
33
33
  export const NetworkToProverAPI: Record<string, string> = {
34
34
  mainnet: "https://api.mainnet.aptoslabs.com/keyless/prover/v0",
35
35
  testnet: "https://api.testnet.aptoslabs.com/keyless/prover/v0",
36
- devnet: "https://prover.keyless.devnet.aptoslabs.com/v0",
36
+ devnet: "https://api.devnet.aptoslabs.com/keyless/prover/v0",
37
37
  // Use the devnet service for local environment
38
38
  local: "https://api.devnet.aptoslabs.com/keyless/prover/v0",
39
39
  };
@@ -26,6 +26,12 @@ export function floorToWholeHour(timestampInSeconds: number): number {
26
26
  return Math.floor(date.getTime() / 1000);
27
27
  }
28
28
 
29
+ export function ceilingToWholeHour(timestampInSeconds: number): number {
30
+ const date = new Date(timestampInSeconds * 1000);
31
+ date.setHours(date.getHours() + 1);
32
+ return floorToWholeHour(date.getTime() / 1000)
33
+ }
34
+
29
35
  export function base64UrlDecode(base64Url: string): string {
30
36
  // Replace base64url-specific characters
31
37
  const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * hardcoded for now, we would want to have it injected dynamically
8
8
  */
9
- export const VERSION = "1.16.0-zeta.2";
9
+ export const VERSION = "1.16.0-zeta.3";
@@ -1,2 +0,0 @@
1
- import{a as v}from"./chunk-LYOUEPDG.mjs";import{a as x}from"./chunk-VJ3OBIFQ.mjs";import{a as E}from"./chunk-KGHBTSDR.mjs";import{d as y}from"./chunk-RYRID5HT.mjs";import{a as u,b as f}from"./chunk-XGDLSWBF.mjs";import{i as S,j as F,k as A,n as d}from"./chunk-T4HO5JMQ.mjs";import{b as K}from"./chunk-F3ZVWLDH.mjs";import{d as b}from"./chunk-QHB5A5YP.mjs";import{a as g}from"./chunk-3IFR6T3V.mjs";import{a as P}from"./chunk-UMLUOYFK.mjs";import{b as w}from"./chunk-AOCNYMMX.mjs";import{jwtDecode as H}from"jwt-decode";import Z from"eventemitter3";var ee={"https://accounts.google.com":"https://www.googleapis.com/oauth2/v3/certs"},s=class s extends P{constructor(e){super();let{address:r,ephemeralKeyPair:t,uidKey:o,uidVal:n,aud:a,pepper:c,proofOrFetcher:i,proofFetchCallback:p,jwt:l}=e;if(this.ephemeralKeyPair=t,this.publicKey=S.create(e),this.accountAddress=r?K.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=n,this.aud=a,this.jwt=l,this.emitter=new Z,this.proofOrPromise=i,i instanceof d)this.proof=i;else{if(p===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async z=>{await p(z),this.emitter.removeAllListeners()}),this.init(i)}this.signingScheme=2;let h=w.fromHexInput(c).toUint8Array();if(h.length!==s.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${s.PEPPER_LENGTH}`);this.pepper=h,this.isJwtValid=!0}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Connot serialize - proof undefined");this.proof.serialize(e)}static deserialize(e){let r=e.deserializeStr(),t=e.deserializeStr(),o=e.deserializeFixedBytes(31),n=x.deserialize(e),a=d.deserialize(e);return s.fromJWTAndProof({proof:a,pepper:o,uidKey:t,jwt:r,ephemeralKeyPair:n})}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){let r=new f(this.sign(e)),t=new u(this.publicKey);return new y(t,r)}signTransactionWithAuthenticator(e){let r=new f(this.signTransaction(e)),t=new u(this.publicKey);return new y(t,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}sign(e){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw new Error("EphemeralKeyPair is expired");if(this.proof===void 0)throw new Error("Proof not defined");let t=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(e);return new F({jwtHeader:b(this.jwt.split(".")[0]),ephemeralCertificate:new A(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:t,ephemeralSignature:o})}signTransaction(e){if(this.proof===void 0)throw new Error("Proof not found");let r=E(e),o=new m(r,this.proof.proof).hash();return this.sign(o)}verifySignature(e){throw new Error("Not implemented")}static fromBytes(e){return s.deserialize(new g(e))}static fromJWTAndProof(e){let{proof:r,jwt:t,ephemeralKeyPair:o,pepper:n,proofFetchCallback:a}=e,c=e.uidKey??"sub",i=H(t),p=i.iss;if(typeof i.aud!="string")throw new Error("aud was not found or an array of values");let l=i.aud,h=i[c];return new s({proofOrFetcher:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:h,aud:l,pepper:n,jwt:t,proofFetchCallback:a})}};s.PEPPER_LENGTH=31;var T=s,m=class extends v{constructor(e,r){super();this.transaction=e,this.proof=r,this.domainSeparator="APTOS::TransactionAndProof"}serialize(e){e.serializeFixedBytes(this.transaction.bcsToBytes()),e.serializeOption(this.proof)}};export{ee as a,T as b,m as c};
2
- //# sourceMappingURL=chunk-4TDMJQOJ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/account/KeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport EventEmitter from \"eventemitter3\";\nimport { EphemeralCertificateVariant, HexInput, SigningScheme } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport {\n AnyPublicKey,\n AnySignature,\n KeylessPublicKey,\n KeylessSignature,\n EphemeralCertificate,\n Signature,\n ZeroKnowledgeSig,\n ZkProof,\n} from \"../core/crypto\";\n\nimport { Account } from \"./Account\";\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Hex } from \"../core/hex\";\nimport { AccountAuthenticatorSingleKey } from \"../transactions/authenticator/account\";\nimport { Deserializer, Serializable, Serializer } from \"../bcs\";\nimport { deriveTransactionType } from \"../transactions/transactionBuilder/signingMessage\";\nimport { AnyRawTransaction, AnyRawTransactionInstance } from \"../transactions/types\";\nimport { AptsoDomainSeparator, CryptoHashable } from \"../core/crypto/cryptoHasher\";\nimport { base64UrlDecode } from \"../utils/helpers\";\n\nexport const IssuerToJwkEndpoint: Record<string, string> = {\n \"https://accounts.google.com\": \"https://www.googleapis.com/oauth2/v3/certs\",\n};\n\n/**\n * Account implementation for the Keyless authentication scheme.\n *\n * Used to represent a Keyless based account and sign transactions with it.\n *\n * Use KeylessAccount.fromJWTAndProof to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.\n *\n * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,\n * EphemeralKeyPair, and corresponding proof.\n */\nexport class KeylessAccount extends Serializable implements Account {\n static readonly PEPPER_LENGTH: number = 31;\n\n /**\n * The KeylessPublicKey associated with the account\n */\n readonly publicKey: KeylessPublicKey;\n\n /**\n * The EphemeralKeyPair used to generate sign.\n */\n readonly ephemeralKeyPair: EphemeralKeyPair;\n\n /**\n * The claim on the JWT to identify a user. This is typically 'sub' or 'email'.\n */\n readonly uidKey: string;\n\n /**\n * The value of the uidKey claim on the JWT. This intended to be a stable user identifier.\n */\n readonly uidVal: string;\n\n /**\n * The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's\n * OIDC registration with the identity provider.\n */\n readonly aud: string;\n\n /**\n * A value contains 31 bytes of entropy that preserves privacy of the account. Typically fetched from a pepper provider.\n */\n readonly pepper: Uint8Array;\n\n /**\n * Account address associated with the account\n */\n readonly accountAddress: AccountAddress;\n\n /**\n * The zero knowledge signature (if ready) which contains the proof used to validate the EphemeralKeyPair.\n */\n proof: ZeroKnowledgeSig | undefined;\n\n /**\n * The proof of the EphemeralKeyPair or a promise that provides the proof. This is used to allow for awaiting on\n * fetching the proof.\n */\n readonly proofOrPromise: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n\n /**\n * Signing scheme used to sign transactions\n */\n readonly signingScheme: SigningScheme;\n\n /**\n * The JWT token used to derive the account\n */\n private jwt: string;\n\n /**\n * A value that caches the JWT's validity. A JWT becomes invalid when it's corresponding JWK is rotated from the\n * identity provider's JWK keyset.\n */\n private isJwtValid: boolean;\n\n /**\n * An event emitter used to assist in handling asycronous proof fetching.\n */\n private readonly emitter: EventEmitter<ProofFetchEvents>;\n\n constructor(args: {\n address?: AccountAddress;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n proofOrFetcher: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n }) {\n super();\n const { address, ephemeralKeyPair, uidKey, uidVal, aud, pepper, proofOrFetcher, proofFetchCallback, jwt } = args;\n this.ephemeralKeyPair = ephemeralKeyPair;\n this.publicKey = KeylessPublicKey.create(args);\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n this.uidKey = uidKey;\n this.uidVal = uidVal;\n this.aud = aud;\n this.jwt = jwt;\n this.emitter = new EventEmitter<ProofFetchEvents>();\n this.proofOrPromise = proofOrFetcher;\n if (proofOrFetcher instanceof ZeroKnowledgeSig) {\n this.proof = proofOrFetcher;\n } else {\n if (proofFetchCallback === undefined) {\n throw new Error(\"Must provide callback for async proof fetch\");\n }\n this.emitter.on(\"proofFetchFinish\", async (status) => {\n await proofFetchCallback(status);\n this.emitter.removeAllListeners();\n });\n this.init(proofOrFetcher);\n }\n this.signingScheme = SigningScheme.SingleKey;\n const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();\n if (pepperBytes.length !== KeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper length in bytes should be ${KeylessAccount.PEPPER_LENGTH}`);\n }\n this.pepper = pepperBytes;\n this.isJwtValid = true;\n }\n\n /**\n * This initializes the asyncronous proof fetch\n * @return\n */\n async init(promise: Promise<ZeroKnowledgeSig>) {\n try {\n this.proof = await promise;\n this.emitter.emit(\"proofFetchFinish\", { status: \"Success\" });\n } catch (error) {\n if (error instanceof Error) {\n this.emitter.emit(\"proofFetchFinish\", { status: \"Failed\", error: error.toString() });\n } else {\n this.emitter.emit(\"proofFetchFinish\", { status: \"Failed\", error: \"Unknown\" });\n }\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.jwt);\n serializer.serializeStr(this.uidKey);\n serializer.serializeFixedBytes(this.pepper);\n this.ephemeralKeyPair.serialize(serializer);\n if (this.proof === undefined) {\n throw new Error(\"Connot serialize - proof undefined\");\n }\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): KeylessAccount {\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = ZeroKnowledgeSig.deserialize(deserializer);\n return KeylessAccount.fromJWTAndProof({\n proof,\n pepper,\n uidKey,\n jwt,\n ephemeralKeyPair,\n });\n }\n\n /**\n * Checks if the proof is expired. If so the account must be rederived with a new EphemeralKeyPair\n * and JWT token.\n * @return boolean\n */\n isExpired(): boolean {\n return this.ephemeralKeyPair.isExpired();\n }\n\n /**\n * Sign a message using Keyless.\n * @param message the message to sign, as binary input\n * @return the AccountAuthenticator containing the signature, together with the account's public key\n */\n signWithAuthenticator(message: HexInput): AccountAuthenticatorSingleKey {\n const signature = new AnySignature(this.sign(message));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n /**\n * Sign a transaction using Keyless.\n * @param transaction the raw transaction\n * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key\n */\n signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey {\n const signature = new AnySignature(this.signTransaction(transaction));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n /**\n * Waits for asyncronous proof fetching to finish.\n * @return\n */\n async waitForProofFetch() {\n if (this.proofOrPromise instanceof Promise) {\n await this.proofOrPromise;\n }\n }\n\n /**\n * Sign the given message using Keyless.\n * @param message in HexInput format\n * @returns Signature\n */\n sign(data: HexInput): KeylessSignature {\n const { expiryDateSecs } = this.ephemeralKeyPair;\n if (this.isExpired()) {\n throw new Error(\"EphemeralKeyPair is expired\");\n }\n if (this.proof === undefined) {\n throw new Error(\"Proof not defined\");\n }\n const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();\n const ephemeralSignature = this.ephemeralKeyPair.sign(data);\n\n return new KeylessSignature({\n jwtHeader: base64UrlDecode(this.jwt.split(\".\")[0]),\n ephemeralCertificate: new EphemeralCertificate(this.proof, EphemeralCertificateVariant.ZkProof),\n expiryDateSecs,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n /**\n * Sign the given transaction with Keyless.\n * Signs the transaction and proof to guard against proof malleability.\n * @param transaction the transaction to be signed\n * @returns KeylessSignature\n */\n signTransaction(transaction: AnyRawTransaction): KeylessSignature {\n if (this.proof === undefined) {\n throw new Error(\"Proof not found\");\n }\n const raw = deriveTransactionType(transaction);\n const txnAndProof = new TransactionAndProof(raw, this.proof.proof);\n const signMess = txnAndProof.hash();\n return this.sign(signMess);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this\n verifySignature(args: { message: HexInput; signature: Signature }): boolean {\n throw new Error(\"Not implemented\");\n }\n\n static fromBytes(bytes: Uint8Array): KeylessAccount {\n return KeylessAccount.deserialize(new Deserializer(bytes));\n }\n\n static fromJWTAndProof(args: {\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n proofFetchCallback?: ProofFetchCallback;\n }): KeylessAccount {\n const { proof, jwt, ephemeralKeyPair, pepper, proofFetchCallback } = args;\n const uidKey = args.uidKey ?? \"sub\";\n\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n const iss = jwtPayload.iss!;\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const aud = jwtPayload.aud!;\n const uidVal = jwtPayload[uidKey];\n return new KeylessAccount({\n proofOrFetcher: proof,\n ephemeralKeyPair,\n iss,\n uidKey,\n uidVal,\n aud,\n pepper,\n jwt,\n proofFetchCallback,\n });\n }\n}\n\n/**\n * A container class to hold a transaction and a proof. It implements CryptoHashable which is used to create\n * the signing message for Keyless transactions. We sign over the proof to ensure non-malleability.\n */\nexport class TransactionAndProof extends CryptoHashable {\n /**\n * The transaction to sign.\n */\n transaction: AnyRawTransactionInstance;\n\n /**\n * The zero knowledge proof used in signing the transaction.\n */\n proof?: ZkProof;\n\n /**\n * The domain separator prefix used when hashing.\n */\n domainSeparator: AptsoDomainSeparator;\n\n constructor(transaction: AnyRawTransactionInstance, proof?: ZkProof) {\n super();\n this.transaction = transaction;\n this.proof = proof;\n this.domainSeparator = \"APTOS::TransactionAndProof\";\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.transaction.bcsToBytes());\n serializer.serializeOption(this.proof);\n }\n}\n\nexport type ProofFetchSuccess = {\n status: \"Success\";\n};\n\nexport type ProofFetchFailure = {\n status: \"Failed\";\n error: string;\n};\n\nexport type ProofFetchStatus = ProofFetchSuccess | ProofFetchFailure;\n\nexport type ProofFetchCallback = (status: ProofFetchStatus) => Promise<void>;\n\nexport interface ProofFetchEvents {\n proofFetchFinish: (status: ProofFetchStatus) => void;\n}\n"],"mappings":"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","names":["jwtDecode","EventEmitter","IssuerToJwkEndpoint","_KeylessAccount","Serializable","args","address","ephemeralKeyPair","uidKey","uidVal","aud","pepper","proofOrFetcher","proofFetchCallback","jwt","KeylessPublicKey","AccountAddress","EventEmitter","ZeroKnowledgeSig","status","pepperBytes","Hex","promise","error","serializer","deserializer","EphemeralKeyPair","proof","message","signature","AnySignature","publicKey","AnyPublicKey","AccountAuthenticatorSingleKey","transaction","data","expiryDateSecs","ephemeralPublicKey","ephemeralSignature","KeylessSignature","base64UrlDecode","EphemeralCertificate","raw","deriveTransactionType","signMess","TransactionAndProof","bytes","Deserializer","jwtPayload","jwtDecode","iss","KeylessAccount","CryptoHashable"]}
@@ -1,2 +0,0 @@
1
- import{a as c}from"./chunk-FF4L66LJ.mjs";import{a as e,b as s,c as r,d as n,e as t,g as i,h as a}from"./chunk-KSSJ3CT5.mjs";var g=class{constructor(o){this.config=o}async getLedgerInfo(){return e({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(o){return s({aptosConfig:this.config,...o})}async getBlockByHeight(o){return r({aptosConfig:this.config,...o})}async view(o){return c({aptosConfig:this.config,...o})}async getChainTopUserTransactions(o){return n({aptosConfig:this.config,...o})}async queryIndexer(o){return t({aptosConfig:this.config,...o})}async getIndexerLastSuccessVersion(){return i({aptosConfig:this.config})}async getProcessorStatus(o){return a({aptosConfig:this.config,processorType:o})}};export{g as a};
2
- //# sourceMappingURL=chunk-5YH2YL3L.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/general.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"./aptosConfig\";\nimport {\n getBlockByHeight,\n getBlockByVersion,\n getChainTopUserTransactions,\n getIndexerLastSuccessVersion,\n getLedgerInfo,\n getProcessorStatus,\n queryIndexer,\n} from \"../internal/general\";\nimport { view } from \"../internal/view\";\nimport {\n AnyNumber,\n Block,\n GetChainTopUserTransactionsResponse,\n GetProcessorStatusResponse,\n GraphqlQuery,\n LedgerInfo,\n LedgerVersionArg,\n MoveValue,\n} from \"../types\";\nimport { ProcessorType } from \"../utils/const\";\nimport { InputViewFunctionData } from \"../transactions\";\n\n/**\n * A class to query all `General` Aptos related queries\n */\nexport class General {\n readonly config: AptosConfig;\n\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Queries for the Aptos ledger info\n *\n * @returns Aptos Ledger Info\n *\n * @example\n * const ledgerInfo = await aptos.getLedgerInfo()\n * // an example of the returned data\n * ```\n * {\n * \"chain_id\": 4,\n * \"epoch\": \"8\",\n * \"ledger_version\": \"714\",\n * \"oldest_ledger_version\": \"0\",\n * \"ledger_timestamp\": \"1694695496521775\",\n * \"node_role\": \"validator\",\n * \"oldest_block_height\": \"0\",\n * \"block_height\": \"359\",\n * \"git_hash\": \"c82193f36f4e185fed9f68c4ad21f6c6dd390c6e\"\n * }\n * ```\n */\n async getLedgerInfo(): Promise<LedgerInfo> {\n return getLedgerInfo({ aptosConfig: this.config });\n }\n\n /**\n * Queries for the chain id\n *\n * @example\n * const chainId = await aptos.getChainId()\n *\n * @returns The chain id\n */\n async getChainId(): Promise<number> {\n const result = await this.getLedgerInfo();\n return result.chain_id;\n }\n\n /**\n * Queries for block by transaction version\n *\n * @example\n * const block = await aptos.getBlockByVersion({ledgerVersion:5})\n *\n * @param args.ledgerVersion Ledger version to lookup block information for\n * @param args.options.withTransactions If set to true, include all transactions in the block\n *\n * @returns Block information with optional transactions\n */\n async getBlockByVersion(args: {\n ledgerVersion: AnyNumber;\n options?: { withTransactions?: boolean };\n }): Promise<Block> {\n return getBlockByVersion({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Get block by block height\n *\n * @example\n * const block = await aptos.getBlockByVersion({blockHeight:5})\n *\n * @param args.blockHeight Block height to lookup. Starts at 0\n * @param args.options.withTransactions If set to true, include all transactions in the block\n *\n * @returns Block with optional transactions\n */\n async getBlockByHeight(args: { blockHeight: AnyNumber; options?: { withTransactions?: boolean } }): Promise<Block> {\n return getBlockByHeight({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for a Move view function\n * @param args.payload Payload for the view function\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n *\n * @example\n * const data = await aptos.view({\n * payload: {\n * function: \"0x1::coin::balance\",\n * typeArguments: [\"0x1::aptos_coin::AptosCoin\"],\n * functionArguments: [accountAddress],\n * }\n * })\n *\n * @returns an array of Move values\n */\n async view<T extends Array<MoveValue>>(args: {\n payload: InputViewFunctionData;\n options?: LedgerVersionArg;\n }): Promise<T> {\n return view<T>({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries top user transactions\n *\n * @example\n * const topUserTransactions = await aptos.getChainTopUserTransactions({limit:5})\n *\n * @param args.limit The number of transactions to return\n * @returns GetChainTopUserTransactionsResponse\n */\n async getChainTopUserTransactions(args: { limit: number }): Promise<GetChainTopUserTransactionsResponse> {\n return getChainTopUserTransactions({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * A generic function for retrieving data from Aptos Indexer.\n * For more detailed queries specification see\n * {@link https://cloud.hasura.io/public/graphiql?endpoint=https://api.mainnet.aptoslabs.com/v1/graphql}\n *\n * @example\n * const topUserTransactions = await aptos.queryIndexer({\n * query: `query MyQuery {\n * ledger_infos {\n * chain_id\n * }}`;\n * })\n *\n * @param args.query.query A GraphQL query\n * @param args.query.variables The variables for the query\n *\n * @return The provided T type\n */\n async queryIndexer<T extends {}>(args: { query: GraphqlQuery }): Promise<T> {\n return queryIndexer<T>({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries for the last successful indexer version\n *\n * This is useful to tell what ledger version the indexer is updated to, as it can be behind the full nodes.\n *\n * @example\n * const version = await aptos.getIndexerLastSuccessVersion()\n */\n async getIndexerLastSuccessVersion(): Promise<bigint> {\n return getIndexerLastSuccessVersion({ aptosConfig: this.config });\n }\n\n /**\n * Query the processor status for a specific processor type.\n *\n * @example\n * const status = await aptos.getProcessorStatus({processorType:\"account_transactions_processor\"})\n *\n * @param processorType The processor type to query\n * @returns\n */\n async getProcessorStatus(processorType: ProcessorType): Promise<GetProcessorStatusResponse[0]> {\n return getProcessorStatus({ aptosConfig: this.config, processorType });\n }\n}\n"],"mappings":"4HA8BO,IAAMA,EAAN,KAAc,CAGnB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAwBA,MAAM,eAAqC,CACzC,OAAOC,EAAc,CAAE,YAAa,KAAK,MAAO,CAAC,CACnD,CAUA,MAAM,YAA8B,CAElC,OADe,MAAM,KAAK,cAAc,GAC1B,QAChB,CAaA,MAAM,kBAAkBC,EAGL,CACjB,OAAOC,EAAkB,CACvB,YAAa,KAAK,OAClB,GAAGD,CACL,CAAC,CACH,CAaA,MAAM,iBAAiBA,EAA4F,CACjH,OAAOE,EAAiB,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CAC/D,CAkBA,MAAM,KAAiCA,EAGxB,CACb,OAAOG,EAAQ,CAAE,YAAa,KAAK,OAAQ,GAAGH,CAAK,CAAC,CACtD,CAWA,MAAM,4BAA4BA,EAAuE,CACvG,OAAOI,EAA4B,CACjC,YAAa,KAAK,OAClB,GAAGJ,CACL,CAAC,CACH,CAoBA,MAAM,aAA2BA,EAA2C,CAC1E,OAAOK,EAAgB,CACrB,YAAa,KAAK,OAClB,GAAGL,CACL,CAAC,CACH,CAUA,MAAM,8BAAgD,CACpD,OAAOM,EAA6B,CAAE,YAAa,KAAK,MAAO,CAAC,CAClE,CAWA,MAAM,mBAAmBC,EAAsE,CAC7F,OAAOC,EAAmB,CAAE,YAAa,KAAK,OAAQ,cAAAD,CAAc,CAAC,CACvE,CACF","names":["General","config","getLedgerInfo","args","getBlockByVersion","getBlockByHeight","view","getChainTopUserTransactions","queryIndexer","getIndexerLastSuccessVersion","processorType","getProcessorStatus"]}
@@ -1,2 +0,0 @@
1
- var t="1.16.0-zeta.2";export{t as a};
2
- //# sourceMappingURL=chunk-FLALKQIK.mjs.map
@@ -1,2 +0,0 @@
1
- import{b as c}from"./chunk-4TDMJQOJ.mjs";import{a as l,l as P,m as d,n as h,o as m}from"./chunk-T4HO5JMQ.mjs";import{b as y}from"./chunk-L5CPAOUM.mjs";import{b as g}from"./chunk-F3ZVWLDH.mjs";import{a as x}from"./chunk-AH44UPM4.mjs";import{b as u}from"./chunk-JOXU5RWH.mjs";import{e as K,f as C}from"./chunk-CVCM46UN.mjs";import{b as i}from"./chunk-AOCNYMMX.mjs";async function L(e){let{aptosConfig:r}=e;return x(async()=>{let o=await _(e),t=await w(e);return m.create(t,Number(o.max_exp_horizon_secs))},`keyless-configuration-${r.network}`,1e3*60*5)()}async function _(e){let{aptosConfig:r,options:o}=e,t="0x1::keyless_account::Configuration",{data:n}=await u({aptosConfig:r,originMethod:"getKeylessConfiguration",path:`accounts/${g.from("0x1").toString()}/resource/${t}`,params:{ledger_version:o?.ledgerVersion}});return n.data}async function w(e){let{aptosConfig:r,options:o}=e,t="0x1::keyless_account::Groth16VerificationKey",{data:n}=await u({aptosConfig:r,originMethod:"getGroth16VerificationKey",path:`accounts/${g.from("0x1").toString()}/resource/${t}`,params:{ledger_version:o?.ledgerVersion}});return n.data}async function b(e){let{aptosConfig:r,jwt:o,ephemeralKeyPair:t,uidKey:n,derivationPath:s}=e,p={jwt_b64:o,epk:t.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:t.expiryDateSecs,epk_blinder:i.fromHexInput(t.blinder).toStringWithoutPrefix(),uid_key:n||"sub",derivation_path:s},{data:a}=await K({aptosConfig:r,path:"fetch",body:p,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return i.fromHexInput(a.pepper).toUint8Array()}async function R(e){let{aptosConfig:r,jwt:o,ephemeralKeyPair:t,pepper:n,uidKey:s}=e,p={jwt_b64:o,epk:t.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:i.fromHexInput(t.blinder).toStringWithoutPrefix(),exp_date_secs:t.expiryDateSecs,exp_horizon_secs:l,pepper:i.fromHexInput(n).toStringWithoutPrefix(),uid_key:s||"sub"};console.log(JSON.stringify(p));let{data:a}=await C({aptosConfig:r,path:"prove",body:p,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),f=a.proof,A=new P({a:f.a,b:f.b,c:f.c});return new h({proof:new d(A,0),trainingWheelsSignature:y.fromHex(a.training_wheels_signature)})}async function N(e){let{proofFetchCallback:r}=e,{pepper:o}=e;if(o===void 0?o=await b(e):o=i.fromHexInput(o).toUint8Array(),o.length!==c.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${c.PEPPER_LENGTH} bytes`);let t=R({...e,pepper:o}),n=r?t:await t;return c.fromJWTAndProof({...e,proof:n,pepper:o,proofFetchCallback:r})}export{L as a,b,R as c,N as d};
2
- //# sourceMappingURL=chunk-KCRCX6BL.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/internal/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/keyless}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * keyless namespace and without having a dependency cycle error.\n */\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { getAptosFullNode, postAptosPepperService, postAptosProvingService } from \"../client\";\nimport {\n AccountAddress,\n EPK_HORIZON_SECS,\n EphemeralSignature,\n Groth16Zkp,\n Hex,\n KeylessConfiguration,\n ZeroKnowledgeSig,\n ZkProof,\n} from \"../core\";\nimport { HexInput, LedgerVersionArg, MoveResource, ZkpVariant } from \"../types\";\nimport { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from \"../account\";\nimport {\n Groth16VerificationKeyResponse,\n KeylessConfigurationResponse,\n PepperFetchRequest,\n PepperFetchResponse,\n ProverRequest,\n ProverResponse,\n} from \"../types/keyless\";\nimport { memoizeAsync } from \"../utils/memoize\";\n\nexport async function getKeylessConfig(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfiguration> {\n const { aptosConfig } = args;\n return memoizeAsync(\n async () => {\n const config = await getKeylessConfiguration(args);\n const vk = await getGroth16VerificationKey(args);\n return KeylessConfiguration.create(vk, Number(config.max_exp_horizon_secs));\n },\n `keyless-configuration-${aptosConfig.network}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n\nasync function getKeylessConfiguration(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfigurationResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Configuration\";\n const { data } = await getAptosFullNode<{}, MoveResource<KeylessConfigurationResponse>>({\n aptosConfig,\n originMethod: \"getKeylessConfiguration\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n\n return data.data;\n}\n\nasync function getGroth16VerificationKey(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<Groth16VerificationKeyResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Groth16VerificationKey\";\n const { data } = await getAptosFullNode<{}, MoveResource<Groth16VerificationKeyResponse>>({\n aptosConfig,\n originMethod: \"getGroth16VerificationKey\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n\n return data.data;\n}\n\nexport async function getPepper(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n derivationPath?: string;\n}): Promise<Uint8Array> {\n const { aptosConfig, jwt, ephemeralKeyPair, uidKey, derivationPath } = args;\n\n const body = {\n jwt_b64: jwt,\n epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),\n exp_date_secs: ephemeralKeyPair.expiryDateSecs,\n epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),\n uid_key: uidKey || \"sub\",\n derivation_path: derivationPath,\n };\n const { data } = await postAptosPepperService<PepperFetchRequest, PepperFetchResponse>({\n aptosConfig,\n path: \"fetch\",\n body,\n originMethod: \"getPepper\",\n overrides: { WITH_CREDENTIALS: false },\n });\n return Hex.fromHexInput(data.pepper).toUint8Array();\n}\n\nexport async function getProof(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n}): Promise<ZeroKnowledgeSig> {\n const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey } = args;\n const json = {\n jwt_b64: jwt,\n epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),\n epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),\n exp_date_secs: ephemeralKeyPair.expiryDateSecs,\n exp_horizon_secs: EPK_HORIZON_SECS,\n pepper: Hex.fromHexInput(pepper).toStringWithoutPrefix(),\n uid_key: uidKey || \"sub\",\n };\n\n console.log(JSON.stringify(json))\n\n const { data } = await postAptosProvingService<ProverRequest, ProverResponse>({\n aptosConfig,\n path: \"prove\",\n body: json,\n originMethod: \"getProof\",\n overrides: { WITH_CREDENTIALS: false },\n });\n\n const proofPoints = data.proof;\n const groth16Zkp = new Groth16Zkp({\n a: proofPoints.a,\n b: proofPoints.b,\n c: proofPoints.c,\n });\n\n const signedProof = new ZeroKnowledgeSig({\n proof: new ZkProof(groth16Zkp, ZkpVariant.Groth16),\n trainingWheelsSignature: EphemeralSignature.fromHex(data.training_wheels_signature),\n });\n return signedProof;\n}\n\nexport async function deriveKeylessAccount(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n pepper?: HexInput;\n proofFetchCallback?: ProofFetchCallback;\n}): Promise<KeylessAccount> {\n const { proofFetchCallback } = args;\n let { pepper } = args;\n if (pepper === undefined) {\n pepper = await getPepper(args);\n } else {\n pepper = Hex.fromHexInput(pepper).toUint8Array();\n }\n\n if (pepper.length !== KeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper needs to be ${KeylessAccount.PEPPER_LENGTH} bytes`);\n }\n\n const proofPromise = getProof({ ...args, pepper });\n const proof = proofFetchCallback ? proofPromise : await proofPromise;\n\n const keylessAccount = KeylessAccount.fromJWTAndProof({ ...args, proof, pepper, proofFetchCallback });\n\n return keylessAccount;\n}\n"],"mappings":"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","names":["getKeylessConfig","args","aptosConfig","memoizeAsync","config","getKeylessConfiguration","vk","getGroth16VerificationKey","KeylessConfiguration","options","resourceType","data","getAptosFullNode","AccountAddress","getPepper","jwt","ephemeralKeyPair","uidKey","derivationPath","body","Hex","postAptosPepperService","getProof","pepper","json","EPK_HORIZON_SECS","postAptosProvingService","proofPoints","groth16Zkp","Groth16Zkp","ZeroKnowledgeSig","ZkProof","EphemeralSignature","deriveKeylessAccount","proofFetchCallback","KeylessAccount","proofPromise","proof"]}
@@ -1,2 +0,0 @@
1
- import{a as r,b as o,d as i}from"./chunk-KCRCX6BL.mjs";var t=class{constructor(e){this.config=e}async getKeylessConfig(e){return r({aptosConfig:this.config,options:e})}async getPepper(e){return o({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return i({aptosConfig:this.config,...e})}};export{t as a};
2
- //# sourceMappingURL=chunk-KNMQU2TA.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from \"../account\";\nimport { KeylessConfiguration } from \"../core\";\nimport { deriveKeylessAccount, getKeylessConfig, getPepper } from \"../internal/keyless\";\nimport { HexInput, LedgerVersionArg } from \"../types\";\nimport { AptosConfig } from \"./aptosConfig\";\n\n/**\n * A class to query all `Keyless` related queries on Aptos.\n */\nexport class Keyless {\n constructor(readonly config: AptosConfig) {}\n\n /**\n * Gets the parameters of how Keyless Accounts are configured on chain.\n *\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns KeylessConfiguration\n */\n async getKeylessConfig(options?: LedgerVersionArg): Promise<KeylessConfiguration> {\n return getKeylessConfig({ aptosConfig: this.config, options });\n }\n\n /**\n * Fetches the pepper from the Aptos pepper service API.\n *\n * @param args.jwt JWT token\n * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token\n * @returns The pepper which is a Uint8Array of length 31.\n */\n async getPepper(args: { jwt: string; ephemeralKeyPair: EphemeralKeyPair }): Promise<Uint8Array> {\n return getPepper({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches the pepper from the Aptos pepper service API.\n *\n * @param args.jwt JWT token\n * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token\n * @param args.uidKey a key in the JWT token to use to set the uidVal in the IdCommitment\n * @param args.pepper the pepper\n * @param args.proofFetchCallback a callback function that if set, the fetch of the proof will be done asyncronously. Once\n * if finishes the callback function will be called.\n * @returns A KeylessAccount that can be used to sign transactions\n */\n async deriveKeylessAccount(args: {\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n pepper?: HexInput;\n proofFetchCallback?: ProofFetchCallback;\n }): Promise<KeylessAccount> {\n return deriveKeylessAccount({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"uDAYO,IAAMA,EAAN,KAAc,CACnB,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CAQ3C,MAAM,iBAAiBC,EAA2D,CAChF,OAAOC,EAAiB,CAAE,YAAa,KAAK,OAAQ,QAAAD,CAAQ,CAAC,CAC/D,CASA,MAAM,UAAUE,EAAgF,CAC9F,OAAOC,EAAU,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CACxD,CAaA,MAAM,qBAAqBA,EAMC,CAC1B,OAAOE,EAAqB,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CACnE,CACF","names":["Keyless","config","options","getKeylessConfig","args","getPepper","deriveKeylessAccount"]}
@@ -1,2 +0,0 @@
1
- import{m as p,v as a}from"./chunk-S3EDNXZE.mjs";import{b as n}from"./chunk-JOXU5RWH.mjs";import{c}from"./chunk-CVCM46UN.mjs";async function h(o){let{aptosConfig:t}=o,{data:s}=await n({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return s}async function d(o){let{aptosConfig:t,ledgerVersion:s,options:e}=o,{data:r}=await n({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${s}`,params:{with_transactions:e?.withTransactions}});return r}async function C(o){let{aptosConfig:t,blockHeight:s,options:e}=o,{data:r}=await n({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${s}`,params:{with_transactions:e?.withTransactions}});return r}async function l(o){let{aptosConfig:t,limit:s}=o;return(await i({aptosConfig:t,query:{query:p,variables:{limit:s}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function i(o){let{aptosConfig:t,query:s,originMethod:e}=o,{data:r}=await c({aptosConfig:t,originMethod:e??"queryIndexer",path:"",body:s,overrides:{WITH_CREDENTIALS:!1}});return r}async function g(o){let{aptosConfig:t}=o;return(await i({aptosConfig:t,query:{query:a},originMethod:"getProcessorStatuses"})).processor_status}async function m(o){let t=await g({aptosConfig:o.aptosConfig});return BigInt(t[0].last_success_version)}async function T(o){let{aptosConfig:t,processorType:s}=o;return(await i({aptosConfig:t,query:{query:a,variables:{where_condition:{processor:{_eq:s}}}},originMethod:"getProcessorStatus"})).processor_status[0]}export{h as a,d as b,C as c,l as d,i as e,g as f,m as g,T as h};
2
- //# sourceMappingURL=chunk-KSSJ3CT5.mjs.map