@crossmint/wallets-sdk 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/api/__tests__/test-utils.cjs +1 -1
  2. package/dist/api/__tests__/test-utils.js +1 -1
  3. package/dist/api/client.cjs +1 -1
  4. package/dist/api/client.js +1 -1
  5. package/dist/api/gen/index.cjs +1 -1
  6. package/dist/api/gen/index.js +1 -1
  7. package/dist/api/index.cjs +1 -1
  8. package/dist/api/index.js +1 -1
  9. package/dist/chains/adapters/evm.cjs +1 -1
  10. package/dist/chains/adapters/evm.js +1 -1
  11. package/dist/chains/adapters/solana.cjs +1 -1
  12. package/dist/chains/adapters/solana.js +1 -1
  13. package/dist/chains/adapters/stellar.cjs +1 -1
  14. package/dist/chains/adapters/stellar.js +1 -1
  15. package/dist/chains/chain-adapter.cjs +1 -1
  16. package/dist/chains/chain-adapter.js +1 -1
  17. package/dist/chains/chains.cjs +1 -1
  18. package/dist/chains/chains.js +1 -1
  19. package/dist/{chunk-BM6GYJSE.cjs → chunk-2DB3DLAA.cjs} +1 -1
  20. package/dist/{chunk-NL4MRKYW.cjs → chunk-2GFL3HTC.cjs} +1 -1
  21. package/dist/{chunk-SZXFHFA5.js → chunk-2IBE7HWB.js} +1 -1
  22. package/dist/{chunk-OUZECW5T.js → chunk-2LA5ZWPD.js} +1 -1
  23. package/dist/chunk-47M4FIGW.js +1 -0
  24. package/dist/{chunk-3WJUXFU2.cjs → chunk-63Y6LGFL.cjs} +1 -1
  25. package/dist/{chunk-UTZP5A65.js → chunk-6XKILBKX.js} +1 -1
  26. package/dist/{chunk-XHANQPKI.js → chunk-7JR76V7P.js} +1 -1
  27. package/dist/{chunk-XN7S5JJY.cjs → chunk-ANE62EYK.cjs} +1 -1
  28. package/dist/{chunk-KJNGLQC7.js → chunk-AQRU3SSV.js} +1 -1
  29. package/dist/{chunk-P3SMYLDM.cjs → chunk-B2275OIH.cjs} +1 -1
  30. package/dist/{chunk-ZF4ENDFP.js → chunk-B5ERXUGO.js} +1 -1
  31. package/dist/{chunk-PSK7FYV7.cjs → chunk-BOMJ4MFZ.cjs} +1 -1
  32. package/dist/{chunk-M3IEG5GA.js → chunk-DSLYYS6N.js} +1 -1
  33. package/dist/{chunk-GIYB3U37.cjs → chunk-EY352O5T.cjs} +1 -1
  34. package/dist/{chunk-WQDLMGEG.js → chunk-F42HGJBY.js} +1 -1
  35. package/dist/chunk-GPIDFXMJ.cjs +1 -0
  36. package/dist/{chunk-3SHAB7GH.js → chunk-GQDDB57A.js} +1 -1
  37. package/dist/{chunk-53JN7AMK.js → chunk-HEXHZLES.js} +1 -1
  38. package/dist/{chunk-S3PBSOOZ.cjs → chunk-HH6B2NTT.cjs} +1 -1
  39. package/dist/{chunk-J2C3XP4Z.cjs → chunk-HI7CAJMU.cjs} +1 -1
  40. package/dist/{chunk-YRX44YXB.js → chunk-HLCF6MRD.js} +1 -1
  41. package/dist/{chunk-LKEPKOKU.cjs → chunk-I7R32ENT.cjs} +1 -1
  42. package/dist/chunk-IRAZVSWU.js +1 -0
  43. package/dist/{chunk-J5CHOVJL.cjs → chunk-JJIO5FRQ.cjs} +1 -1
  44. package/dist/{chunk-HSLCNCPW.cjs → chunk-JLKWUFQU.cjs} +1 -1
  45. package/dist/{chunk-OHTCLNE3.cjs → chunk-K7C5ZVNY.cjs} +1 -1
  46. package/dist/{chunk-BDCQ4HVW.js → chunk-LT6GDX64.js} +1 -1
  47. package/dist/{chunk-IX5TSD73.cjs → chunk-LUFASRMR.cjs} +1 -1
  48. package/dist/{chunk-MGQGQXRP.cjs → chunk-LXRF6CRW.cjs} +1 -1
  49. package/dist/{chunk-QVE2LOBH.js → chunk-NHXWNB3V.js} +1 -1
  50. package/dist/{chunk-JJVNOMYX.cjs → chunk-OIHXWQZ3.cjs} +1 -1
  51. package/dist/chunk-PKREDLDO.cjs +1 -0
  52. package/dist/{chunk-4ILFMPNK.js → chunk-PSDE5X7P.js} +1 -1
  53. package/dist/{chunk-26DL7XRG.js → chunk-PT6QTDSN.js} +1 -1
  54. package/dist/{chunk-2277DKO3.js → chunk-PX2QER4D.js} +1 -1
  55. package/dist/{chunk-N7Z3C5RJ.js → chunk-QG6GFZHT.js} +1 -1
  56. package/dist/{chunk-MYIY3CX7.cjs → chunk-QK57CJTH.cjs} +1 -1
  57. package/dist/{chunk-CB3YEJ7F.js → chunk-SFEGES23.js} +1 -1
  58. package/dist/{chunk-WTLEFDHS.cjs → chunk-SHFB7XOM.cjs} +1 -1
  59. package/dist/{chunk-L5X5RA7E.cjs → chunk-U34JZIST.cjs} +1 -1
  60. package/dist/{chunk-N7DIMQBP.cjs → chunk-UPXD2IIW.cjs} +1 -1
  61. package/dist/{chunk-LJNSIXGN.cjs → chunk-V7LXNAA3.cjs} +1 -1
  62. package/dist/{chunk-5BRX4CFK.cjs → chunk-VXFJQERS.cjs} +1 -1
  63. package/dist/chunk-WQQOCTIU.js +1 -0
  64. package/dist/{chunk-ECHVBCCM.js → chunk-XPBFCTYU.js} +1 -1
  65. package/dist/{chunk-TZGYISF7.js → chunk-YJNAB33W.js} +1 -1
  66. package/dist/{chunk-NUGL76QG.js → chunk-YWFVK6C5.js} +1 -1
  67. package/dist/index.cjs +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/logger/index.cjs +1 -1
  70. package/dist/logger/index.js +1 -1
  71. package/dist/logger/init.cjs +1 -1
  72. package/dist/logger/init.js +1 -1
  73. package/dist/sdk.cjs +1 -1
  74. package/dist/sdk.js +1 -1
  75. package/dist/signers/index.cjs +1 -1
  76. package/dist/signers/index.js +1 -1
  77. package/dist/signers/non-custodial/index.cjs +1 -1
  78. package/dist/signers/non-custodial/index.js +1 -1
  79. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  80. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  81. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  82. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  83. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  84. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  85. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  86. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  87. package/dist/utils/constants.cjs +1 -1
  88. package/dist/utils/constants.js +1 -1
  89. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  90. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  91. package/dist/utils/device-signers/index.cjs +1 -1
  92. package/dist/utils/device-signers/index.js +1 -1
  93. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  94. package/dist/wallets/__tests__/test-helpers.js +1 -1
  95. package/dist/wallets/evm.cjs +1 -1
  96. package/dist/wallets/evm.js +1 -1
  97. package/dist/wallets/services/balance-formatter.cjs +1 -1
  98. package/dist/wallets/services/balance-formatter.js +1 -1
  99. package/dist/wallets/services/device-recovery-service.cjs +1 -1
  100. package/dist/wallets/services/device-recovery-service.js +1 -1
  101. package/dist/wallets/services/operation-poller.cjs +1 -1
  102. package/dist/wallets/services/operation-poller.js +1 -1
  103. package/dist/wallets/services/signer-manager.cjs +1 -1
  104. package/dist/wallets/services/signer-manager.js +1 -1
  105. package/dist/wallets/solana.cjs +1 -1
  106. package/dist/wallets/solana.js +1 -1
  107. package/dist/wallets/stellar.cjs +1 -1
  108. package/dist/wallets/stellar.js +1 -1
  109. package/dist/wallets/wallet-factory.cjs +1 -1
  110. package/dist/wallets/wallet-factory.js +1 -1
  111. package/dist/wallets/wallet.cjs +1 -1
  112. package/dist/wallets/wallet.d.cts +2 -1
  113. package/dist/wallets/wallet.d.ts +2 -1
  114. package/dist/wallets/wallet.js +1 -1
  115. package/package.json +3 -3
  116. package/dist/chunk-5VUIA6TB.cjs +0 -1
  117. package/dist/chunk-FJYRJSKU.cjs +0 -1
  118. package/dist/chunk-OQN2SFDC.js +0 -1
  119. package/dist/chunk-SCEZVF7J.js +0 -1
  120. package/dist/chunk-T2R4SPKJ.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkATIC4ENGcjs = require('./chunk-ATIC4ENG.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=class{constructor(n){this.config=n;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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("TEE connection not initialized, initializing now");let n=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkPSK7FYV7cjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;let n=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 */ }`);_chunkPSK7FYV7cjs.a.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw _chunkPSK7FYV7cjs.a.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new (0, _chunkQPCZFIUVcjs.c)(c,p)}if(_chunkPSK7FYV7cjs.a.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkPSK7FYV7cjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.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(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new _chunkQPCZFIUVcjs.a)})),r(new _chunkQPCZFIUVcjs.a)}))}catch(c){_chunkPSK7FYV7cjs.a.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw _chunkPSK7FYV7cjs.a.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();_chunkPSK7FYV7cjs.a.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:_chunkDSIFRRBScjs.a.call(void 0, {authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,_chunkPSK7FYV7cjs.a.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw _chunkPSK7FYV7cjs.a.error("start-onboarding: failed",{error:i.error,code:i.code}),new (0, _chunkQPCZFIUVcjs.b)(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();_chunkPSK7FYV7cjs.a.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),_chunkPSK7FYV7cjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return _chunkPSK7FYV7cjs.a.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}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(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new _chunkQPCZFIUVcjs.a)})),(a=this._authPromise)==null||a.resolve();return}_chunkPSK7FYV7cjs.a.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 e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new (0, _chunkQPCZFIUVcjs.b)(e,s))})}handleOnboardingVerificationFailure(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){_chunkPSK7FYV7cjs.a.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(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new _chunkQPCZFIUVcjs.e}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw _chunkPSK7FYV7cjs.a.error("export-signer: failed",{error:a.error,code:a.code}),new (0, _chunkQPCZFIUVcjs.d)(a.error||"Failed to export private key",a.code)})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};exports.a = m; exports.b = l;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkATIC4ENGcjs = require('./chunk-ATIC4ENG.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=class{constructor(n){this.config=n;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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.info("TEE connection not initialized, initializing now");let n=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkBOMJ4MFZcjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;let n=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 */ }`);_chunkBOMJ4MFZcjs.a.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw _chunkBOMJ4MFZcjs.a.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new (0, _chunkQPCZFIUVcjs.c)(c,p)}if(_chunkBOMJ4MFZcjs.a.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkBOMJ4MFZcjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.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(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new _chunkQPCZFIUVcjs.a)})),r(new _chunkQPCZFIUVcjs.a)}))}catch(c){_chunkBOMJ4MFZcjs.a.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw _chunkBOMJ4MFZcjs.a.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();_chunkBOMJ4MFZcjs.a.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:_chunkDSIFRRBScjs.a.call(void 0, {authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,_chunkBOMJ4MFZcjs.a.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw _chunkBOMJ4MFZcjs.a.error("start-onboarding: failed",{error:i.error,code:i.code}),new (0, _chunkQPCZFIUVcjs.b)(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();_chunkBOMJ4MFZcjs.a.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),_chunkBOMJ4MFZcjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return _chunkBOMJ4MFZcjs.a.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}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(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new _chunkQPCZFIUVcjs.a)})),(a=this._authPromise)==null||a.resolve();return}_chunkBOMJ4MFZcjs.a.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 e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new (0, _chunkQPCZFIUVcjs.b)(e,s))})}handleOnboardingVerificationFailure(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){_chunkBOMJ4MFZcjs.a.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(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new _chunkQPCZFIUVcjs.e}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw _chunkBOMJ4MFZcjs.a.error("export-signer: failed",{error:a.error,code:a.code}),new (0, _chunkQPCZFIUVcjs.d)(a.error||"Failed to export private key",a.code)})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};exports.a = m; exports.b = l;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3WJUXFU2cjs = require('./chunk-3WJUXFU2.cjs');var _chunkMYIY3CX7cjs = require('./chunk-MYIY3CX7.cjs');var _chunkFJYRJSKUcjs = require('./chunk-FJYRJSKU.cjs');var _chunkWTLEFDHScjs = require('./chunk-WTLEFDHS.cjs');var _chunkI3H3U7XWcjs = require('./chunk-I3H3U7XW.cjs');var _chunk44ICOOCJcjs = require('./chunk-44ICOOCJ.cjs');var _chunkW6L7J3KLcjs = require('./chunk-W6L7J3KL.cjs');var _chunkUP5EGWNNcjs = require('./chunk-UP5EGWNN.cjs');var _chunkS3PBSOOZcjs = require('./chunk-S3PBSOOZ.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunk5VUIA6TBcjs = require('./chunk-5VUIA6TB.cjs');var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkOHTCLNE3cjs = require('./chunk-OHTCLNE3.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var N,c,b,x,l,S,F,O,I,C,he,ue,q,G,R= exports.a =class{constructor(e,r){_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,N);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,x);_chunkDSIFRRBScjs.e.call(void 0, this,l);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,F,[]);_chunkDSIFRRBScjs.e.call(void 0, this,O);_chunkDSIFRRBScjs.e.call(void 0, this,I,null);let{chain:t,address:n,owner:a,options:h,alias:u,recovery:d,apiRecoveryServerSignerAddress:g,apiDelegatedServerSignerAddresses:p,signers:y,signer:v}=e;_chunkDSIFRRBScjs.f.call(void 0, this,c,r),this.chain=t,this.address=n,this.owner=a,_chunkDSIFRRBScjs.f.call(void 0, this,N,h),this.alias=u;let m=null;g!=null?m=g:d.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, d)&&(m=d.address),_chunkDSIFRRBScjs.f.call(void 0, this,F,p!=null?p:[]),_chunkDSIFRRBScjs.f.call(void 0, this,b,y!=null?y:[]),_chunkDSIFRRBScjs.f.call(void 0, this,x,new (0, _chunkI3H3U7XWcjs.a)({chain:t,projectId:_chunkDSIFRRBScjs.d.call(void 0, this,c).projectId,environment:_chunkDSIFRRBScjs.d.call(void 0, this,c).environment,apiRecoveryAddress:m,apiDelegatedAddresses:_chunkDSIFRRBScjs.d.call(void 0, this,F),knownOnChainAddresses:()=>[..._chunkDSIFRRBScjs.d.call(void 0, this,b).filter(f=>f.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, f)).map(f=>f.address),..._chunkDSIFRRBScjs.d.call(void 0, this,F)]})),_chunkDSIFRRBScjs.f.call(void 0, this,l,new (0, _chunkFJYRJSKUcjs.a)({apiClient:r,options:h,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,x),recovery:d,initialSigners:_chunkDSIFRRBScjs.d.call(void 0, this,b),signers:()=>this.signers(),signer:v})),_chunkDSIFRRBScjs.f.call(void 0, this,S,new (0, _chunk3WJUXFU2cjs.a)({chain:t,walletAddress:this.address,options:h,signerManager:_chunkDSIFRRBScjs.d.call(void 0, this,l),serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,x),signers:()=>this.signers(),addSigner:f=>this.addSigner(f),removeSigner:f=>this.removeSigner({type:"device",locator:f}),approveSignature:f=>this.approveSignatureAndWait(f),approveTransaction:f=>this.approveTransactionAndWait(f)})),_chunkDSIFRRBScjs.f.call(void 0, this,O,this.initDefaultSigner())}get signer(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner}waitForInit(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,O)})}initDefaultSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||(yield _chunkDSIFRRBScjs.d.call(void 0, this,S).initDeviceSigner(),_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||_chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery))return;let e=_chunkDSIFRRBScjs.d.call(void 0, this,b).length===0?_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery:_chunkDSIFRRBScjs.d.call(void 0, this,b).length===1?_chunkDSIFRRBScjs.d.call(void 0, this,b)[0]:null;if(e==null)return;let r=_chunk44ICOOCJcjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery;try{let a=r.buildInternalConfig(e,t);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(a,{isAdminSigner:n}))}catch(a){_chunkPSK7FYV7cjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery.type,signerCount:_chunkDSIFRRBScjs.d.call(void 0, this,b).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunkDSIFRRBScjs.d.call(void 0, e,l).recovery}static getInitialSigners(e){return _chunkDSIFRRBScjs.d.call(void 0, e,b)}static getApiRecoveryServerSignerAddress(e){var r;return(r=_chunkDSIFRRBScjs.d.call(void 0, e,x).apiRecoveryAddress)!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,F)}get apiClient(){return _chunkDSIFRRBScjs.d.call(void 0, this,c)}get options(){return _chunkDSIFRRBScjs.d.call(void 0, this,N)}get chainAdapter(){return _chunk5VUIA6TBcjs.a.call(void 0, this.chain)}resolveServerSignerApiLocator(e){return _chunkDSIFRRBScjs.d.call(void 0, this,x).apiLocator(e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).recovery}balances(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw _chunkPSK7FYV7cjs.a.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return _chunkPSK7FYV7cjs.a.info("wallet.balances.success"),_chunkWTLEFDHScjs.a.call(void 0, a,this.chain,t,e)})}stagingFund(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.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 _chunkPSK7FYV7cjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkPSK7FYV7cjs.a.info("wallet.stagingFund.success"),t})}nfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getNfts(_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw _chunkPSK7FYV7cjs.a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return _chunkDSIFRRBScjs.h.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new (0, _chunkXZ4NKVEBcjs.y)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let h=_chunkUP5EGWNNcjs.a.call(void 0, e),u=this.resolveChainForEnvironment(),d=_chunkUP5EGWNNcjs.b.call(void 0, r,u);_chunkPSK7FYV7cjs.a.info("wallet.send.start",_chunkDSIFRRBScjs.a.call(void 0, {recipient:h,token:d,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),p;(n==null?void 0:n.signer)==null?p=g.locator():typeof n.signer=="string"?p=n.signer:p=this.resolveServerSignerApiLocator(n.signer);let y=_chunkDSIFRRBScjs.a.call(void 0, {recipient:h,amount:t,signer:p},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),v=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).send(this.walletLocator,d,y);if("message"in v)throw _chunkPSK7FYV7cjs.a.error("wallet.send.error",{error:v}),new (0, _chunkXZ4NKVEBcjs.z)(`Failed to send token: ${JSON.stringify(v.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkPSK7FYV7cjs.a.info("wallet.send.prepared",{transactionId:v.id}),{hash:void 0,explorerLink:void 0,transactionId:v.id};let m=yield this.approveTransactionAndWait(v.id);return _chunkPSK7FYV7cjs.a.info("wallet.send.success",{transactionId:v.id,hash:m.hash}),m})}approveTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkPSK7FYV7cjs.a.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 _chunkPSK7FYV7cjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkPSK7FYV7cjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkPSK7FYV7cjs.a.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var v;let n=typeof t=="string"?t:_chunkW6L7J3KLcjs.a.call(void 0, t),a=yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(n);if(a.signer!=null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).isApprovedSignerStatus(a.signer.status))return(r==null?void 0:r.scopes)!=null&&_chunkPSK7FYV7cjs.a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),_chunkPSK7FYV7cjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(a.signer,null,r);if(a.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 _chunkPSK7FYV7cjs.a.info("wallet.addSigner.resuming",{operationType:a.pendingOperation.type,operationId:a.pendingOperation.id}),this.completeSignerRegistration(a.signer,a.pendingOperation,r)}}let h=typeof t=="string"?t:_chunk44ICOOCJcjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),d=this.chain!=="solana"&&this.chain!=="stellar"?(v=r==null?void 0:r.deployImmediately)!=null?v:!0:void 0,g=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).registerSigner(this.walletLocator,_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),d!=null&&{deployImmediately:d}));if("error"in g)throw _chunkPSK7FYV7cjs.a.error("wallet.addSigner.error",{error:g}),g.code===_chunkXZ4NKVEBcjs.l?new (0, _chunkXZ4NKVEBcjs.m)(g.message):new (0, _chunkXZ4NKVEBcjs.j)(`Failed to register signer: ${JSON.stringify(g.message)}`);let p=_chunkJNKTRQPScjs.b.call(void 0, g,this.chain);if(p==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let y=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(p,y,r)}))})}completeSignerRegistration(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return _chunkDSIFRRBScjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkPSK7FYV7cjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}case"signature":{let n={signatureId:r.id};return _chunkPSK7FYV7cjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},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),_chunkPSK7FYV7cjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkPSK7FYV7cjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkPSK7FYV7cjs.a.info("wallet.addSigner.success");return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=this.resolveSignerLocator(e);return _chunkPSK7FYV7cjs.a.info("wallet.removeSigner.start",{signerLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).removeSigner(this.walletLocator,t,{chain:this.chainAdapter.addSignerChain(this.chain)});if("error"in n)throw _chunkPSK7FYV7cjs.a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let a=n.id;return r!=null&&r.prepareOnly?(_chunkPSK7FYV7cjs.a.info("wallet.removeSigner.prepared",{transactionId:a}),{transactionId:a,status:void 0}):(yield this.approveTransactionAndWait(a),_chunkPSK7FYV7cjs.a.info("wallet.removeSigner.success",{transactionId:a}),{transactionId:a,status:"success"})}))})}useSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,x).resetDelegatedCache(),_chunk44ICOOCJcjs.a.call(void 0, e.type).validateConfig(e);let r=!1;e.type==="device"?yield _chunkDSIFRRBScjs.d.call(void 0, this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=_chunk44ICOOCJcjs.a.call(void 0, e.type).buildInternalConfig(e,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),n=_chunkW6L7J3KLcjs.a.call(void 0, e);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(t,{isAdminSigner:r})),_chunkPSK7FYV7cjs.a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, 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 _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).map(a=>a.locator),n=_chunkDSIFRRBScjs.d.call(void 0, this,x).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;case"recovery":return _chunkDSIFRRBScjs.d.call(void 0, this,l).stripSecretFromRecovery(),_chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;case"unregistered":throw new Error(n.message)}})}tryAutoSelectPasskey(e){return _chunkDSIFRRBScjs.h.call(void 0, 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):_chunkW6L7J3KLcjs.a.call(void 0, e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).signerIsRegistered(e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).isSignerApproved(e)})}needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,S).recover()})}signers(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a,h;_chunkPSK7FYV7cjs.a.info("wallet.signers.start");let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getWallet(this.walletLocator);if("error"in e)throw _chunkPSK7FYV7cjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkXZ4NKVEBcjs.e)(JSON.stringify(e));if(!fe(e)){let u=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw _chunkPSK7FYV7cjs.a.error("wallet.signers.error",{error:u}),new (0, _chunkXZ4NKVEBcjs.d)(u)}let r=(h=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?h:[],n=(yield Promise.all(r.map(u=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{return(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(u.locator)).signer}catch(d){return _chunkPSK7FYV7cjs.a.warn("wallet.signers.mapSigner.failed",{locator:u.locator,error:d}),null}})))).filter(u=>u!=null);return _chunkPSK7FYV7cjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunkDSIFRRBScjs.d.call(void 0, this,c).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)}preAuthIfNeeded(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,O),_chunkDSIFRRBScjs.d.call(void 0, this,I)==null&&_chunkDSIFRRBScjs.f.call(void 0, this,I,this.recover());try{yield _chunkDSIFRRBScjs.d.call(void 0, this,I)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,I,null)}let e=_chunkDSIFRRBScjs.d.call(void 0, this,l).require();e instanceof _chunkS3PBSOOZcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=_chunk44ICOOCJcjs.a.call(void 0, e.type);return t.matchesRecovery(e,r,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&_chunkDSIFRRBScjs.d.call(void 0, this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=_chunkOHTCLNE3cjs.f.call(void 0, this.chain,_chunkDSIFRRBScjs.d.call(void 0, this,c).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d,g;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),n=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getSignature(this.walletLocator,e);if("error"in n)throw _chunkXZ4NKVEBcjs.I.call(void 0, n),new (0, _chunkXZ4NKVEBcjs.v)(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let p=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,p)}let a=(d=n.approvals)==null?void 0:d.pending;if(a==null||a.length===0)return n;let h=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],t],u=yield _chunkDSIFRRBScjs.g.call(void 0, this,C,G).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,C,q).call(this,a),h,(p,y)=>p.signMessage(y.message));return yield this.executeApproveSignatureWithErrorHandling(e,u)})}approveTransactionInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d,g,p,y,v;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getTransaction(this.walletLocator,e);if("error"in t)throw _chunkXZ4NKVEBcjs.I.call(void 0, t),new (0, _chunkXZ4NKVEBcjs.A)(JSON.stringify(t));yield(p=(g=(d=_chunkDSIFRRBScjs.d.call(void 0, this,N))==null?void 0:d.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:p.call(g);let n=_chunkDSIFRRBScjs.d.call(void 0, this,l).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=(y=t.approvals)==null?void 0:y.pending;if(a==null||a.length===0)return t;let h=[...(v=r==null?void 0:r.additionalSigners)!=null?v:[],n],u=yield _chunkDSIFRRBScjs.g.call(void 0, this,C,G).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,C,q).call(this,a),h,(m,f)=>{let Se=m.type==="device",ve=t.chainType==="solana"&&"transaction"in t.onChain&&!Se?t.onChain.transaction:f.message;return m.signTransaction(ve)});return yield this.executeApproveTransactionWithErrorHandling(e,u)})}executeApproveTransactionWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkXZ4NKVEBcjs.I.call(void 0, t),new (0, _chunkXZ4NKVEBcjs.F)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkXZ4NKVEBcjs.I.call(void 0, t),new (0, _chunkXZ4NKVEBcjs.w)(JSON.stringify(t));return t})}waitForSignature(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkMYIY3CX7cjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,c),this.walletLocator,e)})}waitForTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,r=6e4,t={}){return yield _chunkMYIY3CX7cjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,c),this.walletLocator,e,_chunkDSIFRRBScjs.a.call(void 0, {timeoutMs:r},t))})}sleep(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};N=new WeakMap,c=new WeakMap,b=new WeakMap,x=new WeakMap,l=new WeakMap,S=new WeakMap,F=new WeakMap,O=new WeakMap,I=new WeakMap,C=new WeakSet,he=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&_chunkPSK7FYV7cjs.a.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},ue=function(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield _chunkDSIFRRBScjs.g.call(void 0, this,C,he).call(this,r))!=null?n:void 0),t==null)throw new (0, _chunkXZ4NKVEBcjs.j)(`Signer ${r} not found in pending approvals`);return t})},q=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new (0, _chunkXZ4NKVEBcjs.n)(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},G=function(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.all(e.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.g.call(void 0, this,C,ue).call(this,r,n.signer.locator),h=yield t(a,n);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},h),{signer:a.locator()})})))})},_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"balances",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"stagingFund",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"send",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"approve",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"addSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"removeSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"useSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"recover",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"signers",1);function fe(M){return M.type==="smart"&&_chunk5VUIA6TBcjs.b.call(void 0, M.chainType)}exports.a = R;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk63Y6LGFLcjs = require('./chunk-63Y6LGFL.cjs');var _chunkQK57CJTHcjs = require('./chunk-QK57CJTH.cjs');var _chunkGPIDFXMJcjs = require('./chunk-GPIDFXMJ.cjs');var _chunkSHFB7XOMcjs = require('./chunk-SHFB7XOM.cjs');var _chunkI3H3U7XWcjs = require('./chunk-I3H3U7XW.cjs');var _chunk44ICOOCJcjs = require('./chunk-44ICOOCJ.cjs');var _chunkW6L7J3KLcjs = require('./chunk-W6L7J3KL.cjs');var _chunkUP5EGWNNcjs = require('./chunk-UP5EGWNN.cjs');var _chunkK7C5ZVNYcjs = require('./chunk-K7C5ZVNY.cjs');var _chunkHH6B2NTTcjs = require('./chunk-HH6B2NTT.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkPKREDLDOcjs = require('./chunk-PKREDLDO.cjs');var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var N,c,b,x,l,S,F,O,I,C,he,ue,q,G,R= exports.a =class{constructor(e,r){_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,N);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,x);_chunkDSIFRRBScjs.e.call(void 0, this,l);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,F,[]);_chunkDSIFRRBScjs.e.call(void 0, this,O);_chunkDSIFRRBScjs.e.call(void 0, this,I,null);let{chain:t,address:n,owner:a,options:h,alias:u,recovery:d,apiRecoveryServerSignerAddress:g,apiDelegatedServerSignerAddresses:p,signers:y,signer:v}=e;_chunkDSIFRRBScjs.f.call(void 0, this,c,r),this.chain=t,this.address=n,this.owner=a,_chunkDSIFRRBScjs.f.call(void 0, this,N,h),this.alias=u;let m=null;g!=null?m=g:d.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, d)&&(m=d.address),_chunkDSIFRRBScjs.f.call(void 0, this,F,p!=null?p:[]),_chunkDSIFRRBScjs.f.call(void 0, this,b,y!=null?y:[]),_chunkDSIFRRBScjs.f.call(void 0, this,x,new (0, _chunkI3H3U7XWcjs.a)({chain:t,projectId:_chunkDSIFRRBScjs.d.call(void 0, this,c).projectId,environment:_chunkDSIFRRBScjs.d.call(void 0, this,c).environment,apiRecoveryAddress:m,apiDelegatedAddresses:_chunkDSIFRRBScjs.d.call(void 0, this,F),knownOnChainAddresses:()=>[..._chunkDSIFRRBScjs.d.call(void 0, this,b).filter(f=>f.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, f)).map(f=>f.address),..._chunkDSIFRRBScjs.d.call(void 0, this,F)]})),_chunkDSIFRRBScjs.f.call(void 0, this,l,new (0, _chunkGPIDFXMJcjs.a)({apiClient:r,options:h,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,x),recovery:d,initialSigners:_chunkDSIFRRBScjs.d.call(void 0, this,b),signers:()=>this.signers(),signer:v})),_chunkDSIFRRBScjs.f.call(void 0, this,S,new (0, _chunk63Y6LGFLcjs.a)({chain:t,walletAddress:this.address,options:h,signerManager:_chunkDSIFRRBScjs.d.call(void 0, this,l),serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,x),signers:()=>this.signers(),addSigner:f=>this.addSigner(f),removeSigner:f=>this.removeSigner({type:"device",locator:f}),approveSignature:f=>this.approveSignatureAndWait(f),approveTransaction:f=>this.approveTransactionAndWait(f)})),_chunkDSIFRRBScjs.f.call(void 0, this,O,this.initDefaultSigner())}get signer(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner}waitForInit(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,O)})}initDefaultSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||(yield _chunkDSIFRRBScjs.d.call(void 0, this,S).initDeviceSigner(),_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||_chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery))return;let e=_chunkDSIFRRBScjs.d.call(void 0, this,b).length===0?_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery:_chunkDSIFRRBScjs.d.call(void 0, this,b).length===1?_chunkDSIFRRBScjs.d.call(void 0, this,b)[0]:null;if(e==null)return;let r=_chunk44ICOOCJcjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery;try{let a=r.buildInternalConfig(e,t);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(a,{isAdminSigner:n}))}catch(a){_chunkBOMJ4MFZcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery.type,signerCount:_chunkDSIFRRBScjs.d.call(void 0, this,b).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunkDSIFRRBScjs.d.call(void 0, e,l).recovery}static getInitialSigners(e){return _chunkDSIFRRBScjs.d.call(void 0, e,b)}static getApiRecoveryServerSignerAddress(e){var r;return(r=_chunkDSIFRRBScjs.d.call(void 0, e,x).apiRecoveryAddress)!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,F)}get apiClient(){return _chunkDSIFRRBScjs.d.call(void 0, this,c)}get options(){return _chunkDSIFRRBScjs.d.call(void 0, this,N)}get chainAdapter(){return _chunkPKREDLDOcjs.a.call(void 0, this.chain)}resolveServerSignerApiLocator(e){return _chunkDSIFRRBScjs.d.call(void 0, this,x).apiLocator(e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).recovery}balances(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw _chunkBOMJ4MFZcjs.a.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return _chunkBOMJ4MFZcjs.a.info("wallet.balances.success"),_chunkSHFB7XOMcjs.a.call(void 0, a,this.chain,t,e)})}stagingFund(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.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 _chunkBOMJ4MFZcjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkBOMJ4MFZcjs.a.info("wallet.stagingFund.success"),t})}nfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getNfts(_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw _chunkBOMJ4MFZcjs.a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return _chunkDSIFRRBScjs.h.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new (0, _chunkXZ4NKVEBcjs.y)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let h=_chunkUP5EGWNNcjs.a.call(void 0, e),u=this.resolveChainForEnvironment(),d=_chunkUP5EGWNNcjs.b.call(void 0, r,u);_chunkBOMJ4MFZcjs.a.info("wallet.send.start",_chunkDSIFRRBScjs.a.call(void 0, {recipient:h,token:d,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),p;(n==null?void 0:n.signer)==null?p=g.locator():typeof n.signer=="string"?p=n.signer:p=this.resolveServerSignerApiLocator(n.signer);let y=_chunkDSIFRRBScjs.a.call(void 0, {recipient:h,amount:t,signer:p},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),v=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).send(this.walletLocator,d,y);if("message"in v)throw _chunkBOMJ4MFZcjs.a.error("wallet.send.error",{error:v}),new (0, _chunkXZ4NKVEBcjs.z)(`Failed to send token: ${JSON.stringify(v.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkBOMJ4MFZcjs.a.info("wallet.send.prepared",{transactionId:v.id}),{hash:void 0,explorerLink:void 0,transactionId:v.id};let m=yield this.approveTransactionAndWait(v.id);return _chunkBOMJ4MFZcjs.a.info("wallet.send.success",{transactionId:v.id,hash:m.hash}),m})}approveTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkBOMJ4MFZcjs.a.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 _chunkBOMJ4MFZcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkBOMJ4MFZcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkBOMJ4MFZcjs.a.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var v;let n=typeof t=="string"?t:_chunkW6L7J3KLcjs.a.call(void 0, t),a=yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(n);if(a.signer!=null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).isApprovedSignerStatus(a.signer.status))return(r==null?void 0:r.scopes)!=null&&_chunkBOMJ4MFZcjs.a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),_chunkBOMJ4MFZcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(a.signer,null,r);if(a.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 _chunkBOMJ4MFZcjs.a.info("wallet.addSigner.resuming",{operationType:a.pendingOperation.type,operationId:a.pendingOperation.id}),this.completeSignerRegistration(a.signer,a.pendingOperation,r)}}let h=typeof t=="string"?t:_chunk44ICOOCJcjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),d=this.chain!=="solana"&&this.chain!=="stellar"?(v=r==null?void 0:r.deployImmediately)!=null?v:!0:void 0,g=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).registerSigner(this.walletLocator,_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),d!=null&&{deployImmediately:d}));if("error"in g)throw _chunkBOMJ4MFZcjs.a.error("wallet.addSigner.error",{error:g}),g.code===_chunkXZ4NKVEBcjs.l?new (0, _chunkXZ4NKVEBcjs.m)(g.message):new (0, _chunkXZ4NKVEBcjs.j)(`Failed to register signer: ${JSON.stringify(g.message)}`);let p=_chunkJNKTRQPScjs.b.call(void 0, g,this.chain);if(p==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let y=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(p,y,r)}))})}completeSignerRegistration(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return _chunkDSIFRRBScjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkBOMJ4MFZcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}case"signature":{let n={signatureId:r.id};return _chunkBOMJ4MFZcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},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),_chunkBOMJ4MFZcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkBOMJ4MFZcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkBOMJ4MFZcjs.a.info("wallet.addSigner.success");return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=this.resolveSignerLocator(e);return _chunkBOMJ4MFZcjs.a.info("wallet.removeSigner.start",{signerLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).removeSigner(this.walletLocator,t,{chain:this.chainAdapter.addSignerChain(this.chain)});if("error"in n)throw _chunkBOMJ4MFZcjs.a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let a=n.id;return r!=null&&r.prepareOnly?(_chunkBOMJ4MFZcjs.a.info("wallet.removeSigner.prepared",{transactionId:a}),{transactionId:a,status:void 0}):(yield this.approveTransactionAndWait(a),_chunkBOMJ4MFZcjs.a.info("wallet.removeSigner.success",{transactionId:a}),{transactionId:a,status:"success"})}))})}useSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,x).resetDelegatedCache(),_chunk44ICOOCJcjs.a.call(void 0, e.type).validateConfig(e);let r=!1;e.type==="device"?yield _chunkDSIFRRBScjs.d.call(void 0, this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=_chunk44ICOOCJcjs.a.call(void 0, e.type).buildInternalConfig(e,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),n=_chunkW6L7J3KLcjs.a.call(void 0, e);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(t,{isAdminSigner:r})),_chunkBOMJ4MFZcjs.a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, 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 _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).map(a=>a.locator),n=_chunkDSIFRRBScjs.d.call(void 0, this,x).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;case"recovery":return _chunkDSIFRRBScjs.d.call(void 0, this,l).stripSecretFromRecovery(),_chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;case"unregistered":throw new Error(n.message)}})}tryAutoSelectPasskey(e){return _chunkDSIFRRBScjs.h.call(void 0, 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):_chunkW6L7J3KLcjs.a.call(void 0, e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).signerIsRegistered(e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).isSignerApproved(e)})}needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,S).recover()})}signers(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a,h;_chunkBOMJ4MFZcjs.a.info("wallet.signers.start");let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getWallet(this.walletLocator);if("error"in e)throw _chunkBOMJ4MFZcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkXZ4NKVEBcjs.e)(JSON.stringify(e));if(!fe(e)){let u=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw _chunkBOMJ4MFZcjs.a.error("wallet.signers.error",{error:u}),new (0, _chunkXZ4NKVEBcjs.d)(u)}let r=(h=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?h:[],n=(yield Promise.all(r.map(u=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{return(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(u.locator)).signer}catch(d){return _chunkBOMJ4MFZcjs.a.warn("wallet.signers.mapSigner.failed",{locator:u.locator,error:d}),null}})))).filter(u=>u!=null);return _chunkBOMJ4MFZcjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunkDSIFRRBScjs.d.call(void 0, this,c).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)}preAuthIfNeeded(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,O),_chunkDSIFRRBScjs.d.call(void 0, this,I)==null&&_chunkDSIFRRBScjs.f.call(void 0, this,I,this.recover());try{yield _chunkDSIFRRBScjs.d.call(void 0, this,I)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,I,null)}let e=_chunkDSIFRRBScjs.d.call(void 0, this,l).require();e instanceof _chunkHH6B2NTTcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=_chunk44ICOOCJcjs.a.call(void 0, e.type);return t.matchesRecovery(e,r,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&_chunkDSIFRRBScjs.d.call(void 0, this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=_chunkK7C5ZVNYcjs.f.call(void 0, this.chain,_chunkDSIFRRBScjs.d.call(void 0, this,c).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d,g;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),n=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getSignature(this.walletLocator,e);if("error"in n)throw _chunkXZ4NKVEBcjs.I.call(void 0, n),new (0, _chunkXZ4NKVEBcjs.v)(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let p=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,p)}let a=(d=n.approvals)==null?void 0:d.pending;if(a==null||a.length===0)return n;let h=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],t],u=yield _chunkDSIFRRBScjs.g.call(void 0, this,C,G).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,C,q).call(this,a),h,(p,y)=>p.signMessage(y.message));return yield this.executeApproveSignatureWithErrorHandling(e,u)})}approveTransactionInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d,g,p,y,v;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getTransaction(this.walletLocator,e);if("error"in t)throw _chunkXZ4NKVEBcjs.I.call(void 0, t),new (0, _chunkXZ4NKVEBcjs.A)(JSON.stringify(t));yield(p=(g=(d=_chunkDSIFRRBScjs.d.call(void 0, this,N))==null?void 0:d.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:p.call(g);let n=_chunkDSIFRRBScjs.d.call(void 0, this,l).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=(y=t.approvals)==null?void 0:y.pending;if(a==null||a.length===0)return t;let h=[...(v=r==null?void 0:r.additionalSigners)!=null?v:[],n],u=yield _chunkDSIFRRBScjs.g.call(void 0, this,C,G).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,C,q).call(this,a),h,(m,f)=>{let Se=m.type==="device",ve=t.chainType==="solana"&&"transaction"in t.onChain&&!Se?t.onChain.transaction:f.message;return m.signTransaction(ve)});return yield this.executeApproveTransactionWithErrorHandling(e,u)})}executeApproveTransactionWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkXZ4NKVEBcjs.I.call(void 0, t),new (0, _chunkXZ4NKVEBcjs.F)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkXZ4NKVEBcjs.I.call(void 0, t),new (0, _chunkXZ4NKVEBcjs.w)(JSON.stringify(t));return t})}waitForSignature(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkQK57CJTHcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,c),this.walletLocator,e)})}waitForTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,r=6e4,t={}){return yield _chunkQK57CJTHcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,c),this.walletLocator,e,_chunkDSIFRRBScjs.a.call(void 0, {timeoutMs:r},t))})}sleep(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};N=new WeakMap,c=new WeakMap,b=new WeakMap,x=new WeakMap,l=new WeakMap,S=new WeakMap,F=new WeakMap,O=new WeakMap,I=new WeakMap,C=new WeakSet,he=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&_chunkBOMJ4MFZcjs.a.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},ue=function(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield _chunkDSIFRRBScjs.g.call(void 0, this,C,he).call(this,r))!=null?n:void 0),t==null)throw new (0, _chunkXZ4NKVEBcjs.j)(`Signer ${r} not found in pending approvals`);return t})},q=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new (0, _chunkXZ4NKVEBcjs.n)(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},G=function(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.all(e.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.g.call(void 0, this,C,ue).call(this,r,n.signer.locator),h=yield t(a,n);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},h),{signer:a.locator()})})))})},_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"balances",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"stagingFund",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"send",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"approve",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"addSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"removeSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"useSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"recover",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"signers",1);function fe(M){return M.type==="smart"&&_chunkPKREDLDOcjs.b.call(void 0, M.chainType)}exports.a = R;
