@crossmint/wallets-sdk 1.19.0 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/__tests__/constants.d.cts +3 -3
- package/dist/api/__tests__/constants.d.ts +3 -3
- package/dist/api/__tests__/test-utils.cjs +1 -1
- package/dist/api/__tests__/test-utils.d.cts +2 -2
- package/dist/api/__tests__/test-utils.d.ts +2 -2
- package/dist/api/__tests__/test-utils.js +1 -1
- package/dist/api/client.cjs +1 -1
- package/dist/api/client.d.cts +3 -3
- package/dist/api/client.d.ts +3 -3
- package/dist/api/client.js +1 -1
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.d.cts +2 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +1 -1
- package/dist/api/types.d.cts +1 -1
- package/dist/api/types.d.ts +1 -1
- package/dist/chains/adapters/evm.cjs +1 -1
- package/dist/chains/adapters/evm.d.cts +2 -2
- package/dist/chains/adapters/evm.d.ts +2 -2
- package/dist/chains/adapters/evm.js +1 -1
- package/dist/chains/adapters/solana.cjs +1 -1
- package/dist/chains/adapters/solana.d.cts +2 -2
- package/dist/chains/adapters/solana.d.ts +2 -2
- package/dist/chains/adapters/solana.js +1 -1
- package/dist/chains/adapters/stellar.cjs +1 -1
- package/dist/chains/adapters/stellar.d.cts +2 -2
- package/dist/chains/adapters/stellar.d.ts +2 -2
- package/dist/chains/adapters/stellar.js +1 -1
- package/dist/chains/chain-adapter.cjs +1 -1
- package/dist/chains/chain-adapter.d.cts +2 -2
- package/dist/chains/chain-adapter.d.ts +2 -2
- package/dist/chains/chain-adapter.js +1 -1
- package/dist/chains/chains.cjs +1 -1
- package/dist/chains/chains.d.cts +2 -2
- package/dist/chains/chains.d.ts +2 -2
- package/dist/chains/chains.js +1 -1
- package/dist/{chunk-R4LSFTQB.js → chunk-2SQXN4JL.js} +1 -1
- package/dist/{chunk-WY5KEIIJ.cjs → chunk-3E3JUVWL.cjs} +1 -1
- package/dist/{chunk-CMER6QR6.cjs → chunk-3GWEE56X.cjs} +1 -1
- package/dist/{chunk-HUZNB3IW.cjs → chunk-3HUNEWAR.cjs} +1 -1
- package/dist/{chunk-WRXF6ZSY.js → chunk-3RWQHOBG.js} +1 -1
- package/dist/{chunk-P3P5Q5XX.js → chunk-43LFPZII.js} +1 -1
- package/dist/chunk-4M6KYXG7.cjs +1 -0
- package/dist/{chunk-UFYLMDRQ.js → chunk-4VGTYVW7.js} +1 -1
- package/dist/{chunk-X7V2C53V.js → chunk-5T7R5TZO.js} +1 -1
- package/dist/{chunk-HCV4M7X2.cjs → chunk-664ATEWT.cjs} +1 -1
- package/dist/chunk-6CNZXJLK.js +1 -0
- package/dist/{chunk-3F4Z2URU.js → chunk-6EPYTT7A.js} +1 -1
- package/dist/chunk-754XJCSX.cjs +1 -0
- package/dist/chunk-A4F6GFJC.cjs +1 -0
- package/dist/chunk-AI5NDEKL.js +1 -0
- package/dist/chunk-AMGE2J7V.js +1 -0
- package/dist/{chunk-QUPMMNGB.js → chunk-AOZ2VVTT.js} +1 -1
- package/dist/{chunk-XFUCYR24.cjs → chunk-AYCMZ6UJ.cjs} +2 -2
- package/dist/{chunk-YSR4FJK7.js → chunk-BF5VS7HX.js} +1 -1
- package/dist/{chunk-YOF3WB3D.js → chunk-C2R47XW6.js} +1 -1
- package/dist/{chunk-SE5L5SQK.cjs → chunk-DFJ63LIQ.cjs} +1 -1
- package/dist/{chunk-C5LIXILN.js → chunk-DVVGWCH7.js} +1 -1
- package/dist/{chunk-CFRSSHAG.cjs → chunk-ENLWAIYV.cjs} +1 -1
- package/dist/{chunk-3W22A7E7.js → chunk-GFK67DR4.js} +1 -1
- package/dist/{chunk-AEHDAUN4.cjs → chunk-H52MPNZP.cjs} +1 -1
- package/dist/{chunk-LEPWAFFZ.js → chunk-HDVUDIDC.js} +1 -1
- package/dist/{chunk-J5VWZVHL.js → chunk-HODQMDIV.js} +1 -1
- package/dist/chunk-I3FLN7RY.js +1 -0
- package/dist/{chunk-Y5JB3XEX.cjs → chunk-IHIJ7G64.cjs} +1 -1
- package/dist/{chunk-PWHMYEUN.cjs → chunk-IYWWY7T5.cjs} +1 -1
- package/dist/{chunk-WXHLPGEB.js → chunk-J7N56JUE.js} +1 -1
- package/dist/{chunk-PJ76KALO.js → chunk-JAP6U3CJ.js} +1 -1
- package/dist/{chunk-OOMMVXZB.js → chunk-KNAIS6WY.js} +1 -1
- package/dist/{chunk-HHA4QJLV.cjs → chunk-KUT3FS3U.cjs} +1 -1
- package/dist/{chunk-XMV4T3J5.cjs → chunk-LRWKIVXL.cjs} +1 -1
- package/dist/chunk-MFQX2HNH.js +1 -0
- package/dist/{chunk-X2CTI7IK.cjs → chunk-NBZEWJUH.cjs} +1 -1
- package/dist/{chunk-NS7UW4BA.cjs → chunk-NHNNPXP7.cjs} +1 -1
- package/dist/chunk-NULQLE3D.js +1 -0
- package/dist/{chunk-36GZTRZX.cjs → chunk-O673DZDX.cjs} +1 -1
- package/dist/{chunk-6XLTNU2N.cjs → chunk-OAFFHV5G.cjs} +1 -1
- package/dist/{chunk-DCZP3IV7.js → chunk-PEHDJW5W.js} +1 -1
- package/dist/{chunk-GAKX357N.cjs → chunk-PQ4LAXVO.cjs} +1 -1
- package/dist/{chunk-ZACJIS35.cjs → chunk-QD53EMTK.cjs} +1 -1
- package/dist/{chunk-2YLAHC7J.js → chunk-QNNWOOHI.js} +1 -1
- package/dist/{chunk-MT2D5VRF.cjs → chunk-R3CAXQLJ.cjs} +1 -1
- package/dist/{chunk-PH4EWT7R.js → chunk-RAQFOCJT.js} +1 -1
- package/dist/{chunk-PCRZWMYM.js → chunk-RFWRLJEX.js} +1 -1
- package/dist/{chunk-67VE25UL.js → chunk-SGLJQXKH.js} +1 -1
- package/dist/{chunk-MI3DBGDV.cjs → chunk-SINS7Z5F.cjs} +1 -1
- package/dist/chunk-TISVJEJ4.cjs +1 -0
- package/dist/chunk-VRA6S3DJ.cjs +1 -0
- package/dist/{chunk-3FQB7LST.cjs → chunk-VRO4EPRC.cjs} +1 -1
- package/dist/chunk-VUCADC63.cjs +1 -0
- package/dist/{chunk-MVGSX46H.js → chunk-WQ7JSD6A.js} +1 -1
- package/dist/{chunk-3FUVUUXU.cjs → chunk-WS27JTIY.cjs} +1 -1
- package/dist/chunk-XK7Y22KI.cjs +1 -0
- package/dist/{chunk-O2ET3L2R.cjs → chunk-XTYSMO67.cjs} +1 -1
- package/dist/{chunk-HLI46UDR.js → chunk-YHPZJA2F.js} +1 -1
- package/dist/{chunk-2J5RPKHK.js → chunk-YNOT3UTT.js} +1 -1
- package/dist/chunk-Z4OBKN5C.js +1 -0
- package/dist/{chunk-WSCABGVO.cjs → chunk-Z6CVEP22.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/logger/index.cjs +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/init.cjs +1 -1
- package/dist/logger/init.js +1 -1
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.d.cts +8 -5
- package/dist/sdk.d.ts +8 -5
- package/dist/sdk.js +1 -1
- package/dist/signers/descriptors/api-key.d.cts +3 -3
- package/dist/signers/descriptors/api-key.d.ts +3 -3
- package/dist/signers/descriptors/device.d.cts +3 -3
- package/dist/signers/descriptors/device.d.ts +3 -3
- package/dist/signers/descriptors/email.d.cts +3 -3
- package/dist/signers/descriptors/email.d.ts +3 -3
- package/dist/signers/descriptors/external-wallet.d.cts +3 -3
- package/dist/signers/descriptors/external-wallet.d.ts +3 -3
- package/dist/signers/descriptors/index.cjs +1 -1
- package/dist/signers/descriptors/index.d.cts +2 -2
- package/dist/signers/descriptors/index.d.ts +2 -2
- package/dist/signers/descriptors/index.js +1 -1
- package/dist/signers/descriptors/passkey.cjs +1 -1
- package/dist/signers/descriptors/passkey.d.cts +3 -3
- package/dist/signers/descriptors/passkey.d.ts +3 -3
- package/dist/signers/descriptors/passkey.js +1 -1
- package/dist/signers/descriptors/phone.d.cts +3 -3
- package/dist/signers/descriptors/phone.d.ts +3 -3
- package/dist/signers/descriptors/server.cjs +1 -1
- package/dist/signers/descriptors/server.d.cts +3 -3
- package/dist/signers/descriptors/server.d.ts +3 -3
- package/dist/signers/descriptors/server.js +1 -1
- package/dist/signers/descriptors/types.d.cts +4 -3
- package/dist/signers/descriptors/types.d.ts +4 -3
- package/dist/signers/device.d.cts +3 -3
- package/dist/signers/device.d.ts +3 -3
- package/dist/signers/evm-api-key.d.cts +3 -3
- package/dist/signers/evm-api-key.d.ts +3 -3
- package/dist/signers/evm-external-wallet.d.cts +3 -3
- package/dist/signers/evm-external-wallet.d.ts +3 -3
- package/dist/signers/external-wallet-signer.d.cts +2 -2
- package/dist/signers/external-wallet-signer.d.ts +2 -2
- package/dist/signers/index.cjs +1 -1
- package/dist/signers/index.d.cts +2 -2
- package/dist/signers/index.d.ts +2 -2
- package/dist/signers/index.js +1 -1
- package/dist/signers/non-custodial/index.cjs +1 -1
- package/dist/signers/non-custodial/index.d.cts +3 -3
- package/dist/signers/non-custodial/index.d.ts +3 -3
- package/dist/signers/non-custodial/index.js +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.d.cts +3 -3
- package/dist/signers/non-custodial/ncs-evm-signer.d.ts +3 -3
- package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-signer.d.cts +3 -3
- package/dist/signers/non-custodial/ncs-signer.d.ts +3 -3
- package/dist/signers/non-custodial/ncs-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.d.cts +3 -3
- package/dist/signers/non-custodial/ncs-solana-signer.d.ts +3 -3
- package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +3 -3
- package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +3 -3
- package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
- package/dist/signers/passkey.cjs +1 -1
- package/dist/signers/passkey.d.cts +3 -3
- package/dist/signers/passkey.d.ts +3 -3
- package/dist/signers/passkey.js +1 -1
- package/dist/signers/server/assemble-server-signer.d.cts +2 -2
- package/dist/signers/server/assemble-server-signer.d.ts +2 -2
- package/dist/signers/server/evm-server-signer.d.cts +3 -3
- package/dist/signers/server/evm-server-signer.d.ts +3 -3
- package/dist/signers/server/helpers/derive-server-signer.d.cts +2 -2
- package/dist/signers/server/helpers/derive-server-signer.d.ts +2 -2
- package/dist/signers/server/helpers/index.d.cts +3 -3
- package/dist/signers/server/helpers/index.d.ts +3 -3
- package/dist/signers/server/index.d.cts +2 -2
- package/dist/signers/server/index.d.ts +2 -2
- package/dist/signers/server/resolver.cjs +1 -1
- package/dist/signers/server/resolver.d.cts +2 -2
- package/dist/signers/server/resolver.d.ts +2 -2
- package/dist/signers/server/resolver.js +1 -1
- package/dist/signers/server/solana-server-signer.d.cts +3 -3
- package/dist/signers/server/solana-server-signer.d.ts +3 -3
- package/dist/signers/server/stellar-server-signer.d.cts +3 -3
- package/dist/signers/server/stellar-server-signer.d.ts +3 -3
- package/dist/signers/solana-api-key.d.cts +3 -3
- package/dist/signers/solana-api-key.d.ts +3 -3
- package/dist/signers/solana-external-wallet.d.cts +3 -3
- package/dist/signers/solana-external-wallet.d.ts +3 -3
- package/dist/signers/stellar-external-wallet.d.cts +3 -3
- package/dist/signers/stellar-external-wallet.d.ts +3 -3
- package/dist/signers/types.cjs +1 -1
- package/dist/signers/types.d.cts +2 -2
- package/dist/signers/types.d.ts +2 -2
- package/dist/signers/types.js +1 -1
- package/dist/{types-D0tKSMr1.d.ts → types-DOG2X_ok.d.ts} +106 -87
- package/dist/{types-BrPpsHHA.d.cts → types-XN1EunoG.d.cts} +106 -87
- package/dist/utils/constants.cjs +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
- package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
- package/dist/utils/device-signers/createDeviceSigner.d.cts +3 -3
- package/dist/utils/device-signers/createDeviceSigner.d.ts +3 -3
- package/dist/utils/device-signers/index.cjs +1 -1
- package/dist/utils/device-signers/index.d.cts +3 -3
- package/dist/utils/device-signers/index.d.ts +3 -3
- package/dist/utils/device-signers/index.js +1 -1
- package/dist/utils/locators.d.cts +3 -3
- package/dist/utils/locators.d.ts +3 -3
- package/dist/utils/recovery.cjs +1 -1
- package/dist/utils/recovery.d.cts +2 -2
- package/dist/utils/recovery.d.ts +2 -2
- package/dist/utils/recovery.js +1 -1
- package/dist/utils/signer-locator.d.cts +2 -2
- package/dist/utils/signer-locator.d.ts +2 -2
- package/dist/utils/signer-mapping.d.cts +3 -3
- package/dist/utils/signer-mapping.d.ts +3 -3
- package/dist/wallets/__tests__/test-helpers.cjs +1 -1
- package/dist/wallets/__tests__/test-helpers.d.cts +1 -1
- package/dist/wallets/__tests__/test-helpers.d.ts +1 -1
- package/dist/wallets/__tests__/test-helpers.js +1 -1
- package/dist/wallets/evm.cjs +1 -1
- package/dist/wallets/evm.d.cts +2 -2
- package/dist/wallets/evm.d.ts +2 -2
- package/dist/wallets/evm.js +1 -1
- package/dist/wallets/services/balance-formatter.cjs +1 -1
- package/dist/wallets/services/balance-formatter.d.cts +3 -3
- package/dist/wallets/services/balance-formatter.d.ts +3 -3
- package/dist/wallets/services/balance-formatter.js +1 -1
- package/dist/wallets/services/device-recovery-service.cjs +1 -1
- package/dist/wallets/services/device-recovery-service.d.cts +2 -2
- package/dist/wallets/services/device-recovery-service.d.ts +2 -2
- package/dist/wallets/services/device-recovery-service.js +1 -1
- package/dist/wallets/services/operation-poller.cjs +1 -1
- package/dist/wallets/services/operation-poller.d.cts +2 -2
- package/dist/wallets/services/operation-poller.d.ts +2 -2
- package/dist/wallets/services/operation-poller.js +1 -1
- package/dist/wallets/services/signer-manager.cjs +1 -1
- package/dist/wallets/services/signer-manager.d.cts +3 -3
- package/dist/wallets/services/signer-manager.d.ts +3 -3
- package/dist/wallets/services/signer-manager.js +1 -1
- package/dist/wallets/solana.cjs +1 -1
- package/dist/wallets/solana.d.cts +2 -2
- package/dist/wallets/solana.d.ts +2 -2
- package/dist/wallets/solana.js +1 -1
- package/dist/wallets/stellar.cjs +1 -1
- package/dist/wallets/stellar.d.cts +2 -2
- package/dist/wallets/stellar.d.ts +2 -2
- package/dist/wallets/stellar.js +1 -1
- package/dist/wallets/types.d.cts +2 -2
- package/dist/wallets/types.d.ts +2 -2
- package/dist/wallets/wallet-factory.cjs +1 -1
- package/dist/wallets/wallet-factory.d.cts +3 -2
- package/dist/wallets/wallet-factory.d.ts +3 -2
- package/dist/wallets/wallet-factory.js +1 -1
- package/dist/wallets/wallet.cjs +1 -1
- package/dist/wallets/wallet.d.cts +2 -2
- package/dist/wallets/wallet.d.ts +2 -2
- package/dist/wallets/wallet.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-2E6IJLDW.js +0 -1
- package/dist/chunk-4LXZPDTP.cjs +0 -1
- package/dist/chunk-54LGZZX4.js +0 -1
- package/dist/chunk-DBFCNM4F.js +0 -1
- package/dist/chunk-DXF5442W.cjs +0 -1
- package/dist/chunk-FNDMOANS.cjs +0 -1
- package/dist/chunk-GBTTVLK5.cjs +0 -1
- package/dist/chunk-KQDPQXLL.cjs +0 -1
- package/dist/chunk-NM33FBA3.cjs +0 -1
- package/dist/chunk-PA3RU64J.js +0 -1
- package/dist/chunk-PSIZCLMC.js +0 -1
- package/dist/chunk-QYBC7GTA.js +0 -1
- package/dist/chunk-VW24W4N4.js +0 -1
- package/dist/chunk-ZR63HKN6.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNBZEWJUHcjs = require('./chunk-NBZEWJUH.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunkNBZEWJUHcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkNBZEWJUHcjs.a.getOptions(e),alias:e.alias,recovery:_chunkNBZEWJUHcjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkNBZEWJUHcjs.a.getInitialSigners(e)},_chunkNBZEWJUHcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidStellarAddress.call(void 0, e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;_chunkO673DZDXcjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkO673DZDXcjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return _chunkO673DZDXcjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return _chunkO673DZDXcjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunkO673DZDXcjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunkO673DZDXcjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunkO673DZDXcjs.a.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunkD2S37DJ5cjs.I)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkO673DZDXcjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunkO673DZDXcjs.a.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new (0, _chunkD2S37DJ5cjs.I)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunkDSIFRRBScjs.a.call(void 0, {transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new (0, _chunkD2S37DJ5cjs.I)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}exports.a = h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as g}from"./chunk-B4GYB3XY.js";import{j as d}from"./chunk-4I3EXM4B.js";import{a as i}from"./chunk-
|
|
1
|
+
import{c as g}from"./chunk-B4GYB3XY.js";import{j as d}from"./chunk-4I3EXM4B.js";import{a as i}from"./chunk-QNNWOOHI.js";var m={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var t,a,o,s;if(!("chains"in e))throw i.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((a=(t=e.chains)==null?void 0:t[r])==null?void 0:a.status)==="failed")throw i.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new d(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((s=e.chains)==null?void 0:s[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}},signApproval(e,r,n){return e.signTransaction(n)}};export{m as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i=class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o=class extends Error{constructor(n,r){super(n),this.name="SignerAuthenticationError",this.code=r}},
|
|
1
|
+
var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i=class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o=class extends Error{constructor(n,r){super(n),this.name="SignerAuthenticationError",this.code=r}},s=class extends Error{constructor(n,r){super(n),this.name="SignerStatusError",this.code=r}},a=class extends Error{constructor(n,r){super(n),this.name="KeyExportError",this.code=r}},g=class extends Error{constructor(n="The signer session expired before the code could be verified. A new code has been sent."){super(n),this.name="OnboardingSessionExpiredError"}};function S(e){return e.type==="server"&&!("secret"in e)}function c(e){return e._exportPrivateKey!==void 0}export{t as a,i as b,o as c,s as d,a as e,g as f,S as g,c as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _ox = require('ox');var h=37,u=32,d=4;function f(i){let t=_ox.Hex.toBytes(i);return t.length<h?!1:(t[u]&d)!==0}var a=class{constructor(t){this.config=t;this.type="passkey";this.id=t.id}locator(){return this.config.locator}signMessage(t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.config.onSignWithPasskey){let r=yield this.config.onSignWithPasskey(t,this.id===""?void 0:this.id);if(!f(r.metadata.authenticatorData))throw new (0, _chunkD2S37DJ5cjs.B)('The passkey assertion was created without user verification, and the on-chain verifier requires it. Request the assertion with `userVerification: "required"` so the authenticator prompts for biometrics or a PIN.');return r}let{signature:s,metadata:o}=yield _ox.WebAuthnP256.sign({credentialId:this.id,challenge:t});return{signature:{r:`0x${s.r.toString(16)}`,s:`0x${s.s.toString(16)}`},metadata:o}})}signTransaction(t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.signMessage(t)})}};exports.a = a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-AOZ2VVTT.js";import{a as l}from"./chunk-BF5VS7HX.js";import{a as o}from"./chunk-2SQXN4JL.js";import{a as S}from"./chunk-IQARABFX.js";import{a as g}from"./chunk-ECKSTWA3.js";import{a as y}from"./chunk-K7BPGUFU.js";import{a as f}from"./chunk-MN2BGRRJ.js";import{a as C}from"./chunk-FQ5F3VYJ.js";import{a as m}from"./chunk-HAQMNZO5.js";import{a as p}from"./chunk-AI5NDEKL.js";import{a as u}from"./chunk-MLROTECD.js";import{g as i}from"./chunk-4I3EXM4B.js";import{h as t}from"./chunk-NU7VF7MC.js";function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new l(e):r==="stellar"?new o(e):new s(e);case"api-key":return r==="solana"?new u(e):new C(e);case"external-wallet":return r==="solana"?new g(e):r==="stellar"?new y(e):new m(e);case"server":return S(r,e);case"passkey":return new p(e);case"device":if(n==null)throw new i("Device signer key storage is required for device signers");return new f(e,n)}}function k(r,e,n,a){return t(this,null,function*(){if(!e.startsWith("device:"))return null;let w=e.replace("device:","");return(yield a.hasKey(w))?c(r,{type:"device",locator:e,address:n},a):null})}export{c as a,k as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as o}from"./chunk-
|
|
1
|
+
import{g as o}from"./chunk-43LFPZII.js";var g=`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
|
|
2
2
|
Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`,c={type:"server",validateConfig(){},buildInternalConfig(e,r){let{derivedKeyBytes:n,derivedAddress:i}=r.serverSigners.keyMaterialForAssembly(e);return{type:"server",derivedKeyBytes:n,locator:`server:${i}`,address:i}},canAutoAssemble(e,r){return!o(e)||r.serverSigners.hasRecoveryResolutionFor(e.address)},addSignerPayload(e,r){return r.serverSigners.apiLocator(e)},matchesRecovery(e,r,n){let i=n.serverSigners.candidateAddresses(e),s=n.serverSigners.candidateAddresses(r);return i.some(t=>s.includes(t))},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>g};export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i= exports.b =class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o= exports.c =class extends Error{constructor(n,r){super(n),this.name="SignerAuthenticationError",this.code=r}},
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i= exports.b =class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o= exports.c =class extends Error{constructor(n,r){super(n),this.name="SignerAuthenticationError",this.code=r}},s= exports.d =class extends Error{constructor(n,r){super(n),this.name="SignerStatusError",this.code=r}},a= exports.e =class extends Error{constructor(n,r){super(n),this.name="KeyExportError",this.code=r}},g= exports.f =class extends Error{constructor(n="The signer session expired before the code could be verified. A new code has been sent."){super(n),this.name="OnboardingSessionExpiredError"}};function p(e){return e.type==="server"&&!("secret"in e)}function S(e){return e._exportPrivateKey!==void 0}exports.a = t; exports.b = i; exports.c = o; exports.d = s; exports.e = a; exports.f = g; exports.g = p; exports.h = S;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-RV3Q5EIA.js";var c={type:"passkey",validateConfig(){},buildInternalConfig(n,i){var a,s,t,g,C;let e=n,r=(a=o(e))!=null?a:"";return{type:"passkey",id:r,locator:`passkey:${r}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:(t=e.onCreatePasskey)!=null?t:(s=i.passkeyProvider)==null?void 0:s.createPasskey,onSignWithPasskey:(C=e.onSignWithPasskey)!=null?C:(g=i.passkeyProvider)==null?void 0:g.signWithPasskey}},canAutoAssemble(){return!0},addSignerPayload(n){return n},matchesRecovery(n,i){let e=o(n),r=o(i);return e==null||r==null?!0:e===r},adoptsRecoveryConfigOnMatch:!1,signerUnavailableReason:()=>null};export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p}from"./chunk-IHMMTMFG.js";import{a as b}from"./chunk-PWYCEHYZ.js";import{a as g,b as m,c as u,d as A,e as P,f as T}from"./chunk-
|
|
1
|
+
import{a as p}from"./chunk-IHMMTMFG.js";import{a as b}from"./chunk-PWYCEHYZ.js";import{a as g,b as m,c as u,d as A,e as P,f as T}from"./chunk-43LFPZII.js";import{a as n}from"./chunk-QNNWOOHI.js";import{a as v,c as y,h as s}from"./chunk-NU7VF7MC.js";import{validateAPIKey as O,WithLoggerContext as C}from"@crossmint/common-sdk-base";var w=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return s(this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=O(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new p({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return s(this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return s(this,null,function*(){n.info("TEE connection not initialized, initializing now");let i=O(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new p({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");n.info("TEE connection initialized successfully")})}handleAuthRequired(){return s(this,null,function*(){let i=this.getAuthDataOrThrow(),t=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);n.info("get-status: sending request");let h=Date.now(),r=yield t.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:i,data:{authId:this.getAuthId()}},options:f}),a=Date.now()-h;if((r==null?void 0:r.status)!=="success"){let o=(r==null?void 0:r.status)==="error"&&r.error||"Failed to retrieve signer status",l=(r==null?void 0:r.status)==="error"?r.code:void 0;throw n.error("get-status: failed",{status:r==null?void 0:r.status,error:(r==null?void 0:r.status)==="error"?r.error:void 0,code:l,durationMs:a}),_(o,l)?new u(o,l):new A(o,l)}if(n.info("get-status: response received",{signerStatus:r.signerStatus,durationMs:a}),r.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;n.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:e,resolve:c,reject:d}=this.createAuthPromise();if(this._authPromise={promise:e,resolve:c,reject:d},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>s(this,null,function*(){n.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>{var o;return(o=this._authPromise)==null?void 0:o.reject(new g)})),d(new g)}))}catch(o){n.error("handleAuthRequired error",{error:o}),d(o)}try{yield e}catch(o){throw n.error("handleAuthRequired promise error",{error:o}),o}})}ensureAuthenticated(){return s(this,null,function*(){this.getJwtOrThrow(),this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null||i.trim()==="")throw new u(`${this.type} signer requires a valid Crossmint JWT. The user's session is missing or has expired: re-authenticate the user and refresh the JWT before retrying.`,S);return i}getAuthDataOrThrow(){return{jwt:this.getJwtOrThrow(),apiKey:this.config.crossmint.apiKey}}createAuthPromise(){let i,t;return{promise:new Promise((r,a)=>{i=r,t=a}),resolve:i,reject:t}}sendMessageWithOtp(){return s(this,null,function*(){var i;try{yield this.startOnboarding()}catch(t){throw t instanceof u&&((i=this._authPromise)==null||i.reject(t)),t}})}startOnboarding(){return s(this,null,function*(){let i=this.getAuthDataOrThrow(),t=yield this.getTEEConnection(),h=this.getAuthId();n.info("start-onboarding: sending request");let r=Date.now(),a=this.config.type==="phone"?this.config.channel:void 0,e=yield t.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:i,data:v({authId:h},a!=null?{channel:a}:{})},options:f}),c=Date.now()-r;if(this._onboardingConnectionGeneration=t.connectionGeneration,n.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:c}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}if((e==null?void 0:e.status)==="error"){n.error("start-onboarding: failed",{error:e.error,code:e.code});let d=e.error||"Failed to initiate OTP process.";throw _(d,e.code)?new u(d,e.code):new m(d,e.code)}})}getAuthId(){return this.config.type==="email"?this.config.email!=null?`email:${b(this.config.email)}`:this.config.locator:this.config.phone!=null?`phone:${this.config.phone}`:this.config.locator}verifyOtp(i){return s(this,null,function*(){var a;let t;try{let e=yield this.getTEEConnection();n.info("complete-onboarding: sending request");let c=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:this.getAuthDataOrThrow(),data:{onboardingAuthentication:{encryptedOtp:i}}},options:f}),n.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-c})}catch(e){return n.error("complete-onboarding: error",{error:e}),yield this.handleOnboardingVerificationFailure(e)}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new g)})),(a=this._authPromise)==null||a.resolve();return}n.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let h=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",r=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new m(h,r))})}handleOnboardingVerificationFailure(i){return s(this,null,function*(){var r,a,e;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){n.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(c){throw(r=this._authPromise)==null||r.reject(c),c}if(!this._needsAuth){(a=this._authPromise)==null||a.resolve();return}throw new T}throw(e=this._authPromise)==null||e.reject(i),i})}_exportPrivateKey(i,t){return s(this,null,function*(){yield this.ensureAuthenticated();let h=this.getJwtOrThrow(),{scheme:r,encoding:a}=this.getChainKeyParams();if(t!=null){let c=i.on("event:key-exported",d=>{i.off(c),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let e=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:h,apiKey:this.config.crossmint.apiKey},data:{scheme:r,encoding:a,walletAddress:this.config.address,authId:this.getAuthId()}},options:f});if((e==null?void 0:e.status)==="error")throw n.error("export-signer: failed",{error:e.error,code:e.code}),new P(e.error||"Failed to export private key",e.code)})}};y([C({logger:n,methodName:"handleAuthRequired"})],w.prototype,"handleAuthRequired",1);var f={timeoutMs:3e4},S="jwt-required",q=new Set(["unauthorized","unauthenticated"]);function _(E,i){return i!=null&&q.has(i.toLowerCase())?!0:/\bHTTP 401\b/.test(E)}export{w as a,f as b,S as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTISVJEJ4cjs = require('./chunk-TISVJEJ4.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkKUT3FS3Ucjs = require('./chunk-KUT3FS3U.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var c=class p{constructor(e){_chunkO673DZDXcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkKUT3FS3Ucjs.a)(e);this.walletFactory=new (0, _chunkTISVJEJ4cjs.a)(t),_chunkO673DZDXcjs.a.info("wallets.sdk.initialized")}static from(e){return new p(e)}getWallet(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkGMU3ZYLScjs.a.call(void 0, e,t)})}createPasskeySigner(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=t?yield t.createPasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOQFZL5LIcjs = require('./chunk-OQFZL5LI.cjs');var _chunkAUO6R32Hcjs = require('./chunk-AUO6R32H.cjs');var _chunkZPO3XSWUcjs = require('./chunk-ZPO3XSWU.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkTCDH5Q6Qcjs = require('./chunk-TCDH5Q6Q.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var g=[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],D=[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.ARC,_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.CELO,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function ie(t){switch(t){case _commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA:return _chains.baseSepolia;case _commonsdkbase.BlockchainIncludingTestnet.BASE:return _chains.base;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY:return _chains.polygonAmoy;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON:return _chains.polygon;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA:return _chains.optimismSepolia;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM:return _chains.optimism;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA:return _chains.arbitrumSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM:return _chains.arbitrum;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA:return _chains.arbitrumNova;case _commonsdkbase.BlockchainIncludingTestnet.AVALANCHE:return _chains.avalanche;case _commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI:return _chains.avalancheFuji;case _commonsdkbase.BlockchainIncludingTestnet.CELO:return _chains.celo;case _commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA:return _chunkOQFZL5LIcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN:return _chunkAUO6R32Hcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET:return _chunkZPO3XSWUcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.BSC:return _chains.bsc;case _commonsdkbase.BlockchainIncludingTestnet.SHAPE:return _chains.shape;case _commonsdkbase.BlockchainIncludingTestnet.ZORA:return _chains.zora;case _commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA:return _chains.zoraSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA:return _chains.sepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM:return _chains.mainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.ARC:return _chunkTCDH5Q6Qcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET:return _chunkHRUMWG2Fcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO:return _chunkUE3WVHTMcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET:return _chunk5X4EOJFGcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.APECHAIN:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1:case _commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.CURTIS:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function u(t){return g.includes(t)}function c(t){return D.includes(t)}var $={[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE]:_commonsdkbase.BlockchainIncludingTestnet.AVALANCHE_FUJI,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.CELO]:_commonsdkbase.BlockchainIncludingTestnet.CELO_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM]:_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN]:_commonsdkbase.BlockchainIncludingTestnet.ROBINHOOD_CHAIN_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.SCROLL]:_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1]:_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.STORY]:_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.ARC]:_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET};function G(t){return $[t]}function Z(t){return t==="solana"||t==="stellar"||u(t)||c(t)}function oe(t,a){if(!Z(t))throw new (0, _chunkD2S37DJ5cjs.c)(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,i=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(i&&u(r))throw new (0, _chunkD2S37DJ5cjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!i&&c(r)){let n=G(r);if(n!=null)return _chunkO673DZDXcjs.a.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;_chunkO673DZDXcjs.a.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}exports.a = ie; exports.b = u; exports.c = c; exports.d = G; exports.e = Z; exports.f = oe;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as n}from"./chunk-4I3EXM4B.js";import{h as e}from"./chunk-NU7VF7MC.js";import{Hex as g,WebAuthnP256 as c}from"ox";var h=37,u=32,d=4;function f(i){let t=g.toBytes(i);return t.length<h?!1:(t[u]&d)!==0}var a=class{constructor(t){this.config=t;this.type="passkey";this.id=t.id}locator(){return this.config.locator}signMessage(t){return e(this,null,function*(){if(this.config.onSignWithPasskey){let r=yield this.config.onSignWithPasskey(t,this.id===""?void 0:this.id);if(!f(r.metadata.authenticatorData))throw new n('The passkey assertion was created without user verification, and the on-chain verifier requires it. Request the assertion with `userVerification: "required"` so the authenticator prompts for biometrics or a PIN.');return r}let{signature:s,metadata:o}=yield c.sign({credentialId:this.id,challenge:t});return{signature:{r:`0x${s.r.toString(16)}`,s:`0x${s.s.toString(16)}`},metadata:o}})}signTransaction(t){return e(this,null,function*(){return yield this.signMessage(t)})}};export{a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O}from"./chunk-HDVUDIDC.js";import{b as K}from"./chunk-RV3Q5EIA.js";import{a as W}from"./chunk-4VGTYVW7.js";import{g as x}from"./chunk-43LFPZII.js";import{b as P,c as k}from"./chunk-B4GYB3XY.js";import{o as q,t as $}from"./chunk-4I3EXM4B.js";import{a as L}from"./chunk-QNNWOOHI.js";import{a as T,b as I,d as i,e as l,f as a,g as w,h as d}from"./chunk-NU7VF7MC.js";import{ApiClientError as z}from"@crossmint/common-sdk-base";var g,o,p,u,c,S,m,y,C,R,A,v,E,M,D=class{constructor(e){l(this,v);l(this,g);l(this,o);l(this,p,null);l(this,u);l(this,c);l(this,S);l(this,m);l(this,y);l(this,C);l(this,R);l(this,A);if(a(this,u,e.apiClient),a(this,c,e.options),a(this,S,e.chain),a(this,m,e.walletAddress),a(this,y,e.walletLocator),a(this,C,e.serverSignerResolver),e.recoverySigners.length===0)throw new q("At least one recovery signer is required");a(this,o,[...e.recoverySigners]),a(this,R,e.initialSigners),a(this,A,e.signers),a(this,g,e.signer)}get activeSigner(){return i(this,g)}setActiveSigner(e){a(this,g,e)}get recovery(){return i(this,o)[0]}get recoverySigners(){return[...i(this,o)]}get selectedRecovery(){var e,r;return(r=(e=i(this,p))==null?void 0:e.config)!=null?r:null}selectRecovery(e,r=i(this,o)[e]){w(this,v,E).call(this,e),a(this,p,{index:e,config:r})}descriptorContext(){var e,r,n,s,t,h;return{chain:i(this,S),walletAddress:i(this,m),crossmint:i(this,u).crossmint,clientTEEConnection:(e=i(this,c))==null?void 0:e.clientTEEConnection,resetSignerFrame:(r=i(this,c))==null?void 0:r.resetSignerFrame,onAuthRequired:(s=(n=i(this,c))==null?void 0:n.callbacks)==null?void 0:s.onAuthRequired,deviceSignerKeyStorage:(t=i(this,c))==null?void 0:t.deviceSignerKeyStorage,passkeyProvider:(h=i(this,c))==null?void 0:h.passkeyProvider,serverSigners:i(this,C)}}adoptRecoveryConfig(e,r){w(this,v,E).call(this,e),i(this,o)[e]=r}stripSecretFromRecovery(e,r){w(this,v,E).call(this,e);let n=i(this,o)[e];n.type==="server"&&!x(n)&&(i(this,o)[e]={type:"server",address:r})}addRecoverySigner(e){let r=this.recoveryLocator(e);r!=null&&i(this,o).some(s=>this.recoveryLocator(s)===r)||i(this,o).push(e)}removeRecoverySigner(e){let r=i(this,p),n=r==null?null:i(this,o)[r.index],s=r!=null&&this.recoveryLocator(r.config)===e;if(a(this,o,i(this,o).filter(t=>this.recoveryLocator(t)!==e&&!(s&&t===n))),r!=null){let t=s||n==null?-1:i(this,o).indexOf(n);a(this,p,t===-1?null:I(T({},r),{index:t}))}}assemble(e,r){return d(this,null,function*(){var s,t;let n=W(i(this,S),e,(s=i(this,c))==null?void 0:s.deviceSignerKeyStorage);if(r!=null&&r.isAdminSigner)n.status="active";else{let h=yield this.getSignerState(n.locator());n.status=(t=h.signer)==null?void 0:t.status}return n})}require(){if(i(this,g)==null){if(i(this,R).length>1)throw new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations.");let e=this.recovery,r=O(e.type),n=r.signerUnavailableReason();throw n!=null?new Error(n):r.canAutoAssemble(e,this.descriptorContext())?new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available."):new Error("No signer is set. This wallet requires calling wallet.useSigner() before signing operations.")}return i(this,g)}resolveAuthorizingRecovery(){var t,h;let e=this.selectedRecovery;if(e!=null)return{recovery:e,approver:(t=this.recoveryLocator(e))!=null?t:void 0};if(i(this,o).length===1)return{recovery:i(this,o)[0],approver:void 0};let r=i(this,o).map(f=>this.recoveryLocator(f)),n=(h=i(this,g))==null?void 0:h.locator(),s=n==null?-1:r.indexOf(n);if(s===-1){let b=`Call wallet.useRecoveryMethod() with one of them (${r.filter(F=>F!=null).join(", ")}) first.`;throw new $(n==null?`This wallet has multiple recovery methods, so the one authorizing this operation must be selected. ${b}`:`Signer "${n}" is not one of this wallet's recovery methods, and only a recovery method can add or remove signers. ${b}`)}return{recovery:i(this,o)[s],approver:n}}recoveryLocator(e){return e.type==="server"?x(e)?`server:${e.address}`:null:K(e)}withRecoverySigner(e){return d(this,null,function*(){var F;let r=i(this,g),{recovery:n,approver:s}=this.resolveAuthorizingRecovery(),t=n;if(x(t)&&!i(this,C).hasRecoveryResolutionFor(t.address))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useRecoveryMethod({ type: "server", secret: ... }) first with the recovery server secret.');let h=O(t.type),f=this.descriptorContext();if(t.type==="external-wallet"&&!h.canAutoAssemble(t,f))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useRecoveryMethod({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let b=h.buildInternalConfig(t,f);a(this,g,W(i(this,S),b,(F=i(this,c))==null?void 0:F.deviceSignerKeyStorage));try{return yield e(s)}finally{a(this,g,r)}})}getSignerState(e){return d(this,null,function*(){let r=null;try{r=yield i(this,u).getSigner(i(this,y).call(this),e)}catch(s){return L.warn("wallet.signers.getSignerState.fetchFailed",{signerLocator:e,error:s}),{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return L.warn("wallet.signers.getSignerState.errorResponse",{signerLocator:e,response:r}),{response:null,signer:null,pendingOperation:null};let n=P(r,i(this,S));return{response:r,signer:n,pendingOperation:k(r,i(this,S))}})}signerIsRegistered(e){return d(this,null,function*(){return(yield i(this,A).call(this)).some(n=>n.locator===e)})}isSignerApproved(e){return d(this,null,function*(){try{let r=yield w(this,v,M).call(this,e);return this.isApprovedSignerStatus(r==null?void 0:r.status)}catch(r){if(r instanceof z&&r.status===404)return!1;throw L.error("wallet.signers.isSignerApproved.failed",{signerLocator:e,error:r}),r}})}isApprovedSignerStatus(e){return e==="success"||e==="active"}};g=new WeakMap,o=new WeakMap,p=new WeakMap,u=new WeakMap,c=new WeakMap,S=new WeakMap,m=new WeakMap,y=new WeakMap,C=new WeakMap,R=new WeakMap,A=new WeakMap,v=new WeakSet,E=function(e){if(e<0||e>=i(this,o).length)throw new Error(`Recovery signer index ${e} is out of range`)},M=function(e){return d(this,null,function*(){let r=yield i(this,u).getSigner(i(this,y).call(this),e);if(r==null||typeof r!="object"||"error"in r)throw new Error(`Failed to fetch the approval state of signer ${e}`);return P(r,i(this,S))})};export{D as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as g}from"./chunk-
|
|
1
|
+
import{a,b as g}from"./chunk-6EPYTT7A.js";import{a as s}from"./chunk-QNNWOOHI.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as h}from"ox";import{isHex as y,toHex as d}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=y(e)?e:d(e),r=h.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let u=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex",authId:this.getAuthId()}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
2
|
-
Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`,C= exports.a ={type:"server",validateConfig(){},buildInternalConfig(e,r){let{derivedKeyBytes:n,derivedAddress:i}=r.serverSigners.keyMaterialForAssembly(e);return{type:"server",derivedKeyBytes:n,locator:`server:${i}`,address:i}},canAutoAssemble(e,r){return!
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk664ATEWTcjs = require('./chunk-664ATEWT.cjs');var g=`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
|
|
2
|
+
Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`,C= exports.a ={type:"server",validateConfig(){},buildInternalConfig(e,r){let{derivedKeyBytes:n,derivedAddress:i}=r.serverSigners.keyMaterialForAssembly(e);return{type:"server",derivedKeyBytes:n,locator:`server:${i}`,address:i}},canAutoAssemble(e,r){return!_chunk664ATEWTcjs.g.call(void 0, e)||r.serverSigners.hasRecoveryResolutionFor(e.address)},addSignerPayload(e,r){return r.serverSigners.apiLocator(e)},matchesRecovery(e,r,n){let i=n.serverSigners.candidateAddresses(e),s=n.serverSigners.candidateAddresses(r);return i.some(t=>s.includes(t))},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>g};exports.a = C;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as o}from"./chunk-
|
|
1
|
+
import{a as s,b as o}from"./chunk-6EPYTT7A.js";import{a as i}from"./chunk-QNNWOOHI.js";import{h as t}from"./chunk-NU7VF7MC.js";import a from"bs58";var g=class d extends s{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){return yield this.sign(a.decode(e))})}signTransaction(e){return t(this,null,function*(){return yield this.signMessage(e)})}sign(e){return t(this,null,function*(){var r;yield this.handleAuthRequired();let c=this.getJwtOrThrow();i.info("sign: sending request",{keyType:"ed25519"});let u=Date.now(),n=yield(r=this.config.clientTEEConnection)==null?void 0:r.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(e)),encoding:"base58",authId:this.getAuthId()}},options:o});if(i.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign payload");return d.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as r}from"./chunk-4I3EXM4B.js";import{a as o}from"./chunk-
|
|
1
|
+
import{o as r}from"./chunk-4I3EXM4B.js";import{a as o}from"./chunk-QNNWOOHI.js";function i(e){if(e.recoveryMethods!=null&&e.recovery!=null)throw new r("Pass either `recovery` or `recoveryMethods`, not both");if(e.recoveryMethods!=null){if(!Array.isArray(e.recoveryMethods))throw new r("`recoveryMethods` must be an array of recovery methods. To pass a single recovery method, use `recovery`");return e.recoveryMethods}return e.recovery==null?[]:Array.isArray(e.recovery)?(o.warn("wallet.create.recovery.deprecatedListForm",{message:"Passing a list to `recovery` is deprecated. Use `recoveryMethods` instead.",count:e.recovery.length}),e.recovery):[e.recovery]}function s(e){return e.recoveryMethods!=null||Array.isArray(e.recovery)}export{i as a,s as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _ox = require('ox');function d(n){let e=_bs582.default.decode(n)[0];return e!=null&&(e&128)!==0&&(e&127)===1}function c(n){return"transaction"in n.onChain&&typeof n.onChain.transaction=="string"?n.onChain.transaction:void 0}var g={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,e,r){if(!("transaction"in n)||n.transaction==null)throw _chunkO673DZDXcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");return{type:"transaction",id:n.transaction.id}},balanceTokenFields(n){return n!=null&&"mintHash"in n?{mintHash:n.mintHash}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{mintHash:void 0}},signApproval(n,e,r){var t;return n.type==="passkey"?n.signTransaction(_ox.Hex.fromBytes(_ox.Base64.toBytes(r))):n.type!=="external-wallet"?n.signTransaction(r):d(r)?n.signMessage(r):n.signTransaction((t=c(e))!=null?t:r)}};exports.a = g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ue}from"./chunk-2E6IJLDW.js";import{a as pe}from"./chunk-OOMMVXZB.js";import{a as ve}from"./chunk-WXHLPGEB.js";import{a as ye,b as Se}from"./chunk-DCZP3IV7.js";import{a as de}from"./chunk-PCRZWMYM.js";import{a as I}from"./chunk-LEPWAFFZ.js";import{a as _,b as q}from"./chunk-RV3Q5EIA.js";import{a as ge,b as he}from"./chunk-VG67JHRI.js";import{a as ce}from"./chunk-3F4Z2URU.js";import{g as J}from"./chunk-P3P5Q5XX.js";import{a as ae,b as oe,c as le}from"./chunk-PJ76KALO.js";import{b as se}from"./chunk-B4GYB3XY.js";import{f as ne}from"./chunk-PSIZCLMC.js";import{E as Y,F as Z,H as ee,I as re,J as te,O as ie,R as k,d as B,e as V,j as $,l as z,m as Q,n as K,o as D,u as X}from"./chunk-4I3EXM4B.js";import{a as s}from"./chunk-2YLAHC7J.js";import{a as u,b as N,c as R,d as i,e as P,f as x,g as E,h as l}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as A}from"@crossmint/common-sdk-base";var O,d,F,T,o,S,W,M,L,b,fe,we,j,H,w=class{constructor(e,r){P(this,b);P(this,O);P(this,d);P(this,F);P(this,T);P(this,o);P(this,S);P(this,W,[]);P(this,M);P(this,L,null);let{chain:t,address:n,owner:a,options:c,alias:g,recovery:v,apiRecoveryServerSignerAddresses:y,apiDelegatedServerSignerAddresses:h,signers:C,signer:f}=e;x(this,d,r),this.chain=t,this.address=n,this.owner=a,x(this,O,c),this.alias=g;let m=Array.isArray(v)?v:[v],U=y!=null?y:m.filter(p=>p.type==="server"&&J(p)).map(p=>p.address);x(this,W,h!=null?h:[]),x(this,F,C!=null?C:[]),x(this,T,new de({chain:t,projectId:i(this,d).projectId,environment:i(this,d).environment,apiRecoveryAddresses:U,apiDelegatedAddresses:i(this,W),knownOnChainAddresses:()=>[...i(this,F).filter(p=>p.type==="server"&&J(p)).map(p=>p.address),...i(this,W)]})),x(this,o,new ue({apiClient:r,options:c,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,T),recoverySigners:m,initialSigners:i(this,F),signers:()=>this.signers(),signer:f})),m.forEach((p,Ce)=>{p.type==="server"&&!J(p)&&i(this,o).stripSecretFromRecovery(Ce,i(this,T).resolveRecovery(p))}),x(this,S,new ve({chain:t,walletAddress:this.address,options:c,signerManager:i(this,o),serverSignerResolver:i(this,T),signers:()=>this.signers(),addSigner:p=>this.addSigner(p),removeSigner:p=>this.removeSigner({type:"device",locator:p}),approveSignature:p=>this.approveSignatureAndWait(p),approveTransaction:p=>this.approveTransactionAndWait(p)})),x(this,M,this.initDefaultSigner())}get signer(){return i(this,o).activeSigner}waitForInit(){return l(this,null,function*(){yield i(this,M)})}initDefaultSigner(){return l(this,null,function*(){if(i(this,o).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,o).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,F).length===0?i(this,o).recovery:i(this,F).length===1?i(this,F)[0]:null;if(e==null)return;let r=I(e.type),t=i(this,o).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,o).recovery;try{let a=r.buildInternalConfig(e,t);i(this,o).setActiveSigner(yield i(this,o).assemble(a,{isAdminSigner:n}))}catch(a){s.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,o).recovery.type,signerCount:i(this,F).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecoverySigners(e){return e.recoveryMethods}static getInitialSigners(e){return i(e,F)}static getApiRecoveryServerSignerAddresses(e){return i(e,T).apiRecoveryAddresses}static getApiDelegatedServerSignerAddresses(e){return i(e,W)}get apiClient(){return i(this,d)}get options(){return i(this,O)}get chainAdapter(){return ae(this.chain)}resolveServerSignerApiLocator(e){return i(this,T).apiLocator(e)}get recovery(){return i(this,o).recovery}get recoveryMethods(){return i(this,o).recoverySigners}balances(e){return l(this,null,function*(){s.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield i(this,d).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw s.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return s.info("wallet.balances.success"),pe(a,this.chain,t,e)})}stagingFund(e,r){return l(this,null,function*(){s.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw s.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return s.info("wallet.stagingFund.success"),t})}nfts(e){return l(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,d).getNfts(N(u({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw s.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return l(this,null,function*(){let e=yield i(this,d).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return l(this,null,function*(){let r=yield i(this,d).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return l(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return l(this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new ee(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let c=ge(e),g=this.resolveChainForEnvironment(),v=he(r,g);s.info("wallet.send.start",u({recipient:c,token:v,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let y=i(this,o).require(),h;(n==null?void 0:n.signer)==null?h=y.locator():typeof n.signer=="string"?h=n.signer:h=this.resolveServerSignerApiLocator(n.signer);let C=u({recipient:c,amount:t,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield i(this,d).send(this.walletLocator,v,C);if("message"in f)throw s.error("wallet.send.error",{error:f}),new re(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return s.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let m=yield this.approveTransactionAndWait(f.id);return s.info("wallet.send.success",{transactionId:f.id,hash:m.hash}),m})}approveTransaction(e){return l(this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return l(this,null,function*(){if(s.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return s.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return s.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw s.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return l(this,null,function*(){s.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,o).withRecoverySigner(n=>l(this,null,function*(){var m;let a=typeof t=="string"?t:q(t),c=yield i(this,o).getSignerState(a);if(c.signer!=null){if(i(this,o).isApprovedSignerStatus(c.signer.status))return(r==null?void 0:r.scopes)!=null&&s.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:a}),s.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(c.signer,null,r);if(c.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return s.info("wallet.addSigner.resuming",{operationType:c.pendingOperation.type,operationId:c.pendingOperation.id}),this.completeSignerRegistration(c.signer,c.pendingOperation,r)}}let g=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,o).descriptorContext()),y=this.chain!=="solana"&&this.chain!=="stellar"?(m=r==null?void 0:r.deployImmediately)!=null?m:!0:void 0,h=yield i(this,d).registerSigner(this.walletLocator,u(u(u({signer:g,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),y!=null&&{deployImmediately:y}),n!=null&&{approver:n}));if("error"in h)throw s.error("wallet.addSigner.error",{error:h}),h.code===z?new Q(h.message):new $(`Failed to register signer: ${JSON.stringify(h.message)}`);let C=se(h,this.chain);if(C==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let f=this.chainAdapter.extractAddSignerOperation(h,this.chain,{locator:a,type:e.type});return this.completeSignerRegistration(C,f,r)}))})}completeSignerRegistration(e,r,t){return l(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return u({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return s.info("wallet.addSigner.prepared",n),u(u({},e),n)}case"signature":{let n={signatureId:r.id};return s.info("wallet.addSigner.prepared",n),u(u({},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),s.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),s.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else s.info("wallet.addSigner.success");return N(u({},e),{status:"success"})})}removeSigner(e,r){return l(this,null,function*(){let t=this.resolveSignerLocator(e);return s.info("wallet.removeSigner.start",{signerLocator:t}),i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=yield i(this,d).removeSigner(this.walletLocator,t,u({chain:this.chainAdapter.addSignerChain(this.chain)},n!=null&&{approver:n}));if("error"in a)throw s.error("wallet.removeSigner.error",{error:a}),new Error(`Failed to remove signer: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeSigner.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),s.info("wallet.removeSigner.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}addRecoveryMethod(e,r){return l(this,null,function*(){this.assertRecoveryMethodManagementSupported(),s.info("wallet.addRecoveryMethod.start");let t=e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,o).descriptorContext()),c=yield i(this,d).registerRecoveryMethod(this.walletLocator,{recoveryMethods:a,approver:this.resolveRecoveryApprover(n)});if("error"in c)throw s.error("wallet.addRecoveryMethod.error",{error:c}),new $(`Failed to add recovery method: ${JSON.stringify(c.message)}`);let g=c.tx.id;return r!=null&&r.prepareOnly?(s.info("wallet.addRecoveryMethod.prepared",{transactionId:g}),{transactionId:g,status:void 0}):(yield this.approveTransactionAndWait(g),i(this,o).addRecoverySigner(typeof t=="string"?{type:"server",address:t.slice(7)}:t),s.info("wallet.addRecoveryMethod.success",{transactionId:g}),{transactionId:g,status:"success"})}))})}removeRecoveryMethod(e,r){return l(this,null,function*(){this.assertRecoveryMethodManagementSupported();let t=this.resolveSignerLocator(e);return s.info("wallet.removeRecoveryMethod.start",{recoveryMethodLocator:t}),i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=yield i(this,d).removeRecoveryMethod(this.walletLocator,t,{approver:this.resolveRecoveryApprover(n)});if("error"in a)throw s.error("wallet.removeRecoveryMethod.error",{error:a}),new Error(`Failed to remove recovery method: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeRecoveryMethod.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),i(this,o).removeRecoverySigner(t),s.info("wallet.removeRecoveryMethod.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}assertRecoveryMethodManagementSupported(){if(this.chain!=="solana"&&this.chain!=="stellar")throw new X(`Adding and removing recovery methods is not supported on ${this.chain} yet. It is available on Solana and Stellar.`)}resolveRecoveryApprover(e){return e!=null?e:i(this,o).require().locator()}useSigner(e){return l(this,null,function*(){s.info("wallet.useSigner.start"),e.type==="server"&&i(this,T).resetDelegatedCache(),I(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=I(e.type).buildInternalConfig(e,i(this,o).descriptorContext()),n=q(e);i(this,o).setActiveSigner(yield i(this,o).assemble(t,{isAdminSigner:r})),s.info("wallet.useSigner.success",{signerLocator:n})})}useRecoveryMethod(e){return l(this,null,function*(){s.info("wallet.useRecoveryMethod.start"),I(e.type).validateConfig(e);let r=this.matchRecoverySigner(e);if(r==null){let n=this.recoveryMethods.map(a=>i(this,o).recoveryLocator(a)).filter(a=>a!=null).join(", ");throw new D(`Signer "${this.resolveSignerLocator(e)}" is not one of this wallet's recovery methods (${n}).`)}e.type==="server"&&i(this,o).stripSecretFromRecovery(r,i(this,T).resolveRecovery(e));let t=I(e.type).adoptsRecoveryConfigOnMatch?this.recoveryMethods[r]:e.type==="passkey"?this.withPasskeyRecoveryCredentialId(e,r):e;i(this,o).selectRecovery(r,t),s.info("wallet.useRecoveryMethod.success",{recoveryMethodLocator:i(this,o).recoveryLocator(t)})})}resolveNonDeviceSigner(e){return l(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return i(this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return l(this,null,function*(){let t=(yield this.signers()).map(c=>c.locator),n={recoveryIndex:null},a=i(this,T).resolveForUseSigner(e,t,()=>(n.recoveryIndex=this.matchRecoverySigner(e),n.recoveryIndex!=null));switch(a.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return n.recoveryIndex!=null&&i(this,o).stripSecretFromRecovery(n.recoveryIndex,a.address),i(this,S).onSignerSelected(),!0;case"unregistered":throw new Error(a.message)}})}withPasskeyRecoveryCredentialId(e,r){if(_(e)!=null)return e;if(this.recoveryMethods.filter(a=>a.type==="passkey").length>1)throw new D('Multiple passkey recovery methods are registered on this wallet. Please specify the credential id: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');let n=_(this.recoveryMethods[r]);if(n==null)throw new D('The passkey recovery method has no credential id. Please specify it: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');return N(u({},e),{id:n})}tryAutoSelectPasskey(e){return l(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):q(e)}isPasskeyMissingId(e){return _(e)==null}signerIsRegistered(e){return l(this,null,function*(){return i(this,o).signerIsRegistered(e)})}isSignerApproved(e){return l(this,null,function*(){return i(this,o).isSignerApproved(e)})}needsRecovery(){return i(this,S).needsRecovery}recover(){return l(this,null,function*(){yield i(this,S).recover()})}signers(){return l(this,null,function*(){var a,c;s.info("wallet.signers.start");let e=yield i(this,d).getWallet(this.walletLocator);if("error"in e)throw s.error("wallet.signers.error",{error:e}),new V(JSON.stringify(e));if(!me(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw s.error("wallet.signers.error",{error:g}),new B(g)}let r=(c=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?c:[],n=(yield Promise.all(r.map(g=>l(this,null,function*(){try{return(yield i(this,o).getSignerState(g.locator)).signer}catch(v){return s.warn("wallet.signers.mapSigner.failed",{locator:g.locator,error:v}),null}})))).filter(g=>g!=null);return s.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,d).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,o)}preAuthIfNeeded(){return l(this,null,function*(){yield i(this,M),i(this,L)==null&&x(this,L,this.recover());try{yield i(this,L)}finally{x(this,L,null)}let e=i(this,o).require();e instanceof ce&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){return this.matchRecoverySigner(e)!=null}matchRecoverySigner(e){let r=I(e.type),t=i(this,o).descriptorContext(),n=this.recoveryMethods.findIndex(a=>a.type===e.type&&r.matchesRecovery(e,a,t));return n===-1?null:(r.adoptsRecoveryConfigOnMatch&&i(this,o).adoptRecoveryConfig(n,e),n)}resolveChainForEnvironment(){let e=ne(this.chain,i(this,d).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return l(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return l(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return l(this,null,function*(){var v,y;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,o).require(),n=yield i(this,d).getSignature(this.walletLocator,e);if("error"in n)throw k(n),new Y(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let a=(v=n.approvals)==null?void 0:v.pending;if(a==null||a.length===0)return n;let c=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],g=yield E(this,b,H).call(this,E(this,b,j).call(this,a),c,(h,C)=>h.signMessage(C.message));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return l(this,null,function*(){var v,y,h,C,f;let t=yield i(this,d).getTransaction(this.walletLocator,e);if("error"in t)throw k(t),new te(JSON.stringify(t));yield(h=(y=(v=i(this,O))==null?void 0:v.callbacks)==null?void 0:y.onTransactionStart)==null?void 0:h.call(y);let n=i(this,o).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let a=(C=t.approvals)==null?void 0:C.pending;if(a==null||a.length===0)return t;let c=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield E(this,b,H).call(this,E(this,b,j).call(this,a),c,(m,U)=>le(t.chainType,this.chainAdapter).signApproval(m,t,U.message));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return l(this,null,function*(){s.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,d).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw k(t),new ie(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return l(this,null,function*(){let t=yield i(this,d).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw k(t),new Z(JSON.stringify(t));return t})}waitForSignature(e){return l(this,null,function*(){return yield Se(i(this,d),this.walletLocator,e)})}waitForTransaction(n){return l(this,arguments,function*(e,r=6e4,t={}){return yield ye(i(this,d),this.walletLocator,e,u({timeoutMs:r},t))})}sleep(e){return l(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};O=new WeakMap,d=new WeakMap,F=new WeakMap,T=new WeakMap,o=new WeakMap,S=new WeakMap,W=new WeakMap,M=new WeakMap,L=new WeakMap,b=new WeakSet,fe=function(e){return l(this,null,function*(){let r=yield i(this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&s.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},we=function(e,r){return l(this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield E(this,b,fe).call(this,r))!=null?n:void 0),t==null)throw new $(`Signer ${r} not found in pending approvals`);return t})},j=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new K(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},H=function(e,r,t){return l(this,null,function*(){return yield Promise.all(e.map(n=>l(this,null,function*(){let a=yield E(this,b,we).call(this,r,n.signer.locator),c=yield t(a,n);return N(u({},c),{signer:a.locator()})})))})},R([A({logger:s,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"balances",1),R([A({logger:s,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"stagingFund",1),R([A({logger:s,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"send",1),R([A({logger:s,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"approve",1),R([A({logger:s,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addSigner",1),R([A({logger:s,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeSigner",1),R([A({logger:s,methodName:"wallet.addRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addRecoveryMethod",1),R([A({logger:s,methodName:"wallet.removeRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeRecoveryMethod",1),R([A({logger:s,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useSigner",1),R([A({logger:s,methodName:"wallet.useRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useRecoveryMethod",1),R([A({logger:s,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"recover",1),R([A({logger:s,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"signers",1);function me(G){return G.type==="smart"&&oe(G.chainType)}export{w as a};
|
|
1
|
+
import{a as ue}from"./chunk-AMGE2J7V.js";import{a as pe}from"./chunk-KNAIS6WY.js";import{a as ve}from"./chunk-J7N56JUE.js";import{a as ye,b as Se}from"./chunk-PEHDJW5W.js";import{a as de}from"./chunk-RFWRLJEX.js";import{a as I}from"./chunk-HDVUDIDC.js";import{a as _,b as q}from"./chunk-RV3Q5EIA.js";import{a as ge,b as he}from"./chunk-VG67JHRI.js";import{f as ne}from"./chunk-Z4OBKN5C.js";import{a as ce}from"./chunk-6EPYTT7A.js";import{g as J}from"./chunk-43LFPZII.js";import{a as ae,b as oe,c as le}from"./chunk-JAP6U3CJ.js";import{b as se}from"./chunk-B4GYB3XY.js";import{E as Y,F as Z,H as ee,I as re,J as te,O as ie,R as k,d as B,e as V,j as $,l as z,m as Q,n as K,o as D,u as X}from"./chunk-4I3EXM4B.js";import{a as s}from"./chunk-QNNWOOHI.js";import{a as u,b as N,c as R,d as i,e as P,f as x,g as E,h as l}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as A}from"@crossmint/common-sdk-base";var O,d,F,T,o,S,W,M,L,b,fe,we,j,H,w=class{constructor(e,r){P(this,b);P(this,O);P(this,d);P(this,F);P(this,T);P(this,o);P(this,S);P(this,W,[]);P(this,M);P(this,L,null);let{chain:t,address:n,owner:a,options:c,alias:g,recovery:v,apiRecoveryServerSignerAddresses:y,apiDelegatedServerSignerAddresses:h,signers:C,signer:f}=e;x(this,d,r),this.chain=t,this.address=n,this.owner=a,x(this,O,c),this.alias=g;let m=Array.isArray(v)?v:[v],U=y!=null?y:m.filter(p=>p.type==="server"&&J(p)).map(p=>p.address);x(this,W,h!=null?h:[]),x(this,F,C!=null?C:[]),x(this,T,new de({chain:t,projectId:i(this,d).projectId,environment:i(this,d).environment,apiRecoveryAddresses:U,apiDelegatedAddresses:i(this,W),knownOnChainAddresses:()=>[...i(this,F).filter(p=>p.type==="server"&&J(p)).map(p=>p.address),...i(this,W)]})),x(this,o,new ue({apiClient:r,options:c,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,T),recoverySigners:m,initialSigners:i(this,F),signers:()=>this.signers(),signer:f})),m.forEach((p,Ce)=>{p.type==="server"&&!J(p)&&i(this,o).stripSecretFromRecovery(Ce,i(this,T).resolveRecovery(p))}),x(this,S,new ve({chain:t,walletAddress:this.address,options:c,signerManager:i(this,o),serverSignerResolver:i(this,T),signers:()=>this.signers(),addSigner:p=>this.addSigner(p),removeSigner:p=>this.removeSigner({type:"device",locator:p}),approveSignature:p=>this.approveSignatureAndWait(p),approveTransaction:p=>this.approveTransactionAndWait(p)})),x(this,M,this.initDefaultSigner())}get signer(){return i(this,o).activeSigner}waitForInit(){return l(this,null,function*(){yield i(this,M)})}initDefaultSigner(){return l(this,null,function*(){if(i(this,o).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,o).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,F).length===0?i(this,o).recovery:i(this,F).length===1?i(this,F)[0]:null;if(e==null)return;let r=I(e.type),t=i(this,o).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,o).recovery;try{let a=r.buildInternalConfig(e,t);i(this,o).setActiveSigner(yield i(this,o).assemble(a,{isAdminSigner:n}))}catch(a){s.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,o).recovery.type,signerCount:i(this,F).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecoverySigners(e){return e.recoveryMethods}static getInitialSigners(e){return i(e,F)}static getApiRecoveryServerSignerAddresses(e){return i(e,T).apiRecoveryAddresses}static getApiDelegatedServerSignerAddresses(e){return i(e,W)}get apiClient(){return i(this,d)}get options(){return i(this,O)}get chainAdapter(){return ae(this.chain)}resolveServerSignerApiLocator(e){return i(this,T).apiLocator(e)}get recovery(){return i(this,o).recovery}get recoveryMethods(){return i(this,o).recoverySigners}balances(e){return l(this,null,function*(){s.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield i(this,d).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw s.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return s.info("wallet.balances.success"),pe(a,this.chain,t,e)})}stagingFund(e,r){return l(this,null,function*(){s.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw s.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return s.info("wallet.stagingFund.success"),t})}nfts(e){return l(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,d).getNfts(N(u({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw s.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return l(this,null,function*(){let e=yield i(this,d).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return l(this,null,function*(){let r=yield i(this,d).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return l(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return l(this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new ee(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let c=ge(e),g=this.resolveChainForEnvironment(),v=he(r,g);s.info("wallet.send.start",u({recipient:c,token:v,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let y=i(this,o).require(),h;(n==null?void 0:n.signer)==null?h=y.locator():typeof n.signer=="string"?h=n.signer:h=this.resolveServerSignerApiLocator(n.signer);let C=u({recipient:c,amount:t,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield i(this,d).send(this.walletLocator,v,C);if("message"in f)throw s.error("wallet.send.error",{error:f}),new re(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return s.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let m=yield this.approveTransactionAndWait(f.id);return s.info("wallet.send.success",{transactionId:f.id,hash:m.hash}),m})}approveTransaction(e){return l(this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return l(this,null,function*(){if(s.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return s.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return s.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw s.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return l(this,null,function*(){s.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,o).withRecoverySigner(n=>l(this,null,function*(){var m;let a=typeof t=="string"?t:q(t),c=yield i(this,o).getSignerState(a);if(c.signer!=null){if(i(this,o).isApprovedSignerStatus(c.signer.status))return(r==null?void 0:r.scopes)!=null&&s.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:a}),s.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(c.signer,null,r);if(c.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return s.info("wallet.addSigner.resuming",{operationType:c.pendingOperation.type,operationId:c.pendingOperation.id}),this.completeSignerRegistration(c.signer,c.pendingOperation,r)}}let g=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,o).descriptorContext()),y=this.chain!=="solana"&&this.chain!=="stellar"?(m=r==null?void 0:r.deployImmediately)!=null?m:!0:void 0,h=yield i(this,d).registerSigner(this.walletLocator,u(u(u({signer:g,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),y!=null&&{deployImmediately:y}),n!=null&&{approver:n}));if("error"in h)throw s.error("wallet.addSigner.error",{error:h}),h.code===z?new Q(h.message):new $(`Failed to register signer: ${JSON.stringify(h.message)}`);let C=se(h,this.chain);if(C==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let f=this.chainAdapter.extractAddSignerOperation(h,this.chain,{locator:a,type:e.type});return this.completeSignerRegistration(C,f,r)}))})}completeSignerRegistration(e,r,t){return l(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return u({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return s.info("wallet.addSigner.prepared",n),u(u({},e),n)}case"signature":{let n={signatureId:r.id};return s.info("wallet.addSigner.prepared",n),u(u({},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),s.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),s.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else s.info("wallet.addSigner.success");return N(u({},e),{status:"success"})})}removeSigner(e,r){return l(this,null,function*(){let t=this.resolveSignerLocator(e);return s.info("wallet.removeSigner.start",{signerLocator:t}),i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=yield i(this,d).removeSigner(this.walletLocator,t,u({chain:this.chainAdapter.addSignerChain(this.chain)},n!=null&&{approver:n}));if("error"in a)throw s.error("wallet.removeSigner.error",{error:a}),new Error(`Failed to remove signer: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeSigner.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),s.info("wallet.removeSigner.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}addRecoveryMethod(e,r){return l(this,null,function*(){this.assertRecoveryMethodManagementSupported(),s.info("wallet.addRecoveryMethod.start");let t=e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,o).descriptorContext()),c=yield i(this,d).registerRecoveryMethod(this.walletLocator,{recoveryMethods:a,approver:this.resolveRecoveryApprover(n)});if("error"in c)throw s.error("wallet.addRecoveryMethod.error",{error:c}),new $(`Failed to add recovery method: ${JSON.stringify(c.message)}`);let g=c.tx.id;return r!=null&&r.prepareOnly?(s.info("wallet.addRecoveryMethod.prepared",{transactionId:g}),{transactionId:g,status:void 0}):(yield this.approveTransactionAndWait(g),i(this,o).addRecoverySigner(typeof t=="string"?{type:"server",address:t.slice(7)}:t),s.info("wallet.addRecoveryMethod.success",{transactionId:g}),{transactionId:g,status:"success"})}))})}removeRecoveryMethod(e,r){return l(this,null,function*(){this.assertRecoveryMethodManagementSupported();let t=this.resolveSignerLocator(e);return s.info("wallet.removeRecoveryMethod.start",{recoveryMethodLocator:t}),i(this,o).withRecoverySigner(n=>l(this,null,function*(){let a=yield i(this,d).removeRecoveryMethod(this.walletLocator,t,{approver:this.resolveRecoveryApprover(n)});if("error"in a)throw s.error("wallet.removeRecoveryMethod.error",{error:a}),new Error(`Failed to remove recovery method: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeRecoveryMethod.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),i(this,o).removeRecoverySigner(t),s.info("wallet.removeRecoveryMethod.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}assertRecoveryMethodManagementSupported(){if(this.chain!=="solana"&&this.chain!=="stellar")throw new X(`Adding and removing recovery methods is not supported on ${this.chain} yet. It is available on Solana and Stellar.`)}resolveRecoveryApprover(e){return e!=null?e:i(this,o).require().locator()}useSigner(e){return l(this,null,function*(){s.info("wallet.useSigner.start"),e.type==="server"&&i(this,T).resetDelegatedCache(),I(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=I(e.type).buildInternalConfig(e,i(this,o).descriptorContext()),n=q(e);i(this,o).setActiveSigner(yield i(this,o).assemble(t,{isAdminSigner:r})),s.info("wallet.useSigner.success",{signerLocator:n})})}useRecoveryMethod(e){return l(this,null,function*(){s.info("wallet.useRecoveryMethod.start"),I(e.type).validateConfig(e);let r=this.matchRecoverySigner(e);if(r==null){let n=this.recoveryMethods.map(a=>i(this,o).recoveryLocator(a)).filter(a=>a!=null).join(", ");throw new D(`Signer "${this.resolveSignerLocator(e)}" is not one of this wallet's recovery methods (${n}).`)}e.type==="server"&&i(this,o).stripSecretFromRecovery(r,i(this,T).resolveRecovery(e));let t=I(e.type).adoptsRecoveryConfigOnMatch?this.recoveryMethods[r]:e.type==="passkey"?this.withPasskeyRecoveryCredentialId(e,r):e;i(this,o).selectRecovery(r,t),s.info("wallet.useRecoveryMethod.success",{recoveryMethodLocator:i(this,o).recoveryLocator(t)})})}resolveNonDeviceSigner(e){return l(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return i(this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return l(this,null,function*(){let t=(yield this.signers()).map(c=>c.locator),n={recoveryIndex:null},a=i(this,T).resolveForUseSigner(e,t,()=>(n.recoveryIndex=this.matchRecoverySigner(e),n.recoveryIndex!=null));switch(a.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return n.recoveryIndex!=null&&i(this,o).stripSecretFromRecovery(n.recoveryIndex,a.address),i(this,S).onSignerSelected(),!0;case"unregistered":throw new Error(a.message)}})}withPasskeyRecoveryCredentialId(e,r){if(_(e)!=null)return e;if(this.recoveryMethods.filter(a=>a.type==="passkey").length>1)throw new D('Multiple passkey recovery methods are registered on this wallet. Please specify the credential id: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');let n=_(this.recoveryMethods[r]);if(n==null)throw new D('The passkey recovery method has no credential id. Please specify it: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');return N(u({},e),{id:n})}tryAutoSelectPasskey(e){return l(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):q(e)}isPasskeyMissingId(e){return _(e)==null}signerIsRegistered(e){return l(this,null,function*(){return i(this,o).signerIsRegistered(e)})}isSignerApproved(e){return l(this,null,function*(){return i(this,o).isSignerApproved(e)})}needsRecovery(){return i(this,S).needsRecovery}recover(){return l(this,null,function*(){yield i(this,S).recover()})}signers(){return l(this,null,function*(){var a,c;s.info("wallet.signers.start");let e=yield i(this,d).getWallet(this.walletLocator);if("error"in e)throw s.error("wallet.signers.error",{error:e}),new V(JSON.stringify(e));if(!me(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw s.error("wallet.signers.error",{error:g}),new B(g)}let r=(c=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?c:[],n=(yield Promise.all(r.map(g=>l(this,null,function*(){try{return(yield i(this,o).getSignerState(g.locator)).signer}catch(v){return s.warn("wallet.signers.mapSigner.failed",{locator:g.locator,error:v}),null}})))).filter(g=>g!=null);return s.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,d).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,o)}preAuthIfNeeded(){return l(this,null,function*(){yield i(this,M),i(this,L)==null&&x(this,L,this.recover());try{yield i(this,L)}finally{x(this,L,null)}let e=i(this,o).require();e instanceof ce&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){return this.matchRecoverySigner(e)!=null}matchRecoverySigner(e){let r=I(e.type),t=i(this,o).descriptorContext(),n=this.recoveryMethods.findIndex(a=>a.type===e.type&&r.matchesRecovery(e,a,t));return n===-1?null:(r.adoptsRecoveryConfigOnMatch&&i(this,o).adoptRecoveryConfig(n,e),n)}resolveChainForEnvironment(){let e=ne(this.chain,i(this,d).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return l(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return l(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return l(this,null,function*(){var v,y;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,o).require(),n=yield i(this,d).getSignature(this.walletLocator,e);if("error"in n)throw k(n),new Y(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let a=(v=n.approvals)==null?void 0:v.pending;if(a==null||a.length===0)return n;let c=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],g=yield E(this,b,H).call(this,E(this,b,j).call(this,a),c,(h,C)=>h.signMessage(C.message));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return l(this,null,function*(){var v,y,h,C,f;let t=yield i(this,d).getTransaction(this.walletLocator,e);if("error"in t)throw k(t),new te(JSON.stringify(t));yield(h=(y=(v=i(this,O))==null?void 0:v.callbacks)==null?void 0:y.onTransactionStart)==null?void 0:h.call(y);let n=i(this,o).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let a=(C=t.approvals)==null?void 0:C.pending;if(a==null||a.length===0)return t;let c=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield E(this,b,H).call(this,E(this,b,j).call(this,a),c,(m,U)=>le(t.chainType,this.chainAdapter).signApproval(m,t,U.message));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return l(this,null,function*(){s.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,d).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw k(t),new ie(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return l(this,null,function*(){let t=yield i(this,d).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw k(t),new Z(JSON.stringify(t));return t})}waitForSignature(e){return l(this,null,function*(){return yield Se(i(this,d),this.walletLocator,e)})}waitForTransaction(n){return l(this,arguments,function*(e,r=6e4,t={}){return yield ye(i(this,d),this.walletLocator,e,u({timeoutMs:r},t))})}sleep(e){return l(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};O=new WeakMap,d=new WeakMap,F=new WeakMap,T=new WeakMap,o=new WeakMap,S=new WeakMap,W=new WeakMap,M=new WeakMap,L=new WeakMap,b=new WeakSet,fe=function(e){return l(this,null,function*(){let r=yield i(this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&s.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},we=function(e,r){return l(this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield E(this,b,fe).call(this,r))!=null?n:void 0),t==null)throw new $(`Signer ${r} not found in pending approvals`);return t})},j=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new K(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},H=function(e,r,t){return l(this,null,function*(){return yield Promise.all(e.map(n=>l(this,null,function*(){let a=yield E(this,b,we).call(this,r,n.signer.locator),c=yield t(a,n);return N(u({},c),{signer:a.locator()})})))})},R([A({logger:s,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"balances",1),R([A({logger:s,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"stagingFund",1),R([A({logger:s,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"send",1),R([A({logger:s,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"approve",1),R([A({logger:s,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addSigner",1),R([A({logger:s,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeSigner",1),R([A({logger:s,methodName:"wallet.addRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addRecoveryMethod",1),R([A({logger:s,methodName:"wallet.removeRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeRecoveryMethod",1),R([A({logger:s,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useSigner",1),R([A({logger:s,methodName:"wallet.useRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useRecoveryMethod",1),R([A({logger:s,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"recover",1),R([A({logger:s,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"signers",1);function me(G){return G.type==="smart"&&oe(G.chainType)}export{w as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNBZEWJUHcjs = require('./chunk-NBZEWJUH.cjs');var _chunkA4F6GFJCcjs = require('./chunk-A4F6GFJC.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkNBZEWJUHcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkNBZEWJUHcjs.a.getOptions(e),alias:e.alias,recovery:_chunkNBZEWJUHcjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkNBZEWJUHcjs.a.getInitialSigners(e)},_chunkNBZEWJUHcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkO673DZDXcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkO673DZDXcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return _chunkO673DZDXcjs.a.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkO673DZDXcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw _chunkO673DZDXcjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunkD2S37DJ5cjs.D)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunkO673DZDXcjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunkO673DZDXcjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunkO673DZDXcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw _chunkO673DZDXcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkD2S37DJ5cjs.z)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunkO673DZDXcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkD2S37DJ5cjs.z)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw _chunkO673DZDXcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkD2S37DJ5cjs.D)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkO673DZDXcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunkO673DZDXcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return _viem.createPublicClient.call(void 0, {transport:(t=e==null?void 0:e.transport)!=null?t:_viem.http.call(void 0, ),chain:_chunkA4F6GFJCcjs.a.call(void 0, this.chain)})}createTransaction(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkD2S37DJ5cjs.I)(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}exports.a = M;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-QNNWOOHI.js";import a from"bs58";import{Base64 as o,Hex as s}from"ox";function d(n){let e=a.decode(n)[0];return e!=null&&(e&128)!==0&&(e&127)===1}function c(n){return"transaction"in n.onChain&&typeof n.onChain.transaction=="string"?n.onChain.transaction:void 0}var m={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,e,r){if(!("transaction"in n)||n.transaction==null)throw i.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");return{type:"transaction",id:n.transaction.id}},balanceTokenFields(n){return n!=null&&"mintHash"in n?{mintHash:n.mintHash}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{mintHash:void 0}},signApproval(n,e,r){var t;return n.type==="passkey"?n.signTransaction(s.fromBytes(o.toBytes(r))):n.type!=="external-wallet"?n.signTransaction(r):d(r)?n.signMessage(r):n.signTransaction((t=c(e))!=null?t:r)}};export{m as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.20.1";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =200;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./chunk-266RS53K.js";import{a as o}from"./chunk-Q7EO6OOI.js";import{b as n}from"./chunk-2KGAVQXR.js";import{a as s}from"./chunk-
|
|
1
|
+
import{a as t}from"./chunk-266RS53K.js";import{a as o}from"./chunk-Q7EO6OOI.js";import{b as n}from"./chunk-2KGAVQXR.js";import{a as s}from"./chunk-6CNZXJLK.js";import{a as p}from"./chunk-HQ2RXBAN.js";import{a as c}from"./chunk-5T7R5TZO.js";import{a as i}from"./chunk-HHY65A7I.js";import{k as e}from"./chunk-4I3EXM4B.js";function h(r){switch(r){case"email":return o;case"phone":return p;case"passkey":return s;case"device":return t;case"api-key":return i;case"server":return c;case"external-wallet":return n;default:throw new e(`Unknown signer type: ${r}`)}}export{h as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"./chunk-
|
|
1
|
+
import{a as r}from"./chunk-DVVGWCH7.js";import{a as f}from"./chunk-ECKSTWA3.js";import{I as h}from"./chunk-4I3EXM4B.js";import{a as t}from"./chunk-QNNWOOHI.js";import{c as u,h as l}from"./chunk-NU7VF7MC.js";import p from"bs58";import m from"tweetnacl";import{isValidSolanaAddress as y,WithLoggerContext as v}from"@crossmint/common-sdk-base";var c=class c extends r{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:r.getOptions(e),alias:e.alias,recovery:r.getRecoverySigners(e),apiRecoveryServerSignerAddresses:r.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:r.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:r.getInitialSigners(e)},r.getApiClient(e))}static from(e){if(!y(e.address))throw new Error("Wallet is not a Solana wallet");return new c(e)}sendTransaction(e){return l(this,null,function*(){var g,S;t.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((g=e.options)!=null&&g.prepareOnly)return t.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(S=e.additionalSigners)==null?void 0:S.map(o=>new f({type:"external-wallet",address:o.publicKey.toString(),locator:`external-wallet:${o.publicKey.toString()}`,onSign:d=>(d.sign([o]),Promise.resolve(d)),onSignBytes:d=>Promise.resolve(p.encode(m.sign.detached(p.decode(d),o.secretKey)))}))},a=yield this.approveTransactionAndWait(n.id,i);return t.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return l(this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=p.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new h(JSON.stringify(i));return i})}};u([v({logger:t,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1);var T=c;export{T as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-MFQX2HNH.js";import{a as n}from"./chunk-5LNDUSMZ.js";import{a as s}from"./chunk-WQ7JSD6A.js";import{a as i,b as l}from"./chunk-QNNWOOHI.js";import{h as r}from"./chunk-NU7VF7MC.js";import{createCrossmint as w}from"@crossmint/common-sdk-base";import{WebAuthnP256 as y}from"ox";var c=class p{constructor(e){l(e.apiKey);let t=new s(e);this.walletFactory=new o(t),i.info("wallets.sdk.initialized")}static from(e){return new p(e)}getWallet(e,t){return r(this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return r(this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return r(this,null,function*(){return yield n(e,t)})}createPasskeySigner(e,t){return r(this,null,function*(){let a=t?yield t.createPasskey(e):yield y.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}};export{w as a,c as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkO2ET3L2Rcjs = require('./chunk-O2ET3L2R.cjs');var _chunkXMV4T3J5cjs = require('./chunk-XMV4T3J5.cjs');var _chunkHCV4M7X2cjs = require('./chunk-HCV4M7X2.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunk36GZTRZXcjs = require('./chunk-36GZTRZX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var l,m,C,S,y,o,b,A,k,L,K,P,u,q,I,B,$,z,V= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,l,"unknown");_chunkDSIFRRBScjs.e.call(void 0, this,m,!1);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,k);_chunkDSIFRRBScjs.e.call(void 0, this,L);_chunkDSIFRRBScjs.e.call(void 0, this,K);_chunkDSIFRRBScjs.e.call(void 0, this,P);_chunkDSIFRRBScjs.f.call(void 0, this,C,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,S,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,y,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,o,r.signerManager),_chunkDSIFRRBScjs.f.call(void 0, this,b,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,k,r.addSigner),_chunkDSIFRRBScjs.f.call(void 0, this,L,r.removeSigner),_chunkDSIFRRBScjs.f.call(void 0, this,K,r.approveSignature),_chunkDSIFRRBScjs.f.call(void 0, this,P,r.approveTransaction)}get needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"}onSignerSelected(){_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"&&_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown")}initDeviceSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g;if(((g=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:g.deviceSignerKeyStorage)==null||_chunkDSIFRRBScjs.d.call(void 0, this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(h){_chunk36GZTRZXcjs.a.error("wallet.initDeviceSigner.error",{error:h}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery");return}if(_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery")return;let c=_chunkO2ET3L2Rcjs.a.call(void 0, i.type).buildInternalConfig(i,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(c);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(t),_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(t.status)||(_chunk36GZTRZXcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery"))})}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var D;if(_chunk36GZTRZXcjs.a.info("wallet.recover.start"),_chunkDSIFRRBScjs.d.call(void 0, this,l)==="resolved"){_chunk36GZTRZXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunkDSIFRRBScjs.d.call(void 0, this,m)){_chunk36GZTRZXcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}let r=_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,I).call(this,r))){_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}if(r!=null&&r.type!=="device"){_chunk36GZTRZXcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let i=(D=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let c=yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this),t=yield _chunkDSIFRRBScjs.g.call(void 0, this,u,$).call(this,i,c);if(t!=null&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,I).call(this,t))){_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(t),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");let n=t.locator().replace("device:","");try{yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,S),n)}catch(G){_chunk36GZTRZXcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:G})}return}let g=c.filter(n=>n.type==="device"),h=_chunkDSIFRRBScjs.g.call(void 0, this,u,q).call(this,g,i),v=yield _chunkGMU3ZYLScjs.a.call(void 0, i,_chunkDSIFRRBScjs.d.call(void 0, this,S));try{yield _chunkDSIFRRBScjs.d.call(void 0, this,k).call(this,v)}catch(n){if(n instanceof _chunkD2S37DJ5cjs.m){_chunk36GZTRZXcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,S)),_chunkDSIFRRBScjs.f.call(void 0, this,m,!0),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),yield _chunkDSIFRRBScjs.g.call(void 0, this,u,z).call(this);return}else if(H(n))_chunk36GZTRZXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw n instanceof _chunkHCV4M7X2cjs.a||n instanceof Error&&n.name==="AuthRejectedError"?(_chunk36GZTRZXcjs.a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),n):n instanceof _chunkHCV4M7X2cjs.c||n instanceof Error&&n.name==="SignerAuthenticationError"?(_chunk36GZTRZXcjs.a.warn("wallet.recover.device.authenticationFailed",{signerLocator:v.locator,code:n instanceof _chunkHCV4M7X2cjs.c?n.code:void 0}),n):n instanceof _chunkHCV4M7X2cjs.b||n instanceof Error&&n.name==="OtpValidationError"?(_chunk36GZTRZXcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:n instanceof _chunkHCV4M7X2cjs.b?n.code:void 0}),n):(_chunk36GZTRZXcjs.a.error("wallet.recover.device.error",{error:n}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,S)),n)}let p=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble({type:"device",locator:v.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,S)});if(_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(p),p.type==="device"&&(p.status="success"),_chunk36GZTRZXcjs.a.info("wallet.recover.device.success",{signerLocator:v.locator}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),h!=null)try{yield _chunkDSIFRRBScjs.d.call(void 0, this,L).call(this,h),_chunk36GZTRZXcjs.a.info("wallet.recover.staleSignerRemoved",{signerLocator:h})}catch(n){_chunk36GZTRZXcjs.a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:h,error:n})}})}resolveAvailability(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h;let i=(h=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:h.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let c=yield i.getKey(_chunkDSIFRRBScjs.d.call(void 0, this,S));if(c!=null){r.locator=`device:${c}`,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let g=(yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let p=v.locator.replace("device:","");if(yield i.hasKey(p)){yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,S),p),r.locator=v.locator,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}}_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(r,i=(c=>(c=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:c.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield _chunkXMV4T3J5cjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),r,_chunkDSIFRRBScjs.d.call(void 0, this,S),i)}catch(g){return _chunk36GZTRZXcjs.a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,y=new WeakMap,o=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,q=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let c=i.getDeviceName(),t=r.filter(g=>g.name===c);return t.length===1?t[0].locator:void 0},I=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var c;if(_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(r.status))return _chunk36GZTRZXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).getSignerState(r.locator());return r.status=(c=i.signer)==null?void 0:c.status,i.pendingOperation!=null?(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,B).call(this,r,i.pendingOperation),!0):_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(r.status)?(_chunk36GZTRZXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},B=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var p;let c=_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner,t=_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery;if(_chunkHCV4M7X2cjs.g.call(void 0, t)&&!_chunkDSIFRRBScjs.d.call(void 0, this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=_chunkO2ET3L2Rcjs.a.call(void 0, t.type),h=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,h))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,h);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(_chunkXMV4T3J5cjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),v,(p=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:p.deviceSignerKeyStorage));try{i.type==="signature"?yield _chunkDSIFRRBScjs.d.call(void 0, this,K).call(this,i.id):yield _chunkDSIFRRBScjs.d.call(void 0, this,P).call(this,i.id)}catch(D){throw _chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(r),D}finally{_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner!==r&&_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(c)}r.status="success",_chunk36GZTRZXcjs.a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},$=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let c=i.filter(t=>t.locator.startsWith("device:"));for(let t of c){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return _chunk36GZTRZXcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},z=function(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery,i=_chunkO2ET3L2Rcjs.a.call(void 0, r.type),c=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(i.canAutoAssemble(r,c))try{let t=i.buildInternalConfig(r,c);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(t,{isAdminSigner:!0}))}catch(t){_chunk36GZTRZXcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function H(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}exports.a = V;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkXTYSMO67cjs = require('./chunk-XTYSMO67.cjs');var _chunkLRWKIVXLcjs = require('./chunk-LRWKIVXL.cjs');var _chunk664ATEWTcjs = require('./chunk-664ATEWT.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var l,m,C,S,y,o,b,A,k,L,K,P,u,q,I,B,$,z,V= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,l,"unknown");_chunkDSIFRRBScjs.e.call(void 0, this,m,!1);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,k);_chunkDSIFRRBScjs.e.call(void 0, this,L);_chunkDSIFRRBScjs.e.call(void 0, this,K);_chunkDSIFRRBScjs.e.call(void 0, this,P);_chunkDSIFRRBScjs.f.call(void 0, this,C,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,S,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,y,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,o,r.signerManager),_chunkDSIFRRBScjs.f.call(void 0, this,b,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,k,r.addSigner),_chunkDSIFRRBScjs.f.call(void 0, this,L,r.removeSigner),_chunkDSIFRRBScjs.f.call(void 0, this,K,r.approveSignature),_chunkDSIFRRBScjs.f.call(void 0, this,P,r.approveTransaction)}get needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"}onSignerSelected(){_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"&&_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown")}initDeviceSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g;if(((g=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:g.deviceSignerKeyStorage)==null||_chunkDSIFRRBScjs.d.call(void 0, this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(h){_chunkO673DZDXcjs.a.error("wallet.initDeviceSigner.error",{error:h}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery");return}if(_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery")return;let c=_chunkXTYSMO67cjs.a.call(void 0, i.type).buildInternalConfig(i,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(c);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(t),_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(t.status)||(_chunkO673DZDXcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery"))})}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var D;if(_chunkO673DZDXcjs.a.info("wallet.recover.start"),_chunkDSIFRRBScjs.d.call(void 0, this,l)==="resolved"){_chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunkDSIFRRBScjs.d.call(void 0, this,m)){_chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}let r=_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,I).call(this,r))){_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}if(r!=null&&r.type!=="device"){_chunkO673DZDXcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let i=(D=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let c=yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this),t=yield _chunkDSIFRRBScjs.g.call(void 0, this,u,$).call(this,i,c);if(t!=null&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,I).call(this,t))){_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(t),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");let n=t.locator().replace("device:","");try{yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,S),n)}catch(G){_chunkO673DZDXcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:G})}return}let g=c.filter(n=>n.type==="device"),h=_chunkDSIFRRBScjs.g.call(void 0, this,u,q).call(this,g,i),v=yield _chunkGMU3ZYLScjs.a.call(void 0, i,_chunkDSIFRRBScjs.d.call(void 0, this,S));try{yield _chunkDSIFRRBScjs.d.call(void 0, this,k).call(this,v)}catch(n){if(n instanceof _chunkD2S37DJ5cjs.m){_chunkO673DZDXcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,S)),_chunkDSIFRRBScjs.f.call(void 0, this,m,!0),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),yield _chunkDSIFRRBScjs.g.call(void 0, this,u,z).call(this);return}else if(H(n))_chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw n instanceof _chunk664ATEWTcjs.a||n instanceof Error&&n.name==="AuthRejectedError"?(_chunkO673DZDXcjs.a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),n):n instanceof _chunk664ATEWTcjs.c||n instanceof Error&&n.name==="SignerAuthenticationError"?(_chunkO673DZDXcjs.a.warn("wallet.recover.device.authenticationFailed",{signerLocator:v.locator,code:n instanceof _chunk664ATEWTcjs.c?n.code:void 0}),n):n instanceof _chunk664ATEWTcjs.b||n instanceof Error&&n.name==="OtpValidationError"?(_chunkO673DZDXcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:n instanceof _chunk664ATEWTcjs.b?n.code:void 0}),n):(_chunkO673DZDXcjs.a.error("wallet.recover.device.error",{error:n}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,S)),n)}let p=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble({type:"device",locator:v.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,S)});if(_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(p),p.type==="device"&&(p.status="success"),_chunkO673DZDXcjs.a.info("wallet.recover.device.success",{signerLocator:v.locator}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),h!=null)try{yield _chunkDSIFRRBScjs.d.call(void 0, this,L).call(this,h),_chunkO673DZDXcjs.a.info("wallet.recover.staleSignerRemoved",{signerLocator:h})}catch(n){_chunkO673DZDXcjs.a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:h,error:n})}})}resolveAvailability(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h;let i=(h=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:h.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let c=yield i.getKey(_chunkDSIFRRBScjs.d.call(void 0, this,S));if(c!=null){r.locator=`device:${c}`,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let g=(yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let p=v.locator.replace("device:","");if(yield i.hasKey(p)){yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,S),p),r.locator=v.locator,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}}_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(r,i=(c=>(c=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:c.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield _chunkLRWKIVXLcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),r,_chunkDSIFRRBScjs.d.call(void 0, this,S),i)}catch(g){return _chunkO673DZDXcjs.a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,y=new WeakMap,o=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,q=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let c=i.getDeviceName(),t=r.filter(g=>g.name===c);return t.length===1?t[0].locator:void 0},I=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var c;if(_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(r.status))return _chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).getSignerState(r.locator());return r.status=(c=i.signer)==null?void 0:c.status,i.pendingOperation!=null?(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,B).call(this,r,i.pendingOperation),!0):_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(r.status)?(_chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},B=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var p;let c=_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner,t=_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery;if(_chunk664ATEWTcjs.g.call(void 0, t)&&!_chunkDSIFRRBScjs.d.call(void 0, this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=_chunkXTYSMO67cjs.a.call(void 0, t.type),h=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,h))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,h);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(_chunkLRWKIVXLcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),v,(p=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:p.deviceSignerKeyStorage));try{i.type==="signature"?yield _chunkDSIFRRBScjs.d.call(void 0, this,K).call(this,i.id):yield _chunkDSIFRRBScjs.d.call(void 0, this,P).call(this,i.id)}catch(D){throw _chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(r),D}finally{_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner!==r&&_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(c)}r.status="success",_chunkO673DZDXcjs.a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},$=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let c=i.filter(t=>t.locator.startsWith("device:"));for(let t of c){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return _chunkO673DZDXcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},z=function(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery,i=_chunkXTYSMO67cjs.a.call(void 0, r.type),c=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(i.canAutoAssemble(r,c))try{let t=i.buildInternalConfig(r,c);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(t,{isAdminSigner:!0}))}catch(t){_chunkO673DZDXcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function H(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}exports.a = V;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZ6CVEP22cjs = require('./chunk-Z6CVEP22.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunkZ6CVEP22cjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow();_chunkO673DZDXcjs.a.info("sign: sending request",{keyType:"ed25519"});let c=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64",authId:this.getAuthId()}},options:_chunkZ6CVEP22cjs.b});if(_chunkO673DZDXcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-c}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as N}from"./chunk-5LNDUSMZ.js";import{a as R}from"./chunk-
|
|
1
|
+
import{a as N}from"./chunk-5LNDUSMZ.js";import{a as R}from"./chunk-HDVUDIDC.js";import{a as M,b as j}from"./chunk-4VGTYVW7.js";import{a as O,b as E,c as F,g as T}from"./chunk-43LFPZII.js";import{m as W}from"./chunk-4I3EXM4B.js";import{a}from"./chunk-QNNWOOHI.js";import{d as e,e as d,f as s,g as w,h as f}from"./chunk-NU7VF7MC.js";var l,m,C,S,y,o,b,A,k,L,K,P,u,q,I,B,$,z,V=class{constructor(r){d(this,u);d(this,l,"unknown");d(this,m,!1);d(this,C);d(this,S);d(this,y);d(this,o);d(this,b);d(this,A);d(this,k);d(this,L);d(this,K);d(this,P);s(this,C,r.chain),s(this,S,r.walletAddress),s(this,y,r.options),s(this,o,r.signerManager),s(this,b,r.serverSignerResolver),s(this,A,r.signers),s(this,k,r.addSigner),s(this,L,r.removeSigner),s(this,K,r.approveSignature),s(this,P,r.approveTransaction)}get needsRecovery(){return e(this,l)==="needs-recovery"}onSignerSelected(){e(this,l)==="needs-recovery"&&s(this,l,"unknown")}initDeviceSigner(){return f(this,null,function*(){var g;if(((g=e(this,y))==null?void 0:g.deviceSignerKeyStorage)==null||e(this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(h){a.error("wallet.initDeviceSigner.error",{error:h}),s(this,l,"needs-recovery");return}if(e(this,l)==="needs-recovery")return;let c=R(i.type).buildInternalConfig(i,e(this,o).descriptorContext()),t=yield e(this,o).assemble(c);e(this,o).setActiveSigner(t),e(this,o).isApprovedSignerStatus(t.status)||(a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),s(this,l,"needs-recovery"))})}recover(){return f(this,null,function*(){var D;if(a.info("wallet.recover.start"),e(this,l)==="resolved"){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(e(this,m)){a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),s(this,l,"resolved");return}let r=e(this,o).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield w(this,u,I).call(this,r))){s(this,l,"resolved");return}if(r!=null&&r.type!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),s(this,l,"unknown");return}let i=(D=e(this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(e(this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let c=yield e(this,A).call(this),t=yield w(this,u,$).call(this,i,c);if(t!=null&&(yield w(this,u,I).call(this,t))){e(this,o).setActiveSigner(t),s(this,l,"resolved");let n=t.locator().replace("device:","");try{yield i.mapAddressToKey(e(this,S),n)}catch(G){a.warn("wallet.recover.mapAddressToKey.error",{error:G})}return}let g=c.filter(n=>n.type==="device"),h=w(this,u,q).call(this,g,i),v=yield N(i,e(this,S));try{yield e(this,k).call(this,v)}catch(n){if(n instanceof W){a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(e(this,S)),s(this,m,!0),s(this,l,"resolved"),yield w(this,u,z).call(this);return}else if(H(n))a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw n instanceof O||n instanceof Error&&n.name==="AuthRejectedError"?(a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),n):n instanceof F||n instanceof Error&&n.name==="SignerAuthenticationError"?(a.warn("wallet.recover.device.authenticationFailed",{signerLocator:v.locator,code:n instanceof F?n.code:void 0}),n):n instanceof E||n instanceof Error&&n.name==="OtpValidationError"?(a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:n instanceof E?n.code:void 0}),n):(a.error("wallet.recover.device.error",{error:n}),yield i.deleteKey(e(this,S)),n)}let p=yield e(this,o).assemble({type:"device",locator:v.locator,address:e(this,S)});if(e(this,o).setActiveSigner(p),p.type==="device"&&(p.status="success"),a.info("wallet.recover.device.success",{signerLocator:v.locator}),s(this,l,"resolved"),h!=null)try{yield e(this,L).call(this,h),a.info("wallet.recover.staleSignerRemoved",{signerLocator:h})}catch(n){a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:h,error:n})}})}resolveAvailability(r){return f(this,null,function*(){var h;let i=(h=e(this,y))==null?void 0:h.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let c=yield i.getKey(e(this,S));if(c!=null){r.locator=`device:${c}`,s(this,l,"unknown");return}let g=(yield e(this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let p=v.locator.replace("device:","");if(yield i.hasKey(p)){yield i.mapAddressToKey(e(this,S),p),r.locator=v.locator,s(this,l,"unknown");return}}s(this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return f(this,arguments,function*(r,i=(c=>(c=e(this,y))==null?void 0:c.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield j(e(this,C),r,e(this,S),i)}catch(g){return a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,y=new WeakMap,o=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,q=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let c=i.getDeviceName(),t=r.filter(g=>g.name===c);return t.length===1?t[0].locator:void 0},I=function(r){return f(this,null,function*(){var c;if(e(this,o).isApprovedSignerStatus(r.status))return a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield e(this,o).getSignerState(r.locator());return r.status=(c=i.signer)==null?void 0:c.status,i.pendingOperation!=null?(yield w(this,u,B).call(this,r,i.pendingOperation),!0):e(this,o).isApprovedSignerStatus(r.status)?(a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},B=function(r,i){return f(this,null,function*(){var p;let c=e(this,o).activeSigner,t=e(this,o).recovery;if(T(t)&&!e(this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=R(t.type),h=e(this,o).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,h))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,h);e(this,o).setActiveSigner(M(e(this,C),v,(p=e(this,y))==null?void 0:p.deviceSignerKeyStorage));try{i.type==="signature"?yield e(this,K).call(this,i.id):yield e(this,P).call(this,i.id)}catch(D){throw e(this,o).setActiveSigner(r),D}finally{e(this,o).activeSigner!==r&&e(this,o).setActiveSigner(c)}r.status="success",a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},$=function(r,i){return f(this,null,function*(){let c=i.filter(t=>t.locator.startsWith("device:"));for(let t of c){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},z=function(){return f(this,null,function*(){let r=e(this,o).recovery,i=R(r.type),c=e(this,o).descriptorContext();if(i.canAutoAssemble(r,c))try{let t=i.buildInternalConfig(r,c);e(this,o).setActiveSigner(yield e(this,o).assemble(t,{isAdminSigner:!0}))}catch(t){a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function H(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}export{V as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./chunk-
|
|
1
|
+
import{a as t}from"./chunk-3RWQHOBG.js";import{a}from"./chunk-GFK67DR4.js";import{a as i}from"./chunk-SGLJQXKH.js";import{a as r}from"./chunk-OQZTL6ZG.js";var n={evm:t,solana:a,stellar:i};function m(e){return n[r(e)]}function p(e){return Object.prototype.hasOwnProperty.call(n,e)}function A(e,o){return p(e)?n[e]:o}export{m as a,p as b,A as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
1
|
+
import{a as m}from"./chunk-JAP6U3CJ.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=m(s).balanceTokenFields(n);return u(u(u(u({symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=m(s).emptyBalanceTokenFields();return u(u({},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=C(n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function g(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}export{g as a};
|