@seams/wallet 0.10.2 → 0.12.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/README.md +3 -3
- package/THIRD_PARTY_NOTICES.md +33 -1812
- package/dist/.build-inputs.sha256 +1 -1
- package/dist/esm/SeamsWeb/operations/recovery/walletRecoveryCodeBackup.js +100 -0
- package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.js +236 -97
- package/dist/esm/core/signingEngine/uiConfirm/ui/preact/RecoveryCodeBackupSurface.js +558 -0
- package/dist/esm/core/signingEngine/uiConfirm/ui/preact/mountRecoveryCodeBackupSurface.js +82 -0
- package/dist/esm/core/types/sdkSentEvents.js +9 -0
- package/dist/esm/react/components/AccountMenuButton/AccountMenuButtonMock.js +189 -0
- package/dist/esm/react/components/AccountMenuButton/AccountMenuButtonView.js +137 -0
- package/dist/esm/react/components/AccountMenuButton/AccountMenuDeviceDetails.js +39 -0
- package/dist/esm/react/components/AccountMenuButton/AccountMenuDialog.js +39 -13
- package/dist/esm/react/components/AccountMenuButton/AccountMenuMockScreens.js +247 -0
- package/dist/esm/react/components/AccountMenuButton/AccountMenuScreen.js +41 -0
- package/dist/esm/react/components/AccountMenuButton/AuthenticationMethodRow.js +79 -0
- package/dist/esm/react/components/AccountMenuButton/AuthenticationMethodsModal.js +168 -174
- package/dist/esm/react/components/AccountMenuButton/AuthenticationMethodsView.js +19 -0
- package/dist/esm/react/components/AccountMenuButton/ExportKeysScreen.js +30 -0
- package/dist/esm/react/components/AccountMenuButton/LinkedDevicesModal.css +148 -87
- package/dist/esm/react/components/AccountMenuButton/LinkedDevicesModal.js +26 -5
- package/dist/esm/react/components/AccountMenuButton/MenuItem.js +28 -13
- package/dist/esm/react/components/AccountMenuButton/ProfileDropdown.css +73 -69
- package/dist/esm/react/components/AccountMenuButton/ProfileDropdown.js +56 -68
- package/dist/esm/react/components/AccountMenuButton/RecoveryCodeAcknowledgement.js +27 -0
- package/dist/esm/react/components/AccountMenuButton/RecoveryCodeActions.js +53 -0
- package/dist/esm/react/components/AccountMenuButton/TransactionSettingsSection.css +3 -1
- package/dist/esm/react/components/AccountMenuButton/TransactionSettingsSection.js +2 -8
- package/dist/esm/react/components/AccountMenuButton/UserAccountButton.css +1 -1
- package/dist/esm/react/components/AccountMenuButton/UserAccountButton.js +6 -3
- package/dist/esm/react/components/AccountMenuButton/WalletRegionSection.js +4 -4
- package/dist/esm/react/components/AccountMenuButton/Web3AuthProfileButton.css +443 -12
- package/dist/esm/react/components/AccountMenuButton/hooks/useProfileState.js +1 -1
- package/dist/esm/react/components/AccountMenuButton/icons/LayersIcon.js +8 -0
- package/dist/esm/react/components/AccountMenuButton/icons/LockKeyholeIcon.js +22 -0
- package/dist/esm/react/components/AccountMenuButton/icons/PlusIcon.js +8 -0
- package/dist/esm/react/components/AccountMenuButton/icons/SunIcon.js +2 -2
- package/dist/esm/react/components/AccountMenuButton/icons/TouchIcon.css +0 -8
- package/dist/esm/react/components/AccountMenuButton/index.js +135 -115
- package/dist/esm/react/components/QRCodeScanner.js +64 -40
- package/dist/esm/react/components/QRCodeScannerCamera.js +16 -0
- package/dist/esm/react/components/ShowQRCode.js +2 -2
- package/dist/esm/react/externalEvm.js +2 -2
- package/dist/esm/react/index.js +2 -1
- package/dist/esm/react/styles/styles.css +520 -91
- package/dist/esm/react/transactionReview/TransactionReviewHost.js +3 -3
- package/dist/esm/sdk/{adapters-DYPu0nK9.js → adapters-CGvNLOfZ.js} +1 -1
- package/dist/{public/sdk/display-DjoWrSgE.js → esm/sdk/display-DTbGoX4e.js} +1 -1
- package/dist/{public/sdk/exportKeypairOperation-DYCzCbqL.js → esm/sdk/exportKeypairOperation-BHXMSA3v.js} +1 -1
- package/dist/{public/sdk/host-D5b19B_h.js → esm/sdk/host-CHQwi-Nm.js} +1 -1
- package/dist/esm/sdk/{localOnly-KvZeKkH5.js → localOnly-CUVRoMy2.js} +1 -1
- package/dist/esm/sdk/{mountRecoveryCodeBackupSurface-BA2ttbTM.js → mountRecoveryCodeBackupSurface-D1G-iCPI.js} +2 -2
- package/dist/esm/sdk/{pendingWalletRecoveryCodeBackup-BkIrbd6Q.js → pendingWalletRecoveryCodeBackup-DMg5U0Fk.js} +1 -1
- package/dist/esm/sdk/{recovery-entrypoint-DoXswV9I.js → recovery-entrypoint-EHY_b7Z-.js} +1 -1
- package/dist/esm/sdk/registration-CQxxUt5s.js +1 -0
- package/dist/esm/sdk/{registration-BFHEYmgh.js → registration-Drtkzrlc.js} +1 -1
- package/dist/esm/sdk/{requireStepUpAuth-C67sluoC.js → requireStepUpAuth-FqZSU021.js} +1 -1
- package/dist/esm/sdk/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/esm/sdk/runtime-auth-DtpRz88X.js +1 -0
- package/dist/esm/sdk/{runtime-device-link-pf-a_-3u.js → runtime-device-link-DXjabXJb.js} +1 -1
- package/dist/esm/sdk/{runtime-ecdsa-tempo-Ddnuti6f.js → runtime-ecdsa-tempo-DlKMIbyP.js} +1 -1
- package/dist/esm/sdk/{runtime-email-otp-BAG8ZC1J.js → runtime-email-otp-BBPghU2G.js} +1 -1
- package/dist/esm/sdk/{runtime-export-DxL99xfn.js → runtime-export-pw-xJL8o.js} +1 -1
- package/dist/esm/sdk/{runtime-near-BrWP4IxC.js → runtime-near-B-vYxGjl.js} +1 -1
- package/dist/esm/sdk/{runtime-preferences-BjVdHYL0.js → runtime-preferences-D-hY0RfC.js} +1 -1
- package/dist/esm/sdk/{runtime-recovery-BNd_GX5q.js → runtime-recovery-Vg1ND2nl.js} +1 -1
- package/dist/esm/sdk/{runtime-recovery-codes-Dn-NccpU.js → runtime-recovery-codes-rLR4Guy4.js} +1 -1
- package/dist/esm/sdk/sdkSentEvents-Dl8fOL50.js +1 -0
- package/dist/esm/sdk/shared-6bpRPbcM.js +6 -0
- package/dist/{public/sdk/signEvmFamily-DjD3tn8e.js → esm/sdk/signEvmFamily-M0trbeZe.js} +1 -1
- package/dist/esm/sdk/{signEvmFamilyWithUiConfirmForTempo-CwRFbaLM.js → signEvmFamilyWithUiConfirmForTempo-Bo25SwuV.js} +1 -1
- package/dist/esm/sdk/{signEvmWithUiConfirm-BHG0dwVG.js → signEvmWithUiConfirm-CFcqJRj3.js} +1 -1
- package/dist/{public/sdk/signNear-D0tlQXb9.js → esm/sdk/signNear-DGUQZ44s.js} +1 -1
- package/dist/esm/sdk/{signingFlow-Mym5j6aw.js → signingFlow-DZvV4AgG.js} +1 -1
- package/dist/esm/sdk/{transaction-activity-Cb2JyYKv.js → transaction-activity-xfeHKJoq.js} +1 -1
- package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/esm/sdk/{wallet-recovery-D7ywcIHw.js → wallet-recovery-LMtGiEL3.js} +1 -1
- package/dist/esm/sdk/wallet-ui.css +1 -1
- package/dist/{public/sdk/walletCustodyEcdsaContinuity-B8aO2NFb.js → esm/sdk/walletCustodyEcdsaContinuity-D-gYxv6e.js} +1 -1
- package/dist/{public/sdk/walletRecoveryCommit-C3EgMjo-.js → esm/sdk/walletRecoveryCommit-BYRC_2li.js} +1 -1
- package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
- package/dist/esm/wasm/router_ab_ecdsa_client/pkg/router_ab_ecdsa_client_bg.wasm +0 -0
- package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/public/headers.manifest.json +1 -1
- package/dist/public/sdk/{adapters-DYPu0nK9.js → adapters-CGvNLOfZ.js} +1 -1
- package/dist/{esm/sdk/display-DjoWrSgE.js → public/sdk/display-DTbGoX4e.js} +1 -1
- package/dist/{esm/sdk/exportKeypairOperation-DYCzCbqL.js → public/sdk/exportKeypairOperation-BHXMSA3v.js} +1 -1
- package/dist/{esm/sdk/host-D5b19B_h.js → public/sdk/host-CHQwi-Nm.js} +1 -1
- package/dist/public/sdk/{localOnly-KvZeKkH5.js → localOnly-CUVRoMy2.js} +1 -1
- package/dist/public/sdk/{mountRecoveryCodeBackupSurface-BA2ttbTM.js → mountRecoveryCodeBackupSurface-D1G-iCPI.js} +2 -2
- package/dist/public/sdk/{pendingWalletRecoveryCodeBackup-BkIrbd6Q.js → pendingWalletRecoveryCodeBackup-DMg5U0Fk.js} +1 -1
- package/dist/public/sdk/{recovery-entrypoint-DoXswV9I.js → recovery-entrypoint-EHY_b7Z-.js} +1 -1
- package/dist/public/sdk/registration-CQxxUt5s.js +1 -0
- package/dist/public/sdk/{registration-BFHEYmgh.js → registration-Drtkzrlc.js} +1 -1
- package/dist/public/sdk/{requireStepUpAuth-C67sluoC.js → requireStepUpAuth-FqZSU021.js} +1 -1
- package/dist/public/sdk/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/public/sdk/runtime-auth-DtpRz88X.js +1 -0
- package/dist/public/sdk/{runtime-device-link-pf-a_-3u.js → runtime-device-link-DXjabXJb.js} +1 -1
- package/dist/public/sdk/{runtime-ecdsa-tempo-Ddnuti6f.js → runtime-ecdsa-tempo-DlKMIbyP.js} +1 -1
- package/dist/public/sdk/{runtime-email-otp-BAG8ZC1J.js → runtime-email-otp-BBPghU2G.js} +1 -1
- package/dist/public/sdk/{runtime-export-DxL99xfn.js → runtime-export-pw-xJL8o.js} +1 -1
- package/dist/public/sdk/{runtime-near-BrWP4IxC.js → runtime-near-B-vYxGjl.js} +1 -1
- package/dist/public/sdk/{runtime-preferences-BjVdHYL0.js → runtime-preferences-D-hY0RfC.js} +1 -1
- package/dist/public/sdk/{runtime-recovery-BNd_GX5q.js → runtime-recovery-Vg1ND2nl.js} +1 -1
- package/dist/public/sdk/{runtime-recovery-codes-Dn-NccpU.js → runtime-recovery-codes-rLR4Guy4.js} +1 -1
- package/dist/public/sdk/sdkSentEvents-Dl8fOL50.js +1 -0
- package/dist/public/sdk/shared-6bpRPbcM.js +6 -0
- package/dist/{esm/sdk/signEvmFamily-DjD3tn8e.js → public/sdk/signEvmFamily-M0trbeZe.js} +1 -1
- package/dist/public/sdk/{signEvmFamilyWithUiConfirmForTempo-CwRFbaLM.js → signEvmFamilyWithUiConfirmForTempo-Bo25SwuV.js} +1 -1
- package/dist/public/sdk/{signEvmWithUiConfirm-BHG0dwVG.js → signEvmWithUiConfirm-CFcqJRj3.js} +1 -1
- package/dist/{esm/sdk/signNear-D0tlQXb9.js → public/sdk/signNear-DGUQZ44s.js} +1 -1
- package/dist/public/sdk/{signingFlow-Mym5j6aw.js → signingFlow-DZvV4AgG.js} +1 -1
- package/dist/public/sdk/{transaction-activity-Cb2JyYKv.js → transaction-activity-xfeHKJoq.js} +1 -1
- package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
- package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
- package/dist/public/sdk/{wallet-recovery-D7ywcIHw.js → wallet-recovery-LMtGiEL3.js} +1 -1
- package/dist/public/sdk/wallet-ui.css +1 -1
- package/dist/{esm/sdk/walletCustodyEcdsaContinuity-B8aO2NFb.js → public/sdk/walletCustodyEcdsaContinuity-D-gYxv6e.js} +1 -1
- package/dist/{esm/sdk/walletRecoveryCommit-C3EgMjo-.js → public/sdk/walletRecoveryCommit-BYRC_2li.js} +1 -1
- package/dist/public/sdk/workers/email_otp_runtime_bg.wasm +0 -0
- package/dist/public/sdk/workers/evm_crypto_bg.wasm +0 -0
- package/dist/public/sdk/workers/router_ab_ecdsa_client_bg.wasm +0 -0
- package/dist/public/sdk/workers/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/public/sdk/workers/shamir3pass_runtime_bg.wasm +0 -0
- package/dist/public/sdk/workers/tempo_signer_bg.wasm +0 -0
- package/dist/public/sdk/workers/wallet_custody_ceremony_bg.wasm +0 -0
- package/dist/public/sdk/workers/wasm_signer_worker_bg.wasm +0 -0
- package/dist/public/wallet-assets.manifest.json +64 -64
- package/dist/public/wallet-service/index.html +4 -4
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/auth-menu/domain.d.ts +9 -1
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/auth-menu/session.d.ts +7 -3
- package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.d.ts +8 -5
- package/dist/types/wallet/src/core/types/sdkSentEvents.d.ts +4 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/AccountMenuButtonMock.d.ts +17 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/AccountMenuButtonView.d.ts +17 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/AccountMenuDeviceDetails.d.ts +13 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/AccountMenuDialog.d.ts +1 -1
- package/dist/types/wallet/src/react/components/AccountMenuButton/AccountMenuMockScreens.d.ts +43 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/AccountMenuScreen.d.ts +9 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/AuthenticationMethodRow.d.ts +14 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/AuthenticationMethodsModal.d.ts +1 -1
- package/dist/types/wallet/src/react/components/AccountMenuButton/AuthenticationMethodsView.d.ts +8 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/ExportKeysScreen.d.ts +7 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/LinkedDevicesModal.d.ts +1 -1
- package/dist/types/wallet/src/react/components/AccountMenuButton/ProfileDropdown.d.ts +2 -14
- package/dist/types/wallet/src/react/components/AccountMenuButton/RecoveryCodeAcknowledgement.d.ts +5 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/RecoveryCodeActions.d.ts +5 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/icons/LayersIcon.d.ts +2 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/icons/LockKeyholeIcon.d.ts +2 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/icons/PlusIcon.d.ts +2 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/index.d.ts +2 -0
- package/dist/types/wallet/src/react/components/AccountMenuButton/types.d.ts +1 -14
- package/dist/types/wallet/src/react/components/QRCodeScanner.d.ts +1 -0
- package/dist/types/wallet/src/react/components/QRCodeScannerCamera.d.ts +5 -0
- package/dist/types/wallet/src/react/index.d.ts +2 -1
- package/dist/workers/email_otp_runtime_bg.wasm +0 -0
- package/dist/workers/evm_crypto_bg.wasm +0 -0
- package/dist/workers/router_ab_ecdsa_client_bg.wasm +0 -0
- package/dist/workers/router_ab_ed25519_yao_client_bg.wasm +0 -0
- package/dist/workers/shamir3pass_runtime_bg.wasm +0 -0
- package/dist/workers/tempo_signer_bg.wasm +0 -0
- package/dist/workers/wallet_custody_ceremony_bg.wasm +0 -0
- package/dist/workers/wasm_signer_worker_bg.wasm +0 -0
- package/package.json +1 -3
- package/dist/esm/sdk/registration-Cx_f58rb.js +0 -1
- package/dist/esm/sdk/runtime-auth-CKUleRYA.js +0 -1
- package/dist/esm/sdk/sdkSentEvents-DiQ3YVlj.js +0 -1
- package/dist/esm/sdk/shared-CSfgTVcf.js +0 -6
- package/dist/public/sdk/registration-Cx_f58rb.js +0 -1
- package/dist/public/sdk/runtime-auth-CKUleRYA.js +0 -1
- package/dist/public/sdk/sdkSentEvents-DiQ3YVlj.js +0 -1
- package/dist/public/sdk/shared-CSfgTVcf.js +0 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,t}from"./chains-C_X_fNuS.js";import{i as n}from"./base64-DW79QA0h.js";import{o as r,r as i}from"./canonicalPrimitives-Dsbsxgxc.js";import{a,c as o,r as s}from"./ecdsaChainTarget-DJBXHzbH.js";import{m as c,o as l}from"./sdkSentEvents-
|
|
1
|
+
import{c as e,t}from"./chains-C_X_fNuS.js";import{i as n}from"./base64-DW79QA0h.js";import{o as r,r as i}from"./canonicalPrimitives-Dsbsxgxc.js";import{a,c as o,r as s}from"./ecdsaChainTarget-DJBXHzbH.js";import{m as c,o as l}from"./sdkSentEvents-Dl8fOL50.js";import{t as u}from"./jsonRpc-YKL5n8VL.js";import{r as d}from"./types-WGrFMQSw.js";import{i as f}from"./helpers-BnkILY2_.js";import{r as p}from"./operationFingerprint-CUrnoh-M.js";import{i as m}from"./trace-QLsbYdld.js";import{t as h}from"./bytes-DZRW2UDg.js";import{n as g,r as _,t as v}from"./normalization-CeZT7ob0.js";import{a as y,i as b,n as x,r as S}from"./types-DhtByIcQ.js";import{T as C,a as w,g as T,i as ee,o as te,r as ne,s as re,t as ie,v as ae,w as oe,y as se}from"./requireStepUpAuth-FqZSU021.js";const ce=/^0x[0-9a-f]{40}$/,E=Object.freeze({"0x06fdde03":`name()`,"0x095ea7b3":`approve(address,uint256)`,"0x18160ddd":`totalSupply()`,"0x23b872dd":`transferFrom(address,address,uint256)`,"0x2e1a7d4d":`withdraw(uint256)`,"0x313ce567":`decimals()`,"0x42842e0e":`safeTransferFrom(address,address,uint256)`,"0x47e1da2a":`executeBatch(address[],uint256[],bytes[])`,"0x6352211e":`ownerOf(uint256)`,"0x70a08231":`balanceOf(address)`,"0x081812fc":`getApproved(uint256)`,"0x95d89b41":`symbol()`,"0xa22cb465":`setApprovalForAll(address,bool)`,"0xa9059cbb":`transfer(address,uint256)`,"0xb61d27f6":`execute(address,uint256,bytes)`,"0xb88d4fde":`safeTransferFrom(address,address,uint256,bytes)`,"0xd0e30db0":`deposit()`,"0xd505accf":`permit(address,address,uint256,uint256,uint8,bytes32,bytes32)`,"0xdd62ed3e":`allowance(address,address)`,"0xe985e9c5":`isApprovedForAll(address,address)`,"0xe7897444":`setUserToken(address)`,"0xf2fde38b":`transferOwnership(address)`}),D=Object.freeze({"0xbb442b54c85efba2d7b81ea52990ad638cdba483":Object.freeze({"0xa4136862":`setGreeting(string)`,"0xef690cc0":`greeting()`,"0x867ae9d4":`dripTo(address,address[])`}),"0xeb7ab5a6f761072c96147a54b8a15f012e836691":Object.freeze({"0xa4136862":`setGreeting(string)`,"0xcfae3217":`greet()`})});function O(e){let t=String(e||``).trim().toLowerCase();if(ce.test(t))return t}function k(e){return v(e)}function A(e,t){let n=_(e);if(!n)return;let r=O(t);if(r){let e=D[r];if(e&&e[n])return e[n]}return E[n]}function j(e,t){let n=A(e,t);if(n){let e=n.indexOf(`(`),t=(e>0?n.slice(0,e):n).trim();if(t)return`${t}()`}let r=_(e);if(r)return`function ${r}`}function le(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function M(e){let t=g(e,{lowercase:!0});if(t===`0x`)return`data: 0x`;let n=t.slice(2);if(!n)return`data: 0x`;if(n.length<=8)return`data: 0x${n}`;let r=n.slice(0,8),i=le(n.slice(8),64);return[`data: 0x${r}`,...i].join(`
|
|
2
2
|
`)}function N(e,t){let n=e/t,r=e%t;if(r===0n)return n.toString();let i=r*100n/t;if(i===0n)return n.toString();let a=i.toString().padStart(2,`0`).replace(/0+$/,``);return a?`${n.toString()}.${a}`:n.toString()}function P(e){return e>=1000000n?`${N(e,1000000n)}mil`:e>=1000n?`${N(e,1000n)}k`:e.toString()}function F(e){try{return JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t,2)}catch{return String(e)}}function I(e,t,n){let r=String(t??``).trim();if(r)return{label:e,value:r,...typeof n==`string`&&n.trim()?{copyValue:n}:{}}}function L(e){let t=g(e.dataHex);if(t!==`0x`&&!(!Array.isArray(e.abi)||e.abi.length===0))return{dataHex:t,abi:e.abi}}function R(e){let t=j(e.selector,e.to),n=!!e.to&&e.dataHex!==`0x`,r=P(e.tx.gasLimit),i=e.to?`Transaction to contract`:`Contract Deployment`,a=I(`Data`,M(e.dataHex),e.dataHex);a&&(a.renderAs=`file-content`,a.hideLabel=!0,a.hideChevron=!0);let o=[a,I(`Value (wei)`,e.valueWei)].filter(Boolean),s;if(n){let n={id:`evm.eip1559.call`,kind:`generic.contractCall`,label:`Calling ${t||`contract function`} using ${r} gas`,to:e.to,value:e.valueWei,selector:e.selector,fields:o},i=L({dataHex:e.dataHex,abi:e.tx.abi});i&&(n.abiDecodeHint=i),s=[n]}return{id:`evm.eip1559`,kind:`generic.contractCall`,label:i,to:e.to,value:e.valueWei,selector:e.selector,...s?{children:s}:{}}}function z(e){let t=e.request;if(t.kind!==`eip1559`)return{chain:`evm`,intentDigest:e.intentDigest,signerAccount:e.signerAccount,title:e.title||`EVM Transaction`,subtitle:e.subtitle,operations:[{id:`evm.raw`,kind:`raw.fallback`,label:`Unsupported EVM Payload`,raw:F(t)}],raw:{format:`json`,value:F(t)}};let n=t.tx,r=n.to==null?void 0:String(n.to).toLowerCase(),i=n.value.toString(),a=g(String(n.data||`0x`)),o=R({to:r,valueWei:i,tx:n,dataHex:a,selector:k(a)}),s=n.value>0n?n.value:void 0;return{chain:`evm`,chainId:n.chainId,intentDigest:e.intentDigest,signerAccount:e.signerAccount,title:e.title||`EVM Transaction`,subtitle:e.subtitle,operations:[o],...s==null?{}:{totals:{nativeValue:s.toString(),nativeSymbol:`wei`}}}}function B(e,t){let n=typeof e==`string`?e.trim():``;if(!/^0x[0-9a-fA-F]+$/.test(n))throw Error(`Invalid ${t} quantity`);return BigInt(n)}function V(e,t,n){let r=e[t];if(r!==void 0){if(r===null)return null;if(typeof r!=`string`)throw Error(`Invalid ${n} result: ${t}`);return r}}function H(e,t,n){let r=V(e,t,n);if(typeof r==`string`&&!/^0x[0-9a-fA-F]+$/.test(r))throw Error(`Invalid ${n} result: ${t}`);return r}function U(e,t,n){let r=V(e,t,n);if(typeof r==`string`&&!/^0x[0-9a-fA-F]{40}$/.test(r))throw Error(`Invalid ${n} result: ${t}`);return r}function W(e,t,n){let r=V(e,t,n);if(typeof r==`string`&&!/^0x(?:[0-9a-fA-F]{2})*$/.test(r))throw Error(`Invalid ${n} result: ${t}`);return r}function ue(e){if(e===null)return null;if(typeof e!=`object`||Array.isArray(e))throw Error(`Invalid eth_getTransactionReceipt result`);let t=e,n=W(t,`transactionHash`,`eth_getTransactionReceipt`),r=U(t,`from`,`eth_getTransactionReceipt`),i=H(t,`blockNumber`,`eth_getTransactionReceipt`),a=H(t,`status`,`eth_getTransactionReceipt`),o=H(t,`gasUsed`,`eth_getTransactionReceipt`),s=H(t,`effectiveGasPrice`,`eth_getTransactionReceipt`),c=H(t,`gasPrice`,`eth_getTransactionReceipt`);return{...n===void 0?{}:{transactionHash:n},...r===void 0?{}:{from:r},...i===void 0?{}:{blockNumber:i},...a===void 0?{}:{status:a},...o===void 0?{}:{gasUsed:o},...s===void 0?{}:{effectiveGasPrice:s},...c===void 0?{}:{gasPrice:c}}}function de(e){if(e===null)return null;if(typeof e!=`object`||Array.isArray(e))throw Error(`Invalid eth_getBlockByNumber result`);let t=e,n=H(t,`number`,`eth_getBlockByNumber`),r=H(t,`baseFeePerGas`,`eth_getBlockByNumber`);return{...n===void 0?{}:{number:n},...r===void 0?{}:{baseFeePerGas:r}}}function fe(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Invalid eth_getTransactionByHash result: calls`);let t=e,n=U(t,`to`,`eth_getTransactionByHash`),r=W(t,`input`,`eth_getTransactionByHash`),i=W(t,`data`,`eth_getTransactionByHash`),a=H(t,`value`,`eth_getTransactionByHash`);return{...n===void 0?{}:{to:n},...r===void 0?{}:{input:r},...i===void 0?{}:{data:i},...a===void 0?{}:{value:a}}}function pe(e){if(e===null)return null;if(typeof e!=`object`||Array.isArray(e))throw Error(`Invalid eth_getTransactionByHash result`);let t=e,n=H(t,`blockNumber`,`eth_getTransactionByHash`),r=U(t,`from`,`eth_getTransactionByHash`),i=H(t,`nonce`,`eth_getTransactionByHash`),a=U(t,`to`,`eth_getTransactionByHash`),o=W(t,`input`,`eth_getTransactionByHash`),s=H(t,`value`,`eth_getTransactionByHash`),c=t.calls;if(c!=null&&!Array.isArray(c))throw Error(`Invalid eth_getTransactionByHash result: calls`);let l=Array.isArray(c)?c.map(fe):c;return{...n===void 0?{}:{blockNumber:n},...r===void 0?{}:{from:r},...i===void 0?{}:{nonce:i},...a===void 0?{}:{to:a},...o===void 0?{}:{input:o},...s===void 0?{}:{value:s},...l===void 0?{}:{calls:l}}}function me(e){let t=e?.reason;if(t instanceof Error)return t;let n=String(t||``).trim()||`Operation aborted`,r=Error(n);return r.code=`aborted`,r}function G(e){if(e?.aborted)throw me(e)}async function he(e,t){G(t);let n=Math.max(0,Math.floor(Number(e)||0));await new Promise((e,r)=>{let i=null,a=()=>{i&&=(globalThis.clearTimeout(i),null),t?.removeEventListener(`abort`,o)},o=()=>{a(),r(me(t))};i=globalThis.setTimeout(()=>{a(),e()},n),t?.addEventListener(`abort`,o,{once:!0})})}function ge(e){let t=e/1000000000n,n=e%1000000000n;if(n===0n)return t.toString();let r=n.toString().padStart(9,`0`).replace(/0+$/,``);return`${t.toString()}.${r}`}function K(e){let t=String(e||``).trim();return/^0x[0-9a-fA-F]{40}$/.test(t)?t:null}function q(e){let t=String(e||``).trim();return/^0x[0-9a-fA-F]+$/.test(t)?t:null}function _e(e){let t=e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean).map(e=>new URL(e).toString());if(t.length===0)throw Error(`RPC URL is not configured`);return Array.from(new Set(t))}function J(e){let t=_e(String(e.rpcUrl||``).trim()),n=e.fetchImpl||fetch.bind(globalThis),r=Math.max(1,Math.floor(Number(e.requestTimeoutMs??15e3)||0)),i=async e=>{let i=Math.max(1,Math.floor(Number(e.timeoutMs??r)||0)),a=Date.now(),o=()=>Math.max(1,i-Math.max(0,Date.now()-a)),s=new AbortController,c=async e=>{let t=o(),n=null,r=!1;try{return await new Promise((a,o)=>{n=setTimeout(()=>{if(!r){r=!0;try{e.onTimeout?.()}catch{}o(Error(`${e.label} timed out after ${i}ms`))}},t),e.promise.then(e=>{r||(r=!0,n&&clearTimeout(n),a(e))},e=>{r||(r=!0,n&&clearTimeout(n),o(e))})})}finally{n&&clearTimeout(n)}},l=JSON.stringify({jsonrpc:`2.0`,id:Date.now(),method:e.method,params:e.params}),d=null,f=null;for(let[r,i]of t.entries()){let a=r<t.length-1;s=new AbortController;try{let t=await c({promise:n(i,{method:`POST`,headers:{"content-type":`application/json`},body:l,signal:s.signal}),label:`${e.method} request`,onTimeout:()=>{s.abort()}});if((t.status===429||t.status>=500)&&a){await t.body?.cancel();continue}d=t;break}catch(e){if(f=e,a)continue}}if(!d)throw f?.name===`AbortError`?Error(`${e.method} request timed out after ${i}ms`):f instanceof Error?f:Error(`RPC request failed`);if(d.status===429)throw Error(`RPC throttled; retry shortly`);if(!d.ok)throw Error(`RPC HTTP ${d.status}`);let p=u(await c({promise:d.json(),label:`${e.method} response`,onTimeout:()=>{s.abort();try{d.body?.cancel()}catch{}}}).catch(t=>{throw t?.name===`AbortError`?Error(`${e.method} response timed out after ${i}ms`):t}));if(!p.ok)throw Error(`Invalid ${e.method} response: ${p.error}`);let m=p.value;if(m.kind===`failure`){let t=String(m.error.message||`${e.method} failed`).trim(),n=m.error.code!==void 0&&m.error.code!==null?String(m.error.code).trim():``,r=m.error.data===void 0?``:(()=>{try{return JSON.stringify(m.error.data)}catch{return String(m.error.data)}})(),i=[t];n&&i.push(`code=${n}`),r&&i.push(`data=${r}`);let a=Error(i.join(` | `));throw n&&(a.code=n),m.error.data!==void 0&&(a.data=m.error.data),a.rpcMethod=e.method,a}return m.result},a=async e=>ue(await i({method:`eth_getTransactionReceipt`,params:[e.txHash],...e.timeoutMs==null?{}:{timeoutMs:e.timeoutMs}})),o=async e=>de(await i({method:`eth_getBlockByNumber`,params:[e.blockTag,!1],...e.timeoutMs==null?{}:{timeoutMs:e.timeoutMs}})),s=async e=>pe(await i({method:`eth_getTransactionByHash`,params:[e.txHash],...e.timeoutMs==null?{}:{timeoutMs:e.timeoutMs}})),c=async e=>B(await i({method:`eth_getTransactionCount`,params:[e.address,e.blockTag??`latest`],...e.timeoutMs==null?{}:{timeoutMs:e.timeoutMs}}),`eth_getTransactionCount`);return{request:i,getTransactionReceipt:a,getBlockByNumber:o,getTransactionByHash:s,getTransactionCount:c,waitForTransactionReceipt:async e=>{let t=Math.max(1,Math.floor(Number(e.timeoutMs??9e4)||0)),n=Math.max(1,Math.floor(Number(e.pollIntervalMs??1250)||0)),i=Math.max(1,Math.floor(Number(e.confirmations??1)||0)),l=Date.now()+t,u=Date.now(),d=Math.min(3e4,Math.max(n*3,Math.floor(t/3))),f=Math.min(15e3,Math.max(n*3,Math.floor(t/6))),p=Math.min(1e4,Math.max(n*3,Math.floor(t/5))),m=null,h=null,g=null,_=null,v=0,y=!1,b=0,x=0,S=0;for(K(e.transactionSenderAddress)&&(g=e.transactionSenderAddress),typeof e.nonceHint==`bigint`&&e.nonceHint>=0n&&(_=e.nonceHint);Date.now()<l;){G(e.signal);let C=null;try{let t=Math.max(1,l-Date.now());C=await a({txHash:e.txHash,timeoutMs:Math.min(r,t)}),m=null}catch(e){m=e instanceof Error?e.message:String(e)}if(C&&typeof C==`object`&&typeof C.blockNumber==`string`){let t=q(C.blockNumber);if(!t)throw Error(`Receipt missing valid blockNumber`);let a=B(t,`receipt.blockNumber`);if(i<=1)return C;let s=Math.max(1,l-Date.now()),c=q((await o({blockTag:`latest`,timeoutMs:Math.min(r,s)}).catch(()=>null))?.number);if(c){let e=B(c,`latest.number`);if(e>=a&&e-a+1n>=BigInt(i))return C}await he(n,e.signal);continue}let w;if(g===null||_===null||!y){let t=Math.max(1,l-Date.now()),n=await s({txHash:e.txHash,timeoutMs:Math.min(r,t)}).catch(()=>null);w=n;let i=K(n?.from),a=q(n?.nonce);if(i&&a){let e=B(a,`tx.nonce`);g===null&&(g=i),_===null&&(_=e),g.toLowerCase()===i.toLowerCase()&&_===e&&(y=!0,b=0,x=0)}}if(g&&_!==null){let t=g,n=_,m=e=>{let r=K(e?.from),i=q(e?.nonce);if(!r||!i||r.toLowerCase()!==t.toLowerCase())return!1;try{return B(i,`tx.nonce`)===n}catch{return!1}},h=Math.max(1,l-Date.now()),C=await c({address:g,blockTag:`latest`,timeoutMs:Math.min(r,h)}).catch(()=>null);if(C!==null&&C>_){let t=Math.max(1,l-Date.now()),n=w===void 0?await s({txHash:e.txHash,timeoutMs:Math.min(r,t)}).catch(()=>null):w;w=n;let u=q(n?.blockNumber);if(m(n)&&(y=!0),u)v=0,b=0,x=0;else if(m(n))v=0,b=0,x=0;else{let e=Math.max(1,l-Date.now()),t=await c({address:g,blockTag:`pending`,timeoutMs:Math.min(r,e)}).catch(()=>null);t!==null&&t<=_?(v=0,x=0):(v+=1,x=0)}if(v>=2){let t=Math.max(1,l-Date.now()),n=await a({txHash:e.txHash,timeoutMs:Math.min(r,t)}).catch(()=>null);if(n&&typeof n.blockNumber==`string`){let e=q(n.blockNumber);if(e){let t=B(e,`receipt.blockNumber`);if(i<=1)return n;let a=Math.max(1,l-Date.now()),s=q((await o({blockTag:`latest`,timeoutMs:Math.min(r,a)}).catch(()=>null))?.number);if(s){let e=B(s,`latest.number`);if(e>=t&&e-t+1n>=BigInt(i))return n}v=0}}if(v>=2){let e=Error(`Transaction dropped or replaced: account nonce advanced past tx nonce (${_.toString()} -> ${C.toString()}).`);throw e.code=`tx_dropped_or_replaced`,e.reason=`dropped`,e.txNonce=_.toString(),e.latestNonce=C.toString(),e.txFrom=g,e.finalizationBranch=`dropped_nonce_advanced`,e}}}else if(C!==null&&C<=_){if(v=0,C<_&&!y){let t=Math.max(1,l-Date.now()),n=w===void 0?await s({txHash:e.txHash,timeoutMs:Math.min(r,t)}).catch(()=>null):w;if(w=n,m(n))y=!0,S=0,b=0,x=0;else{let e=Math.max(1,l-Date.now()),t=await c({address:g,blockTag:`pending`,timeoutMs:Math.min(r,e)}).catch(()=>null);t!==null&&t<=_?(S+=1,b=0,x=0):t!==null&&t>_?(S=0,b=0,x+=1):(S=0,b=0,x=0)}let i=Date.now()-u;if(S>=2&&i>=p){let e=Error(`Transaction dropped or queued behind a nonce gap: tx hash never became visible while account nonce stayed behind tx nonce (${C.toString()} < ${_.toString()}).`);throw e.code=`tx_dropped_or_replaced`,e.reason=`dropped`,e.txNonce=_.toString(),e.latestNonce=C.toString(),e.txFrom=g,e.finalizationBranch=`dropped_nonce_gap`,e}if(x>=2&&i>=f){let e=Error(`Transaction dropped or replaced: tx hash never became visible and pending nonce moved ahead of tx nonce (${_.toString()}).`);throw e.code=`tx_dropped_or_replaced`,e.reason=`replaced`,e.txNonce=_.toString(),e.latestNonce=C.toString(),e.txFrom=g,e.finalizationBranch=`dropped_hash_disappeared`,e}}if(y){let t=Math.max(1,l-Date.now()),n=w===void 0?await s({txHash:e.txHash,timeoutMs:Math.min(r,t)}).catch(()=>null):w;if(w=n,m(n))b=0,x=0;else{let e=Math.max(1,l-Date.now()),t=await c({address:g,blockTag:`pending`,timeoutMs:Math.min(r,e)}).catch(()=>null);t!==null&&t<=_?x=0:t!==null&&t>_?x+=1:x=0}let i=Date.now()-u;if(x>=2&&i>=f){let e=Error(`Transaction dropped or replaced: tx hash disappeared and pending nonce moved ahead of tx nonce (${_.toString()}).`);throw e.code=`tx_dropped_or_replaced`,e.reason=`replaced`,e.txNonce=_.toString(),e.latestNonce=C.toString(),e.txFrom=g,e.finalizationBranch=`dropped_hash_disappeared`,e}}if(!y){let t=Math.max(1,l-Date.now()),n=w===void 0?await s({txHash:e.txHash,timeoutMs:Math.min(r,t)}).catch(()=>null):w;if(w=n,m(n))y=!0,b=0,x=0;else{let e=Math.max(1,l-Date.now()),t=await c({address:g,blockTag:`pending`,timeoutMs:Math.min(r,e)}).catch(()=>null);t!==null&&t===_&&C===_?(b+=1,x=0):t!==null&&t>_?(b=0,x+=1):(b=0,x=0)}let i=Date.now()-u;if(b>=3&&i>=d){let e=Error(`Transaction dropped or replaced: tx hash never became visible to RPC pending pool at nonce ${_.toString()}.`);throw e.code=`tx_dropped_or_replaced`,e.reason=`dropped`,e.txNonce=_.toString(),e.latestNonce=C.toString(),e.txFrom=g,e.finalizationBranch=`dropped_hash_disappeared`,e}if(x>=2&&i>=f){let e=Error(`Transaction dropped or replaced: tx hash never became visible and pending nonce moved ahead of tx nonce (${_.toString()}).`);throw e.code=`tx_dropped_or_replaced`,e.reason=`replaced`,e.txNonce=_.toString(),e.latestNonce=C.toString(),e.txFrom=g,e.finalizationBranch=`dropped_hash_disappeared`,e}}}}if(typeof e.maxFeePerGasHint==`bigint`){let n=Math.max(1,l-Date.now()),i=await o({blockTag:`latest`,timeoutMs:Math.min(r,n)}).catch(()=>null),a=String(i?.baseFeePerGas||``).trim();if(/^0x[0-9a-fA-F]+$/.test(a)){let n=null;try{n=B(a,`baseFeePerGas`)}catch{n=null}if(n!==null&&n>e.maxFeePerGasHint){h===null&&(h=Date.now());let r=Math.min(3e4,Math.floor(t/3));if(Date.now()-h>=r){let t=Error(`Transaction pending due to underpriced fees: maxFeePerGas=${ge(e.maxFeePerGasHint)} gwei, latest baseFee=${ge(n)} gwei. Retry to re-sign with refreshed fee caps.`);throw t.finalizationBranch=`underpriced_fee`,t}}else h=null}}await he(n,e.signal)}G(e.signal);let C=m?`; last RPC error: ${m}`:``,w=Error(`Timed out waiting for tx receipt after ${t}ms${C}`);throw w.finalizationBranch=`timeout`,w}}}function ve(e){let t=o(e.subjectId),n=X(e.leaseId,`leaseId`),r=X(e.operationId,`operationId`),i=X(e.operationFingerprint,`operationFingerprint`),a={chainTarget:e.chainTarget,subjectId:t,sender:Re(e.sender),nonce:Y(e.nonce,`nonce`).toString(),leaseId:n,operationId:r,operationFingerprint:i};return e.nonceKey!=null&&(a.nonceKey=Y(e.nonceKey,`nonceKey`).toString()),Number.isSafeInteger(e.reservedAtMs)&&(a.reservedAtMs=e.reservedAtMs),Number.isSafeInteger(e.expiresAtMs)&&(a.expiresAtMs=e.expiresAtMs),a}function ye(e){if(!e||typeof e!=`object`)throw Error(`[evmNonceBackend] invalid managed nonce snapshot: object`);let t=Ie(e),n=o(e.subjectId??e.walletId),r=Re(e.sender),i=Y(e.nonce,`nonce`),a=e.nonceKey==null?void 0:Y(e.nonceKey,`nonceKey`),s=X(e.leaseId,`leaseId`),c=X(e.operationId,`operationId`),l=X(e.operationFingerprint,`operationFingerprint`),u=Be(e.reservedAtMs),d=Be(e.expiresAtMs);return{chainTarget:t,subjectId:n,sender:r,...a==null?{}:{nonceKey:a},nonce:i,leaseId:s,operationId:c,operationFingerprint:l,...u==null?{}:{reservedAtMs:u},...d==null?{}:{expiresAtMs:d}}}function be(e){let t={chainTarget:s({chain:e.chain,chainId:e.chainId,networkSlug:e.networkKey}),subjectId:o(e.walletId),sender:Re(e.sender)};return e.nonceKey!=null&&(t.nonceKey=Y(e.nonceKey,`nonceKey`)),t}const xe=15e3;function Se(e){return{async fetchChainNonce(t){let n=Fe(t);return await e.fetchChainNonce(n)},async fetchBroadcastTransactionStatus(t){let n=Fe(t);return await e.fetchBroadcastTransactionStatus({...n,txHash:ze(t.txHash)})}}}function Ce(e){let t=e.fetchImpl||fetch.bind(globalThis);return Se({fetchChainNonce:async n=>await Ee({chains:e.chains,input:n,fetchImpl:t}),fetchBroadcastTransactionStatus:async n=>await we({chains:e.chains,input:n,fetchImpl:t})})}async function we(e){let t=De(e.chains,e.input),n=await Te({rpcUrl:t,method:`eth_getTransactionReceipt`,params:[e.input.txHash],fetchImpl:e.fetchImpl});if(n&&typeof n==`object`)return{kind:`finalized`};let r=await Te({rpcUrl:t,method:`eth_getTransactionByHash`,params:[e.input.txHash],fetchImpl:e.fetchImpl});return r&&typeof r==`object`?{kind:`pending`}:{kind:`missing`}}async function Te(e){return await J({rpcUrl:e.rpcUrl,fetchImpl:e.fetchImpl,requestTimeoutMs:xe}).request({method:e.method,params:e.params})}async function Ee(e){return Ve(await J({rpcUrl:De(e.chains,e.input),fetchImpl:e.fetchImpl,requestTimeoutMs:xe}).request({method:`eth_getTransactionCount`,params:[e.input.sender,`pending`]}),`eth_getTransactionCount`)}function De(e,n){let r=n.chain,i=n.chainId,a=String(n.networkKey||``).trim().toLowerCase(),o=e=>e.filter(e=>{let t=Me(e);return typeof t==`number`&&t===i}),s=e=>e.filter(e=>String(e.network||``).trim().toLowerCase()===a),c=e.filter(e=>Oe(e));if(!c.length)throw Error(`[evmNonceBackend] missing RPC config for nonce-enabled chains`);let l=s(c);if(l.length===1){let e=l[0];return je({chain:e,requestedChain:r,networkKey:n.networkKey,chainId:i}),Ae({chain:e,chainId:i,networkKey:n.networkKey}),Pe(e.rpcUrl,e.network)}if(l.length>1){let e=o(l).filter(e=>ke(e,r));if(e.length===1){let t=e[0];return Pe(t.rpcUrl,t.network)}throw Error(`[evmNonceBackend] ambiguous networkKey mapping for ${n.networkKey} (chainId=${String(i)})`)}let u=o(c),d=u.filter(e=>ke(e,r));if(d.length===1){let e=d[0];return Pe(e.rpcUrl,e.network)}if(d.length>1){let e=d.map(e=>String(e.network||``).trim()).join(`, `);throw Error(`[evmNonceBackend] ambiguous chainId routing for ${r} chainId=${String(i)} across [${e}]`)}if(u.length>0){let e=Array.from(new Set(u.map(e=>t(e.network))));throw Error(`[evmNonceBackend] chainId=${String(i)} is configured for [${e.join(`, `)}] but is incompatible with ${r} routing`)}throw Error(`[evmNonceBackend] unable to resolve RPC URL for ${r} ${n.networkKey} (chainId=${String(i)})`)}function Oe(e){let n=t(e.network);return n===`evm`||n===`tempo`}function ke(e,n){let r=t(e.network);return n===`tempo`?r===`tempo`:r===`evm`||r===`tempo`}function Ae(e){let t=Me(e.chain);if(typeof t!=`number`)throw Error(`[evmNonceBackend] configured network ${e.chain.network} is missing numeric chainId`);if(t!==e.chainId)throw Error(`[evmNonceBackend] chainId mismatch for network ${e.networkKey}: expected ${t}, received ${String(e.chainId)}`)}function je(e){if(ke(e.chain,e.requestedChain))return;let n=t(e.chain.network);throw Error(`[evmNonceBackend] network ${e.networkKey} (family=${n}) is incompatible with ${e.requestedChain} request (chainId=${String(e.chainId)})`)}function Me(e){return Ne(e)?e.chainId:void 0}function Ne(e){return t(e.network)!==`near`}function Pe(e,t){let n=String(e||``).trim();if(!n)throw Error(`[evmNonceBackend] missing rpcUrl for ${t}`);return n}function Fe(e){let t=e.chainTarget.kind;if(t!==`evm`&&t!==`tempo`)throw Error(`[evmNonceBackend] invalid chain '${String(t)}'`);let n=String(e.chainTarget.networkSlug||``).trim().toLowerCase();if(!n)throw Error(`[evmNonceBackend] networkKey is required`);return{chain:t,networkKey:n,chainId:e.chainTarget.chainId,sender:Le(e.sender,`sender`),nonceKey:t===`tempo`?Y(e.nonceKey,`nonceKey`):0n,walletId:String(o(e.subjectId))}}function Ie(e){if(e.chainTarget)return a(e.chainTarget);let t=e.chain;if(t!==`evm`&&t!==`tempo`)throw Error(`[evmNonceBackend] invalid managed nonce snapshot: chain`);let n=String(e.networkKey||``).trim();if(!n)throw Error(`[evmNonceBackend] invalid managed nonce snapshot: networkKey`);let r=e.chainId;if(typeof r!=`number`||!Number.isSafeInteger(r)||r<=0)throw Error(`[evmNonceBackend] invalid managed nonce snapshot: chainId`);return s({chain:t,chainId:r,networkSlug:n})}function Le(e,t){let n=String(e||``).trim().toLowerCase();if(!/^0x[0-9a-f]{40}$/.test(n))throw Error(`[evmNonceBackend] invalid ${t}: expected 20-byte 0x-prefixed hex`);return n}function Re(e){return Le(e,`sender`)}function ze(e){let t=String(e||``).trim().toLowerCase();if(!/^0x[0-9a-f]{64}$/.test(t))throw Error(`[evmNonceBackend] invalid txHash: expected 32-byte 0x-prefixed hex`);return t}function Y(e,t){try{let n=BigInt(e);if(n<0n)throw Error(`[evmNonceBackend] ${t} must be non-negative`);return n}catch{throw Error(`[evmNonceBackend] invalid ${t}: expected bigint-compatible value`)}}function X(e,t){let n=String(e||``).trim();if(!n)throw Error(`[evmNonceBackend] invalid managed nonce snapshot: ${t}`);return n}function Be(e){if(e==null)return;let t=Math.floor(Number(e));return Number.isSafeInteger(t)?t:void 0}function Ve(e,t){let n=String(e||``).trim();if(!/^0x[0-9a-fA-F]+$/.test(n))throw Error(`[evmNonceBackend] invalid ${t} result: expected hex quantity`);return BigInt(n)}function He(e){return e.kind===`required`?e.authPlan.signingAuthPlan:void 0}async function Ue(e){let t=He(e.thresholdEcdsaStepUp),n=e.thresholdEcdsaStepUp.kind===`required`?e.thresholdEcdsaStepUp.runtime:void 0,r=n?.reusableAuthorization??{kind:`active`},i=We({signingAuthPlan:t,hasEmailOtpSigning:!!n?.emailOtpSigning,hasThresholdEcdsaRequest:e.hasThresholdEcdsaRequest,needsWebAuthn:e.needsWebAuthn,reusableAuthorization:r});if(!i)throw Error(`[chains] ${e.explicitAuthErrorLabel} signing requires explicit auth input`);let a=await ie({operation:{kind:`evm_family_threshold_ecdsa_step_up`,usesNeeded:Math.max(1,Math.floor(Number(e.requiredSignatureUses)||1))},selectedLane:i,policy:Ge(t,r),methods:{...n?.emailOtpSigning?{emailOtp:{method:`email_otp`,prepareChallenge:n.emailOtpSigning.prepare,...n.emailOtpSigning.resend?{resendChallenge:n.emailOtpSigning.resend}:{},complete:async()=>void 0}}:{},passkey:{method:`passkey`,prepare:async()=>({}),complete:async()=>void 0}}});if(a.method===`warm_session`){if(!t||!Ke(t))throw Error(`[chains] warm-session step-up requires an existing warm-session plan`);return{kind:`warm_session`,confirmationAuthPayload:{signingAuthPlan:t}}}if(a.method===`email_otp`){let e=qe({signingAuthPlan:t,prepared:a});if(!S(e))throw Error(`[chains] Email OTP step-up requires an Email OTP signing auth plan`);return{kind:`email_otp`,confirmationAuthPayload:{signingAuthPlan:e},emailOtpPrompt:a.prompt}}let o=qe({signingAuthPlan:t,prepared:a});if(!b(o))throw Error(`[chains] passkey step-up requires a passkey signing auth plan`);return{kind:`passkey`,confirmationAuthPayload:{signingAuthPlan:o}}}function We(e){return e.reusableAuthorization.kind===`absent`?{authMethod:e.reusableAuthorization.requiredFactor}:e.signingAuthPlan?S(e.signingAuthPlan)?{authMethod:`email_otp`}:b(e.signingAuthPlan)?{authMethod:`passkey`}:{authMethod:e.signingAuthPlan.method}:e.hasEmailOtpSigning?{authMethod:`email_otp`}:!e.hasThresholdEcdsaRequest&&e.needsWebAuthn?{authMethod:`passkey`}:null}function Ge(e,t){if(t.kind===`absent`)return{kind:`use_selected_lane`};if(e&&y(e)){if(e.curve!==`ecdsa`)throw Error(`[chains] EVM-family warm-session step-up requires an ECDSA auth plan`);return{kind:`reuse_warm_session`,authorization:{method:e.method,curve:`ecdsa`,materialActivation:e.materialActivation,authorization:e.authorization,expiresAtMs:e.expiresAtMs,remainingUses:e.remainingUses}}}return{kind:`use_selected_lane`}}function Ke(e){return y(e)&&e.curve===`ecdsa`}function qe(e){if(e.signingAuthPlan)return e.prepared.method===`email_otp`?{kind:`emailOtpReauth`,method:`email_otp`,emailOtpPrompt:e.prepared.prompt}:e.prepared.method===`passkey`&&!b(e.signingAuthPlan)?{kind:`passkeyReauth`,method:`passkey`}:e.signingAuthPlan;if(e.prepared.method===`email_otp`)return{kind:`emailOtpReauth`,method:`email_otp`,emailOtpPrompt:e.prepared.prompt};if(e.prepared.method===`passkey`)return{kind:`passkeyReauth`,method:`passkey`};throw Error(`[chains] warm-session step-up requires an existing signing auth plan`)}function Je(e){return{kind:`warm_session`,signingAuthPlan:e.signingAuthPlan,materialActivation:e.signingAuthPlan.materialActivation,authorization:e.signingAuthPlan.authorization,expiresAtMs:e.signingAuthPlan.expiresAtMs,remainingUses:e.signingAuthPlan.remainingUses}}function Ye(e){return{kind:`email_otp`,signingAuthPlan:e.signingAuthPlan,challengeId:$e(e.confirmation.emailOtpChallengeId,e.prompt,`EVM-family step-up authorization`),otpCode:Qe(e.confirmation.otpCode),...e.prompt.emailHint?{emailHint:e.prompt.emailHint}:{}}}function Xe(e){if(!e.confirmation.credential)throw Error(`[chains] missing WebAuthn credential for EVM-family step-up authorization`);return{kind:`passkey`,signingAuthPlan:e.signingAuthPlan,credential:f(e.confirmation.credential)}}function Ze(e){if(e.prepared.kind===`active_wallet_authority`)throw Error(`[chains] active Wallet Authority confirmation has no threshold step-up`);return e.prepared.kind===`warm_session`?Je({signingAuthPlan:e.prepared.confirmationAuthPayload.signingAuthPlan}):e.prepared.kind===`email_otp`?Ye({signingAuthPlan:e.prepared.confirmationAuthPayload.signingAuthPlan,prompt:e.prepared.emailOtpPrompt,confirmation:e.confirmation}):Xe({signingAuthPlan:e.prepared.confirmationAuthPayload.signingAuthPlan,confirmation:e.confirmation})}function Qe(e){let t=String(e||``).trim();if(!/^\d{6}$/.test(t))throw Error(`[chains] missing Email OTP code from touchConfirm`);return t}function $e(e,t,n){let r=String(e||t.challengeId||``).trim();if(!r)throw Error(`[chains] missing Email OTP challenge id for ${n}`);return r}const et=`AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`,tt=`pending-intent-digest`,Z=new Map;function nt(e){return String(e||``).trim()}function rt(e){let t=nt(e.requestId);t&&Z.set(t,e.preparation)}function it(e){let t=nt(e);if(!t)return;let n=Z.get(t);if(n)return Z.delete(t),n}function at(e){let t=nt(e);t&&Z.delete(t)}var Q=class extends Error{constructor(e){super(`[chains] threshold ECDSA material was superseded (${e.supersessionKind}): prepared ${String(e.preparedMaterialActivation.activationId)}, current ${String(e.currentMaterialActivation.activationId)}`),this.name=`EvmFamilyEcdsaMaterialSupersededError`,this.superseded=e}};function ot(e){return e instanceof Q}function st(e){return e.curve===`ed25519`?{curve:e.curve,thresholdSessionId:e.thresholdSessionId,expiresAtMs:e.expiresAtMs,remainingUses:e.remainingUses}:{curve:e.curve,materialActivationId:String(e.materialActivation.activationId),expiresAtMs:e.expiresAtMs,remainingUses:e.remainingUses}}function ct(e){switch(e.kind){case`material_for_step_up`:return e.material;case`material_from_canonical_capability`:case`material_from_step_up`:return e.material.signerSession}}function lt(e){return typeof e?.signReady==`function`}async function ut(t){let a=String(t.operationFingerprint||``).trim();if(!a)throw Error(`[chains] exact EVM signing operation fingerprint digest is required`);return{laneDigest:p(d.signingOperationFingerprint(a)),intentDigest:i(n(t.signingDigest32)),displayDigest:await r(e(t.displayModel))}}function dt(e){return{intentDigest:e.intentDigestHex,challengeB64u:e.challengeB64u,displayModel:e.displayModel}}function ft(e,t){return String(e.laneDigest)===String(t.laneDigest)&&String(e.intentDigest)===String(t.intentDigest)&&String(e.displayDigest)===String(t.displayDigest)}function pt(e){if(e.prepared.operation!==e.operation)throw Error(`[chains] prepared ECDSA operation step-up does not match the operation being signed`);if(!ft(e.prepared.operationDigests,e.operationDigests))throw Error(`[chains] prepared ECDSA operation step-up digest drift`)}function mt(e){if(!e.prepared)throw Error(`[chains] passkey ECDSA step-up requires an operation prepared before confirmation`);let t=String(e.prepared.prepared.challengeB64u||``).trim();if(!t||t!==String(e.challengeB64u||``).trim())throw Error(`[chains] passkey ECDSA step-up challenge does not match the prepared operation`);return t}function $(e){throw Error(`[chains] unsupported EVM-family signing authorization: ${String(e)}`)}async function ht(e){switch(e.authorization.kind){case`active_wallet_authority`:return{kind:`active_wallet_authority`,confirmationAuthPayload:{signingAuthPlan:e.authorization.confirmationAuthPlan}};case`owner`:return await Ue({thresholdEcdsaStepUp:e.thresholdEcdsaStepUp,hasThresholdEcdsaRequest:e.hasThresholdEcdsaRequest,needsWebAuthn:e.needsWebAuthn,requiredSignatureUses:e.requiredSignatureUses,explicitAuthErrorLabel:e.explicitAuthErrorLabel});default:return $(e.authorization)}}function gt(e){if(e.input.authorization.kind!==`active_wallet_authority`)throw Error(`[chains] pending active Wallet Authority confirmation requires exact authorization`);return{ctx:{touchConfirm:e.input.touchConfirm},sessionId:e.sessionId,chain:e.config.targetKind,kind:`intentDigest`,signingSubject:{kind:`evm_wallet`,walletId:e.input.walletId},signingAuthPlan:e.input.authorization.confirmationAuthPlan,challengeB64u:et,intentDigest:tt,displayModel:e.config.buildDisplayModel({request:e.input.request,signerAccount:e.input.walletId,title:e.config.title,subtitle:e.config.body}),title:e.config.title,body:e.config.body,confirmationConfigOverride:e.input.confirmationConfigOverride}}async function _t(e){let t=String(e.operation.intent.operationId);m(t,`material_queue`,e.queuedAt);let n=performance.now(),r=await e.resolveMaterial(e.request,e.operation,e.operationDigests);return m(t,`material_authorization`,n),await e.engine.signReady(e.request,r.material,e.operation,e.operationDigests)}async function vt(e){let{config:t,input:r}=e,i=w(`intent`),a=`signing:${t.flowName}:${r.walletId}:${i}`,o=r.request.senderSignatureAlgorithm===`secp256k1`,s=r.thresholdEcdsaStepUp,u=s.kind===`not_required`?void 0:s.runtime,d=He(s),p=r.authorization.kind===`owner`&&s.kind===`required`&&(s.runtime.reusableAuthorization.kind===`absent`||!y(s.authPlan.signingAuthPlan));if(o&&!d)switch(r.authorization.kind){case`owner`:throw Error(`[chains] threshold ECDSA transaction signing requires an explicit auth plan`);case`active_wallet_authority`:break;default:$(r.authorization)}let g=d??(r.authorization.kind===`active_wallet_authority`?r.authorization.confirmationAuthPlan:null),_=g?re(g):`passkey`,v=e=>{try{r.onEvent?.(c({...e,flowId:a,walletId:r.walletId,authMethod:_}))}catch{}},b=new Set,S=e=>{if(!b.has(e)){b.add(e);try{u?.onAuthSideEffectStarted?.(e)}catch{}}},ie=e=>{e.phase===`auth.passkey.prompt.started`&&S(`passkey_reauth`);let t=te(e,_);t&&v(t)},ce=async(e,t)=>{let n=async e=>{await t[e]?.()};if(!r.signingSessionPlan){await C({commands:e,execute:n});return}let i=await oe({steps:ae(se({sessionPlan:r.signingSessionPlan,operation:r.signingOperation||null,commands:e})),executor:{execute:async e=>{await n(e.kind)}},onTransition:r.onSigningOperationTransition});if(!i.ok)throw i.error;if(i.finalState.kind===`failed`)throw Error(i.finalState.reason)},E=t.webauthn.kind===`supported`&&t.webauthn.requestNeedsWebAuthn(r.request),D=r.request,O=null,k=!1,A=!1,j=s.kind===`required`?s.operation:null,le=async()=>{if(j)return j;throw Error(`[chains] threshold ECDSA transaction signing requires an operation`)},M=async()=>{if(!(k||!O||!r.releaseNonceReservation)){k=!0;try{await r.releaseNonceReservation(O)}catch{}}},N=async()=>{if(!O)return;let e=String(O.leaseId||``).trim(),n=String(O.operationId||``).trim(),i=String(O.operationFingerprint||``).trim();if(!e||!n||!i)throw Error(`[chains] managed ${t.nonceErrorLabel} nonce reservation is missing lease metadata`);await r.ctx.nonceCoordinator.markSigned({leaseId:e,operationId:n,operationFingerprint:i})},P=(async()=>{if(r.prepareRequestWithManagedNonce){let e=await r.prepareRequestWithManagedNonce();D=e.request,O=e.reservation}let e=await t.buildIntent({workerCtx:r.workerCtx,request:D});t.webauthn.kind===`supported`&&t.webauthn.validateIntent(e);let i=e.signRequests[0];if(!i)throw Error(`[chains] signing intent has no sign requests`);let a=ee(i),o=h(a),s=t.buildDisplayModel({request:D,intentDigest:o,signerAccount:r.walletId,title:t.title,subtitle:t.body}),c=n(a);if(p&&i.algorithm===`secp256k1`&&u&&j&&r.resolveEcdsaSigningMaterialPlan){let e=await ut({operationFingerprint:r.signingOperation?.operationFingerprint,signingDigest32:ee(i),displayModel:s}),t=await r.resolveEcdsaSigningMaterialPlan();switch(t.kind){case`ready`:V=t.value;break;case`authorization_required`:V=t.requirement;break;case`superseded`:throw new Q(t.replacement);case`failed`:throw Error(`[chains] threshold ECDSA material is unavailable: ${t.failure.reason}`)}let n=V;if(!n)throw Error(`[chains] ECDSA preparation did not produce signing material`);let a=await u.operationStepUp.prepare({operation:j,operationDigests:e,material:ct(n)});H={prepared:a,operation:j,operationDigests:e},c=a.challengeB64u}return{intent:e,challengeB64u:c,intentDigestHex:o,displayModel:s}})();r.authorization.kind===`active_wallet_authority`&&rt({requestId:i,preparation:P.then(dt)});let F=null,I=null,L=null,R=null,z=!1,B=null,V=null,H=null,U=async(e,t,n)=>{if(r.resolveEcdsaSigningMaterialPlan){let e=await r.resolveEcdsaSigningMaterialPlan();switch(e.kind){case`ready`:V=e.value;break;case`authorization_required`:V=e.requirement;break;case`superseded`:throw new Q(e.replacement);case`failed`:throw Error(`[chains] threshold ECDSA material is unavailable: ${e.failure.reason}`)}}let i=V;if(!i)throw Error(`[chains] missing ready threshold ECDSA material for secp256k1 signing`);if(!I||I.kind===`warm_session`){if(i.kind===`material_for_step_up`)throw Error(`[chains] auth-neutral ECDSA material reached signing without a same-method step-up`);return i}if(!u)throw Error(`[chains] ECDSA operation step-up runtime is unavailable`);let a=H;if(!a)throw Error(`[chains] ECDSA step-up signing requires an operation prepared before confirmation`);return pt({prepared:a,operation:t,operationDigests:n}),{kind:`material_from_step_up`,material:await u.operationStepUp.authorize({authorization:I,prepared:a.prepared,material:ct(i)})}},W=async()=>{if(r.authorization.kind===`active_wallet_authority`){v({phase:l.STEP_05_CONFIRMATION_DISPLAYED,status:`waiting_for_user`,interaction:{kind:`transaction_confirmation`,overlay:`show`}}),r.onConfirmationDisplayed?.();let e=gt({config:t,input:r,sessionId:i});L=await ne({runtime:r.touchConfirm,request:e})(),R=await P,z=R.intent.signRequests.some(e=>e.algorithm===`secp256k1`);let n=await ht({authorization:r.authorization,thresholdEcdsaStepUp:s,hasThresholdEcdsaRequest:o,needsWebAuthn:E,requiredSignatureUses:t.requiredSignatureUsesForRequest(r.request),explicitAuthErrorLabel:t.explicitAuthErrorLabel});if(!y(n.confirmationAuthPayload.signingAuthPlan)&&!x(n.confirmationAuthPayload.signingAuthPlan))throw Error(`[chains] active Wallet Authority signing requires a session auth plan`);F=n;let a=n.confirmationAuthPayload.signingAuthPlan;v({phase:l.STEP_06_AUTH_WARM_SESSION_CLAIMED,status:`succeeded`,interaction:{kind:`none`,overlay:`none`},data:x(a)?{walletSessionId:String(a.walletSessionId),expiresAtMs:a.expiresAtMs,authorityId:String(a.authorityId),authMethodId:String(a.authMethodId)}:st(a)}),S(`auth_confirmed`),v({phase:l.STEP_05_CONFIRMATION_APPROVED,status:`succeeded`,interaction:{kind:`transaction_confirmation`,overlay:`hide`}});return}R=await P,z=R.intent.signRequests.some(e=>e.algorithm===`secp256k1`),v({phase:l.STEP_05_CONFIRMATION_DISPLAYED,status:`waiting_for_user`,interaction:{kind:`transaction_confirmation`,overlay:`show`}}),r.onConfirmationDisplayed?.();let e=await ht({authorization:r.authorization,thresholdEcdsaStepUp:s,hasThresholdEcdsaRequest:o,needsWebAuthn:E,requiredSignatureUses:t.requiredSignatureUsesForRequest(r.request),explicitAuthErrorLabel:t.explicitAuthErrorLabel});F=e;let n=e.confirmationAuthPayload;if(y(n.signingAuthPlan)||x(n.signingAuthPlan)){let e=n.signingAuthPlan;v({phase:l.STEP_06_AUTH_WARM_SESSION_CLAIMED,status:`succeeded`,interaction:{kind:`none`,overlay:`none`},data:x(e)?{walletSessionId:String(e.walletSessionId),expiresAtMs:e.expiresAtMs,authorityId:String(e.authorityId),authMethodId:String(e.authMethodId)}:st(e)})}let a={ctx:{touchConfirm:r.touchConfirm},sessionId:i,chain:t.targetKind,kind:`intentDigest`,signingSubject:{kind:`evm_wallet`,walletId:r.walletId},challengeB64u:R.challengeB64u,intentDigest:R.intentDigestHex,displayModel:R.displayModel,title:t.title,body:t.body,onProgress:ie,confirmationConfigOverride:r.confirmationConfigOverride},c=e.kind===`passkey`?{...a,...e.confirmationAuthPayload,webauthnChallenge:{kind:`intent_digest`,challengeB64u:mt({prepared:H,challengeB64u:R.challengeB64u})}}:e.kind===`email_otp`?{...a,...e.confirmationAuthPayload,emailOtpPrompt:e.emailOtpPrompt}:{...a,...e.confirmationAuthPayload};L=await ne({runtime:r.touchConfirm,request:c})();let u=L;if(!u)throw Error(`[chains] signing confirmation did not produce a decision`);switch(S(`auth_confirmed`),r.authorization.kind){case`owner`:I=Ze({prepared:e,confirmation:u});break;default:$(r.authorization)}v({phase:l.STEP_05_CONFIRMATION_APPROVED,status:`succeeded`,interaction:{kind:`transaction_confirmation`,overlay:`hide`}})},ue=async()=>{if(!R)throw Error(`[chains] signing intent must be prepared before threshold admission`);if(!L)throw Error(`[chains] signing confirmation is required before threshold admission`);if(!F)throw Error(`[chains] signing auth payload is required before threshold admission`);switch(r.authorization.kind){case`owner`:if(!I)throw Error(`[chains] signing step-up authorization is required before threshold admission`);if(z&&!j)throw Error(`[chains] threshold ECDSA operation must be prepared before signing`);break;case`active_wallet_authority`:break;default:$(r.authorization)}},de=async()=>{let e=performance.now();if(!R)throw Error(`[chains] signing intent must be prepared before signing`);if(!L)throw Error(`[chains] signing confirmation must complete before signing`);let n=R.intent;z&&v({phase:l.STEP_10_COMMIT_STARTED,status:`running`,interaction:{kind:`none`,overlay:`none`}});let a=[];for(let e of n.signRequests){let n;if(e.kind===`webauthn`){if(t.webauthn.kind!==`supported`)throw Error(`[chains] WebAuthn signing is not supported for this chain`);if(!L.credential)throw Error(`[chains] missing WebAuthn credential from touchConfirm`);n=(await t.webauthn.resolveKeyRef({ctx:r.ctx,walletId:r.walletId,workerCtx:r.workerCtx,signReq:e,credential:f(L.credential)})).keyRef}else if(e.algorithm===`secp256k1`){let t=await ut({operationFingerprint:r.signingOperation?.operationFingerprint,signingDigest32:e.digest32,displayModel:R.displayModel});switch(r.authorization.kind){case`active_wallet_authority`:{let n=r.signingOperation?.operationId;if(!n)throw Error(`[chains] active Wallet Authority ECDSA signing requires an operation id`);a.push(await r.authorization.sign({requestId:i,operationId:String(n),operationDigests:t,signingDigest32:e.digest32}));continue}case`owner`:break;default:$(r.authorization)}let n=await le(),o=r.engines.secp256k1;if(!o)throw Error(`[chains] missing engine for algorithm: ${e.algorithm}`);if(!lt(o))throw Error(`[chains] secp256k1 signing engine requires ready material support`);if(!r.runEcdsaMaterialUse)throw Error(`[chains] secp256k1 signing requires exact material serialization`);a.push(await r.runEcdsaMaterialUse(_t.bind(void 0,{request:e,engine:o,operation:n,operationDigests:t,queuedAt:performance.now(),resolveMaterial:U})));continue}else throw Error(`[chains] unsupported ${t.explicitAuthErrorLabel} signing algorithm: ${e.algorithm}`);let o=r.engines.webauthnP256;if(!o)throw Error(`[chains] missing engine for algorithm: ${e.algorithm}`);a.push(await o.sign(e,n))}let o=performance.now();B=await n.finalize(a),A=!0,await N();let s=null;j?s=String(j.intent.operationId):r.authorization.kind===`active_wallet_authority`&&r.signingOperation&&(s=String(r.signingOperation.operationId)),s!==null&&(m(s,`transaction_assembly`,o),m(s,`commit_total`,e)),v({phase:l.STEP_11_TRANSACTION_SIGNED,status:`succeeded`,interaction:{kind:`none`,overlay:`hide`}}),v({phase:l.STEP_15_COMPLETED,status:`succeeded`,interaction:{kind:`none`,overlay:`none`},data:{operation:`sign`}})};try{if(await ce([T.ShowConfirmation,T.PreparePayload,T.Sign],{[T.ShowConfirmation]:W,[T.PreparePayload]:ue,[T.Sign]:de}),!B)throw Error(`[chains] signing operation completed without a signed result`);let e=B;return O?{...e,managedNonce:ve(O)}:e}catch(e){throw A||(O?await M():r.releaseNonceReservation&&await P.then(async()=>{await M()}).catch(()=>void 0)),e}}export{tt as a,Ce as c,J as d,z as f,k as g,j as h,et as i,ye as l,M as m,ot as n,at as o,P as p,vt as r,it as s,Q as t,be as u};
|
package/dist/public/sdk/{transaction-activity-Cb2JyYKv.js → transaction-activity-xfeHKJoq.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./chunk-dVx5-UGu.js";import{_ as t}from"./sdkSentEvents-
|
|
1
|
+
import{n as e}from"./chunk-dVx5-UGu.js";import{_ as t}from"./sdkSentEvents-Dl8fOL50.js";var n=e({beginTransactionActivity:()=>i,failTransactionActivity:()=>f,observeTransactionActivity:()=>d,observeTransactionLifecycleReport:()=>h,retainTransactionActivity:()=>a,setTransactionActivityView:()=>l,transactionBroadcastStarted:()=>p});let r=null;function i(e,t){if(e.requestId)switch(e.type){case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:case`PM_SIGN_TEMPO`:r?.surface?.dispose(),r={requestId:e.requestId,post:t,surface:null,state:{kind:`signing`},view:`expanded`,retained:!1,signingHash:null};return;default:return}}function a(e,t){return!r||r.requestId!==e?!1:(r.surface=t,r.retained=!0,o(),!0)}function o(){if(!(!r?.retained||!r.surface)){if(!r.surface.element.isConnected){r=null;return}r.surface.showReceipt({state:r.state,view:r.view,onView:s,onDismiss:c}),r.post({type:`TRANSACTION_ACTIVITY`,requestId:r.requestId,payload:r.view})}}function s(e){r&&(r.view=e,o())}function c(){let e=r;r=null,e?.surface?.dispose(),e?.retained&&e.post({type:`TRANSACTION_ACTIVITY`,requestId:e.requestId,payload:`closed`})}function l(e,t){r?.requestId===e&&(t===`closed`?c():s(`toast`))}function u(e,t){if(!e||typeof e!=`object`)return null;let n=Reflect.get(e,t);return typeof n==`string`&&n.length>0?n:null}function d(e){if(!(!r||e.requestId!==r.requestId)){if(e.type===`PM_RESULT`){let t=e.payload?.result;r.signingHash=u(t,`rawTxHex`),r.state.kind===`signing`&&(r.state={kind:`signed`}),t&&typeof t==`object`&&Reflect.get(t,`success`)===!1&&(r.state={kind:`failed`,hash:null,message:u(t,`error`)??`The operation did not complete.`});let n=m(t);n&&(r.state=n)}else if(e.type===`PROGRESS`&&t(e.payload)&&e.payload.flow===`signing`){let t=e.payload,n=u(t.data,`txHash`)??u(t.data,`txId`);if(r.state.kind===`confirmed`||r.state.kind===`reverted`)return;switch(t.phase){case`signing.transaction.signed`:r.state={kind:`signed`};break;case`signing.broadcast.started`:r.state={kind:`broadcasting`};break;case`signing.broadcast.accepted`:r.state={kind:`submitted`,hash:n};break;case`signing.receipt.finalized`:r.state={kind:`confirmed`,hash:n};break;case`signing.receipt.reverted`:r.state={kind:`reverted`,hash:n,message:`The network reverted this transaction. Network fees may still apply.`};break;case`signing.failed`:case`signing.broadcast.rejected`:r.state={kind:`failed`,hash:n,message:t.message};break;default:return}}else return;o()}}function f(e,t){!r||r.requestId!==e||(r.state={kind:`failed`,hash:null,message:t instanceof Error?t.message:`The operation did not complete.`},o())}function p(e){!r||r.signingHash!==e||r.state.kind!==`signed`||(r.state={kind:`broadcasting`},o())}function m(e){if(!e||typeof e!=`object`)return null;let t=u(e,`transactionId`);if(!t)return null;let n=Reflect.get(e,`result`),r=n&&typeof n==`object`?Reflect.get(n,`status`):null;if(r&&typeof r==`object`){if(Object.hasOwn(r,`SuccessValue`))return{kind:`confirmed`,hash:t};if(Object.hasOwn(r,`Failure`))return{kind:`reverted`,hash:t,message:`The network could not execute this transaction. Network fees may still apply.`}}return{kind:`unknown`,hash:t,message:`Submitted to the network. The response did not include a final execution outcome.`}}function h(e){if(r?.signingHash)switch(e.type){case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:{let t=e.payload;if(!t||t.signedResult.rawTxHex!==r.signingHash||r.state.kind===`confirmed`||r.state.kind===`reverted`)return;e.type===`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`?r.state={kind:`submitted`,hash:e.payload?.txHash??null}:e.type===`PM_REPORT_TEMPO_FINALIZED`?r.state=e.payload?.receiptStatus===`reverted`?{kind:`reverted`,hash:e.payload.txHash??null,message:`The network reverted this transaction. Network fees may still apply.`}:e.payload?.receiptStatus===`success`?{kind:`confirmed`,hash:e.payload.txHash??null}:{kind:`unknown`,hash:e.payload?.txHash??null,message:`The network response did not include an execution status.`}:r.state={kind:`unknown`,hash:null,message:`The transaction did not complete as expected. Check its network status before retrying.`},o();return}default:return}}export{a,h as i,f as n,n as o,d as r,i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./primitives-CqrjmIAH.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as e}from"./host-
|
|
1
|
+
import"./primitives-CqrjmIAH.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as e}from"./host-CHQwi-Nm.js";import"./activeWalletSession-WdZkhtBB.js";import"./capabilityKinds-N8xo_IEh.js";import"./errors-DIWY1KR9.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`ecdsa`,`email_otp`,`export`,`recovery`,`preferences`])});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./primitives-CqrjmIAH.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as e}from"./host-
|
|
1
|
+
import"./primitives-CqrjmIAH.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as e}from"./host-CHQwi-Nm.js";import"./activeWalletSession-WdZkhtBB.js";import"./capabilityKinds-N8xo_IEh.js";import"./errors-DIWY1KR9.js";e();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./primitives-CqrjmIAH.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as e}from"./host-
|
|
1
|
+
import"./primitives-CqrjmIAH.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as e}from"./host-CHQwi-Nm.js";import"./activeWalletSession-WdZkhtBB.js";import"./capabilityKinds-N8xo_IEh.js";import"./errors-DIWY1KR9.js";e({supportedRuntimeRouteKinds:new Set([`auth`,`near`,`export`,`device_link`,`recovery`,`preferences`])});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./primitives-CqrjmIAH.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as e}from"./host-
|
|
1
|
+
import"./primitives-CqrjmIAH.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as e}from"./host-CHQwi-Nm.js";import"./activeWalletSession-WdZkhtBB.js";import"./capabilityKinds-N8xo_IEh.js";import"./errors-DIWY1KR9.js";export{e as initWalletIFrame};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,D as t,M as n,O as r,T as i,j as a,n as o,s}from"./domainIds-BzkGsRqO.js";import{c,j as l,k as u,l as d,u as f}from"./chains-C_X_fNuS.js";import{_ as p,i as m,r as h,t as g}from"./primitives-CqrjmIAH.js";import{i as _,r as v}from"./base64-DW79QA0h.js";import{l as ee}from"./capabilityKinds-N8xo_IEh.js";import{a as y,n as b,r as x}from"./canonicalPrimitives-Dsbsxgxc.js";import{d as te,h as S,s as C}from"./walletAuthority-BWvfaKIX.js";import{r as w}from"./walletAuthMethodRecord-CnBw27ED.js";const T=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,E=Object.freeze(Array.from(T).reduce((e,t,n)=>(e[t]=n,e),{}));function D(e){if(!e)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function O(e){if(e.byteLength!==20)throw Error(`Email OTP recovery key bytes must be exactly 20 bytes`);let t=0,n=0,r=``;for(let i=0;i<e.byteLength;i++)for(t=t<<8|e[i],n+=8;n>=5;)n-=5,r+=T[t>>n&31],t&=(1<<n)-1;return r}function k(e){let t=A(e),n=[],r=0;for(let e=0;e<8;e++)n.push(t.slice(r,r+4)),r+=4;return n.join(`-`)}function ne(e){if(e.length!==10)throw Error(`Email OTP recovery code set must contain 10 keys`);return[k(e[0]),k(e[1]),k(e[2]),k(e[3]),k(e[4]),k(e[5]),k(e[6]),k(e[7]),k(e[8]),k(e[9])]}function A(e){let t=String(e||``).replace(/[\s-]/g,``).toUpperCase();if(t.length!==32)throw Error(`Email OTP recovery key must be 32 Crockford Base32 characters`);if(D(t))throw Error(`Email OTP recovery key must not be decimal-only`);for(let e=0;e<t.length;e++)if(E[t[e]]===void 0)throw Error(`Email OTP recovery key contains unsupported characters`);return t}function re(e){let t=A(e),n=new Uint8Array(20),r=0,i=0,a=0;for(let e=0;e<t.length;e++)r=r<<5|E[t[e]],i+=5,i>=8&&(i-=8,n[a]=r>>i&255,r&=(1<<i)-1,a+=1);return n}async function ie(e){let t=String(e.keySetId||``).trim();if(!/^(near_ed25519|evm_family_ecdsa):\S+$/.test(t))throw Error(`wallet recovery key-set id is invalid`);return b(`wallet-recovery-key-v1:${_(await f(c({domain:`seams/wallet-recovery/key-lifecycle/v1`,reservationId:e.reservationId,keySetId:t})))}`)}function ae(e){if(typeof e!=`string`||e.length===0||e.length>512||e.trim()!==e||o(e))throw Error(`recovery code reservation id must be a compact opaque identifier`);return e}function oe(e){return e.kind===`passkey`?se(e):ce(e)}function se(e){let t={version:`wallet_recovery_committed_projection_v1`,storeVersion:l(e.storeVersion,`storeVersion`,`is invalid`),walletId:e.walletId,recoveryOperationId:e.recoveryOperationId,targetDeviceId:e.targetDeviceId,targetAuthorityId:e.targetAuthorityId,targetWalletAuthMethodId:e.targetWalletAuthMethodId,authority:e.authority,kind:`passkey`,authMethod:e.authMethod,target:{kind:`passkey`,rpId:e.authMethod.rpId,credentialIdB64u:e.authMethod.credentialIdB64u}};return P(t),t}function ce(e){let t={version:`wallet_recovery_committed_projection_v1`,storeVersion:l(e.storeVersion,`storeVersion`,`is invalid`),walletId:e.walletId,recoveryOperationId:e.recoveryOperationId,targetDeviceId:e.targetDeviceId,targetAuthorityId:e.targetAuthorityId,targetWalletAuthMethodId:e.targetWalletAuthMethodId,authority:e.authority,kind:`google_email_otp`,authMethod:e.authMethod,target:{kind:`google_email_otp`,provider:`google`,providerSubject:e.providerSubject,emailHashHex:H(e.emailHashHex),registrationAuthorityId:l(e.registrationAuthorityId,`registrationAuthorityId`,`is invalid`),enrollment:M(e.enrollment)}};return P(t),t}async function le(n,a){let o=F(n);if(o.version!==`wallet_recovery_committed_projection_v1`)throw Error(`wallet recovery committed projection version is invalid`);if(o.kind!==a.kind)throw Error(`wallet recovery committed projection target changed`);let s=V(r(o.walletId),`walletId`),c=V(e(o.recoveryOperationId),`recoveryOperationId`),u=V(ee(o.targetDeviceId),`targetDeviceId`),d=V(t(o.targetAuthorityId),`targetAuthorityId`),f=V(i(o.targetWalletAuthMethodId),`targetWalletAuthMethodId`),p=te(o.authority);if(!p.ok)throw Error(`wallet recovery authority projection is invalid`);let m=p.value;if(m.state!==`active`||!C(m)||!await S(m))throw Error(`wallet recovery authority projection digest or lifecycle is invalid`);let h=w(o.authMethod);if(!h||h.status!==`active`)throw Error(`wallet recovery auth method projection is invalid`);let g={version:`wallet_recovery_committed_projection_v1`,storeVersion:l(o.storeVersion,`storeVersion`,`is invalid`),walletId:s,recoveryOperationId:c,targetDeviceId:u,targetAuthorityId:d,targetWalletAuthMethodId:f,authority:m};if(a.kind===`passkey`){if(h.kind!==`passkey`)throw Error(`wallet recovery target method family changed`);let e=ue(o.target),t={...g,kind:`passkey`,authMethod:h,target:e};return N(t,a),P(t),t}if(h.kind!==`email_otp`)throw Error(`wallet recovery target method family changed`);let _=j(o.target),v={...g,kind:`google_email_otp`,authMethod:h,target:_};return N(v,a),P(v),v}function ue(e){let t=I(e);if(t.kind!==`passkey`)throw Error(`wallet recovery passkey target is invalid`);return{kind:`passkey`,rpId:V(n(t.rpId),`target.rpId`),credentialIdB64u:V(a(t.credentialIdB64u),`target.credentialIdB64u`)}}function j(e){let t=L(e);if(t.kind!==`google_email_otp`||t.provider!==`google`)throw Error(`wallet recovery Google Email OTP target is invalid`);return{kind:`google_email_otp`,provider:`google`,providerSubject:V(s(t.providerSubject),`target.providerSubject`),emailHashHex:H(t.emailHashHex),registrationAuthorityId:l(t.registrationAuthorityId,`target.registrationAuthorityId`,`is invalid`),enrollment:M(t.enrollment)}}function M(e){let t=R(e);if(t.kind!==`email_otp_enrollment_reference_v1`)throw Error(`wallet recovery Email OTP enrollment is invalid`);return{kind:`email_otp_enrollment_reference_v1`,enrollmentId:l(t.enrollmentId,`enrollment.enrollmentId`,`is invalid`),enrollmentSealKeyVersion:l(t.enrollmentSealKeyVersion,`enrollment.enrollmentSealKeyVersion`,`is invalid`)}}function N(e,t){if(e.kind!==t.kind||e.walletId!==t.walletId||e.recoveryOperationId!==t.recoveryOperationId||e.targetDeviceId!==t.targetDeviceId||e.targetAuthorityId!==t.targetAuthorityId||e.targetWalletAuthMethodId!==t.targetWalletAuthMethodId)throw Error(`wallet recovery committed projection identity changed`);if(e.kind===`passkey`&&t.kind===`passkey`){if(e.target.rpId!==t.rpId||e.target.credentialIdB64u!==t.credentialIdB64u)throw Error(`wallet recovery passkey target changed`);return}if(e.kind!==`google_email_otp`||t.kind!==`google_email_otp`)throw Error(`wallet recovery target identity changed`);if(e.target.providerSubject!==t.providerSubject||e.target.emailHashHex!==t.emailHashHex||e.target.registrationAuthorityId!==t.registrationAuthorityId||e.target.enrollment.enrollmentId!==t.enrollment.enrollmentId||e.target.enrollment.enrollmentSealKeyVersion!==t.enrollment.enrollmentSealKeyVersion)throw Error(`wallet recovery Google Email OTP target changed`)}function P(e){if(e.authority.walletId!==e.walletId||e.authority.authorityId!==e.targetAuthorityId||e.authority.principal.deviceId!==e.targetDeviceId||e.authority.provenance.kind!==`wallet_recovery`||e.authority.provenance.recoveryOperationId!==e.recoveryOperationId||e.authority.provenance.continuityAuthorityId===e.targetAuthorityId||e.authMethod.walletId!==e.walletId||e.authMethod.walletAuthorityId!==e.targetAuthorityId||e.authMethod.walletAuthMethodId!==e.targetWalletAuthMethodId||e.authMethod.status!==`active`)throw Error(`wallet recovery committed projection relations are invalid`);if(e.kind===`passkey`){if(e.authMethod.kind!==`passkey`||e.target.rpId!==e.authMethod.rpId||e.target.credentialIdB64u!==e.authMethod.credentialIdB64u)throw Error(`wallet recovery passkey projection relations are invalid`);return}if(e.authMethod.kind!==`email_otp`||e.target.emailHashHex!==e.authMethod.emailHashHex||e.target.registrationAuthorityId!==e.authMethod.registrationAuthorityId)throw Error(`wallet recovery Google Email OTP projection relations are invalid`)}function F(e){let t=z(e);if(t===null)throw Error(`wallet recovery committed projection must be an object`);return B(t,[`version`,`kind`,`storeVersion`,`walletId`,`recoveryOperationId`,`targetDeviceId`,`targetAuthorityId`,`targetWalletAuthMethodId`,`authority`,`authMethod`,`target`],`wallet recovery committed projection`),{version:Reflect.get(t,`version`),kind:Reflect.get(t,`kind`),storeVersion:Reflect.get(t,`storeVersion`),walletId:Reflect.get(t,`walletId`),recoveryOperationId:Reflect.get(t,`recoveryOperationId`),targetDeviceId:Reflect.get(t,`targetDeviceId`),targetAuthorityId:Reflect.get(t,`targetAuthorityId`),targetWalletAuthMethodId:Reflect.get(t,`targetWalletAuthMethodId`),authority:Reflect.get(t,`authority`),authMethod:Reflect.get(t,`authMethod`),target:Reflect.get(t,`target`)}}function I(e){let t=z(e);if(t===null)throw Error(`wallet recovery passkey target must be an object`);return B(t,[`kind`,`rpId`,`credentialIdB64u`],`wallet recovery passkey target`),{kind:Reflect.get(t,`kind`),rpId:Reflect.get(t,`rpId`),credentialIdB64u:Reflect.get(t,`credentialIdB64u`)}}function L(e){let t=z(e);if(t===null)throw Error(`wallet recovery Google Email OTP target must be an object`);return B(t,[`kind`,`provider`,`providerSubject`,`emailHashHex`,`registrationAuthorityId`,`enrollment`],`wallet recovery Google Email OTP target`),{kind:Reflect.get(t,`kind`),provider:Reflect.get(t,`provider`),providerSubject:Reflect.get(t,`providerSubject`),emailHashHex:Reflect.get(t,`emailHashHex`),registrationAuthorityId:Reflect.get(t,`registrationAuthorityId`),enrollment:Reflect.get(t,`enrollment`)}}function R(e){let t=z(e);if(t===null)throw Error(`wallet recovery Email OTP enrollment must be an object`);return B(t,[`kind`,`enrollmentId`,`enrollmentSealKeyVersion`],`wallet recovery Email OTP enrollment`),{kind:Reflect.get(t,`kind`),enrollmentId:Reflect.get(t,`enrollmentId`),enrollmentSealKeyVersion:Reflect.get(t,`enrollmentSealKeyVersion`)}}function z(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function B(e,t,n){let r=new Set(t),i=Object.keys(e);if(i.length!==t.length||i.some(e=>!r.has(e)))throw Error(`${n} contains unexpected fields`)}function V(e,t){if(!e.ok)throw Error(`${t} is invalid`);return e.value}function H(e){let t=l(e,`emailHashHex`,`is invalid`);if(!/^[0-9a-f]{64}$/.test(t))throw Error(`emailHashHex is invalid`);return t}const U=/^wallet-rkid-v1-[A-Za-z0-9_-]{43}$/;function W(e,t=`recoveryKeyId`){if(typeof e!=`string`||!U.test(e))throw Error(`${t} must be a derived wallet recovery key id`);return e}function de(){let e=[],t=[];for(let n=0;n<10;n+=1){let n=pe();t.push(n),e.push(k(O(n)))}return{codes:e,codeBytes:t}}function fe(e){for(let t of e.codeBytes)t.fill(0)}function pe(){let e=globalThis.crypto;if(!e?.getRandomValues)throw Error(`a secure random source is required to issue wallet recovery codes`);return e.getRandomValues(new Uint8Array(20))}function me(e,t=`recoveryCodeLocator`){try{return x(e)}catch(e){throw Error(`${t} ${e instanceof Error?e.message:`must be a canonical digest`}`)}}async function he(e){if(!(e instanceof Uint8Array)||e.length!==20)throw Error(`recovery code bytes must be exactly 20 bytes`);let t=null;try{let n=new TextEncoder().encode(`seams/wallet-recovery/code-locator/v1`);t=new Uint8Array(8+n.length+e.length);let r=new DataView(t.buffer);return r.setUint32(0,n.length,!1),t.set(n,4),r.setUint32(4+n.length,e.length,!1),t.set(e,8+n.length),me(_(await d(t)))}finally{t?.fill(0)}}function ge(e){return{custodySecretKind:`wallet_custody_seed_v1`,nonceB64u:e.nonceB64u,wrappedCustodySecretB64u:e.wrappedCustodySecretB64u,aadHashB64u:e.aadHashB64u}}function _e(e,t){let n=t.label||`walletRecoverySetRotation`,i=u(e,n);p(i,be,n);let a=r(i.walletId);if(!a.ok)throw Error(`${n}.walletId ${a.error.message}`);if(String(a.value)!==String(t.expectedWalletId))throw Error(`${n}.walletId is outside the authenticated wallet`);if(!Array.isArray(i.manifestKekWraps))throw Error(`${n}.manifestKekWraps must be an array`);if(i.manifestKekWraps.length!==10)throw Error(`${n}.manifestKekWraps must carry exactly 10 recovery-code wraps`);let o=i.manifestKekWraps.map((e,t)=>{let r=u(e,`${n}.manifestKekWraps[${t}]`);return p(r,ye,`${n}.manifestKekWraps[${t}]`),{recoveryKeyId:W(r.recoveryKeyId,`${n}.manifestKekWraps[${t}].recoveryKeyId`),nonceB64u:m(r.nonceB64u,`${n}.manifestKekWraps[${t}].nonceB64u`),ciphertextB64u:h(r.ciphertextB64u,`${n}.manifestKekWraps[${t}].ciphertextB64u`),aadHashB64u:g(r.aadHashB64u,`${n}.manifestKekWraps[${t}].aadHashB64u`)}}),s=new Set;for(let e of o){let t=String(e.recoveryKeyId);if(!s.add(t))throw Error(`${n} contains duplicate recovery key ids`)}if(!Array.isArray(i.entries)||i.entries.length!==1)throw Error(`${n}.entries must carry exactly one wallet custody seed entry`);let c=G(i.entries[0],`${n}.entries[0]`);return{walletId:a.value,manifestKekWraps:o,entry:c}}const ve=[`custodySecretKind`,`nonceB64u`,`wrappedCustodySecretB64u`,`aadHashB64u`],ye=[`recoveryKeyId`,`nonceB64u`,`ciphertextB64u`,`aadHashB64u`],be=[`walletId`,`manifestKekWraps`,`entries`];function G(e,t){let n=u(e,t);if(p(n,ve,t),n.custodySecretKind!==`wallet_custody_seed_v1`)throw Error(`${t}.custodySecretKind must be wallet_custody_seed_v1; lane holder shares are reprovisioned, not recovered`);return ge({nonceB64u:m(n.nonceB64u,`${t}.nonceB64u`),wrappedCustodySecretB64u:h(n.wrappedCustodySecretB64u,`${t}.wrappedCustodySecretB64u`),aadHashB64u:g(n.aadHashB64u,`${t}.aadHashB64u`)})}function K(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} must be an object`);return e}function q(e,t){let n=typeof e==`string`?e.trim():``;if(!n)throw Error(`${t} is required`);return n}function xe(e){let t=K(e,`rotation worker result`);if(!Array.isArray(t.recoveryManifestKekWraps)||t.recoveryManifestKekWraps.length!==10)throw Error(`rotation worker result must contain exactly 10 recovery wraps`);return{walletId:q(t.walletId,`rotation worker walletId`),recoveryManifestKekWraps:t.recoveryManifestKekWraps.map((e,t)=>{let n=K(e,`rotation worker wrap ${t}`);return{recoveryKeyId:q(n.recoveryKeyId,`rotation worker wrap ${t} recoveryKeyId`),nonceB64u:q(n.nonceB64u,`rotation worker wrap ${t} nonceB64u`),ciphertextB64u:q(n.ciphertextB64u,`rotation worker wrap ${t} ciphertextB64u`),aadHashB64u:q(n.aadHashB64u,`rotation worker wrap ${t} aadHashB64u`)}}),recoveryEntryNonceB64u:q(t.recoveryEntryNonceB64u,`rotation worker recoveryEntryNonceB64u`),recoveryEntryCiphertextB64u:q(t.recoveryEntryCiphertextB64u,`rotation worker recoveryEntryCiphertextB64u`),recoveryEntryAadHashB64u:q(t.recoveryEntryAadHashB64u,`rotation worker recoveryEntryAadHashB64u`)}}function Se(e){let t=xe(e),n=r(t.walletId);if(!n.ok)throw Error(`rotation worker wallet id is invalid: ${n.error.message}`);let i={custodySecretKind:`wallet_custody_seed_v1`,nonceB64u:m(t.recoveryEntryNonceB64u,`rotation.entry.nonceB64u`),wrappedCustodySecretB64u:h(t.recoveryEntryCiphertextB64u,`rotation.entry.wrappedCustodySecretB64u`),aadHashB64u:g(t.recoveryEntryAadHashB64u,`rotation.entry.aadHashB64u`)};return _e({walletId:n.value,manifestKekWraps:t.recoveryManifestKekWraps.map(e=>({recoveryKeyId:W(e.recoveryKeyId,`rotation.recoveryKeyId`),nonceB64u:m(e.nonceB64u,`rotation.wrap.nonceB64u`),ciphertextB64u:h(e.ciphertextB64u,`rotation.wrap.ciphertextB64u`),aadHashB64u:g(e.aadHashB64u,`rotation.wrap.aadHashB64u`)})),entries:[i]},{expectedWalletId:n.value,label:`rotation.workerResult`})}const J=`secp256k1_bip340_sha256_v1`;function Y(e,t,n){let r=new Set(n);for(let n of Object.keys(e))if(!r.has(n))throw Error(`${t}.${n} is not a supported field`);for(let r of n)if(!Object.hasOwn(e,r))throw Error(`${t}.${r} is required`)}function X(e,t){if(typeof e!=`string`||e.length===0||e.trim()!==e)throw Error(`${t} must be a non-empty canonical identifier`);for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r<33||r>126)throw Error(`${t} must contain visible ASCII bytes`)}return e}function Z(e){return e.startsWith(`evm_family_ecdsa:`)&&e.length>17}function Ce(e,t){let n=X(e,t);if(!Z(n))throw Error(`${t} must identify an ECDSA key set`);return n}function Q(e,t){try{return x(e)}catch{throw Error(`${t} must be canonical base64url for 32 bytes`)}}function we(e,t){if(typeof e!=`string`||!/^[A-Za-z0-9_-]+$/.test(e))throw Error(`${t} must be canonical base64url`);let n;try{n=v(e)}catch{throw Error(`${t} must be valid base64url`)}if(n.length!==33||n[0]!==2&&n[0]!==3||_(n)!==e)throw Error(`${t} must be canonical compressed secp256k1 public key bytes`);return e}function Te(e,t){if(typeof e!=`number`||!Number.isSafeInteger(e)||e<=0)throw Error(`${t} must be a positive safe integer`);return e}function Ee(e,t){if(typeof e!=`string`||!/^[A-Za-z0-9_-]+$/.test(e))throw Error(`${t} must be canonical base64url`);let n;try{n=v(e)}catch{throw Error(`${t} must be valid base64url`)}if(n.length!==64||_(n)!==e)throw Error(`${t} must be canonical base64url for 64 bytes`);return e}function $(e){let t=u(e,`walletRecoveryEcdsaPossessionChallenge`);if(Y(t,`walletRecoveryEcdsaPossessionChallenge`,[`kind`,`walletId`,`reservationId`,`replacementId`,`keySetId`,`keyHandle`,`recordedKeyManifestDigestB64u`,`publicCapabilityDigestB64u`,`authorityRefDigestB64u`,`derivationClientSharePublicKey33B64u`,`expectedServerGeneration`,`expiresAtMs`,`serverNonceB64u`]),t.kind!==`wallet_recovery_ecdsa_possession_challenge_v1`)throw Error(`walletRecoveryEcdsaPossessionChallenge.kind is invalid`);let n=Ce(t.keySetId,`walletRecoveryEcdsaPossessionChallenge.keySetId`);return{kind:`wallet_recovery_ecdsa_possession_challenge_v1`,walletId:X(t.walletId,`walletRecoveryEcdsaPossessionChallenge.walletId`),reservationId:X(t.reservationId,`walletRecoveryEcdsaPossessionChallenge.reservationId`),replacementId:X(t.replacementId,`walletRecoveryEcdsaPossessionChallenge.replacementId`),keySetId:n,keyHandle:X(t.keyHandle,`walletRecoveryEcdsaPossessionChallenge.keyHandle`),recordedKeyManifestDigestB64u:Q(t.recordedKeyManifestDigestB64u,`walletRecoveryEcdsaPossessionChallenge.recordedKeyManifestDigestB64u`),publicCapabilityDigestB64u:Q(t.publicCapabilityDigestB64u,`walletRecoveryEcdsaPossessionChallenge.publicCapabilityDigestB64u`),authorityRefDigestB64u:Q(t.authorityRefDigestB64u,`walletRecoveryEcdsaPossessionChallenge.authorityRefDigestB64u`),derivationClientSharePublicKey33B64u:we(t.derivationClientSharePublicKey33B64u,`walletRecoveryEcdsaPossessionChallenge.derivationClientSharePublicKey33B64u`),expectedServerGeneration:X(t.expectedServerGeneration,`walletRecoveryEcdsaPossessionChallenge.expectedServerGeneration`),expiresAtMs:Te(t.expiresAtMs,`walletRecoveryEcdsaPossessionChallenge.expiresAtMs`),serverNonceB64u:Q(t.serverNonceB64u,`walletRecoveryEcdsaPossessionChallenge.serverNonceB64u`)}}function De(e){let t=u(e,`walletRecoveryEcdsaPossessionProof`);if(Y(t,`walletRecoveryEcdsaPossessionProof`,[`kind`,`scheme`,`signature64B64u`]),t.kind!==`wallet_recovery_ecdsa_possession_proof_v1`)throw Error(`walletRecoveryEcdsaPossessionProof.kind is invalid`);if(t.scheme!==J)throw Error(`walletRecoveryEcdsaPossessionProof.scheme is invalid`);return{kind:`wallet_recovery_ecdsa_possession_proof_v1`,scheme:J,signature64B64u:Ee(t.signature64B64u,`walletRecoveryEcdsaPossessionProof.signature64B64u`)}}function Oe(e){let t=$(e),n=[`seams/wallet-recovery/ecdsa-existing-material-possession/v1`,J,t.walletId,t.reservationId,t.replacementId,t.keySetId,t.keyHandle,v(t.recordedKeyManifestDigestB64u),v(t.publicCapabilityDigestB64u),v(t.authorityRefDigestB64u),v(t.derivationClientSharePublicKey33B64u),t.expectedServerGeneration,v(t.serverNonceB64u),ke(t.expiresAtMs)],r=[];for(let e of n){let t=typeof e==`string`?new TextEncoder().encode(e):e,n=t.length;if(n>4294967295)throw Error(`wallet recovery possession field is too large`);r.push(n>>>24&255,n>>>16&255,n>>>8&255,n&255,...t)}return Uint8Array.from(r)}function ke(e){let t=BigInt(e),n=new Uint8Array(8);for(let e=n.length-1;e>=0;--e)n[e]=Number(t&255n),t>>=8n;return n}async function Ae(e){return y(Oe(e))}export{G as a,fe as c,ie as d,ae as f,Se as i,oe as l,re as m,De as n,he as o,ne as p,Ae as r,de as s,$ as t,le as u};
|
|
1
|
+
import{A as e,D as t,M as n,O as r,T as i,j as a,n as o,s}from"./domainIds-BzkGsRqO.js";import{c,j as l,k as u,l as d,u as f}from"./chains-C_X_fNuS.js";import{_ as p,i as m,r as h,t as g}from"./primitives-CqrjmIAH.js";import{i as _,r as v}from"./base64-DW79QA0h.js";import{l as ee}from"./capabilityKinds-N8xo_IEh.js";import{a as y,n as b,r as x}from"./canonicalPrimitives-Dsbsxgxc.js";import{d as te,h as S,s as C}from"./walletAuthority-BWvfaKIX.js";import{r as w}from"./walletAuthMethodRecord-CnBw27ED.js";const T=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,E=Object.freeze(Array.from(T).reduce((e,t,n)=>(e[t]=n,e),{}));function D(e){if(!e)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function O(e){if(e.byteLength!==20)throw Error(`Email OTP recovery key bytes must be exactly 20 bytes`);let t=0,n=0,r=``;for(let i=0;i<e.byteLength;i++)for(t=t<<8|e[i],n+=8;n>=5;)n-=5,r+=T[t>>n&31],t&=(1<<n)-1;return r}function k(e){let t=A(e),n=[],r=0;for(let e=0;e<8;e++)n.push(t.slice(r,r+4)),r+=4;return n.join(`-`)}function ne(e){if(e.length!==10)throw Error(`Email OTP recovery code set must contain 10 keys`);return[k(e[0]),k(e[1]),k(e[2]),k(e[3]),k(e[4]),k(e[5]),k(e[6]),k(e[7]),k(e[8]),k(e[9])]}function A(e){let t=String(e||``).replace(/[\s-]/g,``).toUpperCase();if(t.length!==32)throw Error(`Email OTP recovery key must be 32 Crockford Base32 characters`);if(D(t))throw Error(`Email OTP recovery key must not be decimal-only`);for(let e=0;e<t.length;e++)if(E[t[e]]===void 0)throw Error(`Email OTP recovery key contains unsupported characters`);return t}function re(e){let t=A(e),n=new Uint8Array(20),r=0,i=0,a=0;for(let e=0;e<t.length;e++)r=r<<5|E[t[e]],i+=5,i>=8&&(i-=8,n[a]=r>>i&255,r&=(1<<i)-1,a+=1);return n}async function ie(e){let t=String(e.keySetId||``).trim();if(!/^(near_ed25519|evm_family_ecdsa):\S+$/.test(t))throw Error(`wallet recovery key-set id is invalid`);return b(`wallet-recovery-key-v1:${_(await f(c({domain:`seams/wallet-recovery/key-lifecycle/v1`,reservationId:e.reservationId,keySetId:t})))}`)}function ae(e){if(typeof e!=`string`||e.length===0||e.length>512||e.trim()!==e||o(e))throw Error(`recovery code reservation id must be a compact opaque identifier`);return e}function oe(e){return e.kind===`passkey`?se(e):ce(e)}function se(e){let t={version:`wallet_recovery_committed_projection_v1`,storeVersion:l(e.storeVersion,`storeVersion`,`is invalid`),walletId:e.walletId,recoveryOperationId:e.recoveryOperationId,targetDeviceId:e.targetDeviceId,targetAuthorityId:e.targetAuthorityId,targetWalletAuthMethodId:e.targetWalletAuthMethodId,authority:e.authority,kind:`passkey`,authMethod:e.authMethod,target:{kind:`passkey`,rpId:e.authMethod.rpId,credentialIdB64u:e.authMethod.credentialIdB64u}};return P(t),t}function ce(e){let t={version:`wallet_recovery_committed_projection_v1`,storeVersion:l(e.storeVersion,`storeVersion`,`is invalid`),walletId:e.walletId,recoveryOperationId:e.recoveryOperationId,targetDeviceId:e.targetDeviceId,targetAuthorityId:e.targetAuthorityId,targetWalletAuthMethodId:e.targetWalletAuthMethodId,authority:e.authority,kind:`google_email_otp`,authMethod:e.authMethod,target:{kind:`google_email_otp`,provider:`google`,providerSubject:e.providerSubject,emailHashHex:H(e.emailHashHex),registrationAuthorityId:l(e.registrationAuthorityId,`registrationAuthorityId`,`is invalid`),enrollment:M(e.enrollment)}};return P(t),t}async function le(n,a){let o=F(n);if(o.version!==`wallet_recovery_committed_projection_v1`)throw Error(`wallet recovery committed projection version is invalid`);if(o.kind!==a.kind)throw Error(`wallet recovery committed projection target changed`);let s=V(r(o.walletId),`walletId`),c=V(e(o.recoveryOperationId),`recoveryOperationId`),u=V(ee(o.targetDeviceId),`targetDeviceId`),d=V(t(o.targetAuthorityId),`targetAuthorityId`),f=V(i(o.targetWalletAuthMethodId),`targetWalletAuthMethodId`),p=te(o.authority);if(!p.ok)throw Error(`wallet recovery authority projection is invalid`);let m=p.value;if(m.state!==`active`||!C(m)||!await S(m))throw Error(`wallet recovery authority projection digest or lifecycle is invalid`);let h=w(o.authMethod);if(!h||h.status!==`active`)throw Error(`wallet recovery auth method projection is invalid`);let g={version:`wallet_recovery_committed_projection_v1`,storeVersion:l(o.storeVersion,`storeVersion`,`is invalid`),walletId:s,recoveryOperationId:c,targetDeviceId:u,targetAuthorityId:d,targetWalletAuthMethodId:f,authority:m};if(a.kind===`passkey`){if(h.kind!==`passkey`)throw Error(`wallet recovery target method family changed`);let e=ue(o.target),t={...g,kind:`passkey`,authMethod:h,target:e};return N(t,a),P(t),t}if(h.kind!==`email_otp`)throw Error(`wallet recovery target method family changed`);let _=j(o.target),v={...g,kind:`google_email_otp`,authMethod:h,target:_};return N(v,a),P(v),v}function ue(e){let t=I(e);if(t.kind!==`passkey`)throw Error(`wallet recovery passkey target is invalid`);return{kind:`passkey`,rpId:V(n(t.rpId),`target.rpId`),credentialIdB64u:V(a(t.credentialIdB64u),`target.credentialIdB64u`)}}function j(e){let t=L(e);if(t.kind!==`google_email_otp`||t.provider!==`google`)throw Error(`wallet recovery Google Email OTP target is invalid`);return{kind:`google_email_otp`,provider:`google`,providerSubject:V(s(t.providerSubject),`target.providerSubject`),emailHashHex:H(t.emailHashHex),registrationAuthorityId:l(t.registrationAuthorityId,`target.registrationAuthorityId`,`is invalid`),enrollment:M(t.enrollment)}}function M(e){let t=R(e);if(t.kind!==`email_otp_enrollment_reference_v1`)throw Error(`wallet recovery Email OTP enrollment is invalid`);return{kind:`email_otp_enrollment_reference_v1`,enrollmentId:l(t.enrollmentId,`enrollment.enrollmentId`,`is invalid`),enrollmentSealKeyVersion:l(t.enrollmentSealKeyVersion,`enrollment.enrollmentSealKeyVersion`,`is invalid`)}}function N(e,t){if(e.kind!==t.kind||e.walletId!==t.walletId||e.recoveryOperationId!==t.recoveryOperationId||e.targetDeviceId!==t.targetDeviceId||e.targetAuthorityId!==t.targetAuthorityId||e.targetWalletAuthMethodId!==t.targetWalletAuthMethodId)throw Error(`wallet recovery committed projection identity changed`);if(e.kind===`passkey`&&t.kind===`passkey`){if(e.target.rpId!==t.rpId||e.target.credentialIdB64u!==t.credentialIdB64u)throw Error(`wallet recovery passkey target changed`);return}if(e.kind!==`google_email_otp`||t.kind!==`google_email_otp`)throw Error(`wallet recovery target identity changed`);if(e.target.providerSubject!==t.providerSubject||e.target.emailHashHex!==t.emailHashHex||e.target.registrationAuthorityId!==t.registrationAuthorityId||e.target.enrollment.enrollmentId!==t.enrollment.enrollmentId||e.target.enrollment.enrollmentSealKeyVersion!==t.enrollment.enrollmentSealKeyVersion)throw Error(`wallet recovery Google Email OTP target changed`)}function P(e){if(e.authority.walletId!==e.walletId||e.authority.authorityId!==e.targetAuthorityId||e.authority.principal.deviceId!==e.targetDeviceId||e.authority.provenance.kind!==`wallet_recovery`||e.authority.provenance.recoveryOperationId!==e.recoveryOperationId||e.authority.provenance.continuityAuthorityId===e.targetAuthorityId||e.authMethod.walletId!==e.walletId||e.authMethod.walletAuthorityId!==e.targetAuthorityId||e.authMethod.walletAuthMethodId!==e.targetWalletAuthMethodId||e.authMethod.status!==`active`)throw Error(`wallet recovery committed projection relations are invalid`);if(e.kind===`passkey`){if(e.authMethod.kind!==`passkey`||e.target.rpId!==e.authMethod.rpId||e.target.credentialIdB64u!==e.authMethod.credentialIdB64u)throw Error(`wallet recovery passkey projection relations are invalid`);return}if(e.authMethod.kind!==`email_otp`||e.target.emailHashHex!==e.authMethod.emailHashHex||e.target.registrationAuthorityId!==e.authMethod.registrationAuthorityId)throw Error(`wallet recovery Google Email OTP projection relations are invalid`)}function F(e){let t=z(e);if(t===null)throw Error(`wallet recovery committed projection must be an object`);return B(t,[`version`,`kind`,`storeVersion`,`walletId`,`recoveryOperationId`,`targetDeviceId`,`targetAuthorityId`,`targetWalletAuthMethodId`,`authority`,`authMethod`,`target`],`wallet recovery committed projection`),{version:Reflect.get(t,`version`),kind:Reflect.get(t,`kind`),storeVersion:Reflect.get(t,`storeVersion`),walletId:Reflect.get(t,`walletId`),recoveryOperationId:Reflect.get(t,`recoveryOperationId`),targetDeviceId:Reflect.get(t,`targetDeviceId`),targetAuthorityId:Reflect.get(t,`targetAuthorityId`),targetWalletAuthMethodId:Reflect.get(t,`targetWalletAuthMethodId`),authority:Reflect.get(t,`authority`),authMethod:Reflect.get(t,`authMethod`),target:Reflect.get(t,`target`)}}function I(e){let t=z(e);if(t===null)throw Error(`wallet recovery passkey target must be an object`);return B(t,[`kind`,`rpId`,`credentialIdB64u`],`wallet recovery passkey target`),{kind:Reflect.get(t,`kind`),rpId:Reflect.get(t,`rpId`),credentialIdB64u:Reflect.get(t,`credentialIdB64u`)}}function L(e){let t=z(e);if(t===null)throw Error(`wallet recovery Google Email OTP target must be an object`);return B(t,[`kind`,`provider`,`providerSubject`,`emailHashHex`,`registrationAuthorityId`,`enrollment`],`wallet recovery Google Email OTP target`),{kind:Reflect.get(t,`kind`),provider:Reflect.get(t,`provider`),providerSubject:Reflect.get(t,`providerSubject`),emailHashHex:Reflect.get(t,`emailHashHex`),registrationAuthorityId:Reflect.get(t,`registrationAuthorityId`),enrollment:Reflect.get(t,`enrollment`)}}function R(e){let t=z(e);if(t===null)throw Error(`wallet recovery Email OTP enrollment must be an object`);return B(t,[`kind`,`enrollmentId`,`enrollmentSealKeyVersion`],`wallet recovery Email OTP enrollment`),{kind:Reflect.get(t,`kind`),enrollmentId:Reflect.get(t,`enrollmentId`),enrollmentSealKeyVersion:Reflect.get(t,`enrollmentSealKeyVersion`)}}function z(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function B(e,t,n){let r=new Set(t),i=Object.keys(e);if(i.length!==t.length||i.some(e=>!r.has(e)))throw Error(`${n} contains unexpected fields`)}function V(e,t){if(!e.ok)throw Error(`${t} is invalid`);return e.value}function H(e){let t=l(e,`emailHashHex`,`is invalid`);if(!/^[0-9a-f]{64}$/.test(t))throw Error(`emailHashHex is invalid`);return t}const U=/^wallet-rkid-v1-[A-Za-z0-9_-]{43}$/;function W(e,t=`recoveryKeyId`){if(typeof e!=`string`||!U.test(e))throw Error(`${t} must be a derived wallet recovery key id`);return e}function de(){let e=[],t=[];for(let n=0;n<10;n+=1){let n=pe();t.push(n),e.push(k(O(n)))}return{codes:e,codeBytes:t}}function fe(e){for(let t of e.codeBytes)t.fill(0)}function pe(){let e=globalThis.crypto;if(!e?.getRandomValues)throw Error(`a secure random source is required to issue wallet recovery codes`);return e.getRandomValues(new Uint8Array(20))}function me(e,t=`recoveryCodeLocator`){try{return x(e)}catch(e){throw Error(`${t} ${e instanceof Error?e.message:`must be a canonical digest`}`)}}async function he(e){if(!(e instanceof Uint8Array)||e.length!==20)throw Error(`recovery code bytes must be exactly 20 bytes`);let t=null;try{let n=new TextEncoder().encode(`seams/wallet-recovery/code-locator/v1`);t=new Uint8Array(8+n.length+e.length);let r=new DataView(t.buffer);return r.setUint32(0,n.length,!1),t.set(n,4),r.setUint32(4+n.length,e.length,!1),t.set(e,8+n.length),me(_(await d(t)))}finally{t?.fill(0)}}function ge(e){return{custodySecretKind:`wallet_custody_seed_v1`,nonceB64u:e.nonceB64u,wrappedCustodySecretB64u:e.wrappedCustodySecretB64u,aadHashB64u:e.aadHashB64u}}function _e(e,t){let n=t.label||`walletRecoverySetRotation`,i=u(e,n);p(i,be,n);let a=r(i.walletId);if(!a.ok)throw Error(`${n}.walletId ${a.error.message}`);if(String(a.value)!==String(t.expectedWalletId))throw Error(`${n}.walletId is outside the authenticated wallet`);if(!Array.isArray(i.manifestKekWraps))throw Error(`${n}.manifestKekWraps must be an array`);if(i.manifestKekWraps.length!==10)throw Error(`${n}.manifestKekWraps must carry exactly 10 recovery-code wraps`);let o=i.manifestKekWraps.map((e,t)=>{let r=u(e,`${n}.manifestKekWraps[${t}]`);return p(r,ye,`${n}.manifestKekWraps[${t}]`),{recoveryKeyId:W(r.recoveryKeyId,`${n}.manifestKekWraps[${t}].recoveryKeyId`),nonceB64u:m(r.nonceB64u,`${n}.manifestKekWraps[${t}].nonceB64u`),ciphertextB64u:h(r.ciphertextB64u,`${n}.manifestKekWraps[${t}].ciphertextB64u`),aadHashB64u:g(r.aadHashB64u,`${n}.manifestKekWraps[${t}].aadHashB64u`)}}),s=new Set;for(let e of o){let t=String(e.recoveryKeyId);if(!s.add(t))throw Error(`${n} contains duplicate recovery key ids`)}if(!Array.isArray(i.entries)||i.entries.length!==1)throw Error(`${n}.entries must carry exactly one wallet custody seed entry`);let c=G(i.entries[0],`${n}.entries[0]`);return{walletId:a.value,manifestKekWraps:o,entry:c}}const ve=[`custodySecretKind`,`nonceB64u`,`wrappedCustodySecretB64u`,`aadHashB64u`],ye=[`recoveryKeyId`,`nonceB64u`,`ciphertextB64u`,`aadHashB64u`],be=[`walletId`,`manifestKekWraps`,`entries`];function G(e,t){let n=u(e,t);if(p(n,ve,t),n.custodySecretKind!==`wallet_custody_seed_v1`)throw Error(`${t}.custodySecretKind must be wallet_custody_seed_v1; lane holder shares are reprovisioned, not recovered`);return ge({nonceB64u:m(n.nonceB64u,`${t}.nonceB64u`),wrappedCustodySecretB64u:h(n.wrappedCustodySecretB64u,`${t}.wrappedCustodySecretB64u`),aadHashB64u:g(n.aadHashB64u,`${t}.aadHashB64u`)})}function K(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} must be an object`);return e}function q(e,t){let n=typeof e==`string`?e.trim():``;if(!n)throw Error(`${t} is required`);return n}function xe(e){let t=K(e,`rotation worker result`);if(!Array.isArray(t.recoveryManifestKekWraps)||t.recoveryManifestKekWraps.length!==10)throw Error(`rotation worker result must contain exactly 10 recovery wraps`);return{walletId:q(t.walletId,`rotation worker walletId`),recoveryManifestKekWraps:t.recoveryManifestKekWraps.map((e,t)=>{let n=K(e,`rotation worker wrap ${t}`);return{recoveryKeyId:q(n.recoveryKeyId,`rotation worker wrap ${t} recoveryKeyId`),nonceB64u:q(n.nonceB64u,`rotation worker wrap ${t} nonceB64u`),ciphertextB64u:q(n.ciphertextB64u,`rotation worker wrap ${t} ciphertextB64u`),aadHashB64u:q(n.aadHashB64u,`rotation worker wrap ${t} aadHashB64u`)}}),recoveryEntryNonceB64u:q(t.recoveryEntryNonceB64u,`rotation worker recoveryEntryNonceB64u`),recoveryEntryCiphertextB64u:q(t.recoveryEntryCiphertextB64u,`rotation worker recoveryEntryCiphertextB64u`),recoveryEntryAadHashB64u:q(t.recoveryEntryAadHashB64u,`rotation worker recoveryEntryAadHashB64u`)}}function Se(e){let t=xe(e),n=r(t.walletId);if(!n.ok)throw Error(`rotation worker wallet id is invalid: ${n.error.message}`);let i={custodySecretKind:`wallet_custody_seed_v1`,nonceB64u:m(t.recoveryEntryNonceB64u,`rotation.entry.nonceB64u`),wrappedCustodySecretB64u:h(t.recoveryEntryCiphertextB64u,`rotation.entry.wrappedCustodySecretB64u`),aadHashB64u:g(t.recoveryEntryAadHashB64u,`rotation.entry.aadHashB64u`)};return _e({walletId:n.value,manifestKekWraps:t.recoveryManifestKekWraps.map(e=>({recoveryKeyId:W(e.recoveryKeyId,`rotation.recoveryKeyId`),nonceB64u:m(e.nonceB64u,`rotation.wrap.nonceB64u`),ciphertextB64u:h(e.ciphertextB64u,`rotation.wrap.ciphertextB64u`),aadHashB64u:g(e.aadHashB64u,`rotation.wrap.aadHashB64u`)})),entries:[i]},{expectedWalletId:n.value,label:`rotation.workerResult`})}const J=`secp256k1_bip340_sha256_v1`;function Y(e,t,n){let r=new Set(n);for(let n of Object.keys(e))if(!r.has(n))throw Error(`${t}.${n} is not a supported field`);for(let r of n)if(!Object.hasOwn(e,r))throw Error(`${t}.${r} is required`)}function X(e,t){if(typeof e!=`string`||e.length===0||e.trim()!==e)throw Error(`${t} must be a non-empty canonical identifier`);for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r<33||r>126)throw Error(`${t} must contain visible ASCII bytes`)}return e}function Z(e){return e.startsWith(`evm_family_ecdsa:`)&&e.length>17}function Ce(e,t){let n=X(e,t);if(!Z(n))throw Error(`${t} must identify an ECDSA key set`);return n}function Q(e,t){try{return x(e)}catch{throw Error(`${t} must be canonical base64url for 32 bytes`)}}function we(e,t){if(typeof e!=`string`||!/^[A-Za-z0-9_-]+$/.test(e))throw Error(`${t} must be canonical base64url`);let n;try{n=v(e)}catch{throw Error(`${t} must be valid base64url`)}if(n.length!==33||n[0]!==2&&n[0]!==3||_(n)!==e)throw Error(`${t} must be canonical compressed secp256k1 public key bytes`);return e}function Te(e,t){if(typeof e!=`number`||!Number.isSafeInteger(e)||e<=0)throw Error(`${t} must be a positive safe integer`);return e}function Ee(e,t){if(typeof e!=`string`||!/^[A-Za-z0-9_-]+$/.test(e))throw Error(`${t} must be canonical base64url`);let n;try{n=v(e)}catch{throw Error(`${t} must be valid base64url`)}if(n.length!==64||_(n)!==e)throw Error(`${t} must be canonical base64url for 64 bytes`);return e}function $(e){let t=u(e,`walletRecoveryEcdsaPossessionChallenge`);if(Y(t,`walletRecoveryEcdsaPossessionChallenge`,[`kind`,`walletId`,`reservationId`,`replacementId`,`keySetId`,`keyHandle`,`recordedKeyManifestDigestB64u`,`publicCapabilityDigestB64u`,`authorityRefDigestB64u`,`derivationClientSharePublicKey33B64u`,`expectedServerGeneration`,`expiresAtMs`,`serverNonceB64u`]),t.kind!==`wallet_recovery_ecdsa_possession_challenge_v1`)throw Error(`walletRecoveryEcdsaPossessionChallenge.kind is invalid`);let n=Ce(t.keySetId,`walletRecoveryEcdsaPossessionChallenge.keySetId`);return{kind:`wallet_recovery_ecdsa_possession_challenge_v1`,walletId:X(t.walletId,`walletRecoveryEcdsaPossessionChallenge.walletId`),reservationId:X(t.reservationId,`walletRecoveryEcdsaPossessionChallenge.reservationId`),replacementId:X(t.replacementId,`walletRecoveryEcdsaPossessionChallenge.replacementId`),keySetId:n,keyHandle:X(t.keyHandle,`walletRecoveryEcdsaPossessionChallenge.keyHandle`),recordedKeyManifestDigestB64u:Q(t.recordedKeyManifestDigestB64u,`walletRecoveryEcdsaPossessionChallenge.recordedKeyManifestDigestB64u`),publicCapabilityDigestB64u:Q(t.publicCapabilityDigestB64u,`walletRecoveryEcdsaPossessionChallenge.publicCapabilityDigestB64u`),authorityRefDigestB64u:Q(t.authorityRefDigestB64u,`walletRecoveryEcdsaPossessionChallenge.authorityRefDigestB64u`),derivationClientSharePublicKey33B64u:we(t.derivationClientSharePublicKey33B64u,`walletRecoveryEcdsaPossessionChallenge.derivationClientSharePublicKey33B64u`),expectedServerGeneration:X(t.expectedServerGeneration,`walletRecoveryEcdsaPossessionChallenge.expectedServerGeneration`),expiresAtMs:Te(t.expiresAtMs,`walletRecoveryEcdsaPossessionChallenge.expiresAtMs`),serverNonceB64u:Q(t.serverNonceB64u,`walletRecoveryEcdsaPossessionChallenge.serverNonceB64u`)}}function De(e){let t=u(e,`walletRecoveryEcdsaPossessionProof`);if(Y(t,`walletRecoveryEcdsaPossessionProof`,[`kind`,`scheme`,`signature64B64u`]),t.kind!==`wallet_recovery_ecdsa_possession_proof_v1`)throw Error(`walletRecoveryEcdsaPossessionProof.kind is invalid`);if(t.scheme!==J)throw Error(`walletRecoveryEcdsaPossessionProof.scheme is invalid`);return{kind:`wallet_recovery_ecdsa_possession_proof_v1`,scheme:J,signature64B64u:Ee(t.signature64B64u,`walletRecoveryEcdsaPossessionProof.signature64B64u`)}}function Oe(e){let t=$(e),n=[`seams/wallet-recovery/ecdsa-existing-material-possession/v1`,J,t.walletId,t.reservationId,t.replacementId,t.keySetId,t.keyHandle,v(t.recordedKeyManifestDigestB64u),v(t.publicCapabilityDigestB64u),v(t.authorityRefDigestB64u),v(t.derivationClientSharePublicKey33B64u),t.expectedServerGeneration,v(t.serverNonceB64u),ke(t.expiresAtMs)],r=[];for(let e of n){let t=typeof e==`string`?new TextEncoder().encode(e):e,n=t.length;if(n>4294967295)throw Error(`wallet recovery possession field is too large`);r.push(n>>>24&255,n>>>16&255,n>>>8&255,n&255,...t)}return Uint8Array.from(r)}function ke(e){let t=BigInt(e),n=new Uint8Array(8);for(let e=n.length-1;e>=0;--e)n[e]=Number(t&255n),t>>=8n;return n}async function Ae(e){return y(Oe(e))}export{G as a,fe as c,ie as d,ae as f,A as g,re as h,Se as i,oe as l,ne as m,De as n,he as o,T as p,Ae as r,de as s,$ as t,le as u};
|