@@ -1 +1 @@
1
- import{a}from"./chunk-M3IEG5GA.js";import{a as r}from"./chunk-QVE2LOBH.js";import{a as t}from"./chunk-SZXFHFA5.js";import{a as n}from"./chunk-OQZTL6ZG.js";var i={evm:a,solana:r,stellar:t};function g(e){return i[n(e)]}function m(e){return Object.prototype.hasOwnProperty.call(i,e)}export{g as a,m as b};
1
+ import{a}from"./chunk-DSLYYS6N.js";import{a as r}from"./chunk-NHXWNB3V.js";import{a as t}from"./chunk-2IBE7HWB.js";import{a as n}from"./chunk-OQZTL6ZG.js";var i={evm:a,solana:r,stellar:t};function g(e){return i[n(e)]}function m(e){return Object.prototype.hasOwnProperty.call(i,e)}export{g as a,m as b};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkS3PBSOOZcjs = require('./chunk-S3PBSOOZ.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkS3PBSOOZcjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkPSK7FYV7cjs.a.info("sign: sending request",{keyType:"secp256k1"});let y=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"}},options:_chunkS3PBSOOZcjs.b});if(_chunkPSK7FYV7cjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(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"}}};exports.a = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHH6B2NTTcjs = require('./chunk-HH6B2NTT.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkHH6B2NTTcjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkBOMJ4MFZcjs.a.info("sign: sending request",{keyType:"secp256k1"});let y=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"}},options:_chunkHH6B2NTTcjs.b});if(_chunkBOMJ4MFZcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(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"}}};exports.a = c;
@@ -0,0 +1 @@
1
+ import{a as b}from"./chunk-JEKHYLBB.js";import{a as x}from"./chunk-GQDDB57A.js";import{f as R}from"./chunk-DCKFFFPG.js";import{b as A,c as P}from"./chunk-B4GYB3XY.js";import{a as w}from"./chunk-PSDE5X7P.js";import{d as r,e as o,f as t,g as F,h}from"./chunk-NU7VF7MC.js";import{ApiClientError as W}from"@crossmint/common-sdk-base";var a,n,p,g,S,C,u,d,v,f,m,O,E=class{constructor(e){o(this,m);o(this,a);o(this,n);o(this,p);o(this,g);o(this,S);o(this,C);o(this,u);o(this,d);o(this,v);o(this,f);t(this,p,e.apiClient),t(this,g,e.options),t(this,S,e.chain),t(this,C,e.walletAddress),t(this,u,e.walletLocator),t(this,d,e.serverSignerResolver),t(this,n,e.recovery),t(this,v,e.initialSigners),t(this,f,e.signers),t(this,a,e.signer)}get activeSigner(){return r(this,a)}setActiveSigner(e){t(this,a,e)}get recovery(){return r(this,n)}descriptorContext(){var e,i,s,l,c;return{chain:r(this,S),walletAddress:r(this,C),crossmint:r(this,p).crossmint,clientTEEConnection:(e=r(this,g))==null?void 0:e.clientTEEConnection,resetSignerFrame:(i=r(this,g))==null?void 0:i.resetSignerFrame,onAuthRequired:(l=(s=r(this,g))==null?void 0:s.callbacks)==null?void 0:l.onAuthRequired,deviceSignerKeyStorage:(c=r(this,g))==null?void 0:c.deviceSignerKeyStorage,serverSigners:r(this,d)}}adoptRecoveryConfig(e){t(this,n,e)}stripSecretFromRecovery(){let e=r(this,d).resolvedRecoveryAddress;r(this,n)!=null&&r(this,n).type==="server"&&!R(r(this,n))&&e!=null&&t(this,n,{type:"server",address:e})}assemble(e,i){return h(this,null,function*(){var l,c;let s=x(r(this,S),e,(l=r(this,g))==null?void 0:l.deviceSignerKeyStorage);if(i!=null&&i.isAdminSigner)s.status="active";else{let y=yield this.getSignerState(s.locator());s.status=(c=y.signer)==null?void 0:c.status}return s})}require(){if(r(this,a)==null){if(r(this,v).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=b(r(this,n).type),i=e.signerUnavailableReason();throw i!=null?new Error(i):e.canAutoAssemble(r(this,n),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 r(this,a)}withRecoverySigner(e){return h(this,null,function*(){var y;let i=r(this,a);if(R(r(this,n))&&!r(this,d).hasRecoveryResolution)throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let s=b(r(this,n).type),l=this.descriptorContext();if(r(this,n)!=null&&r(this,n).type==="external-wallet"&&!s.canAutoAssemble(r(this,n),l))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let c=s.buildInternalConfig(r(this,n),l);t(this,a,x(r(this,S),c,(y=r(this,g))==null?void 0:y.deviceSignerKeyStorage));try{return yield e()}finally{t(this,a,i)}})}getSignerState(e){return h(this,null,function*(){let i=null;try{i=yield r(this,p).getSigner(r(this,u).call(this),e)}catch(l){return w.warn("wallet.signers.getSignerState.fetchFailed",{signerLocator:e,error:l}),{response:null,signer:null,pendingOperation:null}}if(i==null||typeof i!="object"||"error"in i)return w.warn("wallet.signers.getSignerState.errorResponse",{signerLocator:e,response:i}),{response:null,signer:null,pendingOperation:null};let s=A(i,r(this,S));return{response:i,signer:s,pendingOperation:P(i,r(this,S))}})}signerIsRegistered(e){return h(this,null,function*(){return(yield r(this,f).call(this)).some(s=>s.locator===e)})}isSignerApproved(e){return h(this,null,function*(){try{let i=yield F(this,m,O).call(this,e);return this.isApprovedSignerStatus(i==null?void 0:i.status)}catch(i){if(i instanceof W&&i.status===404)return!1;throw w.error("wallet.signers.isSignerApproved.failed",{signerLocator:e,error:i}),i}})}isApprovedSignerStatus(e){return e==="success"||e==="active"}};a=new WeakMap,n=new WeakMap,p=new WeakMap,g=new WeakMap,S=new WeakMap,C=new WeakMap,u=new WeakMap,d=new WeakMap,v=new WeakMap,f=new WeakMap,m=new WeakSet,O=function(e){return h(this,null,function*(){let i=yield r(this,p).getSigner(r(this,u).call(this),e);if(i==null||typeof i!="object"||"error"in i)throw new Error(`Failed to fetch the approval state of signer ${e}`);return A(i,r(this,S))})};export{E as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkLJNSIXGNcjs = require('./chunk-LJNSIXGN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkLJNSIXGNcjs.c,version:_chunkLJNSIXGNcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkPSK7FYV7cjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?_chunkPSK7FYV7cjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkPSK7FYV7cjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkPSK7FYV7cjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkPSK7FYV7cjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?_chunkPSK7FYV7cjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkPSK7FYV7cjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkXZ4NKVEBcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkXZ4NKVEBcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var _chunkV7LXNAA3cjs = require('./chunk-V7LXNAA3.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkV7LXNAA3cjs.c,version:_chunkV7LXNAA3cjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkBOMJ4MFZcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let t=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in t?_chunkBOMJ4MFZcjs.a.error("wallets.api.createWallet.error",{error:t.error,chainType:e.chainType}):"address"in t&&_chunkBOMJ4MFZcjs.a.info("wallets.api.createWallet.success",{address:t.address,chainType:e.chainType}),t})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkBOMJ4MFZcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkBOMJ4MFZcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return t.status===422?this.getSignature(e,s):t.json()})}getSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=encodeURIComponent(s),a=new URLSearchParams;r.chain&&a.append("chain",r.chain);let p=`${this.apiPrefix}/${e}/signers/${t}${a.size>0?`?${a.toString()}`:""}`;return(yield this.delete(p,{headers:this.headers})).json()})}getSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=encodeURIComponent(s),t=yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers});if(!t.ok){let a=null;try{a=yield t.text()}catch(p){}throw new (0, _commonsdkbase.ApiClientError)(`API request failed: ${t.status} ${t.statusText}`,t.status,t.statusText,a)}return t.json()})}send(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkBOMJ4MFZcjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let a=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in a?_chunkBOMJ4MFZcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:a.error}):"id"in a&&_chunkBOMJ4MFZcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:a.id}),a})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkXZ4NKVEBcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkXZ4NKVEBcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ2C3XP4Zcjs = require('./chunk-J2C3XP4Z.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkW6L7J3KLcjs = require('./chunk-W6L7J3KL.cjs');var _chunk7SOKSLRQcjs = require('./chunk-7SOKSLRQ.cjs');var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunkOHTCLNE3cjs = require('./chunk-OHTCLNE3.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",w= exports.a =class{constructor(t){this.apiClient=t}getWallet(t,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r,i;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkXZ4NKVEBcjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunkXZ4NKVEBcjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");r=t,i=e}else{if(this.apiClient.isServerSide)throw new (0, _chunkXZ4NKVEBcjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");i=t,r=this.getWalletLocator(i)}let n=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},i),{chain:_chunkOHTCLNE3cjs.f.call(void 0, i.chain,this.apiClient.environment)});_chunkPSK7FYV7cjs.a.info("walletFactory.getWallet.start");let a=yield this.apiClient.getWallet(r);if("error"in a)throw _chunkPSK7FYV7cjs.a.warn("walletFactory.getWallet.notFound",{error:a.error}),new (0, _chunkXZ4NKVEBcjs.e)(JSON.stringify(a));return _chunkPSK7FYV7cjs.a.info("walletFactory.getWallet.success",{address:a.address}),yield this.createWalletInstance(a,n)})}createWallet(t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o,c,y,u,d,C;let e=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{chain:_chunkOHTCLNE3cjs.f.call(void 0, t.chain,this.apiClient.environment)});if(yield(y=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:y.call(c),_chunkPSK7FYV7cjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkPSK7FYV7cjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkXZ4NKVEBcjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let r=(u=e.signers)!=null?u:[],i=((d=e.options)==null?void 0:d.deviceSignerKeyStorage)!=null&&!r.some(m=>m.type==="device"),n=i?[...r,{type:"device"}]:r,a=yield this.registerSigners(n,e.chain,(C=e.options)==null?void 0:C.deviceSignerKeyStorage),s;if(e.recovery.type==="passkey"&&e.recovery.id==null)s=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:m}=_chunkQ66YRLSWcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);s={type:"server",address:m}}else s=e.recovery;let l=yield this.createSmartWallet(e,s,a,i);if("error"in l)throw _chunkPSK7FYV7cjs.a.error("walletFactory.createWallet.error",{error:l.error}),new (0, _chunkXZ4NKVEBcjs.g)(JSON.stringify(l));return _chunkPSK7FYV7cjs.a.info("walletFactory.createWallet.success",{address:l.address}),yield this.createWalletInstance(l,e)})}createSmartWallet(t,e,r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=o=>{var c,y;return{type:"smart",chainType:this.getChainType(t.chain),config:_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {adminSigner:e},t.plugins?{plugins:t.plugins}:{}),o!=null?{delegatedSigners:o}:{}),owner:(c=t.owner)!=null?c:void 0,alias:(y=t.alias)!=null?y:void 0}},a=yield this.apiClient.createWallet(n(r));if(!(i&&"error"in a&&a.code===_chunkXZ4NKVEBcjs.l))return a;_chunkPSK7FYV7cjs.a.info("walletFactory.createWallet.deviceSignerUnsupported.retryWithoutDeviceSigner",{chain:t.chain});let l=r.filter(o=>!this.isBuiltDeviceSigner(o));return yield this.apiClient.createWallet(n(l))})}isBuiltDeviceSigner(t){let e=t.signer;return typeof e=="object"&&e!=null&&e.type==="device"}mergePhoneChannel(t,e){return t.type!=="phone"||(e==null?void 0:e.type)!=="phone"||e.channel==null?t:_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{channel:e.channel})}createWalletInstance(t,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var y,u;this.validateExistingWalletConfig(t,e);let r=e,i=t.config.adminSigner,n=((y=r.recovery)==null?void 0:y.type)==="server"||((u=r.recovery)==null?void 0:u.type)==="external-wallet"?r.recovery:this.mergePhoneChannel(i,r.recovery),a=t.config.delegatedSigners,s=a;if(s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet"))s=r.signers;else if(s!=null){let d=r.signers;s=s.map(C=>this.mergePhoneChannel(C,d==null?void 0:d.find(m=>m.type==="phone"&&C.type==="phone"&&_chunkW6L7J3KLcjs.a.call(void 0, m)===C.locator)))}let l=i.type==="server"&&"address"in i&&!("secret"in i)?i.address:void 0,o=(a!=null?a:[]).filter(d=>d.type==="server"&&"address"in d&&!("secret"in d)).map(d=>d.address),c=new (0, _chunkJ2C3XP4Zcjs.a)({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:n,apiRecoveryServerSignerAddress:l,apiDelegatedServerSignerAddresses:o,signers:s!=null?s:[]},this.apiClient);return yield c.waitForInit(),c})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(i=t.name)!=null?i:`Crossmint Wallet ${Date.now()}`,r=t.onCreatePasskey?yield t.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:r.id,name:e,publicKey:{x:r.publicKey.x.toString(),y:r.publicKey.y.toString()}}})}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&_chunk7SOKSLRQcjs.b.call(void 0, e.owner)!==_chunk7SOKSLRQcjs.b.call(void 0, t.owner))throw new (0, _chunkXZ4NKVEBcjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new (0, _chunkXZ4NKVEBcjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let r=e;if(r.recovery!=null||r.signers!=null){let i=t.config,n=i==null?void 0:i.adminSigner;if(r.recovery!=null&&n!=null){if(r.recovery.type!==n.type)throw new (0, _chunkXZ4NKVEBcjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunk7SOKSLRQcjs.c.call(void 0, r.recovery,n)}let a=r.signers;a!=null&&this.validateSigners(t,a,e.chain)}}validateSigners(t,e,r){let i=t.config,n=i==null?void 0:i.delegatedSigners;if(e.length!==0){if(n==null||n.length===0)throw new (0, _chunkXZ4NKVEBcjs.g)(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${$}`);for(let a of e){let s=n.find(l=>{if(this.isMatchingPasskeySigner(a,l,i)||l.type==="device"&&a.type==="device")return!0;if(a.type==="server"){let{primary:o,legacy:c}=_chunkQ66YRLSWcjs.c.call(void 0, a,r,this.apiClient.projectId,this.apiClient.environment);return l.locator===`server:${o.derivedAddress}`||c!=null&&l.locator===`server:${c.derivedAddress}`}return l.locator===_chunkW6L7J3KLcjs.a.call(void 0, a)});if(s==null){let l=n.map(o=>o.locator).join(", ");throw new (0, _chunkXZ4NKVEBcjs.g)(`Signer '${a.type}' does not exist in wallet "${t.address}". Available signers: ${l}. ${$}`)}_chunk7SOKSLRQcjs.c.call(void 0, a,s)}}}isMatchingPasskeySigner(t,e,r){var n,a;let i=((a=(n=r.delegatedSigners)==null?void 0:n.filter(s=>s.type==="passkey").length)!=null?a:0)+(r.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&i===1)return e.type==="passkey";if(t.id==null&&i>1)throw new (0, _chunkXZ4NKVEBcjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;return yield Promise.all((i=t==null?void 0:t.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(n.type==="passkey")return n.id==null?{signer:yield this.createPasskeySigner(n)}:{signer:n};if(n.type==="device"){if(n.publicKey!=null)return{signer:{type:"device",publicKey:n.publicKey,name:n.name}};if(n.locator!=null)return{signer:n.locator};if(r==null)throw new (0, _chunkXZ4NKVEBcjs.g)("Device signer key storage is required for device signers");let a=yield _chunkGMU3ZYLScjs.a.call(void 0, r);return{signer:{type:"device",publicKey:a.publicKey,name:a.name}}}if(n.type==="server"&&e!=null){let{derivedAddress:a}=_chunkQ66YRLSWcjs.b.call(void 0, n,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${a}`}}return{signer:_chunkW6L7J3KLcjs.a.call(void 0, n)}})))!=null?i:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let i=e[1];return{walletLocator:e[0],chain:i==null?void 0:i.chain}}let r=e[0];return{chain:r==null?void 0:r.chain}}})],w.prototype,"getWallet",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],w.prototype,"createWallet",1);exports.a = w;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHI7CAJMUcjs = require('./chunk-HI7CAJMU.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkW6L7J3KLcjs = require('./chunk-W6L7J3KL.cjs');var _chunk7SOKSLRQcjs = require('./chunk-7SOKSLRQ.cjs');var _chunkK7C5ZVNYcjs = require('./chunk-K7C5ZVNY.cjs');var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",w= exports.a =class{constructor(t){this.apiClient=t}getWallet(t,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r,i;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkXZ4NKVEBcjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunkXZ4NKVEBcjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");r=t,i=e}else{if(this.apiClient.isServerSide)throw new (0, _chunkXZ4NKVEBcjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");i=t,r=this.getWalletLocator(i)}let n=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},i),{chain:_chunkK7C5ZVNYcjs.f.call(void 0, i.chain,this.apiClient.environment)});_chunkBOMJ4MFZcjs.a.info("walletFactory.getWallet.start");let a=yield this.apiClient.getWallet(r);if("error"in a)throw _chunkBOMJ4MFZcjs.a.warn("walletFactory.getWallet.notFound",{error:a.error}),new (0, _chunkXZ4NKVEBcjs.e)(JSON.stringify(a));return _chunkBOMJ4MFZcjs.a.info("walletFactory.getWallet.success",{address:a.address}),yield this.createWalletInstance(a,n)})}createWallet(t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o,c,y,u,d,C;let e=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{chain:_chunkK7C5ZVNYcjs.f.call(void 0, t.chain,this.apiClient.environment)});if(yield(y=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:y.call(c),_chunkBOMJ4MFZcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkBOMJ4MFZcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkXZ4NKVEBcjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let r=(u=e.signers)!=null?u:[],i=((d=e.options)==null?void 0:d.deviceSignerKeyStorage)!=null&&!r.some(m=>m.type==="device"),n=i?[...r,{type:"device"}]:r,a=yield this.registerSigners(n,e.chain,(C=e.options)==null?void 0:C.deviceSignerKeyStorage),s;if(e.recovery.type==="passkey"&&e.recovery.id==null)s=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:m}=_chunkQ66YRLSWcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);s={type:"server",address:m}}else s=e.recovery;let l=yield this.createSmartWallet(e,s,a,i);if("error"in l)throw _chunkBOMJ4MFZcjs.a.error("walletFactory.createWallet.error",{error:l.error}),new (0, _chunkXZ4NKVEBcjs.g)(JSON.stringify(l));return _chunkBOMJ4MFZcjs.a.info("walletFactory.createWallet.success",{address:l.address}),yield this.createWalletInstance(l,e)})}createSmartWallet(t,e,r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=o=>{var c,y;return{type:"smart",chainType:this.getChainType(t.chain),config:_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {adminSigner:e},t.plugins?{plugins:t.plugins}:{}),o!=null?{delegatedSigners:o}:{}),owner:(c=t.owner)!=null?c:void 0,alias:(y=t.alias)!=null?y:void 0}},a=yield this.apiClient.createWallet(n(r));if(!(i&&"error"in a&&a.code===_chunkXZ4NKVEBcjs.l))return a;_chunkBOMJ4MFZcjs.a.info("walletFactory.createWallet.deviceSignerUnsupported.retryWithoutDeviceSigner",{chain:t.chain});let l=r.filter(o=>!this.isBuiltDeviceSigner(o));return yield this.apiClient.createWallet(n(l))})}isBuiltDeviceSigner(t){let e=t.signer;return typeof e=="object"&&e!=null&&e.type==="device"}mergePhoneChannel(t,e){return t.type!=="phone"||(e==null?void 0:e.type)!=="phone"||e.channel==null?t:_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{channel:e.channel})}createWalletInstance(t,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var y,u;this.validateExistingWalletConfig(t,e);let r=e,i=t.config.adminSigner,n=((y=r.recovery)==null?void 0:y.type)==="server"||((u=r.recovery)==null?void 0:u.type)==="external-wallet"?r.recovery:this.mergePhoneChannel(i,r.recovery),a=t.config.delegatedSigners,s=a;if(s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet"))s=r.signers;else if(s!=null){let d=r.signers;s=s.map(C=>this.mergePhoneChannel(C,d==null?void 0:d.find(m=>m.type==="phone"&&C.type==="phone"&&_chunkW6L7J3KLcjs.a.call(void 0, m)===C.locator)))}let l=i.type==="server"&&"address"in i&&!("secret"in i)?i.address:void 0,o=(a!=null?a:[]).filter(d=>d.type==="server"&&"address"in d&&!("secret"in d)).map(d=>d.address),c=new (0, _chunkHI7CAJMUcjs.a)({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:n,apiRecoveryServerSignerAddress:l,apiDelegatedServerSignerAddresses:o,signers:s!=null?s:[]},this.apiClient);return yield c.waitForInit(),c})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(i=t.name)!=null?i:`Crossmint Wallet ${Date.now()}`,r=t.onCreatePasskey?yield t.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:r.id,name:e,publicKey:{x:r.publicKey.x.toString(),y:r.publicKey.y.toString()}}})}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&_chunk7SOKSLRQcjs.b.call(void 0, e.owner)!==_chunk7SOKSLRQcjs.b.call(void 0, t.owner))throw new (0, _chunkXZ4NKVEBcjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new (0, _chunkXZ4NKVEBcjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let r=e;if(r.recovery!=null||r.signers!=null){let i=t.config,n=i==null?void 0:i.adminSigner;if(r.recovery!=null&&n!=null){if(r.recovery.type!==n.type)throw new (0, _chunkXZ4NKVEBcjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunk7SOKSLRQcjs.c.call(void 0, r.recovery,n)}let a=r.signers;a!=null&&this.validateSigners(t,a,e.chain)}}validateSigners(t,e,r){let i=t.config,n=i==null?void 0:i.delegatedSigners;if(e.length!==0){if(n==null||n.length===0)throw new (0, _chunkXZ4NKVEBcjs.g)(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${$}`);for(let a of e){let s=n.find(l=>{if(this.isMatchingPasskeySigner(a,l,i)||l.type==="device"&&a.type==="device")return!0;if(a.type==="server"){let{primary:o,legacy:c}=_chunkQ66YRLSWcjs.c.call(void 0, a,r,this.apiClient.projectId,this.apiClient.environment);return l.locator===`server:${o.derivedAddress}`||c!=null&&l.locator===`server:${c.derivedAddress}`}return l.locator===_chunkW6L7J3KLcjs.a.call(void 0, a)});if(s==null){let l=n.map(o=>o.locator).join(", ");throw new (0, _chunkXZ4NKVEBcjs.g)(`Signer '${a.type}' does not exist in wallet "${t.address}". Available signers: ${l}. ${$}`)}_chunk7SOKSLRQcjs.c.call(void 0, a,s)}}}isMatchingPasskeySigner(t,e,r){var n,a;let i=((a=(n=r.delegatedSigners)==null?void 0:n.filter(s=>s.type==="passkey").length)!=null?a:0)+(r.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&i===1)return e.type==="passkey";if(t.id==null&&i>1)throw new (0, _chunkXZ4NKVEBcjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;return yield Promise.all((i=t==null?void 0:t.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(n.type==="passkey")return n.id==null?{signer:yield this.createPasskeySigner(n)}:{signer:n};if(n.type==="device"){if(n.publicKey!=null)return{signer:{type:"device",publicKey:n.publicKey,name:n.name}};if(n.locator!=null)return{signer:n.locator};if(r==null)throw new (0, _chunkXZ4NKVEBcjs.g)("Device signer key storage is required for device signers");let a=yield _chunkGMU3ZYLScjs.a.call(void 0, r);return{signer:{type:"device",publicKey:a.publicKey,name:a.name}}}if(n.type==="server"&&e!=null){let{derivedAddress:a}=_chunkQ66YRLSWcjs.b.call(void 0, n,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${a}`}}return{signer:_chunkW6L7J3KLcjs.a.call(void 0, n)}})))!=null?i:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let i=e[1];return{walletLocator:e[0],chain:i==null?void 0:i.chain}}let r=e[0];return{chain:r==null?void 0:r.chain}}})],w.prototype,"getWallet",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkBOMJ4MFZcjs.a,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],w.prototype,"createWallet",1);exports.a = w;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var w=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],D=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function X(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.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;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.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;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.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET: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:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA: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 I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM]:_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_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.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function ee(t,a){if(!F(t))throw new (0, _chunkXZ4NKVEBcjs.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,T=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&I(r))throw new (0, _chunkXZ4NKVEBcjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return _chunkPSK7FYV7cjs.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;_chunkPSK7FYV7cjs.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 = X; exports.b = I; exports.c = C; exports.d = g; exports.e = F; exports.f = ee;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var w=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],D=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function X(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.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;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.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;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.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET: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:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA: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 I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM]:_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_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.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function ee(t,a){if(!F(t))throw new (0, _chunkXZ4NKVEBcjs.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,T=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&I(r))throw new (0, _chunkXZ4NKVEBcjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return _chunkBOMJ4MFZcjs.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;_chunkBOMJ4MFZcjs.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 = X; exports.b = I; exports.c = C; exports.d = g; exports.e = F; exports.f = ee;
@@ -1 +1 @@
1
- import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{o as w}from"./chunk-7FEY62ID.js";import{a as l}from"./chunk-4ILFMPNK.js";import{c as m,h as n}from"./chunk-NU7VF7MC.js";import{getEnvironmentForKey as K,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as b}from"ox";var R={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!P())throw new w("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=K(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield b.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield b.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};m([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
1
+ import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{o as w}from"./chunk-7FEY62ID.js";import{a as l}from"./chunk-PSDE5X7P.js";import{c as m,h as n}from"./chunk-NU7VF7MC.js";import{getEnvironmentForKey as K,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as b}from"ox";var R={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!P())throw new w("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=K(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield b.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield b.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};m([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunkPSK7FYV7cjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunkPSK7FYV7cjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunkXZ4NKVEBcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkJNKTRQPScjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunkBOMJ4MFZcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunkBOMJ4MFZcjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunkXZ4NKVEBcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkJNKTRQPScjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var o={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,a){if(!("transaction"in n)||n.transaction==null)throw _chunkPSK7FYV7cjs.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}}};exports.a = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var o={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,a){if(!("transaction"in n)||n.transaction==null)throw _chunkBOMJ4MFZcjs.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}}};exports.a = o;
@@ -1 +1 @@
1
- import{a as e}from"./chunk-4ILFMPNK.js";var s={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,a){if(!("transaction"in n)||n.transaction==null)throw e.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}}};export{s as a};
1
+ import{a as e}from"./chunk-PSDE5X7P.js";var s={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,a){if(!("transaction"in n)||n.transaction==null)throw e.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}}};export{s as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHSLCNCPWcjs = require('./chunk-HSLCNCPW.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkJ5CHOVJLcjs = require('./chunk-J5CHOVJL.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkPSK7FYV7cjs.b.call(void 0, e.apiKey);let t=new (0, _chunkJ5CHOVJLcjs.a)(e);this.walletFactory=new (0, _chunkHSLCNCPWcjs.a)(t),_chunkPSK7FYV7cjs.a.info("wallets.sdk.initialized")}static from(e){return new c(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){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJLKWUFQUcjs = require('./chunk-JLKWUFQU.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkJJIO5FRQcjs = require('./chunk-JJIO5FRQ.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkBOMJ4MFZcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkJJIO5FRQcjs.a)(e);this.walletFactory=new (0, _chunkJLKWUFQUcjs.a)(t),_chunkBOMJ4MFZcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(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){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLUFASRMRcjs = require('./chunk-LUFASRMR.cjs');var _chunkLXRF6CRWcjs = require('./chunk-LXRF6CRW.cjs');var _chunkVXFJQERScjs = require('./chunk-VXFJQERS.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var i={evm:_chunkLUFASRMRcjs.a,solana:_chunkLXRF6CRWcjs.a,stellar:_chunkVXFJQERScjs.a};function h(e){return i[_chunkENU3EKBGcjs.a.call(void 0, e)]}function g(e){return Object.prototype.hasOwnProperty.call(i,e)}exports.a = h; exports.b = g;
@@ -1 +1 @@
1
- import{b as n,c as i}from"./chunk-SCEZVF7J.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
1
+ import{b as n,c as i}from"./chunk-47M4FIGW.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
@@ -1 +1 @@
1
- import{a as f}from"./chunk-IHMMTMFG.js";import{a as u,b as g,c as v,d as y,e as P}from"./chunk-DCKFFFPG.js";import{a as o}from"./chunk-4ILFMPNK.js";import{a as E,c as w,h}from"./chunk-NU7VF7MC.js";import{validateAPIKey as A,WithLoggerContext as T}from"@crossmint/common-sdk-base";var m=class{constructor(n){this.config=n;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 h(this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return h(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 h(this,null,function*(){o.info("TEE connection not initialized, initializing now");let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return h(this,null,function*(){var d;let n=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 */ }`);o.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw o.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new v(c,p)}if(o.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>h(this,null,function*(){o.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(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new u)})),r(new u)}))}catch(c){o.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw o.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return h(this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return h(this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:E({authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,o.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw o.error("start-onboarding: failed",{error:i.error,code:i.code}),new g(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return h(this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return o.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}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(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new u)})),(a=this._authPromise)==null||a.resolve();return}o.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 e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new g(e,s))})}handleOnboardingVerificationFailure(n){return h(this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){o.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(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new P}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return h(this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw o.error("export-signer: failed",{error:a.error,code:a.code}),new y(a.error||"Failed to export private key",a.code)})}};w([T({logger:o,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};export{m as a,l as b};
1
+ import{a as f}from"./chunk-IHMMTMFG.js";import{a as u,b as g,c as v,d as y,e as P}from"./chunk-DCKFFFPG.js";import{a as o}from"./chunk-PSDE5X7P.js";import{a as E,c as w,h}from"./chunk-NU7VF7MC.js";import{validateAPIKey as A,WithLoggerContext as T}from"@crossmint/common-sdk-base";var m=class{constructor(n){this.config=n;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 h(this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return h(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 h(this,null,function*(){o.info("TEE connection not initialized, initializing now");let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return h(this,null,function*(){var d;let n=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 */ }`);o.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw o.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new v(c,p)}if(o.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>h(this,null,function*(){o.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(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new u)})),r(new u)}))}catch(c){o.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw o.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return h(this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return h(this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:E({authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,o.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw o.error("start-onboarding: failed",{error:i.error,code:i.code}),new g(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return h(this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return o.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}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(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new u)})),(a=this._authPromise)==null||a.resolve();return}o.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 e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new g(e,s))})}handleOnboardingVerificationFailure(n){return h(this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){o.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(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new P}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return h(this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw o.error("export-signer: failed",{error:a.error,code:a.code}),new y(a.error||"Failed to export private key",a.code)})}};w([T({logger:o,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};export{m as a,l as b};
@@ -1 +1 @@
1
- import{A as C,B as x,C as A,D as y,E as k,I as w,s as M,v as m,x as b}from"./chunk-7FEY62ID.js";import{a as E}from"./chunk-4ILFMPNK.js";import{d as S}from"./chunk-SCEZVF7J.js";import{h as l}from"./chunk-NU7VF7MC.js";function W(i,o,a,r){return l(this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};E.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new x("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw w(t),new C(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new A(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new y("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new k("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function B(i,o,a,r){return l(this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new b("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,S)),n=yield i.getSignature(o,a),"error"in n)throw w(n),new m(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new M("Signature signing failed");if(!n.outputSignature)throw new m("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return l(this,null,function*(){return new Promise(o=>setTimeout(o,i))})}export{W as a,B as b};
1
+ import{A as C,B as x,C as A,D as y,E as k,I as w,s as M,v as m,x as b}from"./chunk-7FEY62ID.js";import{a as E}from"./chunk-PSDE5X7P.js";import{d as S}from"./chunk-47M4FIGW.js";import{h as l}from"./chunk-NU7VF7MC.js";function W(i,o,a,r){return l(this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};E.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new x("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw w(t),new C(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new A(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new y("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new k("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function B(i,o,a,r){return l(this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new b("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,S)),n=yield i.getSignature(o,a),"error"in n)throw w(n),new m(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new M("Signature signing failed");if(!n.outputSignature)throw new m("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return l(this,null,function*(){return new Promise(o=>setTimeout(o,i))})}export{W as a,B as b};
@@ -1 +1 @@
1
- import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{b as i,c as s}from"./chunk-7FEY62ID.js";import{a as E}from"./chunk-4ILFMPNK.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as R,arbitrum as N,arbitrumNova as p,modeTestnet as h,mode as d,mainnet as f,bsc as W,shape as U,zora as V,zoraSepolia as B,sepolia as y,flowMainnet as H,flowTestnet as v,plume as x,plumeTestnet as b}from"viem/chains";var w=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],D=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.ETHEREUM,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function ee(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return R;case e.ARBITRUM:return N;case e.ARBITRUMNOVA:return p;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return W;case e.SHAPE:return U;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return y;case e.ETHEREUM:return f;case e.FLOW:return H;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return b;case e.PLUME:return x;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA: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 I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.ETHEREUM]:e.ETHEREUM_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function te(t,a){if(!F(t))throw new s(`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,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return E.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;E.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}export{ee as a,I as b,C as c,g as d,F as e,te as f};
1
+ import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{b as i,c as s}from"./chunk-7FEY62ID.js";import{a as E}from"./chunk-PSDE5X7P.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as R,arbitrum as N,arbitrumNova as p,modeTestnet as h,mode as d,mainnet as f,bsc as W,shape as U,zora as V,zoraSepolia as B,sepolia as y,flowMainnet as H,flowTestnet as v,plume as x,plumeTestnet as b}from"viem/chains";var w=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],D=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.ETHEREUM,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function ee(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return R;case e.ARBITRUM:return N;case e.ARBITRUMNOVA:return p;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return W;case e.SHAPE:return U;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return y;case e.ETHEREUM:return f;case e.FLOW:return H;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return b;case e.PLUME:return x;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA: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 I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.ETHEREUM]:e.ETHEREUM_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function te(t,a){if(!F(t))throw new s(`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,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return E.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;E.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}export{ee as a,I as b,C as c,g as d,F as e,te as f};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkLJNSIXGNcjs = require('./chunk-LJNSIXGN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function R(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};_chunkPSK7FYV7cjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new (0, _chunkXZ4NKVEBcjs.B)("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw _chunkXZ4NKVEBcjs.I.call(void 0, t),new (0, _chunkXZ4NKVEBcjs.A)(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new (0, _chunkXZ4NKVEBcjs.C)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunkXZ4NKVEBcjs.D)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new (0, _chunkXZ4NKVEBcjs.E)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function W(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new (0, _chunkXZ4NKVEBcjs.x)("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,_chunkLJNSIXGNcjs.d)),n=yield i.getSignature(o,a),"error"in n)throw _chunkXZ4NKVEBcjs.I.call(void 0, n),new (0, _chunkXZ4NKVEBcjs.v)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunkXZ4NKVEBcjs.s)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunkXZ4NKVEBcjs.v)("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(o=>setTimeout(o,i))})}exports.a = R; exports.b = W;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkBOMJ4MFZcjs = require('./chunk-BOMJ4MFZ.cjs');var _chunkV7LXNAA3cjs = require('./chunk-V7LXNAA3.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function R(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};_chunkBOMJ4MFZcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new (0, _chunkXZ4NKVEBcjs.B)("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw _chunkXZ4NKVEBcjs.I.call(void 0, t),new (0, _chunkXZ4NKVEBcjs.A)(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new (0, _chunkXZ4NKVEBcjs.C)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunkXZ4NKVEBcjs.D)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new (0, _chunkXZ4NKVEBcjs.E)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function W(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new (0, _chunkXZ4NKVEBcjs.x)("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,_chunkV7LXNAA3cjs.d)),n=yield i.getSignature(o,a),"error"in n)throw _chunkXZ4NKVEBcjs.I.call(void 0, n),new (0, _chunkXZ4NKVEBcjs.v)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunkXZ4NKVEBcjs.s)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunkXZ4NKVEBcjs.v)("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(o=>setTimeout(o,i))})}exports.a = R; exports.b = W;