@crossmint/wallets-sdk 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/__tests__/constants.d.cts +1 -1
- package/dist/api/__tests__/constants.d.ts +1 -1
- package/dist/api/__tests__/test-utils.cjs +1 -1
- package/dist/api/__tests__/test-utils.d.cts +1 -1
- package/dist/api/__tests__/test-utils.d.ts +1 -1
- package/dist/api/__tests__/test-utils.js +1 -1
- package/dist/api/client.cjs +1 -1
- package/dist/api/client.d.cts +1 -1
- package/dist/api/client.d.ts +1 -1
- package/dist/api/client.js +1 -1
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.d.cts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/types.d.cts +1 -1
- package/dist/api/types.d.ts +1 -1
- package/dist/chains/chains.cjs +1 -1
- package/dist/chains/chains.js +1 -1
- package/dist/{chunk-2O6HQK34.js → chunk-2L3ALABB.js} +1 -1
- package/dist/chunk-2YZQ4YYU.cjs +1 -0
- package/dist/chunk-3EQ6LL7S.cjs +3 -0
- package/dist/chunk-3HGHIZUM.js +1 -0
- package/dist/chunk-54AGQUDX.js +1 -0
- package/dist/{chunk-ITE2NCJQ.js → chunk-55VVCZZI.js} +1 -1
- package/dist/chunk-5HBCBS5W.cjs +1 -0
- package/dist/{chunk-MDINF2FR.js → chunk-5LN6KXFF.js} +1 -1
- package/dist/{chunk-DKKQWNW2.js → chunk-6MG5B26I.js} +1 -1
- package/dist/chunk-6SVERTV3.js +1 -0
- package/dist/{chunk-LOH2AUJ2.js → chunk-6ZO5Q6UF.js} +1 -1
- package/dist/chunk-7KVV2MJH.js +1 -0
- package/dist/{chunk-UMYBTYNJ.cjs → chunk-AEI5YK44.cjs} +1 -1
- package/dist/chunk-AHCLROCH.cjs +1 -0
- package/dist/{chunk-4OR2XVWE.cjs → chunk-B3LVLCQQ.cjs} +1 -1
- package/dist/{chunk-NXPEGMMQ.cjs → chunk-B7EMVOYB.cjs} +1 -1
- package/dist/chunk-BDDLUP62.cjs +1 -0
- package/dist/{chunk-ABNALSRA.js → chunk-CMGXTYC7.js} +1 -1
- package/dist/{chunk-ROPXBIF4.cjs → chunk-CNF7UPOI.cjs} +1 -1
- package/dist/{chunk-QYWFJC7Q.cjs → chunk-DGBLZC3D.cjs} +1 -1
- package/dist/chunk-DOIIACVT.js +1 -0
- package/dist/chunk-E3H6RZHM.js +1 -0
- package/dist/chunk-EGL3LHTY.js +1 -0
- package/dist/{chunk-7VFS3EJT.js → chunk-FFYOHSGP.js} +1 -1
- package/dist/chunk-FJPAMX7L.js +1 -0
- package/dist/chunk-GSNFNRH2.cjs +1 -0
- package/dist/{chunk-6O4RMHUQ.cjs → chunk-GUP2PIJO.cjs} +1 -1
- package/dist/{chunk-5UAALAXV.js → chunk-GZCR52HV.js} +1 -1
- package/dist/{chunk-RHAM7DUE.cjs → chunk-HHVIOE43.cjs} +1 -1
- package/dist/chunk-IB2JS6WX.js +1 -0
- package/dist/{chunk-7M2KPJVJ.js → chunk-IDNVSMIL.js} +1 -1
- package/dist/{chunk-JLTD3KKU.cjs → chunk-LR4JIGWX.cjs} +1 -1
- package/dist/chunk-LWA3SX6Z.cjs +1 -0
- package/dist/{chunk-JGWGYONV.js → chunk-MB6IDU3A.js} +1 -1
- package/dist/chunk-MRLWVOFK.cjs +1 -0
- package/dist/{chunk-3AVTANVU.cjs → chunk-MTT7UFU3.cjs} +1 -1
- package/dist/chunk-MVQ24ML4.cjs +1 -0
- package/dist/chunk-NOYMQ6J5.cjs +1 -0
- package/dist/{chunk-FWKQEP6I.js → chunk-NPIMFXJ5.js} +1 -1
- package/dist/chunk-NZXYWQE5.js +1 -0
- package/dist/{chunk-Q4EIDR3A.cjs → chunk-OIZ7ZSZ7.cjs} +1 -1
- package/dist/chunk-OOU7QZJ5.js +1 -0
- package/dist/chunk-OWDSSX2P.js +1 -0
- package/dist/{chunk-6EUBBDIV.cjs → chunk-PEXE6P6S.cjs} +1 -1
- package/dist/{chunk-UXWIALMX.cjs → chunk-PTLVEO7E.cjs} +1 -1
- package/dist/{chunk-N3UCY2Y2.cjs → chunk-Q2RVHFFW.cjs} +1 -1
- package/dist/{chunk-JCNK347W.cjs → chunk-Q34P6JFX.cjs} +1 -1
- package/dist/chunk-QRCGBBPU.js +1 -0
- package/dist/chunk-QT4XQUYM.cjs +1 -0
- package/dist/chunk-QVM2QBXE.cjs +1 -0
- package/dist/{chunk-6X5JEJD7.js → chunk-R3SPSOEE.js} +1 -1
- package/dist/{chunk-RFWG2QIH.js → chunk-SR3F22XV.js} +1 -1
- package/dist/{chunk-E4EOD7MP.cjs → chunk-UV6RKGBY.cjs} +1 -1
- package/dist/chunk-X6CVAVC7.cjs +1 -0
- package/dist/chunk-XYTDDT77.js +3 -0
- package/dist/{chunk-RVECUVVA.js → chunk-YBHPAOH7.js} +1 -1
- package/dist/{chunk-Q2454TBL.js → chunk-YHD5NORG.js} +1 -1
- package/dist/chunk-ZMP33IOH.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/logger/index.cjs +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/init.cjs +1 -1
- package/dist/logger/init.js +1 -1
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.d.cts +1 -1
- package/dist/sdk.d.ts +1 -1
- package/dist/sdk.js +1 -1
- package/dist/signers/device.d.cts +1 -1
- package/dist/signers/device.d.ts +1 -1
- package/dist/signers/evm-api-key.d.cts +1 -1
- package/dist/signers/evm-api-key.d.ts +1 -1
- package/dist/signers/evm-external-wallet.d.cts +1 -1
- package/dist/signers/evm-external-wallet.d.ts +1 -1
- package/dist/signers/external-wallet-signer.d.cts +1 -1
- package/dist/signers/external-wallet-signer.d.ts +1 -1
- package/dist/signers/index.cjs +1 -1
- package/dist/signers/index.d.cts +1 -1
- package/dist/signers/index.d.ts +1 -1
- package/dist/signers/index.js +1 -1
- package/dist/signers/non-custodial/index.cjs +1 -1
- package/dist/signers/non-custodial/index.d.cts +1 -1
- package/dist/signers/non-custodial/index.d.ts +1 -1
- package/dist/signers/non-custodial/index.js +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.d.cts +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.d.ts +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-signer.d.cts +1 -1
- package/dist/signers/non-custodial/ncs-signer.d.ts +1 -1
- package/dist/signers/non-custodial/ncs-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.d.cts +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.d.ts +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
- package/dist/signers/passkey.d.cts +1 -1
- package/dist/signers/passkey.d.ts +1 -1
- package/dist/signers/server/assemble-server-signer.cjs +1 -1
- package/dist/signers/server/assemble-server-signer.d.cts +1 -1
- package/dist/signers/server/assemble-server-signer.d.ts +1 -1
- package/dist/signers/server/assemble-server-signer.js +1 -1
- package/dist/signers/server/evm-server-signer.cjs +1 -1
- package/dist/signers/server/evm-server-signer.d.cts +1 -1
- package/dist/signers/server/evm-server-signer.d.ts +1 -1
- package/dist/signers/server/evm-server-signer.js +1 -1
- package/dist/signers/server/helpers/derive-server-signer.cjs +1 -1
- package/dist/signers/server/helpers/derive-server-signer.d.cts +1 -1
- package/dist/signers/server/helpers/derive-server-signer.d.ts +1 -1
- package/dist/signers/server/helpers/derive-server-signer.js +1 -1
- package/dist/signers/server/helpers/index.cjs +1 -1
- package/dist/signers/server/helpers/index.d.cts +1 -1
- package/dist/signers/server/helpers/index.d.ts +1 -1
- package/dist/signers/server/helpers/index.js +1 -1
- package/dist/signers/server/index.cjs +1 -1
- package/dist/signers/server/index.d.cts +1 -1
- package/dist/signers/server/index.d.ts +1 -1
- package/dist/signers/server/index.js +1 -1
- package/dist/signers/server/solana-server-signer.cjs +1 -1
- package/dist/signers/server/solana-server-signer.d.cts +1 -1
- package/dist/signers/server/solana-server-signer.d.ts +1 -1
- package/dist/signers/server/solana-server-signer.js +1 -1
- package/dist/signers/server/stellar-server-signer.cjs +1 -1
- package/dist/signers/server/stellar-server-signer.d.cts +1 -1
- package/dist/signers/server/stellar-server-signer.d.ts +1 -1
- package/dist/signers/server/stellar-server-signer.js +1 -1
- package/dist/signers/solana-api-key.d.cts +1 -1
- package/dist/signers/solana-api-key.d.ts +1 -1
- package/dist/signers/solana-external-wallet.cjs +1 -1
- package/dist/signers/solana-external-wallet.d.cts +1 -1
- package/dist/signers/solana-external-wallet.d.ts +1 -1
- package/dist/signers/solana-external-wallet.js +1 -1
- package/dist/signers/stellar-external-wallet.d.cts +1 -1
- package/dist/signers/stellar-external-wallet.d.ts +1 -1
- package/dist/signers/types.cjs +1 -1
- package/dist/signers/types.d.cts +1 -1
- package/dist/signers/types.d.ts +1 -1
- package/dist/signers/types.js +1 -1
- package/dist/{types-DvahNo1f.d.cts → types-CbJcRrxL.d.cts} +9 -1
- package/dist/{types-Dr1Gx-k4.d.ts → types-CpyIKxWr.d.ts} +9 -1
- package/dist/utils/constants.cjs +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
- package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
- package/dist/utils/device-signers/createDeviceSigner.d.cts +1 -1
- package/dist/utils/device-signers/createDeviceSigner.d.ts +1 -1
- package/dist/utils/device-signers/index.cjs +1 -1
- package/dist/utils/device-signers/index.d.cts +1 -1
- package/dist/utils/device-signers/index.d.ts +1 -1
- package/dist/utils/device-signers/index.js +1 -1
- package/dist/utils/device-signers/storage-partitioning.cjs +1 -0
- package/dist/utils/device-signers/storage-partitioning.d.cts +13 -0
- package/dist/utils/device-signers/storage-partitioning.d.ts +13 -0
- package/dist/utils/device-signers/storage-partitioning.js +1 -0
- package/dist/utils/errors.cjs +1 -1
- package/dist/utils/errors.d.cts +11 -2
- package/dist/utils/errors.d.ts +11 -2
- package/dist/utils/errors.js +1 -1
- package/dist/utils/secure-wipe.cjs +1 -0
- package/dist/utils/secure-wipe.d.cts +7 -0
- package/dist/utils/secure-wipe.d.ts +7 -0
- package/dist/utils/secure-wipe.js +1 -0
- package/dist/utils/server-key-derivation.cjs +1 -1
- package/dist/utils/server-key-derivation.js +1 -1
- package/dist/utils/server-signers/createServerSigner.cjs +1 -1
- package/dist/utils/server-signers/createServerSigner.js +1 -1
- package/dist/utils/server-signers/index.cjs +1 -1
- package/dist/utils/server-signers/index.js +1 -1
- package/dist/utils/signer-locator.d.cts +1 -1
- package/dist/utils/signer-locator.d.ts +1 -1
- package/dist/utils/signer-mapping.d.cts +1 -1
- package/dist/utils/signer-mapping.d.ts +1 -1
- package/dist/utils/signer-validation.cjs +1 -1
- package/dist/utils/signer-validation.js +1 -1
- package/dist/wallets/__tests__/test-helpers.cjs +1 -1
- package/dist/wallets/__tests__/test-helpers.d.cts +1 -1
- package/dist/wallets/__tests__/test-helpers.d.ts +1 -1
- package/dist/wallets/__tests__/test-helpers.js +1 -1
- package/dist/wallets/evm.cjs +1 -1
- package/dist/wallets/evm.d.cts +1 -1
- package/dist/wallets/evm.d.ts +1 -1
- package/dist/wallets/evm.js +1 -1
- package/dist/wallets/solana.cjs +1 -1
- package/dist/wallets/solana.d.cts +1 -1
- package/dist/wallets/solana.d.ts +1 -1
- package/dist/wallets/solana.js +1 -1
- package/dist/wallets/stellar.cjs +1 -1
- package/dist/wallets/stellar.d.cts +1 -1
- package/dist/wallets/stellar.d.ts +1 -1
- package/dist/wallets/stellar.js +1 -1
- package/dist/wallets/types.d.cts +1 -1
- package/dist/wallets/types.d.ts +1 -1
- package/dist/wallets/wallet-factory.cjs +1 -1
- package/dist/wallets/wallet-factory.d.cts +1 -1
- package/dist/wallets/wallet-factory.d.ts +1 -1
- package/dist/wallets/wallet-factory.js +1 -1
- package/dist/wallets/wallet.cjs +1 -1
- package/dist/wallets/wallet.d.cts +13 -7
- package/dist/wallets/wallet.d.ts +13 -7
- package/dist/wallets/wallet.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-2FKIDTGK.js +0 -1
- package/dist/chunk-2Y3AQN2S.cjs +0 -1
- package/dist/chunk-3SVXPFSP.cjs +0 -1
- package/dist/chunk-3VRN3GKQ.js +0 -1
- package/dist/chunk-4B5WUVBN.cjs +0 -1
- package/dist/chunk-4DJWSV7I.cjs +0 -1
- package/dist/chunk-5G45T3H7.js +0 -1
- package/dist/chunk-5OYPWGMX.js +0 -1
- package/dist/chunk-6562ESCJ.cjs +0 -1
- package/dist/chunk-ACI6AVBC.js +0 -3
- package/dist/chunk-BITOMWYZ.js +0 -1
- package/dist/chunk-CCW5NTUF.js +0 -1
- package/dist/chunk-EHMQ5WD7.cjs +0 -1
- package/dist/chunk-GZP2JQ6P.cjs +0 -1
- package/dist/chunk-KFXIIFEJ.cjs +0 -1
- package/dist/chunk-N355UETO.js +0 -1
- package/dist/chunk-NBPZ3T3M.js +0 -1
- package/dist/chunk-OWQZPI3U.cjs +0 -1
- package/dist/chunk-PYIURK5B.js +0 -1
- package/dist/chunk-R6UUHH3F.js +0 -1
- package/dist/chunk-SFYQFNRC.cjs +0 -3
- package/dist/chunk-XNZLCUTY.js +0 -1
- package/dist/chunk-YF5G4U6L.cjs +0 -1
- package/dist/chunk-YGL4ITFK.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGSNFNRH2cjs = require('./chunk-GSNFNRH2.cjs');var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var R={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c= exports.a =class extends _chunk3VYGTPRFcjs.a{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!_chunkGSNFNRH2cjs.a.call(void 0, ))throw new (0, _chunkQVM2QBXEcjs.m)("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=_commonsdkbase.getEnvironmentForKey.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunkLR4JIGWXcjs.a.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 _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunk2GKPWQBQcjs.g.call(void 0, 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=>_chunk2GKPWQBQcjs.g.call(void 0, 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 _ox.WebAuthnP256.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 _ox.WebAuthnP256.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}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as g}from"./chunk-
|
|
1
|
+
import{a,b as g}from"./chunk-QRCGBBPU.js";import{a as s}from"./chunk-SR3F22XV.js";import{g as t}from"./chunk-J3R36SGJ.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let 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:g});if(s.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"}}};export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQ34P6JFXcjs = require('./chunk-Q34P6JFX.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkGUP2PIJOcjs = require('./chunk-GUP2PIJO.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkLR4JIGWXcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkGUP2PIJOcjs.a)(e);this.walletFactory=new (0, _chunkQ34P6JFXcjs.a)(t),_chunkLR4JIGWXcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunkYHV3672Rcjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunk2GKPWQBQcjs.g.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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkZMP33IOHcjs = require('./chunk-ZMP33IOH.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkZMP33IOHcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunkLR4JIGWXcjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunkZMP33IOHcjs.b});if(_chunkLR4JIGWXcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-5LN6KXFF.js";import{a as n}from"./chunk-OQZTL6ZG.js";import{a as t}from"./chunk-E3H6RZHM.js";function h(s){let{secret:o,chain:e,projectId:a,environment:p}=s,c=n(e),r=t(o,a,p,c);return{type:"server",address:i(r,e),keyBytes:r}}export{h as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hkdf as l}from"@noble/hashes/hkdf";import{sha256 as f}from"@noble/hashes/sha2";import{bytesToHex as E,hexToBytes as h}from"@noble/hashes/utils";var m="crossmint",g="xmsk1_";function T(t,r,s,n){let e=d(t),i=h(e),o=u(n),c=`${r}:${s}:${n}-${o}`;return l(f,i,m,c,32)}function _(t,r,s,n){let e=d(t),i=h(e),o=`${r}:${s}:${n}-alias`,c=l(f,i,m,o,17);return`s-${E(c).slice(0,34)}`}var a=64;function d(t){let r=t.startsWith(g)?t.slice(g.length):t;if(r.length!==a)throw new Error(`Invalid server signer secret: expected ${a}-char hex string (256-bit), got ${r.length} chars`);return r}function u(t){return t==="solana"||t==="stellar"?"ed25519":"secp256k1"}export{T as a,_ as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CrossmintSDKError as t,WalletErrorCode as e}from"@crossmint/common-sdk-base";var o=class extends t{constructor(s,r){super(s,e.API_KEY_INVALID,r)}},c=class extends t{constructor(s,r){super(s,e.ENVIRONMENT_INVALID,r)}},I=class extends t{constructor(s,r){super(s,e.WALLET_CREATION_FAILED,r)}},p=class extends t{constructor(s,r){super(s,e.WALLET_TYPE_INVALID,r)}},i=class extends t{constructor(s,r){super(s,e.WALLET_NOT_AVAILABLE,r)}},x=class extends t{constructor(s,r){super(s,e.WALLET_NOT_AVAILABLE,r)}},N=class extends t{constructor(s,r){super(s,e.WALLET_CREATION_FAILED,r)}},A=class extends t{constructor(s,r){super(s,e.WALLET_TYPE_INVALID,r)}},g=class extends t{constructor(s,r){super(s,e.SIGNER_INVALID,r)}},u=class extends t{constructor(s,r){super(s,e.SIGNER_INVALID,r)}},f="DEVICE_SIGNER_NOT_SUPPORTED",E=class extends t{constructor(s,r){super(s,e.SIGNER_INVALID,r)}},_=class extends t{constructor(s,r){super(s,e.ENVIRONMENT_INVALID,r)}},L=class extends t{constructor(s,r){super(s,e.MESSAGE_INVALID,r)}},T=class extends t{constructor(s,r){super(s,e.MESSAGE_INVALID,r)}},l=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},a=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},d=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},D=class extends t{constructor(s,r){super(s,e.NO_SIGNATURE,r)}},S=class extends t{constructor(s,r){super(s,e.NO_SIGNATURE,r)}},R=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},O=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},C=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},G=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},V=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},F=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},P=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},W=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},M=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},U=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},m=class extends t{constructor(s,r){super(s,e.RECIPIENT_ADDRESS_INVALID,r)}};export{o as a,c as b,I as c,p as d,i as e,x as f,N as g,A as h,g as i,u as j,f as k,E as l,_ as m,L as n,T as o,l as p,a as q,d as r,D as s,S as t,R as u,O as v,C as w,G as x,V as y,F as z,P as A,W as B,M as C,U as D,m as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-YHD5NORG.js";import{a as s}from"./chunk-N4IWDL6M.js";import{a as l}from"./chunk-6ZO5Q6UF.js";import{a,b as i}from"./chunk-SR3F22XV.js";import{g as r}from"./chunk-J3R36SGJ.js";import{createCrossmint as C}from"@crossmint/common-sdk-base";import{WebAuthnP256 as p}from"ox";var o=class c{constructor(e){i(e.apiKey);let t=new l(e);this.walletFactory=new n(t),a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return r(this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return r(this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return r(this,null,function*(){return yield s(e,t)})}createPasskeySigner(e){return r(this,null,function*(){let t=yield p.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};export{C as a,o as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function l(...f){for(let n of f)n!=null&&n.fill(0)}export{l as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});function a(){if(typeof navigator=="undefined")return!1;let t=navigator.userAgent;if(!t)return!1;let r=t.match(/Chrome\/(\d+)/);if(r!=null)return parseInt(r[1],10)>=115;let e=t.match(/Firefox\/(\d+)/);return e!=null?parseInt(e[1],10)>=103:!!/Safari\/\d+/.test(t)}exports.a = a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunkQ2RVHFFWcjs = require('./chunk-Q2RVHFFW.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkQ2RVHFFWcjs.c,version:_chunkQ2RVHFFWcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkLR4JIGWXcjs.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?_chunkLR4JIGWXcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkLR4JIGWXcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkLR4JIGWXcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkLR4JIGWXcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.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?_chunkLR4JIGWXcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkLR4JIGWXcjs.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, _chunkQVM2QBXEcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkQVM2QBXEcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
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{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{b as i,c as s}from"./chunk-EGL3LHTY.js";import{a as E}from"./chunk-SR3F22XV.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
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.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, _chunkQVM2QBXEcjs.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, _chunkQVM2QBXEcjs.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 _chunkLR4JIGWXcjs.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;_chunkLR4JIGWXcjs.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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,b as i,c as a}from"./chunk-EM3D5Q3A.js";import{a as n}from"./chunk-FJPAMX7L.js";import{g as t}from"./chunk-J3R36SGJ.js";var o=class{constructor(e){this.type="server";let r=i(e.derivedKeyBytes);this._address=s(r.publicKey),this._locator=e.locator,this.secretKey=r.secretKey,n(e.derivedKeyBytes)}address(){return this._address}locator(){return this._locator}signMessage(e){return t(this,null,function*(){if(!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw new Error("StellarServerSigner.signMessage: expected a base64-encoded string");let r=Buffer.from(e,"base64"),c=a(r,this.secretKey);return{signature:Buffer.from(c).toString("base64")}})}signTransaction(e){return t(this,null,function*(){return yield this.signMessage(e)})}};export{o as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as o}from"./chunk-
|
|
1
|
+
import{a as s,b as o}from"./chunk-QRCGBBPU.js";import{a as r}from"./chunk-SR3F22XV.js";import{g as t}from"./chunk-J3R36SGJ.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();r.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};export{a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQ2RVHFFWcjs = require('./chunk-Q2RVHFFW.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkQ2RVHFFWcjs.c,packageVersion:_chunkQ2RVHFFWcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});function e(...f){for(let n of f)n!=null&&n.fill(0)}exports.a = e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as a}from"./chunk-
|
|
1
|
+
import{g as a}from"./chunk-EGL3LHTY.js";import{isEmailValid as c}from"@crossmint/common-sdk-auth";var m=(n,t,o)=>`Wallet signer configuration mismatch at "${n}" - expected "${o}" from existing wallet but found "${t}"`;function u(n){let o=n.toLowerCase().split("@"),r=o[1],i=r==="googlemail.com",e=(i||r==="gmail.com")&&o[0].includes(".");return i&&(o[1]="gmail.com"),e&&(o[0]=o[0].replace(/\./g,"")),`${o[0]}@${o[1]}`}function f(n){return/^0x[0-9a-fA-F]+$/.test(n)?BigInt(n).toString():n}function l(n,t=""){if(typeof n=="string"){if(c(n))return u(n);if(t.endsWith(".x")||t.endsWith(".y"))return f(n)}return n}function d(n,t,o=""){if(n!==t){if(n==null||t==null)throw new Error(`Cannot compare null or undefined signer configs at path: ${o}`);for(let r of Object.keys(n)){if(!(r in t))continue;let i=o?`${o}.${r}`:r,s=n[r],e=t[r];if(typeof s=="object"&&s!==null&&typeof e=="object"&&e!==null)d(s,e,i);else if(l(s,i)!==l(e,i))throw new a(m(i,s,e))}}}export{l as a,d as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLWA3SX6Zcjs = require('./chunk-LWA3SX6Z.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _accounts = require('viem/accounts');var _utils = require('@noble/hashes/utils');var s=class{constructor(r){this.type="server";this.account=_accounts.privateKeyToAccount.call(void 0, `0x${_utils.bytesToHex.call(void 0, r.derivedKeyBytes)}`),this._address=this.account.address,this._locator=r.locator,_chunkLWA3SX6Zcjs.a.call(void 0, r.derivedKeyBytes)}address(){return this._address}locator(){return this._locator}signMessage(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(!r.startsWith("0x"))throw new Error(`EVMServerSigner.signMessage expects a 0x-prefixed hex string, got: ${r.slice(0,10)}...`);return{signature:yield this.account.signMessage({message:{raw:r}})}})}signTransaction(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.signMessage(r)})}};exports.a = s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3EQ6LL7Scjs = require('./chunk-3EQ6LL7S.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunk3EQ6LL7Scjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk3EQ6LL7Scjs.a.getOptions(e),alias:e.alias,recovery:_chunk3EQ6LL7Scjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunk3EQ6LL7Scjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunk3EQ6LL7Scjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk3EQ6LL7Scjs.a.getInitialSigners(e)},_chunk3EQ6LL7Scjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidStellarAddress.call(void 0, e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d;_chunkLR4JIGWXcjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkLR4JIGWXcjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return _chunkLR4JIGWXcjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return _chunkLR4JIGWXcjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunkLR4JIGWXcjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunkLR4JIGWXcjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunkLR4JIGWXcjs.a.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunkQVM2QBXEcjs.w)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkLR4JIGWXcjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunkLR4JIGWXcjs.a.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new (0, _chunkQVM2QBXEcjs.w)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunk2GKPWQBQcjs.a.call(void 0, {transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new (0, _chunkQVM2QBXEcjs.w)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.requireSigner().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}exports.a = h;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQT4XQUYMcjs = require('./chunk-QT4XQUYM.cjs');var _chunkDGBLZC3Dcjs = require('./chunk-DGBLZC3D.cjs');var _chunkB3LVLCQQcjs = require('./chunk-B3LVLCQQ.cjs');var _chunkB7EMVOYBcjs = require('./chunk-B7EMVOYB.cjs');var _chunkSPTXAOFRcjs = require('./chunk-SPTXAOFR.cjs');var _chunkGEY3BU62cjs = require('./chunk-GEY3BU62.cjs');var _chunkPHPBBEXUcjs = require('./chunk-PHPBBEXU.cjs');var _chunkA33BEWR7cjs = require('./chunk-A33BEWR7.cjs');var _chunkOGP7B5O3cjs = require('./chunk-OGP7B5O3.cjs');var _chunkIJ632UXDcjs = require('./chunk-IJ632UXD.cjs');var _chunkUV6RKGBYcjs = require('./chunk-UV6RKGBY.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');function M(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkDGBLZC3Dcjs.a)(e):r==="stellar"?new (0, _chunkB3LVLCQQcjs.a)(e):new (0, _chunkB7EMVOYBcjs.a)(e);case"api-key":return r==="solana"?new (0, _chunkIJ632UXDcjs.a)(e):new (0, _chunkPHPBBEXUcjs.a)(e);case"external-wallet":return r==="solana"?new (0, _chunkUV6RKGBYcjs.a)(e):r==="stellar"?new (0, _chunkSPTXAOFRcjs.a)(e):new (0, _chunkA33BEWR7cjs.a)(e);case"server":return _chunkQT4XQUYMcjs.a.call(void 0, r,e);case"passkey":return new (0, _chunkOGP7B5O3cjs.a)(e);case"device":if(n==null)throw new (0, _chunkQVM2QBXEcjs.g)("Device signer key storage is required for device signers");return new (0, _chunkGEY3BU62cjs.a)(e,n)}}exports.a = M;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5FH7WFWLcjs = require('./chunk-5FH7WFWL.cjs');var _chunkLWA3SX6Zcjs = require('./chunk-LWA3SX6Z.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var o=class{constructor(e){this.type="server";let r=_chunk5FH7WFWLcjs.b.call(void 0, e.derivedKeyBytes);this._address=_chunk5FH7WFWLcjs.a.call(void 0, r.publicKey),this._locator=e.locator,this.secretKey=r.secretKey,_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes)}address(){return this._address}locator(){return this._locator}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw new Error("StellarServerSigner.signMessage: expected a base64-encoded string");let r=Buffer.from(e,"base64"),c=_chunk5FH7WFWLcjs.c.call(void 0, r,this.secretKey);return{signature:Buffer.from(c).toString("base64")}})}signTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.signMessage(e)})}};exports.a = o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as o}from"./chunk-
|
|
1
|
+
import{a as s,b as o}from"./chunk-QRCGBBPU.js";import{a as r}from"./chunk-SR3F22XV.js";import{g as t}from"./chunk-J3R36SGJ.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(){if(typeof navigator=="undefined")return!1;let t=navigator.userAgent;if(!t)return!1;let r=t.match(/Chrome\/(\d+)/);if(r!=null)return parseInt(r[1],10)>=115;let e=t.match(/Firefox\/(\d+)/);return e!=null?parseInt(e[1],10)>=103:!!/Safari\/\d+/.test(t)}export{o as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunk5FH7WFWLcjs = require('./chunk-5FH7WFWL.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunk5FH7WFWLcjs = require('./chunk-5FH7WFWL.cjs');var _chunk2YZQ4YYUcjs = require('./chunk-2YZQ4YYU.cjs');var _accounts = require('viem/accounts');var _utils = require('@noble/hashes/utils');var _web3js = require('@solana/web3.js');function y(r,e){switch(_chunkENU3EKBGcjs.a.call(void 0, e)){case"evm":return _accounts.privateKeyToAccount.call(void 0, `0x${_utils.bytesToHex.call(void 0, r)}`).address;case"solana":return _web3js.Keypair.fromSeed(r).publicKey.toBase58();case"stellar":return _chunk5FH7WFWLcjs.a.call(void 0, _chunk5FH7WFWLcjs.b.call(void 0, r).publicKey)}}function x(r,e,i,t){if(typeof window!="undefined")throw new Error("Server signers can only be used from server-side code.");let s=_chunkENU3EKBGcjs.a.call(void 0, e),n=_chunk2YZQ4YYUcjs.a.call(void 0, r.secret,i,t,s),a=y(n,e);return{derivedKeyBytes:n,derivedAddress:a}}function B(r,e,i,t){if(typeof window!="undefined")throw new Error("Server signers can only be used from server-side code.");let s=_chunkENU3EKBGcjs.a.call(void 0, e),n=_chunk2YZQ4YYUcjs.a.call(void 0, r.secret,i,t,s),a=y(n,e),c={derivedKeyBytes:n,derivedAddress:a},p=typeof e=="string"?e:String(e);if(s==="evm"&&p!=="evm"){let v=_chunk2YZQ4YYUcjs.a.call(void 0, r.secret,i,t,p),m=y(v,e);return{primary:c,legacy:{derivedKeyBytes:v,derivedAddress:m}}}return{primary:c,legacy:null}}exports.a = y; exports.b = x; exports.c = B;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-FJPAMX7L.js";import{g as e}from"./chunk-J3R36SGJ.js";import{privateKeyToAccount as i}from"viem/accounts";import{bytesToHex as a}from"@noble/hashes/utils";var s=class{constructor(r){this.type="server";this.account=i(`0x${a(r.derivedKeyBytes)}`),this._address=this.account.address,this._locator=r.locator,t(r.derivedKeyBytes)}address(){return this._address}locator(){return this._locator}signMessage(r){return e(this,null,function*(){if(!r.startsWith("0x"))throw new Error(`EVMServerSigner.signMessage expects a 0x-prefixed hex string, got: ${r.slice(0,10)}...`);return{signature:yield this.account.signMessage({message:{raw:r}})}})}signTransaction(r){return e(this,null,function*(){return yield this.signMessage(r)})}};export{s as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i=class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o=class extends Error{constructor(n,r){super(n),this.name="SignerStatusError",this.code=r}},a=class extends Error{constructor(n,r){super(n),this.name="KeyExportError",this.code=r}};function l(e){return e.type==="server"&&!("secret"in e)}function p(e){return e._exportPrivateKey!==void 0}export{t as a,i as b,o as c,a as d,l as e,p as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _commonsdkauth = require('@crossmint/common-sdk-auth');var m=(n,t,o)=>`Wallet signer configuration mismatch at "${n}" - expected "${o}" from existing wallet but found "${t}"`;function u(n){let o=n.toLowerCase().split("@"),r=o[1],i=r==="googlemail.com",e=(i||r==="gmail.com")&&o[0].includes(".");return i&&(o[1]="gmail.com"),e&&(o[0]=o[0].replace(/\./g,"")),`${o[0]}@${o[1]}`}function f(n){return/^0x[0-9a-fA-F]+$/.test(n)?BigInt(n).toString():n}function l(n,t=""){if(typeof n=="string"){if(_commonsdkauth.isEmailValid.call(void 0, n))return u(n);if(t.endsWith(".x")||t.endsWith(".y"))return f(n)}return n}function d(n,t,o=""){if(n!==t){if(n==null||t==null)throw new Error(`Cannot compare null or undefined signer configs at path: ${o}`);for(let r of Object.keys(n)){if(!(r in t))continue;let i=o?`${o}.${r}`:r,s=n[r],e=t[r];if(typeof s=="object"&&s!==null&&typeof e=="object"&&e!==null)d(s,e,i);else if(l(s,i)!==l(e,i))throw new (0, _chunkQVM2QBXEcjs.g)(m(i,s,e))}}}exports.a = l; exports.b = d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk3EQ6LL7Scjs = require('./chunk-3EQ6LL7S.cjs');var _chunkUV6RKGBYcjs = require('./chunk-UV6RKGBY.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunk3EQ6LL7Scjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk3EQ6LL7Scjs.a.getOptions(e),alias:e.alias,recovery:_chunk3EQ6LL7Scjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunk3EQ6LL7Scjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunk3EQ6LL7Scjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk3EQ6LL7Scjs.a.getInitialSigners(e)},_chunk3EQ6LL7Scjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, e.address))throw new Error("Wallet is not a Solana wallet");return new o(e)}sendTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,p;_chunkLR4JIGWXcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return _chunkLR4JIGWXcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new (0, _chunkUV6RKGBYcjs.a)({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return _chunkLR4JIGWXcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.requireSigner().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=_bs582.default.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new (0, _chunkQVM2QBXEcjs.w)(JSON.stringify(i));return i})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;exports.a = f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.6.0";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =500;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPEXE6P6Scjs = require('./chunk-PEXE6P6S.cjs');var _chunk3EQ6LL7Scjs = require('./chunk-3EQ6LL7S.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkOIZ7ZSZ7cjs = require('./chunk-OIZ7ZSZ7.cjs');var _chunkHHVIOE43cjs = require('./chunk-HHVIOE43.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.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.",u= exports.a =class{constructor(r){this.apiClient=r}getWallet(r,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i,t;if(typeof r=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkQVM2QBXEcjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunkQVM2QBXEcjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");i=r,t=e}else{if(this.apiClient.isServerSide)throw new (0, _chunkQVM2QBXEcjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");t=r,i=this.getWalletLocator(t)}let a=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{chain:_chunkHHVIOE43cjs.f.call(void 0, t.chain,this.apiClient.environment)});_chunkLR4JIGWXcjs.a.info("walletFactory.getWallet.start");let n=yield this.apiClient.getWallet(i);if("error"in n)throw _chunkLR4JIGWXcjs.a.warn("walletFactory.getWallet.notFound",{error:n.error}),new (0, _chunkQVM2QBXEcjs.e)(JSON.stringify(n));return _chunkLR4JIGWXcjs.a.info("walletFactory.getWallet.success",{address:n.address}),yield this.createWalletInstance(n,a)})}createWallet(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,c,d,h,C,p,F,P;let e=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},r),{chain:_chunkHHVIOE43cjs.f.call(void 0, r.chain,this.apiClient.environment)});if(yield(d=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:d.call(c),_chunkLR4JIGWXcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkLR4JIGWXcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkQVM2QBXEcjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let t=((h=e.options)==null?void 0:h.deviceSignerKeyStorage)!=null&&e.chain!=="solana"?this.ensureDeviceSignerInSigners(e):(C=e.signers)!=null?C:[],a=yield this.registerSigners(t,e.chain,(p=e.options)==null?void 0:p.deviceSignerKeyStorage),n;if(e.recovery.type==="passkey"&&e.recovery.id==null)n=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:I}=_chunkOIZ7ZSZ7cjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);n={type:"server",address:I}}else n=e.recovery;let s=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {adminSigner:n},e.plugins?{plugins:e.plugins}:{}),a!=null?{delegatedSigners:a}:{}),owner:(F=e.owner)!=null?F:void 0,alias:(P=e.alias)!=null?P:void 0});if("error"in s)throw _chunkLR4JIGWXcjs.a.error("walletFactory.createWallet.error",{error:s.error}),new (0, _chunkQVM2QBXEcjs.g)(JSON.stringify(s));return _chunkLR4JIGWXcjs.a.info("walletFactory.createWallet.success",{address:s.address}),yield this.createWalletInstance(s,e)})}createWalletInstance(r,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var h,C;this.validateExistingWalletConfig(r,e);let i=e,t=r.config.adminSigner,a=((h=i.recovery)==null?void 0:h.type)==="server"||((C=i.recovery)==null?void 0:C.type)==="external-wallet"?i.recovery:t,n=r.config.delegatedSigners,s=n;s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet")&&(s=i.signers);let o=t.type==="server"&&"address"in t&&!("secret"in t)?t.address:void 0,c=(n!=null?n:[]).filter(p=>p.type==="server"&&"address"in p&&!("secret"in p)).map(p=>p.address),d=new (0, _chunk3EQ6LL7Scjs.a)({chain:e.chain,address:r.address,owner:r.owner,options:e.options,alias:e.alias,recovery:a,apiRecoveryServerSignerAddress:o,apiDelegatedServerSignerAddresses:c,signers:s!=null?s:[]},this.apiClient);return yield d.waitForInit(),d})}getWalletLocator(r){return`me:${this.getChainType(r.chain)}:smart`+(r.alias!=null?`:alias:${r.alias}`:"")}createPasskeySigner(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;if(r.type!=="passkey")throw new Error("Signer is not a passkey");let e=(t=r.name)!=null?t:`Crossmint Wallet ${Date.now()}`,i=r.onCreatePasskey?yield r.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:i.id,name:e,publicKey:{x:i.publicKey.x.toString(),y:i.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(r){var t;let e=(t=r.signers)!=null?t:[];return e.some(a=>a.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(r,e){if(e.owner!=null&&r.owner!=null&&_chunkPEXE6P6Scjs.a.call(void 0, e.owner)!==_chunkPEXE6P6Scjs.a.call(void 0, r.owner))throw new (0, _chunkQVM2QBXEcjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&r.chainType!=="solana"||e.chain!=="solana"&&r.chainType==="solana"||e.chain==="stellar"&&r.chainType!=="stellar"||e.chain!=="stellar"&&r.chainType==="stellar")throw new (0, _chunkQVM2QBXEcjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${r.chainType}.`);if(r.type!=="smart")return;let i=e;if(i.recovery!=null||i.signers!=null){let t=r.config,a=t==null?void 0:t.adminSigner;if(i.recovery!=null&&a!=null){if(i.recovery.type!==a.type)throw new (0, _chunkQVM2QBXEcjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkPEXE6P6Scjs.b.call(void 0, i.recovery,a)}let n=i.signers;n!=null&&this.validateSigners(r,n,e.chain)}}validateSigners(r,e,i){let t=r.config,a=t==null?void 0:t.delegatedSigners;if(e.length!==0){if(a==null||a.length===0)throw new (0, _chunkQVM2QBXEcjs.g)(`${e.length} signer(s) specified, but wallet "${r.address}" has no signers. ${$}`);for(let n of e){let s=a.find(o=>{if(this.isMatchingPasskeySigner(n,o,t)||o.type==="device"&&n.type==="device")return!0;if(n.type==="server"){let{primary:c,legacy:d}=_chunkOIZ7ZSZ7cjs.c.call(void 0, n,i,this.apiClient.projectId,this.apiClient.environment);return o.locator===`server:${c.derivedAddress}`||d!=null&&o.locator===`server:${d.derivedAddress}`}return o.locator===_chunkNX256LAHcjs.a.call(void 0, n)});if(s==null){let o=a.map(c=>c.locator).join(", ");throw new (0, _chunkQVM2QBXEcjs.g)(`Signer '${n.type}' does not exist in wallet "${r.address}". Available signers: ${o}. ${$}`)}_chunkPEXE6P6Scjs.b.call(void 0, n,s)}}}isMatchingPasskeySigner(r,e,i){var a,n;let t=((n=(a=i.delegatedSigners)==null?void 0:a.filter(s=>s.type==="passkey").length)!=null?n:0)+(i.adminSigner.type==="passkey"?1:0);if(r.type==="passkey"){if(r.id==null&&t===1)return e.type==="passkey";if(r.id==null&&t>1)throw new (0, _chunkQVM2QBXEcjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(r,e,i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;return yield Promise.all((t=r==null?void 0:r.map(a=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(a.type==="passkey")return a.id==null?{signer:yield this.createPasskeySigner(a)}:{signer:a};if(a.type==="device"){if(a.publicKey!=null)return{signer:{type:"device",publicKey:a.publicKey,name:a.name}};if(a.locator!=null)return{signer:a.locator};if(i==null)throw new (0, _chunkQVM2QBXEcjs.g)("Device signer key storage is required for device signers");let n=yield _chunkYHV3672Rcjs.a.call(void 0, i);return{signer:{type:"device",publicKey:n.publicKey,name:n.name}}}if(a.type==="server"&&e!=null){let{derivedAddress:n}=_chunkOIZ7ZSZ7cjs.b.call(void 0, a,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${n}`}}return{signer:_chunkNX256LAHcjs.a.call(void 0, a)}})))!=null?t:[])})}getChainType(r){return r==="solana"?"solana":r==="stellar"?"stellar":"evm"}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"walletFactory.getWallet",buildContext(r,e){if(typeof e[0]=="string"){let t=e[1];return{walletLocator:e[0],chain:t==null?void 0:t.chain}}let i=e[0];return{chain:i==null?void 0:i.chain}}})],u.prototype,"getWallet",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"walletFactory.createWallet",buildContext(r,e){return{chain:e[0].chain}}})],u.prototype,"createWallet",1);exports.a = u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"./chunk-O6VBO7KG.js";import{a as l,b as f,c as w,d as v}from"./chunk-OWDSSX2P.js";import{a as n}from"./chunk-SR3F22XV.js";import{c as E,g as d}from"./chunk-J3R36SGJ.js";import{validateAPIKey as y,WithLoggerContext as A}from"@crossmint/common-sdk-base";var p=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=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 d(this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=y(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new m({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return d(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 d(this,null,function*(){n.info("TEE connection not initialized, initializing now");let r=y(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new m({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");n.info("TEE connection initialized successfully")})}handleAuthRequired(){return d(this,null,function*(){var u;let r=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);n.info("get-status: sending request");let t=Date.now(),e=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:g}),i=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let o=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",a=(e==null?void 0:e.status)==="error"?e.code:void 0;throw n.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:a,durationMs:i}),new w(o,a)}if(n.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:i}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;n.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:c,resolve:s,reject:h}=this.createAuthPromise();if(this._authPromise={promise:c,resolve:s,reject:h},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>d(this,null,function*(){n.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>{var o;return(o=this._authPromise)==null?void 0:o.reject(new l)})),h(new l)}))}catch(o){n.error("handleAuthRequired error",{error:o}),h(o)}try{yield c}catch(o){throw n.error("handleAuthRequired promise error",{error:o}),o}})}ensureAuthenticated(){return d(this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((i,c)=>{r=i,t=c}),resolve:r,reject:t}}sendMessageWithOtp(){return d(this,null,function*(){var s,h;let r=yield this.getTEEConnection(),t=this.getAuthId();n.info("start-onboarding: sending request");let e=Date.now(),i=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:g}),c=Date.now()-e;if(n.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:c}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error"){n.error("start-onboarding: failed",{error:i.error,code:i.code});let u=new f(i.error||"Failed to initiate OTP process.",i.code);(h=this._authPromise)==null||h.reject(u)}})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return d(this,null,function*(){var s,h,u,o;let t;try{let a=yield this.getTEEConnection();n.info("complete-onboarding: sending request");let P=Date.now();t=yield a.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:r}}},options:g}),n.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-P})}catch(a){throw n.error("complete-onboarding: error",{error:a}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(a),a}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(),a=>this.verifyOtp(a),()=>{var a;return(a=this._authPromise)==null?void 0:a.reject(new l)})),(u=this._authPromise)==null||u.resolve();return}n.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0}),this._needsAuth=!0;let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",i=(t==null?void 0:t.status)==="error"?t.code:void 0,c=new f(e,i);throw(o=this._authPromise)==null||o.reject(c),c})}_exportPrivateKey(r,t){return d(this,null,function*(){yield this.handleAuthRequired();let e=this.getJwtOrThrow(),{scheme:i,encoding:c}=this.getChainKeyParams();if(t!=null){let h=r.on("event:key-exported",u=>{r.off(h),u.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:i,encoding:c,walletAddress:this.config.address,authId:this.getAuthId()}},options:g});if((s==null?void 0:s.status)==="error")throw n.error("export-signer: failed",{error:s.error,code:s.code}),new v(s.error||"Failed to export private key",s.code)})}};E([A({logger:n,methodName:"handleAuthRequired"})],p.prototype,"handleAuthRequired",1);var g={timeoutMs:3e4};export{p as a,g as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkMRLWVOFKcjs = require('./chunk-MRLWVOFK.cjs');var _chunkAHCLROCHcjs = require('./chunk-AHCLROCH.cjs');var _chunkNOYMQ6J5cjs = require('./chunk-NOYMQ6J5.cjs');function l(a,e){switch(_chunkENU3EKBGcjs.a.call(void 0, a)){case"evm":return new (0, _chunkMRLWVOFKcjs.a)(e);case"solana":return new (0, _chunkAHCLROCHcjs.a)(e);case"stellar":return new (0, _chunkNOYMQ6J5cjs.a)(e)}}exports.a = l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.API_KEY_INVALID,r)}},c= exports.b =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.ENVIRONMENT_INVALID,r)}},I= exports.c =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_CREATION_FAILED,r)}},p= exports.d =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_TYPE_INVALID,r)}},i= exports.e =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_NOT_AVAILABLE,r)}},x= exports.f =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_NOT_AVAILABLE,r)}},N= exports.g =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_CREATION_FAILED,r)}},A= exports.h =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_TYPE_INVALID,r)}},g= exports.i =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNER_INVALID,r)}},u= exports.j =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNER_INVALID,r)}},K= exports.k ="DEVICE_SIGNER_NOT_SUPPORTED",E= exports.l =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNER_INVALID,r)}},_= exports.m =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.ENVIRONMENT_INVALID,r)}},L= exports.n =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.MESSAGE_INVALID,r)}},T= exports.o =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.MESSAGE_INVALID,r)}},l= exports.p =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},a= exports.q =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},d= exports.r =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},D= exports.s =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_SIGNATURE,r)}},S= exports.t =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_SIGNATURE,r)}},R= exports.u =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},O= exports.v =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},C= exports.w =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},G= exports.x =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},V= exports.y =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},F= exports.z =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},P= exports.A =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},W= exports.B =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},M= exports.C =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},U= exports.D =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},m= exports.E =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.RECIPIENT_ADDRESS_INVALID,r)}};exports.a = o; exports.b = c; exports.c = I; exports.d = p; exports.e = i; exports.f = x; exports.g = N; exports.h = A; exports.i = g; exports.j = u; exports.k = K; exports.l = E; exports.m = _; exports.n = L; exports.o = T; exports.p = l; exports.q = a; exports.r = d; exports.s = D; exports.t = S; exports.u = R; exports.v = O; exports.w = C; exports.x = G; exports.y = V; exports.z = F; exports.A = P; exports.B = W; exports.C = M; exports.D = U; exports.E = m;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"./chunk-OQZTL6ZG.js";import{a as n}from"./chunk-
|
|
1
|
+
import{a as r}from"./chunk-OQZTL6ZG.js";import{a as n}from"./chunk-OOU7QZJ5.js";import{a as i}from"./chunk-7KVV2MJH.js";import{a as t}from"./chunk-IB2JS6WX.js";function c(a,e){switch(r(a)){case"evm":return new n(e);case"solana":return new i(e);case"stellar":return new t(e)}}export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as n,c as i}from"./chunk-
|
|
1
|
+
import{b as n,c as i}from"./chunk-3HGHIZUM.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
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkSCEPJO4Qcjs = require('./chunk-SCEPJO4Q.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkSCEPJO4Qcjs = require('./chunk-SCEPJO4Q.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var l=class extends _chunkSCEPJO4Qcjs.a{constructor(n){super(n),this.onSign=n.onSign}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for solana external wallet signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.onSign==null)throw new Error("[SolanaExternalWalletSigner] No onSign callback provided. Pass an onSign callback when configuring the external wallet signer.");let c=_bs582.default.decode(n),g=_web3js.VersionedTransaction.deserialize(c),t=yield this.onSign(g),d=new (0, _web3js.PublicKey)(this._address),i=t.message.staticAccountKeys.findIndex(m=>m.equals(d));if(i===-1)throw new (0, _chunkQVM2QBXEcjs.C)("Wallet public key not found in transaction signers");let r=t.signatures[i];if(r==null)throw new (0, _chunkQVM2QBXEcjs.C)("No valid signature found in the transaction");let u=new Uint8Array(Object.values(r));return{signature:_bs582.default.encode(u)}})}};exports.a = l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOIZ7ZSZ7cjs = require('./chunk-OIZ7ZSZ7.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunk2YZQ4YYUcjs = require('./chunk-2YZQ4YYU.cjs');function g(s){let{secret:o,chain:e,projectId:a,environment:p}=s,c=_chunkENU3EKBGcjs.a.call(void 0, e),r=_chunk2YZQ4YYUcjs.a.call(void 0, o,a,p,c);return{type:"server",address:_chunkOIZ7ZSZ7cjs.a.call(void 0, r,e),keyBytes:r}}exports.a = g;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as ve}from"./chunk-N4IWDL6M.js";import{b as Y,c as Q}from"./chunk-KZMDZJGM.js";import{a as O}from"./chunk-GOXB2RBF.js";import{a as _}from"./chunk-55VVCZZI.js";import{c as Se}from"./chunk-5LN6KXFF.js";import{a as pe}from"./chunk-QRCGBBPU.js";import{a as he,b as X,e as I}from"./chunk-OWDSSX2P.js";import{a as P}from"./chunk-FJPAMX7L.js";import{f as ue}from"./chunk-GZCR52HV.js";import{A as le,B as ce,C as de,E as ge,d as Z,e as ee,j as J,k as re,l as j,q as ie,t as V,u as te,v as ne,w as se,x as z,y as ae,z as oe}from"./chunk-EGL3LHTY.js";import{a}from"./chunk-SR3F22XV.js";import{d as M}from"./chunk-3HGHIZUM.js";import{a as b,b as $,c as x,d as t,e as T,f as d,g as u}from"./chunk-J3R36SGJ.js";import{isValidAddress as fe,WithLoggerContext as L}from"@crossmint/common-sdk-base";var p,A,f,S,k,y,F,W,E,N,B,q,K,H,R=class{constructor(e,r){T(this,p);T(this,A);T(this,f);T(this,S);T(this,k);T(this,y,!1);T(this,F,!1);T(this,W,null);T(this,E,null);T(this,N,null);T(this,B,[]);T(this,q);T(this,K,null);T(this,H,!1);let{chain:i,address:n,owner:o,options:g,alias:s,recovery:l,apiRecoveryServerSignerAddress:c,apiDelegatedServerSignerAddresses:h,signers:v,signer:w}=e;d(this,f,r),this.chain=i,this.address=n,this.owner=o,d(this,A,g),this.alias=s,d(this,S,l),c!=null?d(this,N,c):l.type==="server"&&I(l)&&d(this,N,l.address),d(this,B,h!=null?h:[]),d(this,k,v!=null?v:[]),d(this,p,w),d(this,q,this.initDefaultSigner())}get signer(){return t(this,p)}waitForInit(){return u(this,null,function*(){yield t(this,q)})}initDeviceSigner(){return u(this,null,function*(){var n;let e=(n=t(this,A))==null?void 0:n.deviceSignerKeyStorage;if(e==null||t(this,H))return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(o){a.error("wallet.initDeviceSigner.error",{error:o}),d(this,y,!0);return}if(t(this,y))return;let i=this.buildInternalSignerConfig(r);d(this,p,yield this.assembleFullSigner(i,e)),this.isApprovedSignerStatus(t(this,p).status)||(a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t(this,p).locator(),status:t(this,p).status}),d(this,y,!0),d(this,F,!1))})}initDefaultSigner(){return u(this,null,function*(){if(t(this,p)!=null||(yield this.initDeviceSigner(),t(this,p)!=null||t(this,y)))return;let e=t(this,k).length===0?t(this,S):t(this,k).length===1?t(this,k)[0]:null;if(e==null||!this.isAutoAssemblableSignerConfig(e))return;let r=e===t(this,S);try{let i=this.buildInternalSignerConfig(e);d(this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r}))}catch(i){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:t(this,S).type,signerCount:t(this,k).length,error:i})}})}assembleRecoverySignerFallback(){return u(this,null,function*(){if(this.isAutoAssemblableSignerConfig(t(this,S)))try{let e=this.buildInternalSignerConfig(t(this,S));d(this,p,yield this.assembleFullSigner(e,void 0,{isAdminSigner:!0}))}catch(e){a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:t(this,S).type,error:e})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return t(e,S)}static getInitialSigners(e){return t(e,k)}static getApiRecoveryServerSignerAddress(e){var r;return(r=t(e,N))!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return t(e,B)}get apiClient(){return t(this,f)}get options(){return t(this,A)}deriveServerSignerCandidates(e){return Se(e,this.chain,t(this,f).projectId,t(this,f).environment)}resolveServerSignerDerivation(e){var o;if(I(e)){if(t(this,E)!=null)return t(this,E);throw new Error('Cannot resolve server signer derivation: no secret available and no cached recovery resolution. Call wallet.useSigner({ type: "server", secret: ... }) first.')}let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),n=(o=t(this,W))!=null?o:t(this,E);if(n!=null){let g=n.derivedAddress;if(g===r.derivedAddress||i!=null&&g===i.derivedAddress)return P(r.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),n}if(i!=null){if(i.derivedAddress===t(this,N))return P(r.derivedKeyBytes),i;if(t(this,k).some(g=>g.type==="server"&&I(g)&&g.address===i.derivedAddress)||t(this,B).includes(i.derivedAddress))return P(r.derivedKeyBytes),i;P(i.derivedKeyBytes)}return r}resolveServerSignerApiLocator(e){return`server:${this.resolveServerSignerDerivation(e).derivedAddress}`}get recovery(){return t(this,S)}balances(e){return u(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),i;switch(this.chain){case"solana":i="sol";break;case"stellar":i="xlm";break;default:i="eth";break}let n=[i,"usdc",...e!=null?e:[]],o=yield t(this,f).getBalance(this.address,{chains:[r],tokens:n});if("error"in o)throw a.error("wallet.balances.error",{error:o}),new Error(`Failed to get balances for wallet: ${JSON.stringify(o.message)}`);return a.info("wallet.balances.success"),this.transformBalanceResponse(o,i,e)})}stagingFund(e,r){return u(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let i=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in i)throw a.error("wallet.stagingFund.error",{error:i}),new Error(`Failed to fund wallet: ${JSON.stringify(i.message)}`);return a.info("wallet.stagingFund.success"),i})}transformBalanceResponse(e,r,i){let n=c=>{var w,m,D,G,U;let h=(w=c.chains)==null?void 0:w[this.chain],v={};return this.chain==="solana"&&h!=null&&"mintHash"in h?v={mintHash:h.mintHash}:this.chain==="stellar"&&h!=null&&"contractId"in h?v={contractId:h.contractId}:h!=null&&"contractAddress"in h&&(v={contractAddress:h.contractAddress}),b({symbol:(m=c.symbol)!=null?m:"",name:(D=c.name)!=null?D:"",amount:(G=c.amount)!=null?G:"0",decimals:c.decimals,rawAmount:(U=c.rawAmount)!=null?U:"0"},v)},o=e.find(c=>c.symbol===r),g=e.find(c=>c.symbol==="usdc"),s=e.filter(c=>{var h;return c.symbol!==r&&c.symbol!=="usdc"&&(i==null||i.includes((h=c.symbol)!=null?h:""))}),l=c=>{let h={symbol:c,name:c,amount:"0",decimals:0,rawAmount:"0"},v={};return this.chain==="solana"?v={mintHash:void 0}:this.chain==="stellar"?v={contractId:void 0}:v={contractAddress:void 0},b(b({},h),v)};return{nativeToken:o!=null?n(o):l(r),usdc:g!=null?n(g):l("usdc"),tokens:s.map(n)}}nfts(e){return u(this,null,function*(){return yield t(this,f).getNfts($(b({},e),{chain:this.chain,address:this.address}))})}transactions(){return u(this,null,function*(){let e=yield t(this,f).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return u(this,null,function*(){let r=yield t(this,f).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return u(this,null,function*(){let r=this.resolveChainForEnvironment(),i=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in i)throw new Error(`Failed to get transfers: ${JSON.stringify(i.message)}`);return i})}send(e,r,i,n){return u(this,null,function*(){let o=this.resolveChainForEnvironment(),g=me(e),s=Ce(r,o),l=Number(i);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new ne(`Invalid transfer amount: "${i}". Amount must be a positive number greater than zero.`);a.info("wallet.send.start",b({recipient:g,token:s,amount:i},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let c=this.requireSigner(),h;(n==null?void 0:n.signer)==null?h=c.locator():typeof n.signer=="string"?h=n.signer:h=this.resolveServerSignerApiLocator(n.signer);let v=b({recipient:g,amount:i,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),w=yield t(this,f).send(this.walletLocator,s,v);if("message"in w)throw a.error("wallet.send.error",{error:w}),new se(`Failed to send token: ${JSON.stringify(w.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:w.id}),{hash:void 0,explorerLink:void 0,transactionId:w.id};let m=yield this.approveTransactionAndWait(w.id);return a.info("wallet.send.success",{transactionId:w.id,hash:m.hash}),m})}approveTransaction(e){return u(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 u(this,null,function*(){if(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 a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw 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 u(this,null,function*(){a.info("wallet.addSigner.start");let i=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return this.withRecoverySigner(()=>u(this,null,function*(){var h,v,w,m;let n=typeof i=="string"?i:O(i),o=yield this.getSignerState(n);if(o.signer!=null){if(this.isApprovedSignerStatus(o.signer.status))return a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(o.signer,null,r);if(o.pendingOperation!=null)return a.info("wallet.addSigner.resuming",{operationType:o.pendingOperation.type,operationId:o.pendingOperation.id}),this.completeSignerRegistration(o.signer,o.pendingOperation,r)}let g=typeof i=="string"||i.type==="passkey"?i:i.type==="device"&&"publicKey"in i&&i.publicKey!=null?{type:"device",publicKey:i.publicKey,name:i.name}:O(i),s=yield t(this,f).registerSigner(this.walletLocator,b({signer:g,chain:this.getSignerRegistrationChain()},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in s)throw a.error("wallet.addSigner.error",{error:s}),s.code===re?new j(s.message):new J(`Failed to register signer: ${JSON.stringify(s.message)}`);let l=Y(s,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let c=null;if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in s)||s.transaction==null)throw a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");c={type:"transaction",id:s.transaction.id}}else{if(!("chains"in s))throw a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((v=(h=s.chains)==null?void 0:h[this.chain])==null?void 0:v.status)==="failed")throw a.error("wallet.addSigner.failed",{chain:this.chain,signerType:e.type,signerLocator:n,chainStatus:(w=s.chains)==null?void 0:w[this.chain]}),new J(`Signer registration failed for chain ${this.chain} (signer: ${n})`,JSON.stringify((m=s.chains)==null?void 0:m[this.chain]));c=Q(s,this.chain)}return this.completeSignerRegistration(l,c,r)}))})}completeSignerRegistration(e,r,i){return u(this,null,function*(){if(i!=null&&i.prepareOnly){if(r==null)return b({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return a.info("wallet.addSigner.prepared",n),b(b({},e),n)}case"signature":{let n={signatureId:r.id};return a.info("wallet.addSigner.prepared",n),b(b({},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),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return $(b({},e),{status:"success"})})}removeSigner(e,r){return u(this,null,function*(){let i=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:i}),this.withRecoverySigner(()=>u(this,null,function*(){let n=yield t(this,f).removeSigner(this.walletLocator,i,{chain:this.getSignerRegistrationChain()});if("error"in n)throw a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let o=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:o}),{transactionId:o,status:void 0}):(yield this.approveTransactionAndWait(o),a.info("wallet.removeSigner.success",{transactionId:o}),{transactionId:o,status:"success"})}))})}useSigner(e){return u(this,null,function*(){var o;a.info("wallet.useSigner.start"),e.type==="server"&&(P((o=t(this,W))==null?void 0:o.derivedKeyBytes),d(this,W,null)),this.validateSignerInput(e);let r=!1;e.type==="device"?yield this.resolveDeviceSignerAvailability(e):r=yield this.resolveNonDeviceSigner(e);let i=this.buildInternalSignerConfig(e),n=O(e);d(this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r})),a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return u(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return d(this,y,!1),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return d(this,y,!1),!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 d(this,y,!1),!1;if(this.isRecoverySigner(e))return d(this,y,!1),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return u(this,null,function*(){let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),n=yield this.signers();if(n.some(g=>g.locator===`server:${r.derivedAddress}`))return d(this,W,r),this.wipeNonSelectedCandidate(r,i),d(this,y,!1),!1;if(i!=null&&n.some(g=>g.locator===`server:${i.derivedAddress}`))return d(this,W,i),this.wipeNonSelectedCandidate(i,r),d(this,y,!1),!1;if(this.isRecoverySigner(e))return t(this,N)!=null&&i!=null&&i.derivedAddress===t(this,N)?(d(this,E,i),this.wipeNonSelectedCandidate(i,r)):(d(this,E,r),this.wipeNonSelectedCandidate(r,i)),this.stripSecretFromRecovery(),d(this,y,!1),!0;let o=i!=null?`"server:${r.derivedAddress}" or "server:${i.derivedAddress}"`:`"server:${r.derivedAddress}"`;throw P(r.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),new Error(`Signer ${o} is not registered in this wallet.`)})}wipeNonSelectedCandidate(e,r){r!=null&&r!==e&&P(r.derivedKeyBytes)}stripSecretFromRecovery(){t(this,S)!=null&&t(this,S).type==="server"&&!I(t(this,S))&&t(this,E)!=null&&d(this,S,{type:"server",address:t(this,E).derivedAddress})}tryAutoSelectPasskey(e){return u(this,null,function*(){let i=(yield this.signers()).filter(n=>n.type==="passkey");if(i.length===0)return!1;if(i.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=i[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):O(e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return u(this,null,function*(){var n;let r=this.signer;if(I(t(this,S))&&t(this,E)==null)throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(t(this,S)!=null&&t(this,S).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(t(this,S)))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 i=this.buildInternalSignerConfig(t(this,S));d(this,p,_(this.chain,i,(n=t(this,A))==null?void 0:n.deviceSignerKeyStorage));try{return yield e()}finally{d(this,p,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return u(this,null,function*(){return(yield this.signers()).some(i=>i.locator===e)})}isSignerApproved(e){return u(this,null,function*(){var i;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((i=r.signer)==null?void 0:i.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return t(this,y)}recover(){return u(this,null,function*(){var o,g;if(a.info("wallet.recover.start"),t(this,F)){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(t(this,H)){a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),d(this,y,!1),d(this,F,!0);return}let e=()=>{d(this,y,!1),d(this,F,!0)};if(((o=t(this,p))==null?void 0:o.type)==="device"&&(yield this.checkAndResumeDeviceSigner(t(this,p)))){e();return}if(t(this,p)!=null&&t(this,p).type!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),d(this,y,!1);return}let r=(g=t(this,A))==null?void 0:g.deviceSignerKeyStorage;if(r==null){if(!t(this,y))return;throw new Error("Device signer key storage is required to recover a device signer")}let i=yield this.findLocalDeviceSigner(r);if(i!=null&&(yield this.checkAndResumeDeviceSigner(i))){d(this,p,i),e();let s=i.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,s)}catch(l){a.warn("wallet.recover.mapAddressToKey.error",{error:l})}return}let n=yield ve(r,this.address);try{yield this.addSigner(n)}catch(s){let l=s instanceof Error&&s.message.toLowerCase().includes("delegated signer")&&s.message.toLowerCase().includes("already")&&s.message.toLowerCase().includes("approved");if(s instanceof j){a.info("wallet.recover.device.unsupportedFallback",{signerLocator:n.locator}),yield r.deleteKey(this.address),d(this,H,!0),d(this,y,!1),d(this,F,!0),yield this.assembleRecoverySignerFallback();return}else if(l)a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:n.locator});else throw s instanceof he||s instanceof Error&&s.name==="AuthRejectedError"?(a.info("wallet.recover.device.authRejected",{signerLocator:n.locator}),s):s instanceof X||s instanceof Error&&s.name==="OtpValidationError"?(a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:n.locator,code:s instanceof X?s.code:void 0}),s):(a.error("wallet.recover.device.error",{error:s}),yield r.deleteKey(this.address),s)}d(this,p,yield this.assembleFullSigner({type:"device",locator:n.locator,address:this.address},r)),t(this,p).type==="device"&&(t(this,p).status="success"),a.info("wallet.recover.device.success",{signerLocator:n.locator}),e()})}checkAndResumeDeviceSigner(e){return u(this,null,function*(){var i;if(this.isApprovedSignerStatus(e.status))return a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(i=r.signer)==null?void 0:i.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return u(this,null,function*(){var o;let i=t(this,p);if(I(t(this,S))&&t(this,E)==null)throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(t(this,S)!=null&&t(this,S).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(t(this,S)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let n=this.buildInternalSignerConfig(t(this,S));d(this,p,_(this.chain,n,(o=t(this,A))==null?void 0:o.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(g){throw d(this,p,e),g}finally{t(this,p)!==e&&d(this,p,i)}e.status="success",a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return u(this,null,function*(){let i=(yield this.signers()).filter(n=>n.locator.startsWith("device:"));for(let n of i){let o=n.locator.replace("device:","");try{if(yield e.hasKey(o)){let s=_(this.chain,{type:"device",locator:n.locator,address:this.address},e);return a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:n.locator}),s}}catch(g){a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:n.locator,error:g})}}return null})}signers(){return u(this,null,function*(){var o,g;a.info("wallet.signers.start");let e=yield t(this,f).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new ee(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new Z(`Wallet type ${e.type} not supported`);let r=(g=(o=e==null?void 0:e.config)==null?void 0:o.delegatedSigners)!=null?g:[],n=(yield Promise.all(r.map(s=>u(this,null,function*(){try{return(yield this.getSignerState(s.locator)).signer}catch(l){return null}})))).filter(s=>s!=null);return a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(t(this,f).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(t(this,p)==null)throw t(this,k).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):t(this,S).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
|
|
2
|
+
Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`):t(this,S).type==="external-wallet"||!this.isAutoAssemblableSignerConfig(t(this,S))?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
|
|
3
|
+
Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return t(this,p)}preAuthIfNeeded(){return u(this,null,function*(){yield t(this,q),t(this,K)==null&&d(this,K,this.recover());try{yield t(this,K)}finally{d(this,K,null)}let e=this.requireSigner();e instanceof pe&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=t(this,S);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let i=s=>{if(I(s))return[s.address];let{primary:l,legacy:c}=this.deriveServerSignerCandidates(s),h=[l.derivedAddress];return c!=null&&h.push(c.derivedAddress),P(l.derivedKeyBytes,c==null?void 0:c.derivedKeyBytes),h},n=i(e),o=i(r);if(!n.some(s=>o.includes(s)))return!1}else if(O(e)!==O(r))return!1;return d(this,S,e),!0}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return u(this,null,function*(){var g;let r=(g=t(this,A))==null?void 0:g.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let i=yield r.getKey(this.address);if(i!=null){e.locator=`device:${i}`;return}let o=(yield this.signers()).filter(s=>s.locator.startsWith("device:"));for(let s of o){let l=s.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=s.locator;return}}d(this,y,!0),d(this,F,!1)})}assembleFullSigner(o){return u(this,arguments,function*(e,r=(n=>(n=t(this,A))==null?void 0:n.deviceSignerKeyStorage)(),i){var s;let g=_(this.chain,e,r);if(i!=null&&i.isAdminSigner)g.status="active";else{let l=yield this.getSignerState(g.locator());g.status=(s=l.signer)==null?void 0:s.status}return g})}getSignerState(e){return u(this,null,function*(){let r=null;try{r=yield t(this,f).getSigner(this.walletLocator,e)}catch(n){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let i=Y(r,this.chain);return{response:r,signer:i,pendingOperation:Q(r,this.chain)}})}buildInternalSignerConfig(e){var r,i,n,o,g,s;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:t(this,f).crossmint,clientTEEConnection:(r=t(this,A))==null?void 0:r.clientTEEConnection,onAuthRequired:(n=(i=t(this,A))==null?void 0:i.callbacks)==null?void 0:n.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:t(this,f).crossmint,clientTEEConnection:(o=t(this,A))==null?void 0:o.clientTEEConnection,onAuthRequired:(s=(g=t(this,A))==null?void 0:g.callbacks)==null?void 0:s.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return $(b({},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let l=e,c=this.resolveServerSignerDerivation(l),h=new Uint8Array(c.derivedKeyBytes);return c!==t(this,W)&&c!==t(this,E)&&P(c.derivedKeyBytes),{type:"server",derivedKeyBytes:h,locator:`server:${c.derivedAddress}`,address:c.derivedAddress}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}isAutoAssemblableSignerConfig(e){var r;switch(e.type){case"email":case"phone":case"passkey":case"api-key":return!0;case"device":return((r=t(this,A))==null?void 0:r.deviceSignerKeyStorage)!=null;case"server":return!I(e)||t(this,E)!=null;case"external-wallet":return"onSign"in e&&typeof e.onSign=="function";default:return!1}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=ue(this.chain,t(this,f).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return u(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return u(this,null,function*(){let i=yield this.approveSignatureInternal(e,r);return!("error"in i)&&i.status==="success"&&i.outputSignature!=null?{signature:i.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return u(this,null,function*(){var l,c;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let i=this.requireSigner(),n=yield t(this,f).getSignature(this.walletLocator,e);if("error"in n)throw new V(JSON.stringify(n));if(i.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let o=(l=n.approvals)==null?void 0:l.pending;if(o==null||o.length===0)return n;let g=[...(c=r==null?void 0:r.additionalSigners)!=null?c:[],i],s=yield Promise.all(o.map(h=>u(this,null,function*(){let v=g.find(m=>m.locator()===h.signer.locator);if(v==null)throw new J(`Signer ${h.signer.locator} not found in pending approvals`);let w=yield v.signMessage(h.message);return $(b({},w),{signer:v.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,s)})}approveTransactionInternal(e,r){return u(this,null,function*(){var l,c,h,v,w;let i=yield t(this,f).getTransaction(this.walletLocator,e);if("error"in i)throw new z(JSON.stringify(i));yield(h=(c=(l=t(this,A))==null?void 0:l.callbacks)==null?void 0:c.onTransactionStart)==null?void 0:h.call(c);let n=this.requireSigner();if(n.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let o=(v=i.approvals)==null?void 0:v.pending;if(o==null||o.length===0)return i;let g=[...(w=r==null?void 0:r.additionalSigners)!=null?w:[],n],s=yield Promise.all(o.map(m=>u(this,null,function*(){let D=g.find(ye=>ye.locator()===m.signer.locator);if(D==null)throw new J(`Signer ${m.signer.locator} not found in pending approvals`);let G=D.type==="device",U=i.chainType==="solana"&&"transaction"in i.onChain&&!G?i.onChain.transaction:m.message,we=yield D.signTransaction(U);return $(b({},we),{signer:D.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,s)})}executeApproveTransactionWithErrorHandling(e,r){return u(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let i=yield t(this,f).approveTransaction(this.walletLocator,e,{approvals:r});if(i.error)throw new de(JSON.stringify(i));return i})}executeApproveSignatureWithErrorHandling(e,r){return u(this,null,function*(){let i=yield t(this,f).approveSignature(this.walletLocator,e,{approvals:r});if(i.error)throw new te(JSON.stringify(i));return i})}waitForSignature(e){return u(this,null,function*(){let r=null;do if(yield new Promise(i=>setTimeout(i,M)),r=yield t(this,f).getSignature(this.walletLocator,e),"error"in r)throw new V(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new ie("Signature signing failed");if(!r.outputSignature)throw new V("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(g){return u(this,arguments,function*(e,r=6e4,{backoffMultiplier:i=1.1,maxBackoffMs:n=2e3,initialBackoffMs:o=M}={}){var v,w;a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let s=Date.now(),l;do{if(Date.now()-s>r)throw new ae("Transaction confirmation timeout");if(l=yield t(this,f).getTransaction(this.walletLocator,e),l.error)throw new z(JSON.stringify(l));yield this.sleep(o),o=Math.min(o*i,n)}while(l.status==="pending");if(l.status==="failed")throw new oe(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new le("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let c="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,h=(v=l.onChain.txId)!=null?v:c;if(h==null)throw new ce("Transaction hash not found on transaction response");return{hash:h,explorerLink:(w=l.onChain.explorerLink)!=null?w:"",transactionId:l.id}})}sleep(e){return u(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};p=new WeakMap,A=new WeakMap,f=new WeakMap,S=new WeakMap,k=new WeakMap,y=new WeakMap,F=new WeakMap,W=new WeakMap,E=new WeakMap,N=new WeakMap,B=new WeakMap,q=new WeakMap,K=new WeakMap,H=new WeakMap,x([L({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"balances",1),x([L({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"stagingFund",1),x([L({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"send",1),x([L({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"approve",1),x([L({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"addSigner",1),x([L({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"removeSigner",1),x([L({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"useSigner",1),x([L({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"recover",1),x([L({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"signers",1);function me(C){if(typeof C=="string"){if(!fe(C))throw new ge(`Invalid recipient address: "${C}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return C}if("email"in C)return`email:${C.email}`;if("x"in C)return`x:${C.x}`;if("twitter"in C)return`twitter:${C.twitter}`;if("phone"in C)return`phoneNumber:${C.phone}`;if("userId"in C)return`userId:${C.userId}`;throw new Error("Invalid recipient locator")}function Ce(C,e){return fe(C)?`${e}:${C}`:`${e}:${C.toLowerCase()}`}export{R as a};
|