@seams/wallet 0.7.1 → 0.8.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.
Files changed (1880) hide show
  1. package/README.md +4 -5
  2. package/THIRD_PARTY_NOTICES.md +1 -113
  3. package/dist/.build-inputs.sha256 +1 -1
  4. package/dist/esm/SeamsWeb/SeamsWeb.js +12 -3
  5. package/dist/esm/SeamsWeb/assembly/browserSigningSurfaceAssembly.js +2 -2
  6. package/dist/esm/SeamsWeb/assembly/createBrowserRecoveryPublicDeps.js +1 -1
  7. package/dist/esm/SeamsWeb/assembly/createBrowserSigningStores.js +1 -1
  8. package/dist/esm/SeamsWeb/assembly/createBrowserWarmSessionPublicDeps.js +0 -2
  9. package/dist/esm/SeamsWeb/operations/auth/login.js +34 -49
  10. package/dist/esm/SeamsWeb/operations/auth/scheduleLinkedDevicePresignaturePrefill.js +64 -0
  11. package/dist/esm/SeamsWeb/operations/auth/walletAuth.js +2 -3
  12. package/dist/esm/SeamsWeb/operations/auth/walletUnlockEcdsaSubject.js +1 -4
  13. package/dist/esm/SeamsWeb/operations/auth/walletUnlockSubject.js +2 -8
  14. package/dist/esm/SeamsWeb/operations/authMethods/emailOtp/addEmailOtp.js +1 -1
  15. package/dist/esm/SeamsWeb/operations/authMethods/emailOtp/googleEmailOtpWalletAuthFlow.js +5 -9
  16. package/dist/esm/SeamsWeb/operations/authMethods/passkey/addPasskey.js +1 -1
  17. package/dist/esm/SeamsWeb/operations/authMethods/revokeAuthMethod.js +1 -1
  18. package/dist/esm/SeamsWeb/operations/devices/deviceLinkingHttpTransport.js +11 -12
  19. package/dist/esm/SeamsWeb/operations/devices/deviceLinkingResume.js +2 -9
  20. package/dist/esm/SeamsWeb/operations/devices/deviceLinkingWorkerChannels.js +24 -24
  21. package/dist/esm/SeamsWeb/operations/devices/linkDeviceFlow.js +38 -13
  22. package/dist/esm/SeamsWeb/operations/devices/scanDevice.js +1 -1
  23. package/dist/esm/SeamsWeb/operations/near/signNEP413.js +0 -1
  24. package/dist/esm/SeamsWeb/operations/recovery/syncAccount.js +2 -4
  25. package/dist/esm/SeamsWeb/operations/recovery/walletRecovery.js +1 -2
  26. package/dist/esm/SeamsWeb/operations/recovery/walletRecoveryCommit.js +4 -5
  27. package/dist/esm/SeamsWeb/operations/recovery/walletRecoveryDurablePayload.js +5 -9
  28. package/dist/esm/SeamsWeb/operations/recovery/walletRecoveryRotation.js +1 -2
  29. package/dist/esm/SeamsWeb/operations/registration/pendingRegistrationRecovery.js +5 -20
  30. package/dist/esm/SeamsWeb/operations/registration/registration.js +5 -5
  31. package/dist/esm/SeamsWeb/operations/registration/registrationStrictEcdsa.js +1 -1
  32. package/dist/esm/SeamsWeb/operations/registration/registrationTerminalCommit.js +1 -1
  33. package/dist/esm/SeamsWeb/operations/session/thresholdEcdsaProvisioning.js +2 -6
  34. package/dist/esm/SeamsWeb/operations/tempo/executeEvmFamilyTransaction.js +4 -1
  35. package/dist/esm/SeamsWeb/publicApi/auth.js +2 -1
  36. package/dist/esm/SeamsWeb/publicApi/near.js +1 -1
  37. package/dist/esm/SeamsWeb/publicApi/tempo.js +6 -0
  38. package/dist/esm/SeamsWeb/publicApi/transactionReview.js +4 -1
  39. package/dist/esm/SeamsWeb/signingSurface/BrowserSigningSurface.js +28 -19
  40. package/dist/esm/SeamsWeb/walletIframe/client/router.js +1 -2
  41. package/dist/esm/SeamsWeb/walletIframe/client/surface/domain.js +0 -2
  42. package/dist/esm/SeamsWeb/walletIframe/client/transport/IframeTransport.js +0 -4
  43. package/dist/esm/SeamsWeb/walletIframe/client/transport/iframe-transport-handshake.js +1 -1
  44. package/dist/esm/SeamsWeb/walletIframe/host/restoredSessionPresignaturePrefill.js +29 -0
  45. package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuFooter.js +64 -0
  46. package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.js +194 -385
  47. package/dist/esm/SeamsWeb/walletIframe/host/ui/auth-menu/icons.js +136 -0
  48. package/dist/esm/SeamsWeb/walletIframe/shared/exactSessionState.js +6 -26
  49. package/dist/esm/SeamsWeb/walletIframe/shared/messages.js +6 -6
  50. package/dist/esm/SeamsWeb/walletIframe/shared/transactionReview.js +11 -1
  51. package/dist/esm/advanced.js +0 -1
  52. package/dist/esm/base-styles.js +2 -2
  53. package/dist/esm/build-paths.js +0 -2
  54. package/dist/esm/core/accountData/near/accountProjection.js +0 -1
  55. package/dist/esm/core/accountData/near/keyMaterial.js +0 -1
  56. package/dist/esm/core/browser/walletIframe/events.js +1 -5
  57. package/dist/esm/core/browser/walletIframe/host-mode.js +0 -10
  58. package/dist/esm/core/config/chains.js +1 -2
  59. package/dist/esm/core/config/configBuilder.js +0 -1
  60. package/dist/esm/core/config/configHelpers.js +0 -1
  61. package/dist/esm/core/indexedDB/accountKeyMaterial.js +0 -1
  62. package/dist/esm/core/indexedDB/index.js +3 -4
  63. package/dist/esm/core/indexedDB/pendingWalletRecoveryCommit.js +6 -14
  64. package/dist/esm/core/indexedDB/pendingWalletRegistrationCommit.js +139 -273
  65. package/dist/esm/core/indexedDB/schemaNames.js +0 -22
  66. package/dist/esm/core/indexedDB/seamsWalletDB/ecdsaCapabilityManifestRecords.js +3 -3
  67. package/dist/esm/core/indexedDB/seamsWalletDB/ecdsaCapabilityManifestStore.js +3 -3
  68. package/dist/esm/core/indexedDB/seamsWalletDB/ecdsaClientPresignatures.js +1 -1
  69. package/dist/esm/core/indexedDB/seamsWalletDB/pendingWalletRecoveryCodeBackup.js +0 -1
  70. package/dist/esm/core/indexedDB/seamsWalletDB/registrationSetup.js +103 -0
  71. package/dist/esm/core/indexedDB/seamsWalletDB/repositories.js +2 -3
  72. package/dist/esm/core/indexedDB/seamsWalletDB/signingSessionSeals.js +0 -35
  73. package/dist/esm/core/indexedDB/seamsWalletDB/walletCustodyEcdsaContinuity.js +4 -4
  74. package/dist/esm/core/indexedDB/seamsWalletDB/walletSessionAuthorizationStore.js +37 -19
  75. package/dist/esm/core/indexedDB/unifiedIndexedDBManager.js +10 -3
  76. package/dist/esm/core/indexedDB/walletCustodyEd25519MaterialRecord.js +1 -1
  77. package/dist/esm/core/platform/browser/createBrowserPlatformRuntime.js +8 -25
  78. package/dist/esm/core/rpcClients/near/rpcCalls.js +39 -1
  79. package/dist/esm/core/rpcClients/relayer/passkeyCustodyEnvelope.js +3 -13
  80. package/dist/esm/core/rpcClients/relayer/thresholdEcdsa.js +0 -2
  81. package/dist/esm/core/rpcClients/relayer/walletRecoveryPrepare.js +72 -125
  82. package/dist/esm/core/rpcClients/relayer/walletRegistration.js +21 -15
  83. package/dist/esm/core/rpcClients/relayer/walletRegistrationTerminalResponse.js +1 -2
  84. package/dist/esm/core/signingEngine/assembly/createManagers.js +1 -1
  85. package/dist/esm/core/signingEngine/assembly/ports/recovery.js +1 -1
  86. package/dist/esm/core/signingEngine/assembly/ports/shared.js +1 -2
  87. package/dist/esm/core/signingEngine/assembly/warmup.js +1 -5
  88. package/dist/esm/core/signingEngine/chains/evm/display/functionSelectors.js +2 -5
  89. package/dist/esm/core/signingEngine/chains/near/nearSignerWasm.js +2 -33
  90. package/dist/esm/core/signingEngine/flows/recovery/ecdsaDerivationExport.js +0 -1
  91. package/dist/esm/core/signingEngine/flows/recovery/ecdsaExportFlow.js +2 -2
  92. package/dist/esm/core/signingEngine/flows/recovery/ecdsaExportMaterial.js +35 -29
  93. package/dist/esm/core/signingEngine/flows/recovery/ed25519YaoExportFlow.js +3 -3
  94. package/dist/esm/core/signingEngine/flows/recovery/exportKeypairOperation.js +1 -4
  95. package/dist/esm/core/signingEngine/flows/recovery/passkeyEd25519YaoRecovery.js +2 -5
  96. package/dist/esm/core/signingEngine/flows/recovery/stepUpAuthorization.js +1 -1
  97. package/dist/esm/core/signingEngine/flows/registration/accountLifecycle.js +3 -8
  98. package/dist/esm/core/signingEngine/flows/registration/services/passkeyEd25519YaoAddSigner.js +1 -2
  99. package/dist/esm/core/signingEngine/flows/shared/signingStateMachine.js +2 -5
  100. package/dist/esm/core/signingEngine/flows/signEvmFamily/emailOtpSigningSession.js +2 -2
  101. package/dist/esm/core/signingEngine/flows/signEvmFamily/preparedSigning.js +2 -9
  102. package/dist/esm/core/signingEngine/flows/signEvmFamily/readySecp256k1Material.js +0 -2
  103. package/dist/esm/core/signingEngine/flows/signEvmFamily/signEvmFamily.js +6 -8
  104. package/dist/esm/core/signingEngine/flows/signEvmFamily/signers/ecdsaDerivationClientSigningMaterialSource.js +24 -18
  105. package/dist/esm/core/signingEngine/flows/signEvmFamily/signingFlow.js +7 -5
  106. package/dist/esm/core/signingEngine/flows/signEvmFamily/signingFlowRuntime.js +10 -9
  107. package/dist/esm/core/signingEngine/flows/signEvmFamily/transactionExecutor.js +3 -7
  108. package/dist/esm/core/signingEngine/flows/signNear/implicitAccountFunding.js +1 -1
  109. package/dist/esm/core/signingEngine/flows/signNear/shared/ed25519YaoNormalSigning.js +33 -42
  110. package/dist/esm/core/signingEngine/flows/signNear/shared/signatureOnlySigning.js +0 -2
  111. package/dist/esm/core/signingEngine/flows/signNear/shared/signingMaterials.js +1 -7
  112. package/dist/esm/core/signingEngine/flows/signNear/shared/signingSessionAuthMode.js +4 -14
  113. package/dist/esm/core/signingEngine/flows/signNear/signDelegate.js +2 -6
  114. package/dist/esm/core/signingEngine/flows/signNear/signNear.js +2 -2
  115. package/dist/esm/core/signingEngine/flows/signNear/signNep413.js +2 -6
  116. package/dist/esm/core/signingEngine/nonce/NonceCoordinator.js +1 -1
  117. package/dist/esm/core/signingEngine/nonce/nearNonceLane.js +1 -1
  118. package/dist/esm/core/signingEngine/nonce/nonceDiagnostics.js +1 -1
  119. package/dist/esm/core/signingEngine/routerAb/ecdsaDerivation/poolFillRoutes.js +0 -1
  120. package/dist/esm/core/signingEngine/routerAb/ecdsaDerivation/presignaturePool.js +2 -1
  121. package/dist/esm/core/signingEngine/routerAb/ecdsaDerivation/signingMaterialRef.js +0 -3
  122. package/dist/esm/core/signingEngine/session/SigningSessionCoordinator.js +1 -4
  123. package/dist/esm/core/signingEngine/session/authority/authorityOperationResolver.js +17 -68
  124. package/dist/esm/core/signingEngine/session/availability/availableSigningLanes.js +1 -10
  125. package/dist/esm/core/signingEngine/session/availability/persistedAvailableSigningLanes.js +7 -6
  126. package/dist/esm/core/signingEngine/session/emailOtp/EmailOtpWalletSessionCoordinator.js +107 -24
  127. package/dist/esm/core/signingEngine/session/emailOtp/ecdsaBootstrapCommit.js +1 -1
  128. package/dist/esm/core/signingEngine/session/emailOtp/ecdsaLifecycleRuntime.js +0 -3
  129. package/dist/esm/core/signingEngine/session/emailOtp/ecdsaLogin.js +4 -15
  130. package/dist/esm/core/signingEngine/session/emailOtp/ecdsaRecovery.js +12 -16
  131. package/dist/esm/core/signingEngine/session/emailOtp/ed25519ExportContext.js +0 -3
  132. package/dist/esm/core/signingEngine/session/emailOtp/exportRecovery.js +0 -2
  133. package/dist/esm/core/signingEngine/session/identity/clientSessionPersistenceState.js +5 -16
  134. package/dist/esm/core/signingEngine/session/identity/evmFamilyEcdsaIdentity.js +0 -1
  135. package/dist/esm/core/signingEngine/session/identity/exactSigningLaneIdentity.js +1 -1
  136. package/dist/esm/core/signingEngine/session/identity/exactWalletSessionCredential.js +0 -2
  137. package/dist/esm/core/signingEngine/session/identity/selectLane.js +7 -21
  138. package/dist/esm/core/signingEngine/session/material/activeWalletAuthorityEcdsaRuntime.js +3 -9
  139. package/dist/esm/core/signingEngine/session/material/ecdsaCapabilityManifest.js +4 -16
  140. package/dist/esm/core/signingEngine/session/material/ecdsaRoleLocalMaterialResolver.js +1 -14
  141. package/dist/esm/core/signingEngine/session/material/ecdsaSigningCapability.js +1 -1
  142. package/dist/esm/core/signingEngine/session/operationState/preparedOperation.js +1 -5
  143. package/dist/esm/core/signingEngine/session/passkey/ecdsaBootstrap.js +3 -6
  144. package/dist/esm/core/signingEngine/session/passkey/ecdsaKeyFactsInventory.js +0 -1
  145. package/dist/esm/core/signingEngine/session/passkey/ecdsaRecovery.js +1 -4
  146. package/dist/esm/core/signingEngine/session/passkey/ed25519SessionProvision.js +0 -1
  147. package/dist/esm/core/signingEngine/session/passkey/ed25519YaoLocalMaterial.js +2 -3
  148. package/dist/esm/core/signingEngine/session/passkey/ed25519YaoWarmRecovery.js +13 -49
  149. package/dist/esm/core/signingEngine/session/persistence/clientSessionPersistence.js +8 -16
  150. package/dist/esm/core/signingEngine/session/persistence/sealedSessionRecords.js +5 -10
  151. package/dist/esm/core/signingEngine/session/postconditions/runtimePostconditions.js +0 -2
  152. package/dist/esm/core/signingEngine/session/routerAbSigningWalletSession.js +2 -8
  153. package/dist/esm/core/signingEngine/session/warmCapabilities/ecdsaLoginPrefillSigningMaterialSource.js +2 -2
  154. package/dist/esm/core/signingEngine/session/warmCapabilities/nearEd25519CapabilityRehydration.js +1 -1
  155. package/dist/esm/core/signingEngine/session/warmCapabilities/readModel.js +2 -8
  156. package/dist/esm/core/signingEngine/session/warmCapabilities/routerAbWalletSessionCredential.js +1 -12
  157. package/dist/esm/core/signingEngine/session/warmCapabilities/transitions.js +7 -11
  158. package/dist/esm/core/signingEngine/stepUpConfirmation/otpPrompt/authLane.js +0 -1
  159. package/dist/esm/core/signingEngine/stepUpConfirmation/passkeyPrompt/touchIdPrompt.js +6 -30
  160. package/dist/esm/core/signingEngine/stepUpConfirmation/passkeyPrompt/webauthnPromptCoordinator.js +0 -3
  161. package/dist/esm/core/signingEngine/stepUpConfirmation/requireStepUpAuth.js +1 -5
  162. package/dist/esm/core/signingEngine/threshold/commitQueueShared.js +20 -6
  163. package/dist/esm/core/signingEngine/threshold/crypto/ecdsaDerivationClientWasm.js +7 -4
  164. package/dist/esm/core/signingEngine/threshold/crypto/ed25519YaoLaneWasm.js +0 -3
  165. package/dist/esm/core/signingEngine/threshold/ecdsa/bootstrapSession.js +1 -5
  166. package/dist/esm/core/signingEngine/threshold/ecdsa/signingQueue.js +8 -50
  167. package/dist/esm/core/signingEngine/threshold/ed25519/commitQueue.js +7 -43
  168. package/dist/esm/core/signingEngine/threshold/ed25519/walletSession.js +1 -1
  169. package/dist/esm/core/signingEngine/threshold/ed25519/yaoClient.js +1 -35
  170. package/dist/esm/core/signingEngine/threshold/sessionPolicy.js +0 -1
  171. package/dist/esm/core/signingEngine/uiConfirm/PasskeyMpcSessionDurableState.js +1 -4
  172. package/dist/esm/core/signingEngine/uiConfirm/PasskeyMpcSessionManager.js +4 -3
  173. package/dist/esm/core/signingEngine/uiConfirm/UiConfirmManager.js +0 -1
  174. package/dist/esm/core/signingEngine/uiConfirm/handlers/flows/adapters/adapters.js +1 -1
  175. package/dist/esm/core/signingEngine/uiConfirm/handlers/flows/localOnly.js +0 -1
  176. package/dist/esm/core/signingEngine/uiConfirm/ui/preact/TransactionReceipt.js +25 -16
  177. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/abi/abiDecode.js +3 -13
  178. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/tree.js +1 -10
  179. package/dist/esm/core/signingEngine/walletCustody/activateEd25519Capability.js +0 -1
  180. package/dist/esm/core/signingEngine/walletCustody/emailOtpLink.js +10 -13
  181. package/dist/esm/core/signingEngine/walletCustody/openCustodyCache.js +2 -6
  182. package/dist/esm/core/signingEngine/walletCustody/passkeyLink.js +7 -10
  183. package/dist/esm/core/signingEngine/walletCustody/registrationCeremony.js +0 -1
  184. package/dist/esm/core/signingEngine/walletCustody/walletRecoveryCredential.js +0 -1
  185. package/dist/esm/core/signingEngine/walletCustody/walletRecoveryEcdsa.js +0 -1
  186. package/dist/esm/core/signingEngine/walletCustody/walletRecoveryEd25519.js +1 -1
  187. package/dist/esm/core/signingEngine/walletCustody/walletRecoveryManifest.js +0 -2
  188. package/dist/esm/core/signingEngine/walletCustody/walletRecoveryRotation.js +0 -1
  189. package/dist/esm/core/signingEngine/webauthnAuth/walletOriginWebAuthn.js +109 -0
  190. package/dist/esm/core/signingEngine/workerManager/SignerWorkerManager.js +0 -2
  191. package/dist/esm/core/signingEngine/workerManager/deviceLinkingPorts.js +67 -48
  192. package/dist/esm/core/signingEngine/workerManager/ecdsaClientWorkerChannels.js +0 -4
  193. package/dist/esm/core/signingEngine/workerManager/validation.js +1 -1
  194. package/dist/esm/core/signingEngine/workerManager/workerTransport.js +4 -47
  195. package/dist/esm/core/signingEngine/workerManager/workerTypes.js +0 -2
  196. package/dist/esm/core/types/accountIds.js +0 -1
  197. package/dist/esm/core/types/sdkSentEvents.js +1 -2
  198. package/dist/esm/core/types/signer-worker.js +1 -36
  199. package/dist/esm/core/walletRuntimePaths/base.js +11 -1
  200. package/dist/esm/plugins/headers.js +0 -1
  201. package/dist/esm/plugins/next.js +0 -1
  202. package/dist/esm/plugins/plugin-utils.js +0 -1
  203. package/dist/esm/plugins/shared-ts/src/utils/normalize.js +1 -1
  204. package/dist/esm/react/components/AccountMenuButton/AccountsSection.js +1 -1
  205. package/dist/esm/react/components/AccountMenuButton/AuthenticationMethodsModal.js +3 -3
  206. package/dist/esm/react/components/AccountMenuButton/ExportKeysSection.js +2 -2
  207. package/dist/esm/react/components/AccountMenuButton/LinkedDevicesModal.js +8 -8
  208. package/dist/esm/react/components/AccountMenuButton/LockMenuItem.js +2 -1
  209. package/dist/esm/react/components/AccountMenuButton/MenuItem.css +17 -0
  210. package/dist/esm/react/components/AccountMenuButton/ProfileDropdown.js +1 -1
  211. package/dist/esm/react/components/AccountMenuButton/UserAccountButton.css +0 -5
  212. package/dist/esm/react/components/AccountMenuButton/WalletSettingsLayout.css +8 -0
  213. package/dist/esm/react/components/AccountMenuButton/WalletSettingsLayout.js +21 -13
  214. package/dist/esm/react/components/AccountMenuButton/Web3AuthProfileButton.css +0 -52
  215. package/dist/esm/react/components/AccountMenuButton/icons/GlobeIcon.js +12 -27
  216. package/dist/esm/react/components/AccountMenuButton/icons/KeyIcon.js +12 -27
  217. package/dist/esm/react/components/AccountMenuButton/icons/LaptopIcon.js +4 -19
  218. package/dist/esm/react/components/AccountMenuButton/icons/LinkIcon.js +4 -19
  219. package/dist/esm/react/components/AccountMenuButton/icons/LockIcon.js +11 -26
  220. package/dist/esm/react/components/AccountMenuButton/icons/MailIcon.js +10 -25
  221. package/dist/esm/react/components/AccountMenuButton/icons/RecoveryCodesIcon.js +16 -31
  222. package/dist/esm/react/components/AccountMenuButton/icons/ScanIcon.js +9 -24
  223. package/dist/esm/react/components/AccountMenuButton/icons/SlidersIcon.js +14 -29
  224. package/dist/esm/react/components/AccountMenuButton/icons/SmartphoneIcon.js +11 -26
  225. package/dist/esm/react/components/AccountMenuButton/icons/TouchIcon.js +1 -1
  226. package/dist/esm/react/components/AccountMenuButton/icons/lucideIcon.js +27 -0
  227. package/dist/esm/react/components/AccountMenuButton/icons/strokeIcon.js +7 -17
  228. package/dist/esm/react/components/AccountMenuButton/index.js +11 -11
  229. package/dist/esm/react/components/HostedSeamsAuthMenu/SeamsAuthMenuMock.js +1 -1
  230. package/dist/esm/react/components/HostedSeamsAuthMenu/shell.js +1 -1
  231. package/dist/esm/react/components/QRCodeScanner.css +0 -15
  232. package/dist/esm/react/components/QRCodeScanner.js +2 -2
  233. package/dist/esm/react/components/ShowQRCode.css +0 -14
  234. package/dist/esm/react/components/ShowQRCode.js +4 -4
  235. package/dist/esm/react/components/theme/design-tokens.js +1 -2
  236. package/dist/esm/react/context/index.js +1 -1
  237. package/dist/esm/react/context/reactLoginStateBuilders.js +1 -1
  238. package/dist/esm/react/context/seamsManagerSingleton.js +2 -2
  239. package/dist/esm/react/context/useLoginStateRefresher.js +2 -5
  240. package/dist/esm/react/context/useSeamsContextValue.js +1 -1
  241. package/dist/esm/react/context/useSeamsWithSdkFlow.js +2 -3
  242. package/dist/esm/react/context/useWalletIframeLifecycle.js +1 -15
  243. package/dist/esm/react/hooks/useAccountInput.js +4 -4
  244. package/dist/esm/react/hooks/useNearClient.js +3 -3
  245. package/dist/esm/react/hooks/usePreconnectWalletAssets.js +1 -1
  246. package/dist/esm/react/hooks/useQRCamera.js +2 -2
  247. package/dist/esm/react/hooks/useWallet.js +1 -1
  248. package/dist/esm/react/index.js +10 -10
  249. package/dist/esm/react/styles/styles.css +25 -86
  250. package/dist/esm/react/transactionReview/TransactionReviewHost.js +1 -1
  251. package/dist/esm/react/transactionReview/boundCalls.js +2 -2
  252. package/dist/esm/react/transactionReview/contract.js +1 -1
  253. package/dist/esm/react/transactionReview/controller.js +2 -2
  254. package/dist/esm/react/transactionReview/snapshot.js +2 -2
  255. package/dist/esm/sdk/ConfirmationDrawer-DrsREojk.js +1 -0
  256. package/dist/esm/sdk/EvmClient-DoxytQaJ.js +1 -0
  257. package/dist/esm/sdk/NearClient-vJ65Wjrq.js +1 -0
  258. package/dist/esm/sdk/NonceCoordinator-BBeadCSq.js +1 -0
  259. package/dist/esm/sdk/accountIds-C3Ihsd2c.js +1 -0
  260. package/dist/esm/sdk/accountLifecycle-EyfYPnuT.js +1 -0
  261. package/dist/esm/sdk/actions-DZLxCcrU.js +1 -0
  262. package/dist/esm/sdk/adapters-DtAyuoiA.js +2 -0
  263. package/dist/esm/sdk/base-Xtd32asf.js +1 -0
  264. package/dist/esm/sdk/base64-ojm5DKcF.js +1 -0
  265. package/dist/esm/sdk/browser-CsOGMbMy.js +8 -0
  266. package/dist/esm/sdk/bytes-t5S5mkat.js +1 -0
  267. package/dist/esm/sdk/canonicalPrimitives-MPGET2cl.js +1 -0
  268. package/dist/esm/sdk/canonicalSignerErrorCode-C0hh_SVi.js +1 -0
  269. package/dist/esm/sdk/capabilityKinds-XaXXiD2B.js +1 -0
  270. package/dist/esm/sdk/chains-yAls2d9X.js +1 -0
  271. package/dist/esm/sdk/challengeDelivery-cAsaUC6U.js +1 -0
  272. package/dist/esm/sdk/chunk-dVx5-UGu.js +1 -0
  273. package/dist/esm/sdk/configHelpers-CseiVoZD.js +1 -0
  274. package/dist/esm/sdk/csp-stylesheet-B1fAhrGB.js +2 -0
  275. package/dist/esm/sdk/defaultConfigs-CWpApkMq.js +1 -0
  276. package/dist/esm/sdk/display-jK7_hYho.js +1 -0
  277. package/dist/esm/sdk/domainIds-GDzjOs6i.js +1 -0
  278. package/dist/esm/sdk/ecdsaCapabilityManifest-CHFu-QrV.js +1 -0
  279. package/dist/esm/sdk/ecdsaChainTarget-CRcRR78w.js +1 -0
  280. package/dist/esm/sdk/ecdsaPresignLifecycle-CQnCxSlq.js +1 -0
  281. package/dist/esm/sdk/ecdsaPresignPoolIdentity-Ci-ovDlv.js +1 -0
  282. package/dist/esm/sdk/ecdsaWalletRecords-Cm1DdexN.js +1 -0
  283. package/dist/esm/sdk/enrichDisplayModelWithAbi-CR-4ebuU.js +1 -0
  284. package/dist/esm/sdk/enrichDisplayModelWithAbi-CwHKFqF4.js +569 -0
  285. package/dist/esm/sdk/errors-DfbnsXjO.js +1 -0
  286. package/dist/esm/sdk/events-BJyVcnsn.js +1 -0
  287. package/dist/esm/sdk/evmCryptoWasm-CwEXiLrC.js +1 -0
  288. package/dist/esm/sdk/evmFamilyEcdsaIdentity-Br3iFdQx.js +1 -0
  289. package/dist/esm/sdk/exactSessionState-CjD8gekO.js +210 -0
  290. package/dist/esm/sdk/exactSigningLaneIdentity-olheZx_n.js +1 -0
  291. package/dist/esm/sdk/executeWorkerOperation-CrFf3FkL.js +1 -0
  292. package/dist/esm/sdk/export-viewer-host-jo7h_0wl.js +1 -0
  293. package/dist/esm/sdk/helpers-D4QckQhq.js +1 -0
  294. package/dist/esm/sdk/host-BAqOYnju.js +1 -0
  295. package/dist/esm/sdk/intentDigest-CB6zy3lN.js +1 -0
  296. package/dist/esm/sdk/jsonRpc-C85RYR0A.js +1 -0
  297. package/dist/esm/sdk/jsxRuntime.module-CoHsKD_3.js +1 -0
  298. package/dist/esm/sdk/keccak-zexutGfG.js +1 -0
  299. package/dist/esm/sdk/keyMaterialBrands-uVZHfAh3.js +1 -0
  300. package/dist/esm/sdk/localOnly-DBQRG6Qh.js +1 -0
  301. package/dist/esm/sdk/messages-Cv2j4SKI.js +1 -0
  302. package/dist/esm/sdk/mountExportPrivateKeySurface-G7Z_9JMQ.js +1 -0
  303. package/dist/esm/sdk/mountRecoveryCodeBackupSurface-BBCTaQsu.js +2 -0
  304. package/dist/esm/sdk/nearEd25519YaoMaterialActivation-DQIw8ho3.js +1 -0
  305. package/dist/esm/sdk/nearEd25519YaoSigningPreparation-Bp_CvWRz.js +1 -0
  306. package/dist/esm/sdk/nearRpcResults--cBcfmp4.js +1 -0
  307. package/dist/esm/sdk/nonceLaneKeys-BBYi4g51.js +1 -0
  308. package/dist/esm/sdk/normalization-BGPR6osg.js +1 -0
  309. package/dist/esm/sdk/operationFingerprint-5-wH2Ht8.js +1 -0
  310. package/dist/esm/sdk/operationFingerprint-DtQb0pdp.js +1 -0
  311. package/dist/esm/sdk/passkey-custody-LP4UTFbn.js +1 -0
  312. package/dist/esm/sdk/pendingWalletRecoveryCodeBackup-BNk4ebsY.js +1 -0
  313. package/dist/esm/sdk/prfCache-Mbo7_USg.js +1 -0
  314. package/dist/esm/sdk/profileAccountProjection-DHCaMtOu.js +1 -0
  315. package/dist/esm/sdk/promptText-s8TQ6ckX.js +1 -0
  316. package/dist/esm/sdk/recovery-entrypoint-DkT8sFO5.js +1 -0
  317. package/dist/esm/sdk/registration-Btozh7uh.js +1 -0
  318. package/dist/esm/sdk/registration-CSAG_h4Y.js +1 -0
  319. package/dist/esm/sdk/registrationAccounts-DIeEVy6W.js +1 -0
  320. package/dist/esm/sdk/registrationIds-BIel5S0i.js +1 -0
  321. package/dist/esm/sdk/registrationIntent-DV1GYZ3K.js +1 -0
  322. package/dist/esm/sdk/registrationPreparationPreload-vOCqNuG4.js +1 -0
  323. package/dist/esm/sdk/registrationSignerPlan-FzD3TwxB.js +1 -0
  324. package/dist/esm/sdk/relayerHttp-DaPeS929.js +1 -0
  325. package/dist/esm/sdk/routePlan-B_KJaPtm.js +1 -0
  326. package/dist/esm/sdk/router-Dd3fFHk3.js +1 -0
  327. package/dist/esm/sdk/routerAbNormalSigning-D_fHjq5l.js +1 -0
  328. package/dist/esm/sdk/router_ab_ed25519_yao_client_bg.wasm +0 -0
  329. package/dist/esm/sdk/runtime-auth-B2M91rSx.js +1 -0
  330. package/dist/esm/sdk/runtime-device-link-ojjPSRaG.js +1 -0
  331. package/dist/esm/sdk/runtime-ecdsa-tempo-CE4JLgmn.js +1 -0
  332. package/dist/esm/sdk/runtime-email-otp-DDwtKVAe.js +1 -0
  333. package/dist/esm/sdk/runtime-export-JXYk8sQ-.js +1 -0
  334. package/dist/esm/sdk/runtime-near-BB8AG6dV.js +1 -0
  335. package/dist/esm/sdk/runtime-preferences-DKFZYccW.js +1 -0
  336. package/dist/esm/sdk/runtime-recovery-C_XjsDBg.js +1 -0
  337. package/dist/esm/sdk/runtime-recovery-codes-CWp839mH.js +1 -0
  338. package/dist/esm/sdk/runtimeContext-BpObgzbj.js +6 -0
  339. package/dist/esm/sdk/runtimeLoader-DjgBf_yF.js +1 -0
  340. package/dist/esm/sdk/sdkSentEvents-_RGAEeld.js +1 -0
  341. package/dist/esm/sdk/secp256k1-B_6W9QDJ.js +1 -0
  342. package/dist/esm/sdk/secureRandomId-CTdlJ5Mx.js +1 -0
  343. package/dist/esm/sdk/sessionPolicy-CNVK7nJ6.js +1 -0
  344. package/dist/esm/sdk/shared-j_KsFbCT.js +1 -0
  345. package/dist/esm/sdk/signEvmFamily-CcLVBm0f.js +1 -0
  346. package/dist/esm/sdk/signEvmFamilyWithUiConfirmForTempo-DgTbh6jX.js +1 -0
  347. package/dist/esm/sdk/signEvmWithUiConfirm-ChreN7aZ.js +1 -0
  348. package/dist/esm/sdk/signNear-mWbTE2Dl.js +1 -0
  349. package/dist/esm/sdk/signatureUses-CQkkUcwT.js +1 -0
  350. package/dist/esm/sdk/signerDomain-BhUTzDmF.js +1 -0
  351. package/dist/esm/sdk/signerLoader-By0IY24G.js +1 -0
  352. package/dist/esm/sdk/signerSlot-BQ1g5JNV.js +1 -0
  353. package/dist/esm/sdk/signingFlow-LUWrZi2d.js +2 -0
  354. package/dist/esm/sdk/signingSessionSeal-Mr2Xp44o.js +1 -0
  355. package/dist/esm/sdk/surface-measurement-reporter-OICExWKE.js +1 -0
  356. package/dist/esm/sdk/trace-M34pNGuF.js +1 -0
  357. package/dist/esm/sdk/transaction-activity-BbDod7ji.js +1 -0
  358. package/dist/esm/sdk/transactionReview-CBE5oH4c.js +1 -0
  359. package/dist/esm/sdk/transactionReviewAdmission-0ZgWs6q3.js +1 -0
  360. package/dist/esm/sdk/transactionState-9d7f3xVj.js +1 -0
  361. package/dist/esm/sdk/tx-confirm-ui.js +23 -204
  362. package/dist/esm/sdk/types-M7vxrYtJ.js +1 -0
  363. package/dist/esm/sdk/validation-dC1-_uyG.js +1 -0
  364. package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -13
  365. package/dist/esm/sdk/wallet-iframe-host-full.js +1 -6
  366. package/dist/esm/sdk/wallet-iframe-host-near.js +1 -13
  367. package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -4
  368. package/dist/esm/sdk/wallet-recovery-CcDZ1hMH.js +1 -0
  369. package/dist/esm/sdk/wallet-ui.css +1 -6134
  370. package/dist/esm/sdk/walletAuthority-CoWSeqvQ.js +1 -0
  371. package/dist/esm/sdk/walletCustodyEcdsaContinuity-B7xi7nwh.js +1 -0
  372. package/dist/esm/sdk/walletIframeIdentity-C0b0XMQF.js +1 -0
  373. package/dist/esm/sdk/walletRecoveryCommit-ljxVeo-d.js +1 -0
  374. package/dist/esm/sdk/walletRecoveryRotate-HztDcDaY.js +1 -0
  375. package/dist/esm/sdk/warmSessionHydration-BPGM0YRU.js +1 -0
  376. package/dist/esm/sdk/webauthnP256-qu06GNFm.js +1 -0
  377. package/dist/esm/sdk/webauthnPromptCoordinator-DO-qfECu.js +1 -0
  378. package/dist/esm/shared-ts/src/authorization/walletSessionIssuance.js +5 -8
  379. package/dist/esm/shared-ts/src/authorization/walletSignerActivationEquality.js +12 -0
  380. package/dist/esm/shared-ts/src/device-linking/committedSignerPackages.js +2 -5
  381. package/dist/esm/shared-ts/src/device-linking/delegatedActivationPlan.js +1 -5
  382. package/dist/esm/shared-ts/src/device-linking/ed25519ExportRoot.js +11 -15
  383. package/dist/esm/shared-ts/src/device-linking/parsers.js +41 -1
  384. package/dist/esm/shared-ts/src/device-linking/sourceContribution.js +6 -9
  385. package/dist/esm/shared-ts/src/near/actions.js +10 -1
  386. package/dist/esm/shared-ts/src/near/nearClient.js +0 -2
  387. package/dist/esm/shared-ts/src/passkey-custody/primitives.js +5 -1
  388. package/dist/esm/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.js +1 -1
  389. package/dist/esm/shared-ts/src/signing-lanes/index.js +1 -4
  390. package/dist/esm/shared-ts/src/signing-lanes/ownerContinuity.js +3 -8
  391. package/dist/esm/shared-ts/src/signing-lanes/participantDigest.js +0 -1
  392. package/dist/esm/shared-ts/src/signing-lanes/participants.js +1 -1
  393. package/dist/esm/shared-ts/src/signing-lanes/recordParsers.js +13 -17
  394. package/dist/esm/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js +0 -1
  395. package/dist/esm/shared-ts/src/threshold/participants.js +0 -1
  396. package/dist/esm/shared-ts/src/threshold/signingRootScope.js +4 -2
  397. package/dist/esm/shared-ts/src/utils/domainIds.js +1 -7
  398. package/dist/esm/shared-ts/src/utils/ecdsaKeyFactsInventory.js +2 -5
  399. package/dist/esm/shared-ts/src/utils/ecdsaServerTiming.js +0 -1
  400. package/dist/esm/shared-ts/src/utils/encoders.js +1 -1
  401. package/dist/esm/shared-ts/src/utils/errors.js +0 -1
  402. package/dist/esm/shared-ts/src/utils/exactKeys.js +17 -0
  403. package/dist/esm/shared-ts/src/utils/index.js +4 -5
  404. package/dist/esm/shared-ts/src/utils/registrationEstablishedSession.js +1 -1
  405. package/dist/esm/shared-ts/src/utils/registrationIds.js +1 -5
  406. package/dist/esm/shared-ts/src/utils/registrationIntent.js +2 -9
  407. package/dist/esm/shared-ts/src/utils/registrationSetupOperation.js +12 -0
  408. package/dist/esm/shared-ts/src/utils/registrationSignerPlan.js +3 -6
  409. package/dist/esm/shared-ts/src/utils/routerAbEcdsaDerivation.js +2 -3
  410. package/dist/esm/shared-ts/src/utils/routerAbEd25519Yao.js +1 -1
  411. package/dist/esm/shared-ts/src/utils/thresholdEcdsaChainTarget.js +9 -0
  412. package/dist/esm/shared-ts/src/utils/validation.js +0 -1
  413. package/dist/esm/shared-ts/src/utils/walletAuthAuthority.js +0 -1
  414. package/dist/esm/shared-ts/src/utils/walletCapabilityBindings.js +10 -1
  415. package/dist/esm/shared-ts/src/utils/walletManagementProtocol.js +6 -0
  416. package/dist/esm/shared-ts/src/wallet-recovery/index.js +1 -1
  417. package/dist/esm/shared-ts/src/wallet-recovery/recoveryCodeLocator.js +0 -1
  418. package/dist/esm/shared-ts/src/wallet-recovery/recoveryKeyId.js +0 -2
  419. package/dist/esm/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +1 -4
  420. package/dist/esm/theme/base-styles.js +11 -11
  421. package/dist/esm/utils/deviceDetection.js +16 -1
  422. package/dist/esm/utils/menuItemBlink.js +24 -0
  423. package/dist/esm/utils/qrScanner.js +288 -0
  424. package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker.d.ts +12 -753
  425. package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker.js +126 -3701
  426. package/dist/esm/wasm/near_signer/pkg/wasm_signer_worker_bg.wasm +0 -0
  427. package/dist/esm/wasm/router_ab_ecdsa_client/pkg/router_ab_ecdsa_client.d.ts +0 -42
  428. package/dist/esm/wasm/router_ab_ecdsa_client/pkg/router_ab_ecdsa_client.js +2 -106
  429. package/dist/esm/wasm/router_ab_ecdsa_client/pkg/router_ab_ecdsa_client_bg.wasm +0 -0
  430. package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client.d.ts +3 -158
  431. package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client.js +2 -452
  432. package/dist/esm/wasm/router_ab_ed25519_yao_client/pkg/router_ab_ed25519_yao_client_bg.wasm +0 -0
  433. package/dist/public/headers.manifest.json +1 -1
  434. package/dist/public/sdk/ConfirmationDrawer-DrsREojk.js +1 -0
  435. package/dist/public/sdk/EvmClient-DoxytQaJ.js +1 -0
  436. package/dist/public/sdk/NearClient-vJ65Wjrq.js +1 -0
  437. package/dist/public/sdk/NonceCoordinator-BBeadCSq.js +1 -0
  438. package/dist/public/sdk/accountIds-C3Ihsd2c.js +1 -0
  439. package/dist/public/sdk/accountLifecycle-EyfYPnuT.js +1 -0
  440. package/dist/public/sdk/actions-DZLxCcrU.js +1 -0
  441. package/dist/public/sdk/adapters-DtAyuoiA.js +2 -0
  442. package/dist/public/sdk/base-Xtd32asf.js +1 -0
  443. package/dist/public/sdk/base64-ojm5DKcF.js +1 -0
  444. package/dist/public/sdk/browser-CsOGMbMy.js +8 -0
  445. package/dist/public/sdk/bytes-t5S5mkat.js +1 -0
  446. package/dist/public/sdk/canonicalPrimitives-MPGET2cl.js +1 -0
  447. package/dist/public/sdk/canonicalSignerErrorCode-C0hh_SVi.js +1 -0
  448. package/dist/public/sdk/capabilityKinds-XaXXiD2B.js +1 -0
  449. package/dist/public/sdk/chains-yAls2d9X.js +1 -0
  450. package/dist/public/sdk/challengeDelivery-cAsaUC6U.js +1 -0
  451. package/dist/public/sdk/chunk-dVx5-UGu.js +1 -0
  452. package/dist/public/sdk/configHelpers-CseiVoZD.js +1 -0
  453. package/dist/public/sdk/csp-stylesheet-B1fAhrGB.js +2 -0
  454. package/dist/public/sdk/defaultConfigs-CWpApkMq.js +1 -0
  455. package/dist/public/sdk/display-jK7_hYho.js +1 -0
  456. package/dist/public/sdk/domainIds-GDzjOs6i.js +1 -0
  457. package/dist/public/sdk/ecdsaCapabilityManifest-CHFu-QrV.js +1 -0
  458. package/dist/public/sdk/ecdsaChainTarget-CRcRR78w.js +1 -0
  459. package/dist/public/sdk/ecdsaPresignLifecycle-CQnCxSlq.js +1 -0
  460. package/dist/public/sdk/ecdsaPresignPoolIdentity-Ci-ovDlv.js +1 -0
  461. package/dist/public/sdk/ecdsaWalletRecords-Cm1DdexN.js +1 -0
  462. package/dist/public/sdk/enrichDisplayModelWithAbi-CR-4ebuU.js +1 -0
  463. package/dist/public/sdk/enrichDisplayModelWithAbi-CwHKFqF4.js +569 -0
  464. package/dist/public/sdk/errors-DfbnsXjO.js +1 -0
  465. package/dist/public/sdk/events-BJyVcnsn.js +1 -0
  466. package/dist/public/sdk/evmCryptoWasm-CwEXiLrC.js +1 -0
  467. package/dist/public/sdk/evmFamilyEcdsaIdentity-Br3iFdQx.js +1 -0
  468. package/dist/public/sdk/exactSessionState-CjD8gekO.js +210 -0
  469. package/dist/public/sdk/exactSigningLaneIdentity-olheZx_n.js +1 -0
  470. package/dist/public/sdk/executeWorkerOperation-CrFf3FkL.js +1 -0
  471. package/dist/public/sdk/export-viewer-host-jo7h_0wl.js +1 -0
  472. package/dist/public/sdk/helpers-D4QckQhq.js +1 -0
  473. package/dist/public/sdk/host-BAqOYnju.js +1 -0
  474. package/dist/public/sdk/intentDigest-CB6zy3lN.js +1 -0
  475. package/dist/public/sdk/jsonRpc-C85RYR0A.js +1 -0
  476. package/dist/public/sdk/jsxRuntime.module-CoHsKD_3.js +1 -0
  477. package/dist/public/sdk/keccak-zexutGfG.js +1 -0
  478. package/dist/public/sdk/keyMaterialBrands-uVZHfAh3.js +1 -0
  479. package/dist/public/sdk/localOnly-DBQRG6Qh.js +1 -0
  480. package/dist/public/sdk/messages-Cv2j4SKI.js +1 -0
  481. package/dist/public/sdk/mountExportPrivateKeySurface-G7Z_9JMQ.js +1 -0
  482. package/dist/public/sdk/mountRecoveryCodeBackupSurface-BBCTaQsu.js +2 -0
  483. package/dist/public/sdk/nearEd25519YaoMaterialActivation-DQIw8ho3.js +1 -0
  484. package/dist/public/sdk/nearEd25519YaoSigningPreparation-Bp_CvWRz.js +1 -0
  485. package/dist/public/sdk/nearRpcResults--cBcfmp4.js +1 -0
  486. package/dist/public/sdk/nonceLaneKeys-BBYi4g51.js +1 -0
  487. package/dist/public/sdk/normalization-BGPR6osg.js +1 -0
  488. package/dist/public/sdk/operationFingerprint-5-wH2Ht8.js +1 -0
  489. package/dist/public/sdk/operationFingerprint-DtQb0pdp.js +1 -0
  490. package/dist/public/sdk/passkey-custody-LP4UTFbn.js +1 -0
  491. package/dist/public/sdk/pendingWalletRecoveryCodeBackup-BNk4ebsY.js +1 -0
  492. package/dist/public/sdk/prfCache-Mbo7_USg.js +1 -0
  493. package/dist/public/sdk/profileAccountProjection-DHCaMtOu.js +1 -0
  494. package/dist/public/sdk/promptText-s8TQ6ckX.js +1 -0
  495. package/dist/public/sdk/recovery-entrypoint-DkT8sFO5.js +1 -0
  496. package/dist/public/sdk/registration-Btozh7uh.js +1 -0
  497. package/dist/public/sdk/registration-CSAG_h4Y.js +1 -0
  498. package/dist/public/sdk/registrationAccounts-DIeEVy6W.js +1 -0
  499. package/dist/public/sdk/registrationIds-BIel5S0i.js +1 -0
  500. package/dist/public/sdk/registrationIntent-DV1GYZ3K.js +1 -0
  501. package/dist/public/sdk/registrationPreparationPreload-vOCqNuG4.js +1 -0
  502. package/dist/public/sdk/registrationSignerPlan-FzD3TwxB.js +1 -0
  503. package/dist/public/sdk/relayerHttp-DaPeS929.js +1 -0
  504. package/dist/public/sdk/routePlan-B_KJaPtm.js +1 -0
  505. package/dist/public/sdk/router-Dd3fFHk3.js +1 -0
  506. package/dist/public/sdk/routerAbNormalSigning-D_fHjq5l.js +1 -0
  507. package/dist/public/sdk/router_ab_ed25519_yao_client_bg.wasm +0 -0
  508. package/dist/public/sdk/runtime-auth-B2M91rSx.js +1 -0
  509. package/dist/public/sdk/runtime-device-link-ojjPSRaG.js +1 -0
  510. package/dist/public/sdk/runtime-ecdsa-tempo-CE4JLgmn.js +1 -0
  511. package/dist/public/sdk/runtime-email-otp-DDwtKVAe.js +1 -0
  512. package/dist/public/sdk/runtime-export-JXYk8sQ-.js +1 -0
  513. package/dist/public/sdk/runtime-near-BB8AG6dV.js +1 -0
  514. package/dist/public/sdk/runtime-preferences-DKFZYccW.js +1 -0
  515. package/dist/public/sdk/runtime-recovery-C_XjsDBg.js +1 -0
  516. package/dist/public/sdk/runtime-recovery-codes-CWp839mH.js +1 -0
  517. package/dist/public/sdk/runtimeContext-BpObgzbj.js +6 -0
  518. package/dist/public/sdk/runtimeLoader-DjgBf_yF.js +1 -0
  519. package/dist/public/sdk/sdkSentEvents-_RGAEeld.js +1 -0
  520. package/dist/public/sdk/secp256k1-B_6W9QDJ.js +1 -0
  521. package/dist/public/sdk/secureRandomId-CTdlJ5Mx.js +1 -0
  522. package/dist/public/sdk/sessionPolicy-CNVK7nJ6.js +1 -0
  523. package/dist/public/sdk/shared-j_KsFbCT.js +1 -0
  524. package/dist/public/sdk/signEvmFamily-CcLVBm0f.js +1 -0
  525. package/dist/public/sdk/signEvmFamilyWithUiConfirmForTempo-DgTbh6jX.js +1 -0
  526. package/dist/public/sdk/signEvmWithUiConfirm-ChreN7aZ.js +1 -0
  527. package/dist/public/sdk/signNear-mWbTE2Dl.js +1 -0
  528. package/dist/public/sdk/signatureUses-CQkkUcwT.js +1 -0
  529. package/dist/public/sdk/signerDomain-BhUTzDmF.js +1 -0
  530. package/dist/public/sdk/signerLoader-By0IY24G.js +1 -0
  531. package/dist/public/sdk/signerSlot-BQ1g5JNV.js +1 -0
  532. package/dist/public/sdk/signingFlow-LUWrZi2d.js +2 -0
  533. package/dist/public/sdk/signingSessionSeal-Mr2Xp44o.js +1 -0
  534. package/dist/public/sdk/surface-measurement-reporter-OICExWKE.js +1 -0
  535. package/dist/public/sdk/trace-M34pNGuF.js +1 -0
  536. package/dist/public/sdk/transaction-activity-BbDod7ji.js +1 -0
  537. package/dist/public/sdk/transactionReview-CBE5oH4c.js +1 -0
  538. package/dist/public/sdk/transactionReviewAdmission-0ZgWs6q3.js +1 -0
  539. package/dist/public/sdk/transactionState-9d7f3xVj.js +1 -0
  540. package/dist/public/sdk/tx-confirm-ui.js +23 -204
  541. package/dist/public/sdk/types-M7vxrYtJ.js +1 -0
  542. package/dist/public/sdk/validation-dC1-_uyG.js +1 -0
  543. package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -13
  544. package/dist/public/sdk/wallet-iframe-host-full.js +1 -6
  545. package/dist/public/sdk/wallet-iframe-host-near.js +1 -13
  546. package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -4
  547. package/dist/public/sdk/wallet-recovery-CcDZ1hMH.js +1 -0
  548. package/dist/public/sdk/wallet-ui.css +1 -6134
  549. package/dist/public/sdk/walletAuthority-CoWSeqvQ.js +1 -0
  550. package/dist/public/sdk/walletCustodyEcdsaContinuity-B7xi7nwh.js +1 -0
  551. package/dist/public/sdk/walletIframeIdentity-C0b0XMQF.js +1 -0
  552. package/dist/public/sdk/walletRecoveryCommit-ljxVeo-d.js +1 -0
  553. package/dist/public/sdk/walletRecoveryRotate-HztDcDaY.js +1 -0
  554. package/dist/public/sdk/warmSessionHydration-BPGM0YRU.js +1 -0
  555. package/dist/public/sdk/webauthnP256-qu06GNFm.js +1 -0
  556. package/dist/public/sdk/webauthnPromptCoordinator-DO-qfECu.js +1 -0
  557. package/dist/public/sdk/workers/device-linking-key.worker.js +567 -2131
  558. package/dist/public/sdk/workers/ecdsa-derivation-client.worker.js +1529 -2683
  559. package/dist/public/sdk/workers/ecdsa-online-client.worker.js +1 -273
  560. package/dist/public/sdk/workers/ecdsa-presign-client.worker.js +59 -346
  561. package/dist/public/sdk/workers/email-otp.worker.js +307 -2185
  562. package/dist/public/sdk/workers/email_otp_runtime_bg.wasm +0 -0
  563. package/dist/public/sdk/workers/evm-crypto.worker.js +0 -188
  564. package/dist/public/sdk/workers/evm_crypto.wasm +0 -0
  565. package/dist/public/sdk/workers/evm_crypto_bg.wasm +0 -0
  566. package/dist/public/sdk/workers/near-signer.worker.js +16 -718
  567. package/dist/public/sdk/workers/near_signer.wasm +0 -0
  568. package/dist/public/sdk/workers/passkey-confirm.worker.js +0 -134
  569. package/dist/public/sdk/workers/passkey-mpc-export.worker.js +149 -506
  570. package/dist/public/sdk/workers/passkey-mpc-session.worker.js +0 -134
  571. package/dist/public/sdk/workers/router_ab_ecdsa_client_bg.wasm +0 -0
  572. package/dist/public/sdk/workers/router_ab_ed25519_yao_client_bg.wasm +0 -0
  573. package/dist/public/sdk/workers/shamir3pass.worker.js +0 -134
  574. package/dist/public/sdk/workers/shamir3pass_runtime_bg.wasm +0 -0
  575. package/dist/public/sdk/workers/tempo-signer.worker.js +0 -134
  576. package/dist/public/sdk/workers/tempo_signer.wasm +0 -0
  577. package/dist/public/sdk/workers/tempo_signer_bg.wasm +0 -0
  578. package/dist/public/sdk/workers/wallet-custody-ceremony.worker.js +136 -1636
  579. package/dist/public/sdk/workers/wallet_custody_ceremony.js +0 -14
  580. package/dist/public/sdk/workers/wallet_custody_ceremony_bg.wasm +0 -0
  581. package/dist/public/sdk/workers/wasm_signer_worker_bg.wasm +0 -0
  582. package/dist/public/wallet-assets.manifest.json +234 -258
  583. package/dist/public/wallet-service/index.html +4 -4
  584. package/dist/types/shared-ts/src/authorization/capabilityKinds.d.ts +0 -4
  585. package/dist/types/shared-ts/src/authorization/delegatedAuthority.d.ts +2 -1
  586. package/dist/types/shared-ts/src/authorization/walletSessionIssuance.d.ts +9 -2
  587. package/dist/types/shared-ts/src/authorization/walletSignerActivationEquality.d.ts +4 -0
  588. package/dist/types/shared-ts/src/device-linking/committedSignerPackages.d.ts +3 -4
  589. package/dist/types/shared-ts/src/device-linking/contracts.d.ts +6 -63
  590. package/dist/types/shared-ts/src/device-linking/sourceContribution.d.ts +2 -0
  591. package/dist/types/shared-ts/src/passkey-custody/custodyEnvelope.d.ts +5 -12
  592. package/dist/types/shared-ts/src/passkey-custody/primitives.d.ts +9 -0
  593. package/dist/types/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.d.ts +0 -2
  594. package/dist/types/shared-ts/src/signing-lanes/execution.d.ts +11 -12
  595. package/dist/types/shared-ts/src/signing-lanes/ids.d.ts +3 -17
  596. package/dist/types/shared-ts/src/signing-lanes/index.d.ts +0 -4
  597. package/dist/types/shared-ts/src/signing-lanes/ownerContinuity.d.ts +0 -1
  598. package/dist/types/shared-ts/src/signing-lanes/participantDigest.d.ts +0 -18
  599. package/dist/types/shared-ts/src/signing-lanes/participants.d.ts +6 -35
  600. package/dist/types/shared-ts/src/signing-lanes/rotation.d.ts +6 -845
  601. package/dist/types/shared-ts/src/tenant-root/tenantRootIdentifier.d.ts +3 -0
  602. package/dist/types/shared-ts/src/tenant-root/tenantRootOperationRecord.d.ts +2 -1
  603. package/dist/types/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.d.ts +6 -0
  604. package/dist/types/shared-ts/src/threshold/keyMaterialBrands.d.ts +0 -10
  605. package/dist/types/shared-ts/src/threshold/participants.d.ts +1 -1
  606. package/dist/types/shared-ts/src/threshold/signingRootScope.d.ts +1 -0
  607. package/dist/types/shared-ts/src/utils/addWalletAuthMethod.d.ts +1 -133
  608. package/dist/types/shared-ts/src/utils/addWalletAuthMethod.typecheck.d.ts +4 -18
  609. package/dist/types/shared-ts/src/utils/domainIds.d.ts +0 -12
  610. package/dist/types/shared-ts/src/utils/ecdsaKeyFactsInventory.d.ts +2 -11
  611. package/dist/types/shared-ts/src/utils/eip1559TxWasmJson.d.ts +16 -0
  612. package/dist/types/shared-ts/src/utils/emailOtpDomain.d.ts +2 -0
  613. package/dist/types/shared-ts/src/utils/errors.d.ts +0 -4
  614. package/dist/types/shared-ts/src/utils/exactKeys.d.ts +11 -0
  615. package/dist/types/shared-ts/src/utils/failure.d.ts +12 -0
  616. package/dist/types/shared-ts/src/utils/jsonRpc.d.ts +3 -4
  617. package/dist/types/shared-ts/src/utils/near.d.ts +0 -20
  618. package/dist/types/shared-ts/src/utils/nearRpcResults.d.ts +1 -0
  619. package/dist/types/shared-ts/src/utils/normalize.d.ts +0 -2
  620. package/dist/types/shared-ts/src/utils/registrationAuthMethodInput.d.ts +3 -8
  621. package/dist/types/shared-ts/src/utils/registrationSetupOperation.d.ts +3 -0
  622. package/dist/types/shared-ts/src/utils/registrationSignerPlan.d.ts +7 -19
  623. package/dist/types/shared-ts/src/utils/routerAbEcdsaDerivation.d.ts +3 -1
  624. package/dist/types/shared-ts/src/utils/routerAbEd25519Yao.d.ts +1 -0
  625. package/dist/types/shared-ts/src/utils/routerAbEd25519YaoDigests.d.ts +3 -4
  626. package/dist/types/shared-ts/src/utils/routerAbNormalSigningIdentity.d.ts +30 -8
  627. package/dist/types/shared-ts/src/utils/routerApiKeyAuth.d.ts +2 -0
  628. package/dist/types/shared-ts/src/utils/signingSessionSeal.d.ts +10 -11
  629. package/dist/types/shared-ts/src/utils/thresholdEcdsaChainTarget.d.ts +25 -0
  630. package/dist/types/shared-ts/src/utils/validation.d.ts +1 -3
  631. package/dist/types/shared-ts/src/utils/variant.d.ts +18 -0
  632. package/dist/types/shared-ts/src/utils/walletAuthMethodRecord.d.ts +3 -6
  633. package/dist/types/shared-ts/src/utils/walletCapabilityBindings.d.ts +0 -1
  634. package/dist/types/shared-ts/src/utils/walletManagementProtocol.d.ts +3 -0
  635. package/dist/types/shared-ts/src/utils/webauthnDeviceInfo.d.ts +4 -2
  636. package/dist/types/shared-ts/src/utils/wireSchema.d.ts +0 -2
  637. package/dist/types/shared-ts/src/wallet-recovery/backupAcknowledgement.d.ts +0 -1
  638. package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeReservation.d.ts +1 -10
  639. package/dist/types/shared-ts/src/wallet-recovery/recoveryCodes.d.ts +1 -3
  640. package/dist/types/shared-ts/src/wallet-recovery/recoveryEnvelopes.d.ts +3 -16
  641. package/dist/types/shared-ts/src/wallet-recovery/recoveryKeyId.d.ts +5 -21
  642. package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryPreparation.d.ts +15 -0
  643. package/dist/types/shared-ts/src/wallet-recovery/walletRecoveryTarget.d.ts +3 -4
  644. package/dist/types/wallet/build-paths.d.ts +1 -2
  645. package/dist/types/wallet/src/SeamsWeb/SeamsWeb.d.ts +2 -0
  646. package/dist/types/wallet/src/SeamsWeb/operations/auth/scheduleLinkedDevicePresignaturePrefill.d.ts +11 -0
  647. package/dist/types/wallet/src/SeamsWeb/operations/auth/walletAuth.d.ts +2 -1
  648. package/dist/types/wallet/src/SeamsWeb/operations/auth/walletUnlockEcdsaSubject.d.ts +1 -1
  649. package/dist/types/wallet/src/SeamsWeb/operations/auth/walletUnlockSubject.d.ts +3 -20
  650. package/dist/types/wallet/src/SeamsWeb/operations/authMethods/emailOtp/challenge.d.ts +0 -4
  651. package/dist/types/wallet/src/SeamsWeb/operations/authMethods/emailOtp/walletActivation.d.ts +3 -4
  652. package/dist/types/wallet/src/SeamsWeb/operations/devices/deviceLinkingAuthorityInstallation.d.ts +2 -10
  653. package/dist/types/wallet/src/SeamsWeb/operations/devices/deviceLinkingResume.d.ts +0 -1
  654. package/dist/types/wallet/src/SeamsWeb/operations/devices/linkDeviceFlow.d.ts +2 -0
  655. package/dist/types/wallet/src/SeamsWeb/operations/registration/pendingRegistrationRecovery.d.ts +0 -10
  656. package/dist/types/wallet/src/SeamsWeb/operations/session/thresholdEcdsaProvisioning.d.ts +1 -2
  657. package/dist/types/wallet/src/SeamsWeb/operations/tempo/executeEvmFamilyTransaction.d.ts +1 -1
  658. package/dist/types/wallet/src/SeamsWeb/publicApi/types.d.ts +7 -16
  659. package/dist/types/wallet/src/SeamsWeb/signingSurface/ports.d.ts +0 -2
  660. package/dist/types/wallet/src/SeamsWeb/signingSurface/types.d.ts +1 -1
  661. package/dist/types/wallet/src/SeamsWeb/walletIframe/client/surface/domain.d.ts +0 -8
  662. package/dist/types/wallet/src/SeamsWeb/walletIframe/client/transport/iframe-transport-handshake.d.ts +1 -2
  663. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/auth-menu/domain.d.ts +9 -0
  664. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/hostedWalletSeamsSession.d.ts +0 -1
  665. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/restoredSessionPresignaturePrefill.d.ts +2 -1
  666. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuFooter.d.ts +17 -0
  667. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/AuthMenuSurface.d.ts +12 -5
  668. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/ui/auth-menu/icons.d.ts +15 -0
  669. package/dist/types/wallet/src/SeamsWeb/walletIframe/shared/exactSessionReconciliation.d.ts +3 -3
  670. package/dist/types/wallet/src/SeamsWeb/walletIframe/shared/messages.d.ts +5 -15
  671. package/dist/types/wallet/src/advanced.d.ts +1 -1
  672. package/dist/types/wallet/src/core/accountData/near/keyMaterial.d.ts +3 -5
  673. package/dist/types/wallet/src/core/browser/walletIframe/events.d.ts +0 -2
  674. package/dist/types/wallet/src/core/indexedDB/index.d.ts +3 -5
  675. package/dist/types/wallet/src/core/indexedDB/passkeyClientDB.types.d.ts +2 -38
  676. package/dist/types/wallet/src/core/indexedDB/pendingWalletRecoveryCommit.d.ts +1 -4
  677. package/dist/types/wallet/src/core/indexedDB/pendingWalletRegistrationCommit.d.ts +3 -4
  678. package/dist/types/wallet/src/core/indexedDB/schemaNames.d.ts +0 -22
  679. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/ecdsaCapabilityManifestLookups.d.ts +7 -12
  680. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/ecdsaCapabilityManifestRecords.d.ts +1 -1
  681. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/ecdsaCapabilityManifestStore.d.ts +1 -1
  682. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/pendingWalletRecoveryCodeBackup.d.ts +0 -1
  683. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/registrationSetup.d.ts +42 -0
  684. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/signingSessionSeals.d.ts +1 -5
  685. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/walletSessionAuthorizationStore.d.ts +8 -7
  686. package/dist/types/wallet/src/core/indexedDB/unifiedIndexedDBManager.d.ts +1 -0
  687. package/dist/types/wallet/src/core/platform/browser/createBrowserPlatformRuntime.d.ts +1 -6
  688. package/dist/types/wallet/src/core/platform/ecdsaRoleLocalRecords.d.ts +7 -51
  689. package/dist/types/wallet/src/core/platform/http.d.ts +3 -5
  690. package/dist/types/wallet/src/core/platform/index.d.ts +4 -4
  691. package/dist/types/wallet/src/core/platform/ports.d.ts +4 -58
  692. package/dist/types/wallet/src/core/platform/runtime.d.ts +0 -2
  693. package/dist/types/wallet/src/core/platform/secretSources.d.ts +0 -29
  694. package/dist/types/wallet/src/core/rpcClients/near/NearClient.d.ts +1 -1
  695. package/dist/types/wallet/src/core/rpcClients/near/NearRpcError.d.ts +1 -2
  696. package/dist/types/wallet/src/core/rpcClients/relayer/ownerWalletExecutionLanePreflight.d.ts +2 -11
  697. package/dist/types/wallet/src/core/rpcClients/relayer/passkeyCustodyEnvelope.d.ts +0 -6
  698. package/dist/types/wallet/src/core/rpcClients/relayer/thresholdEcdsa.d.ts +2 -9
  699. package/dist/types/wallet/src/core/rpcClients/relayer/walletRecoveryPrepare.d.ts +2 -14
  700. package/dist/types/wallet/src/core/rpcClients/relayer/walletRegistration.d.ts +2 -19
  701. package/dist/types/wallet/src/core/signingEngine/assembly/ports/shared.d.ts +0 -1
  702. package/dist/types/wallet/src/core/signingEngine/assembly/ports/warmSigning.d.ts +0 -2
  703. package/dist/types/wallet/src/core/signingEngine/assembly/warmup.d.ts +0 -1
  704. package/dist/types/wallet/src/core/signingEngine/chains/near/nearSignerWasm.d.ts +0 -10
  705. package/dist/types/wallet/src/core/signingEngine/chains/near/payloads.d.ts +2 -10
  706. package/dist/types/wallet/src/core/signingEngine/flows/recovery/ecdsaDerivationExport.d.ts +3 -4
  707. package/dist/types/wallet/src/core/signingEngine/flows/recovery/ecdsaExportFlow.d.ts +4 -8
  708. package/dist/types/wallet/src/core/signingEngine/flows/recovery/keyExportConfirmation.d.ts +0 -15
  709. package/dist/types/wallet/src/core/signingEngine/flows/recovery/keyExportFlow.d.ts +7 -6
  710. package/dist/types/wallet/src/core/signingEngine/flows/registration/accountLifecycle.d.ts +2 -21
  711. package/dist/types/wallet/src/core/signingEngine/flows/registration/public.d.ts +1 -9
  712. package/dist/types/wallet/src/core/signingEngine/flows/registration/services/passkeyEd25519YaoAddSigner.d.ts +0 -2
  713. package/dist/types/wallet/src/core/signingEngine/flows/shared/signingStateMachine.d.ts +0 -6
  714. package/dist/types/wallet/src/core/signingEngine/flows/signEvmFamily/emailOtpSigningSession.d.ts +1 -1
  715. package/dist/types/wallet/src/core/signingEngine/flows/signEvmFamily/freshAuthRetryPolicy.d.ts +3 -4
  716. package/dist/types/wallet/src/core/signingEngine/flows/signEvmFamily/nonceResolution.d.ts +3 -4
  717. package/dist/types/wallet/src/core/signingEngine/flows/signEvmFamily/readySecp256k1Material.d.ts +7 -18
  718. package/dist/types/wallet/src/core/signingEngine/flows/signEvmFamily/signers/ecdsaDerivationClientSigningMaterialSource.d.ts +1 -0
  719. package/dist/types/wallet/src/core/signingEngine/flows/signEvmFamily/signingFlowRuntime.d.ts +10 -5
  720. package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/ed25519YaoCapabilityResolution.d.ts +4 -14
  721. package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/ed25519YaoNormalSigning.d.ts +0 -5
  722. package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/operationStepUpPreparation.d.ts +3 -5
  723. package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/signingMaterials.d.ts +0 -4
  724. package/dist/types/wallet/src/core/signingEngine/flows/signNear/shared/signingSessionAuthMode.d.ts +0 -9
  725. package/dist/types/wallet/src/core/signingEngine/flows/signNear/signNep413.d.ts +3 -7
  726. package/dist/types/wallet/src/core/signingEngine/interfaces/index.d.ts +0 -1
  727. package/dist/types/wallet/src/core/signingEngine/interfaces/near.d.ts +3 -4
  728. package/dist/types/wallet/src/core/signingEngine/interfaces/operationDeps.d.ts +3 -5
  729. package/dist/types/wallet/src/core/signingEngine/interfaces/operationStepUpPreparation.d.ts +3 -5
  730. package/dist/types/wallet/src/core/signingEngine/nonce/NonceCoordinator.d.ts +1 -1
  731. package/dist/types/wallet/src/core/signingEngine/nonce/nearTransactionReadiness.d.ts +3 -5
  732. package/dist/types/wallet/src/core/signingEngine/nonce/nonceTypes.d.ts +2 -11
  733. package/dist/types/wallet/src/core/signingEngine/routerAb/ecdsaDerivation/clientCeremony.d.ts +5 -22
  734. package/dist/types/wallet/src/core/signingEngine/routerAb/ecdsaDerivation/poolFillRoutes.d.ts +3 -14
  735. package/dist/types/wallet/src/core/signingEngine/routerAb/ecdsaDerivation/signingMaterialRef.d.ts +0 -3
  736. package/dist/types/wallet/src/core/signingEngine/session/authority/authorityOperationResolver.d.ts +1 -24
  737. package/dist/types/wallet/src/core/signingEngine/session/availability/persistedAvailableSigningLanes.d.ts +1 -1
  738. package/dist/types/wallet/src/core/signingEngine/session/availability/readiness.d.ts +0 -2
  739. package/dist/types/wallet/src/core/signingEngine/session/emailOtp/EmailOtpWalletSessionCoordinator.d.ts +37 -14
  740. package/dist/types/wallet/src/core/signingEngine/session/emailOtp/ecdsaLogin.d.ts +0 -3
  741. package/dist/types/wallet/src/core/signingEngine/session/emailOtp/ecdsaPublication.d.ts +3 -5
  742. package/dist/types/wallet/src/core/signingEngine/session/emailOtp/ecdsaRecovery.d.ts +0 -5
  743. package/dist/types/wallet/src/core/signingEngine/session/emailOtp/ed25519ExportContext.d.ts +2 -7
  744. package/dist/types/wallet/src/core/signingEngine/session/emailOtp/secretEscrow.d.ts +0 -1
  745. package/dist/types/wallet/src/core/signingEngine/session/emailOtp/walletUnlock.d.ts +6 -15
  746. package/dist/types/wallet/src/core/signingEngine/session/identity/clientSessionPersistenceState.d.ts +0 -6
  747. package/dist/types/wallet/src/core/signingEngine/session/identity/emailOtpEcdsaDerivationIdentity.d.ts +0 -3
  748. package/dist/types/wallet/src/core/signingEngine/session/identity/evmFamilyEcdsaIdentity.d.ts +3 -8
  749. package/dist/types/wallet/src/core/signingEngine/session/identity/exactSigningLaneIdentity.d.ts +0 -3
  750. package/dist/types/wallet/src/core/signingEngine/session/identity/exactWalletSessionCredential.d.ts +3 -7
  751. package/dist/types/wallet/src/core/signingEngine/session/identity/exactWalletSessionReader.d.ts +3 -6
  752. package/dist/types/wallet/src/core/signingEngine/session/identity/laneIdentity.d.ts +5 -14
  753. package/dist/types/wallet/src/core/signingEngine/session/identity/signingLaneAuthBinding.d.ts +3 -5
  754. package/dist/types/wallet/src/core/signingEngine/session/identity/walletUnlockSubject.d.ts +0 -8
  755. package/dist/types/wallet/src/core/signingEngine/session/keyMaterialBrands.d.ts +1 -4
  756. package/dist/types/wallet/src/core/signingEngine/session/material/activeEcdsaCapabilityRuntime.d.ts +5 -10
  757. package/dist/types/wallet/src/core/signingEngine/session/material/activeWalletAuthorityEcdsaRuntime.d.ts +4 -7
  758. package/dist/types/wallet/src/core/signingEngine/session/material/capabilityPreparationResult.d.ts +3 -22
  759. package/dist/types/wallet/src/core/signingEngine/session/material/ecdsaCapabilityHydration.d.ts +3 -4
  760. package/dist/types/wallet/src/core/signingEngine/session/material/ecdsaRoleLocalMaterialResolver.d.ts +0 -3
  761. package/dist/types/wallet/src/core/signingEngine/session/material/ecdsaSealedRuntime.d.ts +3 -4
  762. package/dist/types/wallet/src/core/signingEngine/session/material/ecdsaSigningCapability.d.ts +5 -0
  763. package/dist/types/wallet/src/core/signingEngine/session/material/nearEd25519YaoSigningPreparation.d.ts +5 -10
  764. package/dist/types/wallet/src/core/signingEngine/session/operationState/authorizationAdmission.d.ts +4 -9
  765. package/dist/types/wallet/src/core/signingEngine/session/operationState/preparedOperation.d.ts +0 -2
  766. package/dist/types/wallet/src/core/signingEngine/session/operationState/types.d.ts +3 -5
  767. package/dist/types/wallet/src/core/signingEngine/session/passkey/ecdsaBootstrap.d.ts +3 -4
  768. package/dist/types/wallet/src/core/signingEngine/session/passkey/ecdsaSessionProvision.d.ts +3 -4
  769. package/dist/types/wallet/src/core/signingEngine/session/passkey/ed25519YaoLocalMaterial.d.ts +0 -1
  770. package/dist/types/wallet/src/core/signingEngine/session/passkey/ed25519YaoWarmRecovery.d.ts +0 -2
  771. package/dist/types/wallet/src/core/signingEngine/session/passkey/unlockEcdsaWarmupPlanner.d.ts +7 -25
  772. package/dist/types/wallet/src/core/signingEngine/session/persistence/ecdsaRoleLocalRecords.d.ts +1 -10
  773. package/dist/types/wallet/src/core/signingEngine/session/persistence/sealedSessionRecords.d.ts +2 -2
  774. package/dist/types/wallet/src/core/signingEngine/session/persistence/sealedSessionTransportAuth.d.ts +0 -5
  775. package/dist/types/wallet/src/core/signingEngine/session/postconditions/runtimePostconditions.d.ts +0 -2
  776. package/dist/types/wallet/src/core/signingEngine/session/routerAbSigningWalletSession.d.ts +1 -1
  777. package/dist/types/wallet/src/core/signingEngine/session/sealedRecovery/sealedRecovery.types.d.ts +3 -4
  778. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/capabilityReaderCore.d.ts +3 -16
  779. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/ecdsaProvisionPlan.d.ts +0 -105
  780. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/ed25519SealedSessionRuntime.d.ts +6 -26
  781. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/persistencePorts.d.ts +3 -4
  782. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/public.d.ts +0 -1
  783. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/routerAbWalletSessionCredential.d.ts +0 -12
  784. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/transitions.d.ts +0 -2
  785. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/types.typecheck.d.ts +1 -10
  786. package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/channel/confirmTypes.d.ts +11 -36
  787. package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/methodRunners.d.ts +1 -5
  788. package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/otpPrompt/authLane.d.ts +5 -8
  789. package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/passkeyPrompt/touchIdPrompt.d.ts +4 -7
  790. package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/passkeyPrompt/webauthnPromptCoordinator.d.ts +3 -9
  791. package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/requireStepUpAuth.d.ts +1 -19
  792. package/dist/types/wallet/src/core/signingEngine/stepUpConfirmation/types.d.ts +7 -32
  793. package/dist/types/wallet/src/core/signingEngine/threshold/commitQueueShared.d.ts +10 -10
  794. package/dist/types/wallet/src/core/signingEngine/threshold/crypto/ecdsaDerivationClientWasm.d.ts +1 -1
  795. package/dist/types/wallet/src/core/signingEngine/threshold/crypto/ed25519YaoLaneWasm.d.ts +1 -15
  796. package/dist/types/wallet/src/core/signingEngine/threshold/ecdsa/activation.d.ts +0 -4
  797. package/dist/types/wallet/src/core/signingEngine/threshold/ecdsa/bootstrapSession.d.ts +3 -8
  798. package/dist/types/wallet/src/core/signingEngine/threshold/ecdsa/signingQueue.d.ts +1 -7
  799. package/dist/types/wallet/src/core/signingEngine/threshold/ed25519/commitQueue.d.ts +1 -6
  800. package/dist/types/wallet/src/core/signingEngine/threshold/ed25519/connectSession.d.ts +0 -1
  801. package/dist/types/wallet/src/core/signingEngine/threshold/ed25519/walletSession.d.ts +6 -36
  802. package/dist/types/wallet/src/core/signingEngine/threshold/ed25519/yaoClient.d.ts +1 -8
  803. package/dist/types/wallet/src/core/signingEngine/threshold/ed25519/yaoPublicCapabilityReferences.d.ts +3 -4
  804. package/dist/types/wallet/src/core/signingEngine/uiConfirm/handlers/flows/requestRegistrationCredentialConfirmation.d.ts +1 -4
  805. package/dist/types/wallet/src/core/signingEngine/uiConfirm/ui/preact/ExportPrivateKeySurface.d.ts +5 -9
  806. package/dist/types/wallet/src/core/signingEngine/uiConfirm/ui/transaction-display/abi/abiDecode.d.ts +0 -1
  807. package/dist/types/wallet/src/core/signingEngine/walletCustody/emailOtpLink.d.ts +0 -1
  808. package/dist/types/wallet/src/core/signingEngine/walletCustody/openCustodyCache.d.ts +0 -3
  809. package/dist/types/wallet/src/core/signingEngine/walletCustody/passkeyLink.d.ts +0 -3
  810. package/dist/types/wallet/src/core/signingEngine/walletCustody/registrationCeremony.d.ts +0 -1
  811. package/dist/types/wallet/src/core/signingEngine/webauthnAuth/walletOriginWebAuthn.d.ts +8 -0
  812. package/dist/types/wallet/src/core/signingEngine/workerManager/SignerWorkerManager.d.ts +0 -2
  813. package/dist/types/wallet/src/core/signingEngine/workerManager/ecdsaClientWorkerChannels.d.ts +0 -8
  814. package/dist/types/wallet/src/core/signingEngine/workerManager/ecdsaPresignLifecycle.d.ts +5 -16
  815. package/dist/types/wallet/src/core/signingEngine/workerManager/validation.d.ts +1 -1
  816. package/dist/types/wallet/src/core/signingEngine/workerManager/workerTypes.d.ts +9 -109
  817. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/device-linking-key/requests.d.ts +0 -5
  818. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/email-otp/crypto.d.ts +2 -12
  819. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/email-otp/custodyRestore.d.ts +0 -10
  820. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/email-otp/otpVerification.d.ts +0 -1
  821. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/email-otp/payloadParsing.d.ts +0 -2
  822. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/email-otp/unlock.d.ts +0 -1
  823. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/near-signer.worker.d.ts +3 -31
  824. package/dist/types/wallet/src/core/types/accountIds.d.ts +1 -1
  825. package/dist/types/wallet/src/core/types/index.d.ts +0 -18
  826. package/dist/types/wallet/src/core/types/linkDevice.d.ts +3 -18
  827. package/dist/types/wallet/src/core/types/sdkPublicResults.d.ts +5 -18
  828. package/dist/types/wallet/src/core/types/sdkSentEvents.d.ts +5 -23
  829. package/dist/types/wallet/src/core/types/seams.d.ts +17 -71
  830. package/dist/types/wallet/src/core/types/secure-confirm-worker.d.ts +0 -5
  831. package/dist/types/wallet/src/core/types/signer-worker.d.ts +75 -134
  832. package/dist/types/wallet/src/externalEvm/types.d.ts +5 -12
  833. package/dist/types/wallet/src/react/components/AccountMenuButton/Toggle.d.ts +0 -15
  834. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/GlobeIcon.d.ts +1 -4
  835. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/KeyIcon.d.ts +1 -4
  836. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/LaptopIcon.d.ts +1 -4
  837. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/LinkIcon.d.ts +1 -4
  838. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/LockIcon.d.ts +1 -4
  839. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/MailIcon.d.ts +1 -4
  840. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/RecoveryCodesIcon.d.ts +1 -4
  841. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/ScanIcon.d.ts +1 -4
  842. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/SlidersIcon.d.ts +1 -4
  843. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/SmartphoneIcon.d.ts +1 -4
  844. package/dist/types/wallet/src/react/components/AccountMenuButton/icons/lucideIcon.d.ts +5 -0
  845. package/dist/types/wallet/src/react/components/theme/design-tokens.d.ts +0 -19
  846. package/dist/types/wallet/src/react/hooks/useAccountInput.d.ts +1 -22
  847. package/dist/types/wallet/src/react/transactionReview/controller.d.ts +3 -10
  848. package/dist/types/wallet/src/utils/menuItemBlink.d.ts +9 -0
  849. package/dist/types/wallet/src/utils/qrScanner.d.ts +1 -21
  850. package/dist/workers/device-linking-key.worker.js +567 -2131
  851. package/dist/workers/ecdsa-derivation-client.worker.js +1529 -2683
  852. package/dist/workers/ecdsa-online-client.worker.js +1 -273
  853. package/dist/workers/ecdsa-presign-client.worker.js +59 -346
  854. package/dist/workers/email-otp.worker.js +307 -2185
  855. package/dist/workers/email_otp_runtime_bg.wasm +0 -0
  856. package/dist/workers/evm-crypto.worker.js +0 -188
  857. package/dist/workers/evm_crypto.wasm +0 -0
  858. package/dist/workers/evm_crypto_bg.wasm +0 -0
  859. package/dist/workers/near-signer.worker.js +16 -718
  860. package/dist/workers/near_signer.wasm +0 -0
  861. package/dist/workers/passkey-confirm.worker.js +0 -134
  862. package/dist/workers/passkey-mpc-export.worker.js +149 -506
  863. package/dist/workers/passkey-mpc-session.worker.js +0 -134
  864. package/dist/workers/router_ab_ecdsa_client_bg.wasm +0 -0
  865. package/dist/workers/router_ab_ed25519_yao_client_bg.wasm +0 -0
  866. package/dist/workers/shamir3pass.worker.js +0 -134
  867. package/dist/workers/shamir3pass_runtime_bg.wasm +0 -0
  868. package/dist/workers/tempo-signer.worker.js +0 -134
  869. package/dist/workers/tempo_signer.wasm +0 -0
  870. package/dist/workers/tempo_signer_bg.wasm +0 -0
  871. package/dist/workers/wallet-custody-ceremony.worker.js +136 -1636
  872. package/dist/workers/wallet_custody_ceremony.js +0 -14
  873. package/dist/workers/wallet_custody_ceremony_bg.wasm +0 -0
  874. package/dist/workers/wasm_signer_worker_bg.wasm +0 -0
  875. package/package.json +1 -14
  876. package/dist/esm/SeamsWeb/walletIframe/client/transport/webauthn-bridge.js +0 -99
  877. package/dist/esm/components/AccountMenuButton/AccountsSection.css +0 -81
  878. package/dist/esm/components/AccountMenuButton/ExportKeysSection.css +0 -96
  879. package/dist/esm/components/AccountMenuButton/HaloBorder/HaloBorder.css +0 -101
  880. package/dist/esm/components/AccountMenuButton/LinkedDevicesModal.css +0 -612
  881. package/dist/esm/components/AccountMenuButton/MenuItem.css +0 -181
  882. package/dist/esm/components/AccountMenuButton/ProfileDropdown.css +0 -80
  883. package/dist/esm/components/AccountMenuButton/TransactionSettingsSection.css +0 -107
  884. package/dist/esm/components/AccountMenuButton/UserAccountButton.css +0 -182
  885. package/dist/esm/components/AccountMenuButton/WalletSettingsLayout.css +0 -456
  886. package/dist/esm/components/AccountMenuButton/Web3AuthProfileButton.css +0 -75
  887. package/dist/esm/components/AccountMenuButton/icons/TouchIcon.css +0 -46
  888. package/dist/esm/components/QRCodeScanner.css +0 -502
  889. package/dist/esm/components/ShowQRCode.css +0 -345
  890. package/dist/esm/core/indexedDB/seamsWalletDB/laneHolderMaterialStore.js +0 -239
  891. package/dist/esm/core/signingEngine/session/emailOtp/coordinatorRuntime.js +0 -131
  892. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/renderers/evm.js +0 -12
  893. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/renderers/near.js +0 -12
  894. package/dist/esm/core/signingEngine/uiConfirm/ui/transaction-display/renderers/tempo.js +0 -12
  895. package/dist/esm/core/signingEngine/webauthnAuth/fallbacks/safari-fallbacks.js +0 -171
  896. package/dist/esm/core/signingEngine/workerManager/nearKeyOps/createNearKeyOps.js +0 -32
  897. package/dist/esm/plugins/shared-ts/src/utils/base58.js +0 -1
  898. package/dist/esm/plugins/shared-ts/src/utils/near.js +0 -1
  899. package/dist/esm/plugins/shared-ts/src/utils/validation.js +0 -2
  900. package/dist/esm/react/SeamsWeb/SeamsWeb.js +0 -1909
  901. package/dist/esm/react/SeamsWeb/assembly/browserSigningSurfaceAssembly.js +0 -817
  902. package/dist/esm/react/SeamsWeb/assembly/browserWorkerWarmupPolicy.js +0 -31
  903. package/dist/esm/react/SeamsWeb/assembly/configureBrowserIndexedDB.js +0 -10
  904. package/dist/esm/react/SeamsWeb/assembly/createBrowserRecoveryPublicDeps.js +0 -95
  905. package/dist/esm/react/SeamsWeb/assembly/createBrowserSigningRuntime.js +0 -34
  906. package/dist/esm/react/SeamsWeb/assembly/createBrowserSigningStores.js +0 -39
  907. package/dist/esm/react/SeamsWeb/assembly/createBrowserStepUpRuntime.js +0 -34
  908. package/dist/esm/react/SeamsWeb/assembly/createBrowserWarmSessionPublicDeps.js +0 -31
  909. package/dist/esm/react/SeamsWeb/assembly/createWalletIframeOverlayState.js +0 -9
  910. package/dist/esm/react/SeamsWeb/assembly/createWalletIframeRouter.js +0 -44
  911. package/dist/esm/react/SeamsWeb/assembly/initializeBrowserSigningRuntime.js +0 -19
  912. package/dist/esm/react/SeamsWeb/assembly/runtimeConfig.js +0 -12
  913. package/dist/esm/react/SeamsWeb/operations/auth/login.js +0 -4398
  914. package/dist/esm/react/SeamsWeb/operations/auth/scheduleEcdsaSessionPresignaturePrefill.js +0 -41
  915. package/dist/esm/react/SeamsWeb/operations/auth/walletAuth.js +0 -143
  916. package/dist/esm/react/SeamsWeb/operations/auth/walletUnlockEcdsaSubject.js +0 -36
  917. package/dist/esm/react/SeamsWeb/operations/auth/walletUnlockSubject.js +0 -294
  918. package/dist/esm/react/SeamsWeb/operations/authMethods/addAuthMethodSourceClaim.js +0 -72
  919. package/dist/esm/react/SeamsWeb/operations/authMethods/emailOtp/addEmailOtp.js +0 -191
  920. package/dist/esm/react/SeamsWeb/operations/authMethods/emailOtp/challenge.js +0 -247
  921. package/dist/esm/react/SeamsWeb/operations/authMethods/emailOtp/googleEmailOtpWalletAuthFlow.js +0 -572
  922. package/dist/esm/react/SeamsWeb/operations/authMethods/emailOtp/localEmailOtpProjection.js +0 -69
  923. package/dist/esm/react/SeamsWeb/operations/authMethods/emailOtp/registrationAuthority.js +0 -62
  924. package/dist/esm/react/SeamsWeb/operations/authMethods/emailOtp/registrationOffer.js +0 -69
  925. package/dist/esm/react/SeamsWeb/operations/authMethods/emailOtp/walletActivation.js +0 -95
  926. package/dist/esm/react/SeamsWeb/operations/authMethods/passkey/addPasskey.js +0 -260
  927. package/dist/esm/react/SeamsWeb/operations/authMethods/passkey/ecdsaBootstrap.js +0 -17
  928. package/dist/esm/react/SeamsWeb/operations/authMethods/passkey/exactPasskeyAuthority.js +0 -34
  929. package/dist/esm/react/SeamsWeb/operations/authMethods/passkey/localPasskeyProjection.js +0 -117
  930. package/dist/esm/react/SeamsWeb/operations/authMethods/passkey/localUnlock.js +0 -16
  931. package/dist/esm/react/SeamsWeb/operations/authMethods/passkey/loginAssertion.js +0 -25
  932. package/dist/esm/react/SeamsWeb/operations/authMethods/passkey/registrationAuthority.js +0 -84
  933. package/dist/esm/react/SeamsWeb/operations/authMethods/revokeAuthMethod.js +0 -205
  934. package/dist/esm/react/SeamsWeb/operations/authMethods/sourcePasskeyProof.js +0 -12
  935. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingAuthorityInstallation.js +0 -444
  936. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingComposition.js +0 -106
  937. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingEd25519ExportRoot.js +0 -194
  938. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingHttpTransport.js +0 -525
  939. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingOwnerTransport.js +0 -135
  940. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingResume.js +0 -219
  941. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingTargetCredential.js +0 -63
  942. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingTargetEd25519ExportRoot.js +0 -61
  943. package/dist/esm/react/SeamsWeb/operations/devices/deviceLinkingWorkerChannels.js +0 -337
  944. package/dist/esm/react/SeamsWeb/operations/devices/linkDevice.js +0 -75
  945. package/dist/esm/react/SeamsWeb/operations/devices/linkDeviceFlow.js +0 -1358
  946. package/dist/esm/react/SeamsWeb/operations/devices/linkDeviceFlowSupport.js +0 -143
  947. package/dist/esm/react/SeamsWeb/operations/devices/linkDeviceTargetActivation.js +0 -119
  948. package/dist/esm/react/SeamsWeb/operations/devices/scanDevice.js +0 -384
  949. package/dist/esm/react/SeamsWeb/operations/devices/walletHostComposition.js +0 -130
  950. package/dist/esm/react/SeamsWeb/operations/devices/walletHostOwnerAuthority.js +0 -191
  951. package/dist/esm/react/SeamsWeb/operations/evm/index.js +0 -35
  952. package/dist/esm/react/SeamsWeb/operations/near/actions.js +0 -484
  953. package/dist/esm/react/SeamsWeb/operations/near/commandSubject.js +0 -14
  954. package/dist/esm/react/SeamsWeb/operations/near/delegateAction.js +0 -247
  955. package/dist/esm/react/SeamsWeb/operations/near/index.js +0 -37
  956. package/dist/esm/react/SeamsWeb/operations/near/signNEP413.js +0 -117
  957. package/dist/esm/react/SeamsWeb/operations/near/signingEventHelpers.js +0 -15
  958. package/dist/esm/react/SeamsWeb/operations/recovery/accountSync.js +0 -21
  959. package/dist/esm/react/SeamsWeb/operations/recovery/recoveryWalletBinding.js +0 -43
  960. package/dist/esm/react/SeamsWeb/operations/recovery/syncAccount.js +0 -914
  961. package/dist/esm/react/SeamsWeb/operations/recovery/walletRecoveryCodeBackup.js +0 -100
  962. package/dist/esm/react/SeamsWeb/operations/recovery/walletRecoveryCommit.js +0 -477
  963. package/dist/esm/react/SeamsWeb/operations/recovery/walletRecoveryDurablePayload.js +0 -386
  964. package/dist/esm/react/SeamsWeb/operations/recovery/walletRecoveryJournal.js +0 -118
  965. package/dist/esm/react/SeamsWeb/operations/recovery/walletRecoveryRotation.js +0 -214
  966. package/dist/esm/react/SeamsWeb/operations/registration/pendingEcdsaRegistrationRecovery.js +0 -184
  967. package/dist/esm/react/SeamsWeb/operations/registration/pendingEcdsaRegistrationRecoveryUnlock.js +0 -247
  968. package/dist/esm/react/SeamsWeb/operations/registration/pendingEcdsaRegistrationRecoveryValidation.js +0 -134
  969. package/dist/esm/react/SeamsWeb/operations/registration/pendingRegistrationRecovery.js +0 -369
  970. package/dist/esm/react/SeamsWeb/operations/registration/registration.js +0 -3818
  971. package/dist/esm/react/SeamsWeb/operations/registration/registrationEd25519Yao.js +0 -166
  972. package/dist/esm/react/SeamsWeb/operations/registration/registrationSignerSet.js +0 -60
  973. package/dist/esm/react/SeamsWeb/operations/registration/registrationStrictEcdsa.js +0 -343
  974. package/dist/esm/react/SeamsWeb/operations/registration/registrationTerminalCommit.js +0 -296
  975. package/dist/esm/react/SeamsWeb/operations/registration/registrationTiming.js +0 -682
  976. package/dist/esm/react/SeamsWeb/operations/session/thresholdEcdsaProvisioning.js +0 -40
  977. package/dist/esm/react/SeamsWeb/operations/session/thresholdWarmSessionBootstrap.js +0 -20
  978. package/dist/esm/react/SeamsWeb/operations/tempo/executeEvmFamilyTransaction.js +0 -565
  979. package/dist/esm/react/SeamsWeb/operations/tempo/feeTokenPreference.js +0 -67
  980. package/dist/esm/react/SeamsWeb/operations/tempo/index.js +0 -39
  981. package/dist/esm/react/SeamsWeb/publicApi/auth.js +0 -23
  982. package/dist/esm/react/SeamsWeb/publicApi/awaitNearReady.js +0 -72
  983. package/dist/esm/react/SeamsWeb/publicApi/capabilitySelection.js +0 -63
  984. package/dist/esm/react/SeamsWeb/publicApi/chainTargets.js +0 -48
  985. package/dist/esm/react/SeamsWeb/publicApi/createPublicApi.js +0 -133
  986. package/dist/esm/react/SeamsWeb/publicApi/currentWallet.js +0 -46
  987. package/dist/esm/react/SeamsWeb/publicApi/devices.js +0 -83
  988. package/dist/esm/react/SeamsWeb/publicApi/evm.js +0 -103
  989. package/dist/esm/react/SeamsWeb/publicApi/keyExport.js +0 -90
  990. package/dist/esm/react/SeamsWeb/publicApi/near.js +0 -449
  991. package/dist/esm/react/SeamsWeb/publicApi/preferences.js +0 -61
  992. package/dist/esm/react/SeamsWeb/publicApi/recovery.js +0 -19
  993. package/dist/esm/react/SeamsWeb/publicApi/tempo.js +0 -238
  994. package/dist/esm/react/SeamsWeb/publicApi/transactionReview.js +0 -12
  995. package/dist/esm/react/SeamsWeb/publicApi/types.js +0 -10
  996. package/dist/esm/react/SeamsWeb/signingSurface/BrowserSigningSurface.js +0 -3908
  997. package/dist/esm/react/SeamsWeb/walletIframe/client/overlay/overlay-controller.js +0 -530
  998. package/dist/esm/react/SeamsWeb/walletIframe/client/overlay/overlay-styles.js +0 -417
  999. package/dist/esm/react/SeamsWeb/walletIframe/client/progress/on-events-progress-bus.js +0 -134
  1000. package/dist/esm/react/SeamsWeb/walletIframe/client/router.js +0 -3368
  1001. package/dist/esm/react/SeamsWeb/walletIframe/client/surface/domain.js +0 -288
  1002. package/dist/esm/react/SeamsWeb/walletIframe/client/surface/geometry.js +0 -128
  1003. package/dist/esm/react/SeamsWeb/walletIframe/client/surface/renderer.js +0 -119
  1004. package/dist/esm/react/SeamsWeb/walletIframe/client/surface/transactionSurfaceQueue.js +0 -125
  1005. package/dist/esm/react/SeamsWeb/walletIframe/client/transactionReviewReservation.js +0 -96
  1006. package/dist/esm/react/SeamsWeb/walletIframe/client/transport/IframeTransport.js +0 -252
  1007. package/dist/esm/react/SeamsWeb/walletIframe/client/transport/iframe-transport-dom.js +0 -71
  1008. package/dist/esm/react/SeamsWeb/walletIframe/client/transport/iframe-transport-handshake.js +0 -211
  1009. package/dist/esm/react/SeamsWeb/walletIframe/client/transport/webauthn-bridge.js +0 -99
  1010. package/dist/esm/react/SeamsWeb/walletIframe/coordinator.js +0 -235
  1011. package/dist/esm/react/SeamsWeb/walletIframe/host/surface-measurement-reporter.js +0 -158
  1012. package/dist/esm/react/SeamsWeb/walletIframe/shared/exactSessionState.js +0 -625
  1013. package/dist/esm/react/SeamsWeb/walletIframe/shared/is-dev-host.js +0 -11
  1014. package/dist/esm/react/SeamsWeb/walletIframe/shared/messages.js +0 -588
  1015. package/dist/esm/react/SeamsWeb/walletIframe/shared/transactionReview.js +0 -83
  1016. package/dist/esm/react/SeamsWeb/walletIframe/shared/unlockOptions.js +0 -54
  1017. package/dist/esm/react/base-styles.js +0 -13
  1018. package/dist/esm/react/build-paths.js +0 -111
  1019. package/dist/esm/react/components/AccountMenuButton/HaloBorder/HaloBorder.css +0 -101
  1020. package/dist/esm/react/config.js +0 -37
  1021. package/dist/esm/react/core/accountData/near/accountProjection.js +0 -119
  1022. package/dist/esm/react/core/accountData/near/accountRefs.js +0 -21
  1023. package/dist/esm/react/core/accountData/near/keyMaterial.js +0 -171
  1024. package/dist/esm/react/core/accountData/near/profileId.js +0 -24
  1025. package/dist/esm/react/core/browser/walletIframe/csp-stylesheet.js +0 -189
  1026. package/dist/esm/react/core/browser/walletIframe/events.js +0 -10
  1027. package/dist/esm/react/core/browser/walletIframe/host-mode.js +0 -19
  1028. package/dist/esm/react/core/browser/walletIframe/hostVariant.js +0 -16
  1029. package/dist/esm/react/core/config/chains.js +0 -90
  1030. package/dist/esm/react/core/config/configBuilder.js +0 -231
  1031. package/dist/esm/react/core/config/configHelpers.js +0 -183
  1032. package/dist/esm/react/core/config/defaultConfigs.js +0 -120
  1033. package/dist/esm/react/core/config/defineConfig.js +0 -48
  1034. package/dist/esm/react/core/config/managedRuntimeScope.js +0 -16
  1035. package/dist/esm/react/core/indexedDB/accountKeyMaterial.js +0 -68
  1036. package/dist/esm/react/core/indexedDB/accountSignerLifecycle.js +0 -143
  1037. package/dist/esm/react/core/indexedDB/index.js +0 -60
  1038. package/dist/esm/react/core/indexedDB/keyMaterialEnvelope.js +0 -69
  1039. package/dist/esm/react/core/indexedDB/lastProfileState.js +0 -22
  1040. package/dist/esm/react/core/indexedDB/linkedAuthoritySignerMaterial.js +0 -291
  1041. package/dist/esm/react/core/indexedDB/nonceLaneCoordinationStore.js +0 -115
  1042. package/dist/esm/react/core/indexedDB/normalization.js +0 -24
  1043. package/dist/esm/react/core/indexedDB/pendingWalletRecoveryCommit.js +0 -482
  1044. package/dist/esm/react/core/indexedDB/pendingWalletRegistrationCommit.js +0 -879
  1045. package/dist/esm/react/core/indexedDB/profileAccountProjection.js +0 -70
  1046. package/dist/esm/react/core/indexedDB/schemaNames.js +0 -845
  1047. package/dist/esm/react/core/indexedDB/seamsWalletDB/ecdsaCapabilityManifestLookups.js +0 -209
  1048. package/dist/esm/react/core/indexedDB/seamsWalletDB/ecdsaCapabilityManifestRecords.js +0 -848
  1049. package/dist/esm/react/core/indexedDB/seamsWalletDB/ecdsaCapabilityManifestStore.js +0 -1215
  1050. package/dist/esm/react/core/indexedDB/seamsWalletDB/ecdsaClientPresignatures.js +0 -235
  1051. package/dist/esm/react/core/indexedDB/seamsWalletDB/manager.js +0 -140
  1052. package/dist/esm/react/core/indexedDB/seamsWalletDB/pendingWalletRecoveryCodeBackup.js +0 -145
  1053. package/dist/esm/react/core/indexedDB/seamsWalletDB/repositories.js +0 -4747
  1054. package/dist/esm/react/core/indexedDB/seamsWalletDB/schema.js +0 -23
  1055. package/dist/esm/react/core/indexedDB/seamsWalletDB/signingSessionSeals.js +0 -205
  1056. package/dist/esm/react/core/indexedDB/seamsWalletDB/walletCustodyEcdsaContinuity.js +0 -198
  1057. package/dist/esm/react/core/indexedDB/seamsWalletDB/walletSessionAuthorizationStore.js +0 -569
  1058. package/dist/esm/react/core/indexedDB/singletons.js +0 -7
  1059. package/dist/esm/react/core/indexedDB/unifiedIndexedDBManager.js +0 -578
  1060. package/dist/esm/react/core/indexedDB/walletCustodyEd25519MaterialRecord.js +0 -60
  1061. package/dist/esm/react/core/platform/browser/createBrowserPlatformRuntime.js +0 -552
  1062. package/dist/esm/react/core/platform/secretSources.js +0 -111
  1063. package/dist/esm/react/core/platform/signerCoreCommandAdapters.js +0 -122
  1064. package/dist/esm/react/core/rpcClients/evm/EvmClient.js +0 -549
  1065. package/dist/esm/react/core/rpcClients/evm/nonceBackend.js +0 -279
  1066. package/dist/esm/react/core/rpcClients/near/NearClient.js +0 -56
  1067. package/dist/esm/react/core/rpcClients/near/NearRpcError.js +0 -105
  1068. package/dist/esm/react/core/rpcClients/near/rpcCalls.js +0 -376
  1069. package/dist/esm/react/core/rpcClients/relayer/ownerWalletExecutionLanePreflight.js +0 -67
  1070. package/dist/esm/react/core/rpcClients/relayer/passkeyCustodyEnvelope.js +0 -228
  1071. package/dist/esm/react/core/rpcClients/relayer/registrationSignerSetRequest.js +0 -8
  1072. package/dist/esm/react/core/rpcClients/relayer/relayerHttp.js +0 -26
  1073. package/dist/esm/react/core/rpcClients/relayer/routerAbNormalSigning.js +0 -812
  1074. package/dist/esm/react/core/rpcClients/relayer/routerAbNormalSigningValidation.js +0 -23
  1075. package/dist/esm/react/core/rpcClients/relayer/sealedRefreshCapabilities.js +0 -148
  1076. package/dist/esm/react/core/rpcClients/relayer/thresholdEcdsa.js +0 -237
  1077. package/dist/esm/react/core/rpcClients/relayer/walletRecoveryFinalize.js +0 -174
  1078. package/dist/esm/react/core/rpcClients/relayer/walletRecoveryGoogleEmailOtp.js +0 -161
  1079. package/dist/esm/react/core/rpcClients/relayer/walletRecoveryPrepare.js +0 -295
  1080. package/dist/esm/react/core/rpcClients/relayer/walletRecoveryRotate.js +0 -311
  1081. package/dist/esm/react/core/rpcClients/relayer/walletRegistration.js +0 -2349
  1082. package/dist/esm/react/core/rpcClients/relayer/walletRegistrationTerminalResponse.js +0 -719
  1083. package/dist/esm/react/core/rpcClients/relayer/walletSessionAuthorizationStatus.js +0 -214
  1084. package/dist/esm/react/core/runtime/createSigningRuntime.js +0 -100
  1085. package/dist/esm/react/core/signingEngine/assembly/createManagers.js +0 -80
  1086. package/dist/esm/react/core/signingEngine/assembly/createPorts.js +0 -54
  1087. package/dist/esm/react/core/signingEngine/assembly/ports/emailOtp.js +0 -30
  1088. package/dist/esm/react/core/signingEngine/assembly/ports/evmFamily.js +0 -73
  1089. package/dist/esm/react/core/signingEngine/assembly/ports/near.js +0 -21
  1090. package/dist/esm/react/core/signingEngine/assembly/ports/recovery.js +0 -75
  1091. package/dist/esm/react/core/signingEngine/assembly/ports/registration.js +0 -22
  1092. package/dist/esm/react/core/signingEngine/assembly/ports/session.js +0 -25
  1093. package/dist/esm/react/core/signingEngine/assembly/ports/shared.js +0 -40
  1094. package/dist/esm/react/core/signingEngine/assembly/ports/stepUpRuntime.js +0 -67
  1095. package/dist/esm/react/core/signingEngine/assembly/ports/warmSigning.js +0 -92
  1096. package/dist/esm/react/core/signingEngine/assembly/warmup.js +0 -68
  1097. package/dist/esm/react/core/signingEngine/chains/evm/bytes.js +0 -22
  1098. package/dist/esm/react/core/signingEngine/chains/evm/display/calldata.js +0 -25
  1099. package/dist/esm/react/core/signingEngine/chains/evm/display/evmTx.js +0 -119
  1100. package/dist/esm/react/core/signingEngine/chains/evm/display/functionSelectors.js +0 -75
  1101. package/dist/esm/react/core/signingEngine/chains/evm/display/gas.js +0 -19
  1102. package/dist/esm/react/core/signingEngine/chains/evm/display/normalization.js +0 -23
  1103. package/dist/esm/react/core/signingEngine/chains/evm/evmAdapter.js +0 -44
  1104. package/dist/esm/react/core/signingEngine/chains/evm/evmCryptoWasm.js +0 -198
  1105. package/dist/esm/react/core/signingEngine/chains/near/display.js +0 -248
  1106. package/dist/esm/react/core/signingEngine/chains/near/nearSignerWasm.js +0 -170
  1107. package/dist/esm/react/core/signingEngine/chains/near/payloads.js +0 -58
  1108. package/dist/esm/react/core/signingEngine/chains/tempo/display.js +0 -130
  1109. package/dist/esm/react/core/signingEngine/chains/tempo/feeToken.js +0 -187
  1110. package/dist/esm/react/core/signingEngine/chains/tempo/tempoAdapter.js +0 -49
  1111. package/dist/esm/react/core/signingEngine/chains/tempo/tempoSignerWasm.js +0 -90
  1112. package/dist/esm/react/core/signingEngine/flows/recovery/ecdsaDerivationExport.js +0 -428
  1113. package/dist/esm/react/core/signingEngine/flows/recovery/ecdsaExportFlow.js +0 -660
  1114. package/dist/esm/react/core/signingEngine/flows/recovery/ecdsaExportMaterial.js +0 -243
  1115. package/dist/esm/react/core/signingEngine/flows/recovery/ed25519YaoExportFlow.js +0 -353
  1116. package/dist/esm/react/core/signingEngine/flows/recovery/exportKeypairOperation.js +0 -216
  1117. package/dist/esm/react/core/signingEngine/flows/recovery/exportLaneSelection.js +0 -283
  1118. package/dist/esm/react/core/signingEngine/flows/recovery/keyExportConfirmation.js +0 -325
  1119. package/dist/esm/react/core/signingEngine/flows/recovery/keyExportFlow.js +0 -81
  1120. package/dist/esm/react/core/signingEngine/flows/recovery/passkeyEd25519YaoRecovery.js +0 -195
  1121. package/dist/esm/react/core/signingEngine/flows/recovery/public.js +0 -26
  1122. package/dist/esm/react/core/signingEngine/flows/recovery/stepUpAuthorization.js +0 -139
  1123. package/dist/esm/react/core/signingEngine/flows/registration/accountLifecycle.js +0 -1098
  1124. package/dist/esm/react/core/signingEngine/flows/registration/nearProvisioningRegistry.js +0 -79
  1125. package/dist/esm/react/core/signingEngine/flows/registration/public.js +0 -85
  1126. package/dist/esm/react/core/signingEngine/flows/registration/services/ecdsaRegistrationSessions.js +0 -77
  1127. package/dist/esm/react/core/signingEngine/flows/registration/services/ecdsaWalletRecords.js +0 -15
  1128. package/dist/esm/react/core/signingEngine/flows/registration/services/passkeyEd25519YaoAddSigner.js +0 -83
  1129. package/dist/esm/react/core/signingEngine/flows/registration/services/registrationAccounts.js +0 -30
  1130. package/dist/esm/react/core/signingEngine/flows/registration/session.js +0 -24
  1131. package/dist/esm/react/core/signingEngine/flows/shared/signingConfirmation.js +0 -194
  1132. package/dist/esm/react/core/signingEngine/flows/shared/signingStateMachine.js +0 -485
  1133. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/accountAuth.js +0 -12
  1134. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/addresses.js +0 -10
  1135. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/authPlanning.js +0 -139
  1136. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/ecdsaLanes.js +0 -102
  1137. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/ecdsaSelection.js +0 -233
  1138. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/emailOtpPublic.js +0 -123
  1139. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/emailOtpSigningSession.js +0 -227
  1140. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/errors.js +0 -127
  1141. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/events.js +0 -39
  1142. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/evmNonceLifecycle.js +0 -49
  1143. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/executorThresholdState.js +0 -22
  1144. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/freshAuthRetryPolicy.js +0 -98
  1145. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/freshWalletSessionRetry.js +0 -76
  1146. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/nonceLifecycleAdapter.js +0 -245
  1147. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/nonceResolution.js +0 -91
  1148. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/operationIds.js +0 -33
  1149. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/preparedSigning.js +0 -383
  1150. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/readySecp256k1Material.js +0 -191
  1151. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/requireEvmFamilyStepUpAuth.js +0 -128
  1152. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signEvmFamily.js +0 -512
  1153. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signEvmFamilyWithUiConfirmForTempo.js +0 -65
  1154. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signEvmWithUiConfirm.js +0 -26
  1155. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signatureUses.js +0 -12
  1156. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signerLoader.js +0 -25
  1157. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signers/ecdsaDerivationClientSigningMaterialSource.js +0 -76
  1158. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signers/secp256k1.js +0 -182
  1159. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signers/webauthnP256.js +0 -84
  1160. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signingFlow.js +0 -631
  1161. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/signingFlowRuntime.js +0 -391
  1162. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/stepUpAuthorization.js +0 -56
  1163. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/tempoNonceLifecycle.js +0 -47
  1164. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/thresholdAdmission.js +0 -87
  1165. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/transactionExecutor.js +0 -143
  1166. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/types.js +0 -20
  1167. package/dist/esm/react/core/signingEngine/flows/signEvmFamily/webauthnP256KeyRef.js +0 -33
  1168. package/dist/esm/react/core/signingEngine/flows/signNear/implicitAccountFunding.js +0 -202
  1169. package/dist/esm/react/core/signingEngine/flows/signNear/nearSigningFlow.js +0 -56
  1170. package/dist/esm/react/core/signingEngine/flows/signNear/requireNearStepUpAuth.js +0 -102
  1171. package/dist/esm/react/core/signingEngine/flows/signNear/shared/confirmationProgress.js +0 -28
  1172. package/dist/esm/react/core/signingEngine/flows/signNear/shared/ed25519YaoCapabilityResolution.js +0 -101
  1173. package/dist/esm/react/core/signingEngine/flows/signNear/shared/ed25519YaoNormalSigning.js +0 -822
  1174. package/dist/esm/react/core/signingEngine/flows/signNear/shared/implicitAccountFundingPort.js +0 -24
  1175. package/dist/esm/react/core/signingEngine/flows/signNear/shared/operationStepUpPreparation.js +0 -68
  1176. package/dist/esm/react/core/signingEngine/flows/signNear/shared/signatureOnlySigning.js +0 -343
  1177. package/dist/esm/react/core/signingEngine/flows/signNear/shared/signingMaterials.js +0 -25
  1178. package/dist/esm/react/core/signingEngine/flows/signNear/shared/signingSessionAuthMode.js +0 -138
  1179. package/dist/esm/react/core/signingEngine/flows/signNear/signDelegate.js +0 -290
  1180. package/dist/esm/react/core/signingEngine/flows/signNear/signNear.js +0 -1238
  1181. package/dist/esm/react/core/signingEngine/flows/signNear/signNep413.js +0 -144
  1182. package/dist/esm/react/core/signingEngine/flows/signNear/signTransactions.js +0 -897
  1183. package/dist/esm/react/core/signingEngine/flows/signNear/signatureUses.js +0 -12
  1184. package/dist/esm/react/core/signingEngine/flows/signNear/stepUpAuthorization.js +0 -42
  1185. package/dist/esm/react/core/signingEngine/interfaces/accountAuthMetadata.js +0 -14
  1186. package/dist/esm/react/core/signingEngine/interfaces/ecdsaChainTarget.js +0 -142
  1187. package/dist/esm/react/core/signingEngine/interfaces/operationStepUpPreparation.js +0 -18
  1188. package/dist/esm/react/core/signingEngine/nonce/NonceCoordinator.js +0 -1026
  1189. package/dist/esm/react/core/signingEngine/nonce/evmNonceLane.js +0 -182
  1190. package/dist/esm/react/core/signingEngine/nonce/nearNonceLane.js +0 -669
  1191. package/dist/esm/react/core/signingEngine/nonce/nearNonceLaneIdentity.js +0 -24
  1192. package/dist/esm/react/core/signingEngine/nonce/nonceCoordinationRecordBoundary.js +0 -216
  1193. package/dist/esm/react/core/signingEngine/nonce/nonceDiagnostics.js +0 -232
  1194. package/dist/esm/react/core/signingEngine/nonce/nonceLaneKeys.js +0 -110
  1195. package/dist/esm/react/core/signingEngine/nonce/nonceLeaseState.js +0 -128
  1196. package/dist/esm/react/core/signingEngine/nonce/nonceTypes.js +0 -59
  1197. package/dist/esm/react/core/signingEngine/nonce/nonceUtils.js +0 -33
  1198. package/dist/esm/react/core/signingEngine/routerAb/ecdsaDerivation/httpRequest.js +0 -74
  1199. package/dist/esm/react/core/signingEngine/routerAb/ecdsaDerivation/poolFillRoutes.js +0 -217
  1200. package/dist/esm/react/core/signingEngine/routerAb/ecdsaDerivation/presignaturePool.js +0 -1216
  1201. package/dist/esm/react/core/signingEngine/routerAb/ecdsaDerivation/presignatureRefillProgress.js +0 -53
  1202. package/dist/esm/react/core/signingEngine/routerAb/ecdsaDerivation/signingMaterialRef.js +0 -22
  1203. package/dist/esm/react/core/signingEngine/session/SigningSessionCoordinator.js +0 -347
  1204. package/dist/esm/react/core/signingEngine/session/authority/authorityOperationResolver.js +0 -165
  1205. package/dist/esm/react/core/signingEngine/session/availability/availableSigningLanes.js +0 -1073
  1206. package/dist/esm/react/core/signingEngine/session/availability/canonicalLaneInventory.js +0 -127
  1207. package/dist/esm/react/core/signingEngine/session/availability/clientSessionExpiryInvalidator.js +0 -72
  1208. package/dist/esm/react/core/signingEngine/session/availability/persistedAvailableSigningLanes.js +0 -213
  1209. package/dist/esm/react/core/signingEngine/session/availability/readiness.js +0 -464
  1210. package/dist/esm/react/core/signingEngine/session/emailOtp/EmailOtpWalletSessionCoordinator.js +0 -47
  1211. package/dist/esm/react/core/signingEngine/session/emailOtp/challengeDelivery.js +0 -56
  1212. package/dist/esm/react/core/signingEngine/session/emailOtp/coordinatorRuntime.js +0 -131
  1213. package/dist/esm/react/core/signingEngine/session/emailOtp/ecdsaBootstrapCommit.js +0 -106
  1214. package/dist/esm/react/core/signingEngine/session/emailOtp/ecdsaLifecycleRuntime.js +0 -50
  1215. package/dist/esm/react/core/signingEngine/session/emailOtp/ecdsaLogin.js +0 -941
  1216. package/dist/esm/react/core/signingEngine/session/emailOtp/ecdsaPublication.js +0 -414
  1217. package/dist/esm/react/core/signingEngine/session/emailOtp/ecdsaRecovery.js +0 -268
  1218. package/dist/esm/react/core/signingEngine/session/emailOtp/ecdsaSigningSessionAuthority.js +0 -95
  1219. package/dist/esm/react/core/signingEngine/session/emailOtp/ed25519ExportContext.js +0 -376
  1220. package/dist/esm/react/core/signingEngine/session/emailOtp/exportRecovery.js +0 -286
  1221. package/dist/esm/react/core/signingEngine/session/emailOtp/exportRecoveryRuntime.js +0 -50
  1222. package/dist/esm/react/core/signingEngine/session/emailOtp/persistedSnapshot.js +0 -22
  1223. package/dist/esm/react/core/signingEngine/session/emailOtp/publicTypes.js +0 -38
  1224. package/dist/esm/react/core/signingEngine/session/emailOtp/routePlan.js +0 -60
  1225. package/dist/esm/react/core/signingEngine/session/emailOtp/runtimeConfig.js +0 -24
  1226. package/dist/esm/react/core/signingEngine/session/emailOtp/sealedRefreshPolicy.js +0 -49
  1227. package/dist/esm/react/core/signingEngine/session/emailOtp/sealedRestoreOrchestrator.js +0 -234
  1228. package/dist/esm/react/core/signingEngine/session/emailOtp/sealedRuntimePurpose.js +0 -16
  1229. package/dist/esm/react/core/signingEngine/session/emailOtp/sealedSessionRegistry.js +0 -40
  1230. package/dist/esm/react/core/signingEngine/session/emailOtp/status.js +0 -72
  1231. package/dist/esm/react/core/signingEngine/session/emailOtp/walletUnlock.js +0 -168
  1232. package/dist/esm/react/core/signingEngine/session/emailOtp/warmSessionRuntime.js +0 -70
  1233. package/dist/esm/react/core/signingEngine/session/emailOtp/workerEnrollment.js +0 -159
  1234. package/dist/esm/react/core/signingEngine/session/emailOtp/workerRequests.js +0 -84
  1235. package/dist/esm/react/core/signingEngine/session/emailOtp/zeroize.js +0 -9
  1236. package/dist/esm/react/core/signingEngine/session/identity/clientSessionPersistenceState.js +0 -95
  1237. package/dist/esm/react/core/signingEngine/session/identity/emailOtpEcdsaDerivationIdentity.js +0 -23
  1238. package/dist/esm/react/core/signingEngine/session/identity/evmFamilyEcdsaIdentity.js +0 -265
  1239. package/dist/esm/react/core/signingEngine/session/identity/exactSigningLaneIdentity.js +0 -338
  1240. package/dist/esm/react/core/signingEngine/session/identity/exactWalletSessionCredential.js +0 -106
  1241. package/dist/esm/react/core/signingEngine/session/identity/exactWalletSessionReader.js +0 -54
  1242. package/dist/esm/react/core/signingEngine/session/identity/laneIdentity.js +0 -168
  1243. package/dist/esm/react/core/signingEngine/session/identity/ownerLaneScope.js +0 -185
  1244. package/dist/esm/react/core/signingEngine/session/identity/selectLane.js +0 -349
  1245. package/dist/esm/react/core/signingEngine/session/identity/signingLaneAuthBinding.js +0 -29
  1246. package/dist/esm/react/core/signingEngine/session/keyMaterialBrands.js +0 -75
  1247. package/dist/esm/react/core/signingEngine/session/lanes/walletExecutionLaneHydration.js +0 -194
  1248. package/dist/esm/react/core/signingEngine/session/lifecycle/canonicalWalletSessionStatus.js +0 -32
  1249. package/dist/esm/react/core/signingEngine/session/lifecycle/walletSessionFailure.js +0 -69
  1250. package/dist/esm/react/core/signingEngine/session/lifecycle/walletSessionStatus.js +0 -123
  1251. package/dist/esm/react/core/signingEngine/session/material/activeEcdsaCapabilityRuntime.js +0 -171
  1252. package/dist/esm/react/core/signingEngine/session/material/activeWalletAuthorityEcdsaRuntime.js +0 -323
  1253. package/dist/esm/react/core/signingEngine/session/material/ecdsaCapabilityHydration.js +0 -75
  1254. package/dist/esm/react/core/signingEngine/session/material/ecdsaCapabilityManifest.js +0 -510
  1255. package/dist/esm/react/core/signingEngine/session/material/ecdsaRoleLocalMaterialResolver.js +0 -122
  1256. package/dist/esm/react/core/signingEngine/session/material/ecdsaSealedRuntime.js +0 -197
  1257. package/dist/esm/react/core/signingEngine/session/material/ecdsaSigningCapability.js +0 -231
  1258. package/dist/esm/react/core/signingEngine/session/material/linkedEcdsaHolderRuntime.js +0 -36
  1259. package/dist/esm/react/core/signingEngine/session/material/mpcCapabilityHydration.js +0 -79
  1260. package/dist/esm/react/core/signingEngine/session/material/nearEd25519YaoMaterialActivation.js +0 -80
  1261. package/dist/esm/react/core/signingEngine/session/material/nearEd25519YaoSigningPreparation.js +0 -122
  1262. package/dist/esm/react/core/signingEngine/session/material/restorableMpcMaterialRef.internal.js +0 -21
  1263. package/dist/esm/react/core/signingEngine/session/material/walletSigningStateFailure.js +0 -84
  1264. package/dist/esm/react/core/signingEngine/session/operationState/authorizationAdmission.js +0 -98
  1265. package/dist/esm/react/core/signingEngine/session/operationState/lanes.js +0 -127
  1266. package/dist/esm/react/core/signingEngine/session/operationState/preparedOperation.js +0 -38
  1267. package/dist/esm/react/core/signingEngine/session/operationState/trace.js +0 -94
  1268. package/dist/esm/react/core/signingEngine/session/operationState/transactionState.js +0 -106
  1269. package/dist/esm/react/core/signingEngine/session/operationState/types.js +0 -88
  1270. package/dist/esm/react/core/signingEngine/session/passkey/ecdsaBootstrap.js +0 -187
  1271. package/dist/esm/react/core/signingEngine/session/passkey/ecdsaKeyFactsInventory.js +0 -206
  1272. package/dist/esm/react/core/signingEngine/session/passkey/ecdsaRecovery.js +0 -87
  1273. package/dist/esm/react/core/signingEngine/session/passkey/ecdsaSessionProvision.js +0 -224
  1274. package/dist/esm/react/core/signingEngine/session/passkey/ecdsaWarmCapabilityBootstrap.js +0 -147
  1275. package/dist/esm/react/core/signingEngine/session/passkey/ed25519Provisioner.js +0 -55
  1276. package/dist/esm/react/core/signingEngine/session/passkey/ed25519SessionProvision.js +0 -229
  1277. package/dist/esm/react/core/signingEngine/session/passkey/ed25519YaoLocalMaterial.js +0 -537
  1278. package/dist/esm/react/core/signingEngine/session/passkey/ed25519YaoRecoveryCapability.js +0 -94
  1279. package/dist/esm/react/core/signingEngine/session/passkey/ed25519YaoSealedSession.js +0 -57
  1280. package/dist/esm/react/core/signingEngine/session/passkey/ed25519YaoWarmRecovery.js +0 -317
  1281. package/dist/esm/react/core/signingEngine/session/passkey/passkeyCustodySessionCache.js +0 -90
  1282. package/dist/esm/react/core/signingEngine/session/passkey/prfCache.js +0 -60
  1283. package/dist/esm/react/core/signingEngine/session/passkey/public.js +0 -15
  1284. package/dist/esm/react/core/signingEngine/session/passkey/unlockEcdsaWarmupPlanner.js +0 -247
  1285. package/dist/esm/react/core/signingEngine/session/passkey/warmSessionHydration.js +0 -9
  1286. package/dist/esm/react/core/signingEngine/session/persistence/clientSessionPersistence.js +0 -143
  1287. package/dist/esm/react/core/signingEngine/session/persistence/durableSealedSessionCommands.js +0 -30
  1288. package/dist/esm/react/core/signingEngine/session/persistence/ecdsaRoleLocalRecords.js +0 -316
  1289. package/dist/esm/react/core/signingEngine/session/persistence/ecdsaSealedRecordKey.js +0 -20
  1290. package/dist/esm/react/core/signingEngine/session/persistence/sealedSessionRecords.js +0 -764
  1291. package/dist/esm/react/core/signingEngine/session/persistence/sealedSessionStore.js +0 -518
  1292. package/dist/esm/react/core/signingEngine/session/persistence/walletSessionAuthorizationProjection.js +0 -51
  1293. package/dist/esm/react/core/signingEngine/session/planning/operationFingerprint.js +0 -30
  1294. package/dist/esm/react/core/signingEngine/session/planning/operationIdBinding.js +0 -36
  1295. package/dist/esm/react/core/signingEngine/session/planning/planner.js +0 -98
  1296. package/dist/esm/react/core/signingEngine/session/postconditions/runtimePostconditions.js +0 -165
  1297. package/dist/esm/react/core/signingEngine/session/public.js +0 -44
  1298. package/dist/esm/react/core/signingEngine/session/routerAbSigningWalletSession.js +0 -125
  1299. package/dist/esm/react/core/signingEngine/session/sealedRecovery/exactRecordLookup.js +0 -148
  1300. package/dist/esm/react/core/signingEngine/session/sealedRecovery/materialActivationKey.js +0 -22
  1301. package/dist/esm/react/core/signingEngine/session/sealedRecovery/recoveryRecord.js +0 -248
  1302. package/dist/esm/react/core/signingEngine/session/sealedRecovery/restoreCoordinator.js +0 -229
  1303. package/dist/esm/react/core/signingEngine/session/userPreferences.js +0 -212
  1304. package/dist/esm/react/core/signingEngine/session/warmCapabilities/capabilityReader.js +0 -62
  1305. package/dist/esm/react/core/signingEngine/session/warmCapabilities/capabilityReaderCore.js +0 -293
  1306. package/dist/esm/react/core/signingEngine/session/warmCapabilities/clearVolatileWarmSigningMaterial.js +0 -44
  1307. package/dist/esm/react/core/signingEngine/session/warmCapabilities/ecdsaBootstrapPersistence.js +0 -107
  1308. package/dist/esm/react/core/signingEngine/session/warmCapabilities/ecdsaBootstrapQueue.js +0 -22
  1309. package/dist/esm/react/core/signingEngine/session/warmCapabilities/ecdsaLoginPrefill.js +0 -93
  1310. package/dist/esm/react/core/signingEngine/session/warmCapabilities/ecdsaLoginPrefillSigningMaterialSource.js +0 -50
  1311. package/dist/esm/react/core/signingEngine/session/warmCapabilities/ecdsaProvisionPlan.js +0 -9
  1312. package/dist/esm/react/core/signingEngine/session/warmCapabilities/ed25519SealedSessionRuntime.js +0 -251
  1313. package/dist/esm/react/core/signingEngine/session/warmCapabilities/nearEd25519CapabilityRehydration.js +0 -98
  1314. package/dist/esm/react/core/signingEngine/session/warmCapabilities/public.js +0 -31
  1315. package/dist/esm/react/core/signingEngine/session/warmCapabilities/readModel.js +0 -161
  1316. package/dist/esm/react/core/signingEngine/session/warmCapabilities/routerAbEd25519WalletSessionState.js +0 -256
  1317. package/dist/esm/react/core/signingEngine/session/warmCapabilities/routerAbWalletSessionCredential.js +0 -73
  1318. package/dist/esm/react/core/signingEngine/session/warmCapabilities/sealedRefreshParity.js +0 -67
  1319. package/dist/esm/react/core/signingEngine/session/warmCapabilities/statusReader.js +0 -100
  1320. package/dist/esm/react/core/signingEngine/session/warmCapabilities/transitions.js +0 -51
  1321. package/dist/esm/react/core/signingEngine/session/warmCapabilities/types.js +0 -122
  1322. package/dist/esm/react/core/signingEngine/session/warmCapabilities/volatileWarmMaterialCommands.js +0 -45
  1323. package/dist/esm/react/core/signingEngine/stepUpConfirmation/channel/confirmCommon.js +0 -89
  1324. package/dist/esm/react/core/signingEngine/stepUpConfirmation/channel/confirmTypes.js +0 -12
  1325. package/dist/esm/react/core/signingEngine/stepUpConfirmation/confirmOperation.js +0 -51
  1326. package/dist/esm/react/core/signingEngine/stepUpConfirmation/intentDigestPreparation.js +0 -29
  1327. package/dist/esm/react/core/signingEngine/stepUpConfirmation/methodSelection.js +0 -41
  1328. package/dist/esm/react/core/signingEngine/stepUpConfirmation/otpPrompt/authLane.js +0 -32
  1329. package/dist/esm/react/core/signingEngine/stepUpConfirmation/otpPrompt/exportAuthorization.js +0 -108
  1330. package/dist/esm/react/core/signingEngine/stepUpConfirmation/otpPrompt/promptText.js +0 -8
  1331. package/dist/esm/react/core/signingEngine/stepUpConfirmation/otpPrompt/signingPrompt.js +0 -15
  1332. package/dist/esm/react/core/signingEngine/stepUpConfirmation/passkeyPrompt/touchIdPrompt.js +0 -295
  1333. package/dist/esm/react/core/signingEngine/stepUpConfirmation/passkeyPrompt/webauthnPromptCoordinator.js +0 -170
  1334. package/dist/esm/react/core/signingEngine/stepUpConfirmation/requireStepUpAuth.js +0 -63
  1335. package/dist/esm/react/core/signingEngine/stepUpConfirmation/types.js +0 -29
  1336. package/dist/esm/react/core/signingEngine/stepUpConfirmation/userConfirmationType.js +0 -15
  1337. package/dist/esm/react/core/signingEngine/threshold/commitQueueShared.js +0 -125
  1338. package/dist/esm/react/core/signingEngine/threshold/crypto/ecdsaDerivationClientWasm.js +0 -616
  1339. package/dist/esm/react/core/signingEngine/threshold/crypto/ed25519YaoLaneWasm.js +0 -70
  1340. package/dist/esm/react/core/signingEngine/threshold/ecdsa/activation.js +0 -267
  1341. package/dist/esm/react/core/signingEngine/threshold/ecdsa/bootstrapSession.js +0 -119
  1342. package/dist/esm/react/core/signingEngine/threshold/ecdsa/operationStepUp.js +0 -110
  1343. package/dist/esm/react/core/signingEngine/threshold/ecdsa/postRegistrationSessionActivation.js +0 -132
  1344. package/dist/esm/react/core/signingEngine/threshold/ecdsa/signingQueue.js +0 -58
  1345. package/dist/esm/react/core/signingEngine/threshold/ed25519/commitQueue.js +0 -52
  1346. package/dist/esm/react/core/signingEngine/threshold/ed25519/connectSession.js +0 -137
  1347. package/dist/esm/react/core/signingEngine/threshold/ed25519/walletSession.js +0 -363
  1348. package/dist/esm/react/core/signingEngine/threshold/ed25519/yaoActiveClientRegistry.js +0 -146
  1349. package/dist/esm/react/core/signingEngine/threshold/ed25519/yaoClient.js +0 -597
  1350. package/dist/esm/react/core/signingEngine/threshold/ed25519/yaoPageLifecycleOwner.js +0 -23
  1351. package/dist/esm/react/core/signingEngine/threshold/ed25519/yaoPublicCapabilityReferences.js +0 -295
  1352. package/dist/esm/react/core/signingEngine/threshold/sessionPolicy.js +0 -94
  1353. package/dist/esm/react/core/signingEngine/uiConfirm/PasskeyMpcExportManager.js +0 -233
  1354. package/dist/esm/react/core/signingEngine/uiConfirm/PasskeyMpcSessionDurableState.js +0 -496
  1355. package/dist/esm/react/core/signingEngine/uiConfirm/PasskeyMpcSessionManager.js +0 -745
  1356. package/dist/esm/react/core/signingEngine/uiConfirm/UiConfirmManager.js +0 -600
  1357. package/dist/esm/react/core/signingEngine/uiConfirm/confirmationReadinessRegistry.js +0 -41
  1358. package/dist/esm/react/core/signingEngine/uiConfirm/exportConfirmRequest.js +0 -149
  1359. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/determineConfirmationConfig.js +0 -82
  1360. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/flowOrchestrator.js +0 -363
  1361. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/flows/adapters/adapters.js +0 -337
  1362. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/flows/adapters/request.js +0 -120
  1363. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/flows/localOnly.js +0 -150
  1364. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/flows/registration.js +0 -235
  1365. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/flows/requestRegistrationCredentialConfirmation.js +0 -178
  1366. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/flows/signing.js +0 -684
  1367. package/dist/esm/react/core/signingEngine/uiConfirm/handlers/handlePromptFromWorker.js +0 -90
  1368. package/dist/esm/react/core/signingEngine/uiConfirm/nearFundingNotice.js +0 -50
  1369. package/dist/esm/react/core/signingEngine/uiConfirm/transactionReviewAdmission.js +0 -8
  1370. package/dist/esm/react/core/signingEngine/uiConfirm/ui/appearance-token-vars.js +0 -31
  1371. package/dist/esm/react/core/signingEngine/uiConfirm/ui/appearance.js +0 -27
  1372. package/dist/esm/react/core/signingEngine/uiConfirm/ui/confirm-surface-resize.js +0 -346
  1373. package/dist/esm/react/core/signingEngine/uiConfirm/ui/confirm-ui.js +0 -516
  1374. package/dist/esm/react/core/signingEngine/uiConfirm/ui/confirmation-body-model.js +0 -24
  1375. package/dist/esm/react/core/signingEngine/uiConfirm/ui/confirmation-model.js +0 -161
  1376. package/dist/esm/react/core/signingEngine/uiConfirm/ui/drawer-gesture.js +0 -16
  1377. package/dist/esm/react/core/signingEngine/uiConfirm/ui/export-private-key-reveal.js +0 -155
  1378. package/dist/esm/react/core/signingEngine/uiConfirm/ui/export-viewer-host.js +0 -207
  1379. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/ConfirmContent.js +0 -131
  1380. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/ConfirmHeader.js +0 -29
  1381. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/ConfirmationBody.js +0 -49
  1382. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/ConfirmationContent.js +0 -137
  1383. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/ConfirmationDrawer.js +0 -294
  1384. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/ConfirmationModal.js +0 -67
  1385. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/CopyStatusIcon.js +0 -41
  1386. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/EmailOtpContent.js +0 -141
  1387. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/EmailOtpInput.js +0 -92
  1388. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/ExportPrivateKeySurface.js +0 -318
  1389. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/HaloBorder.js +0 -91
  1390. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/PadlockIcon.js +0 -32
  1391. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/PasskeyHaloLoading.js +0 -63
  1392. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/PasskeyRegistrationContent.js +0 -75
  1393. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/PasskeyRegistrationDetails.js +0 -33
  1394. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/RecoveryCodeBackupSurface.js +0 -518
  1395. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/ReviewDisclosure.js +0 -128
  1396. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/SeamsWordmark.js +0 -22
  1397. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/TransactionLabel.js +0 -158
  1398. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/TransactionReceipt.js +0 -287
  1399. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/TransactionReview.js +0 -311
  1400. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/TransactionTree.js +0 -284
  1401. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/clipboard.js +0 -26
  1402. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/confirmation-controller.js +0 -80
  1403. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/confirmation-styles.js +0 -20
  1404. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/email-otp-session.js +0 -178
  1405. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/mountConfirmationSurface.js +0 -297
  1406. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/mountExportPrivateKeySurface.js +0 -86
  1407. package/dist/esm/react/core/signingEngine/uiConfirm/ui/preact/mountRecoveryCodeBackupSurface.js +0 -82
  1408. package/dist/esm/react/core/signingEngine/uiConfirm/ui/seamsWordmarkPaths.js +0 -6
  1409. package/dist/esm/react/core/signingEngine/uiConfirm/ui/surface-measurement-binding.js +0 -12
  1410. package/dist/esm/react/core/signingEngine/uiConfirm/ui/surface-resize-events.js +0 -18
  1411. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-activity.js +0 -46
  1412. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/abi/abiDecode.js +0 -325
  1413. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/abi/enrichDisplayModelWithAbi.js +0 -77
  1414. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/confirmation-tree.js +0 -27
  1415. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/formatters.js +0 -57
  1416. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/renderers/evm.js +0 -12
  1417. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/renderers/fallback.js +0 -52
  1418. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/renderers/near.js +0 -12
  1419. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/renderers/tempo.js +0 -12
  1420. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/renderers/types.js +0 -62
  1421. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-display/tree.js +0 -258
  1422. package/dist/esm/react/core/signingEngine/uiConfirm/ui/transaction-receipt.js +0 -50
  1423. package/dist/esm/react/core/signingEngine/uiConfirm/warmSessionUiConfirm.js +0 -65
  1424. package/dist/esm/react/core/signingEngine/walletCustody/activateEd25519Capability.js +0 -123
  1425. package/dist/esm/react/core/signingEngine/walletCustody/ceremonyActiveClientMetadata.js +0 -94
  1426. package/dist/esm/react/core/signingEngine/walletCustody/ceremonyDriver.js +0 -171
  1427. package/dist/esm/react/core/signingEngine/walletCustody/ceremonyStepRunner.js +0 -20
  1428. package/dist/esm/react/core/signingEngine/walletCustody/ed25519ActiveClient.js +0 -100
  1429. package/dist/esm/react/core/signingEngine/walletCustody/ed25519Projection.js +0 -32
  1430. package/dist/esm/react/core/signingEngine/walletCustody/ed25519SeedMaterial.js +0 -92
  1431. package/dist/esm/react/core/signingEngine/walletCustody/emailOtpLink.js +0 -135
  1432. package/dist/esm/react/core/signingEngine/walletCustody/joinCustodyWire.js +0 -64
  1433. package/dist/esm/react/core/signingEngine/walletCustody/openCustodyCache.js +0 -130
  1434. package/dist/esm/react/core/signingEngine/walletCustody/passkeyLink.js +0 -183
  1435. package/dist/esm/react/core/signingEngine/walletCustody/recoveryReplacementEnvelope.js +0 -60
  1436. package/dist/esm/react/core/signingEngine/walletCustody/registrationCeremony.js +0 -461
  1437. package/dist/esm/react/core/signingEngine/walletCustody/unlockedEd25519ExportRootCapability.js +0 -258
  1438. package/dist/esm/react/core/signingEngine/walletCustody/walletRecoveryCredential.js +0 -24
  1439. package/dist/esm/react/core/signingEngine/walletCustody/walletRecoveryEcdsa.js +0 -76
  1440. package/dist/esm/react/core/signingEngine/walletCustody/walletRecoveryEd25519.js +0 -129
  1441. package/dist/esm/react/core/signingEngine/walletCustody/walletRecoveryManifest.js +0 -180
  1442. package/dist/esm/react/core/signingEngine/walletCustody/walletRecoveryRotation.js +0 -103
  1443. package/dist/esm/react/core/signingEngine/webauthnAuth/credentials/collectAuthenticationCredentialForChallengeB64u.js +0 -154
  1444. package/dist/esm/react/core/signingEngine/webauthnAuth/credentials/credentialExtensions.js +0 -36
  1445. package/dist/esm/react/core/signingEngine/webauthnAuth/credentials/helpers.js +0 -273
  1446. package/dist/esm/react/core/signingEngine/webauthnAuth/device/signerSlot.js +0 -25
  1447. package/dist/esm/react/core/signingEngine/webauthnAuth/fallbacks/safari-fallbacks.js +0 -171
  1448. package/dist/esm/react/core/signingEngine/workerManager/SignerWorkerManager.js +0 -70
  1449. package/dist/esm/react/core/signingEngine/workerManager/deviceLinkingPorts.js +0 -323
  1450. package/dist/esm/react/core/signingEngine/workerManager/deviceLinkingSourceContribution.js +0 -158
  1451. package/dist/esm/react/core/signingEngine/workerManager/ecdsaClientWorkerChannels.js +0 -17
  1452. package/dist/esm/react/core/signingEngine/workerManager/ecdsaPresignLifecycle.js +0 -6
  1453. package/dist/esm/react/core/signingEngine/workerManager/ecdsaPresignPoolIdentity.js +0 -49
  1454. package/dist/esm/react/core/signingEngine/workerManager/executeWorkerOperation.js +0 -12
  1455. package/dist/esm/react/core/signingEngine/workerManager/nearKeyOps/createNearKeyOps.js +0 -32
  1456. package/dist/esm/react/core/signingEngine/workerManager/validation.js +0 -114
  1457. package/dist/esm/react/core/signingEngine/workerManager/workerTransport.js +0 -777
  1458. package/dist/esm/react/core/signingEngine/workerManager/workerTypes.js +0 -109
  1459. package/dist/esm/react/core/types/accountIds.js +0 -26
  1460. package/dist/esm/react/core/types/actionBuilders.js +0 -73
  1461. package/dist/esm/react/core/types/confirmationConfig.js +0 -39
  1462. package/dist/esm/react/core/types/eventLogging.js +0 -28
  1463. package/dist/esm/react/core/types/linkDevice.js +0 -49
  1464. package/dist/esm/react/core/types/sdkSentEvents.js +0 -602
  1465. package/dist/esm/react/core/types/secure-confirm-worker.js +0 -22
  1466. package/dist/esm/react/core/types/signer-worker.js +0 -50
  1467. package/dist/esm/react/core/types/walletIframeIdentity.js +0 -15
  1468. package/dist/esm/react/core/walletRuntimePaths/base.js +0 -60
  1469. package/dist/esm/react/core/walletRuntimePaths/emailOtpWorker.js +0 -12
  1470. package/dist/esm/react/core/walletRuntimePaths/multichainWorkers.js +0 -25
  1471. package/dist/esm/react/core/walletRuntimePaths/walletCustodyCeremonyWorker.js +0 -18
  1472. package/dist/esm/react/core/walletRuntimePaths/workers.js +0 -93
  1473. package/dist/esm/react/externalEvm/boundary.js +0 -309
  1474. package/dist/esm/react/externalEvm/controller.js +0 -440
  1475. package/dist/esm/react/externalEvm/types.js +0 -31
  1476. package/dist/esm/react/node_modules/@noble/hashes/esm/_u64.js +0 -36
  1477. package/dist/esm/react/node_modules/@noble/hashes/esm/sha3.js +0 -197
  1478. package/dist/esm/react/node_modules/@noble/hashes/esm/utils.js +0 -87
  1479. package/dist/esm/react/node_modules/viem/_esm/errors/abi.js +0 -48
  1480. package/dist/esm/react/node_modules/viem/_esm/errors/address.js +0 -14
  1481. package/dist/esm/react/node_modules/viem/_esm/errors/base.js +0 -86
  1482. package/dist/esm/react/node_modules/viem/_esm/errors/data.js +0 -16
  1483. package/dist/esm/react/node_modules/viem/_esm/errors/encoding.js +0 -16
  1484. package/dist/esm/react/node_modules/viem/_esm/errors/typedData.js +0 -28
  1485. package/dist/esm/react/node_modules/viem/_esm/errors/version.js +0 -6
  1486. package/dist/esm/react/node_modules/viem/_esm/utils/abi/encodeAbiParameters.js +0 -243
  1487. package/dist/esm/react/node_modules/viem/_esm/utils/address/getAddress.js +0 -28
  1488. package/dist/esm/react/node_modules/viem/_esm/utils/address/isAddress.js +0 -23
  1489. package/dist/esm/react/node_modules/viem/_esm/utils/data/concat.js +0 -23
  1490. package/dist/esm/react/node_modules/viem/_esm/utils/data/isHex.js +0 -10
  1491. package/dist/esm/react/node_modules/viem/_esm/utils/data/pad.js +0 -40
  1492. package/dist/esm/react/node_modules/viem/_esm/utils/data/size.js +0 -16
  1493. package/dist/esm/react/node_modules/viem/_esm/utils/data/slice.js +0 -59
  1494. package/dist/esm/react/node_modules/viem/_esm/utils/encoding/fromHex.js +0 -13
  1495. package/dist/esm/react/node_modules/viem/_esm/utils/encoding/toBytes.js +0 -175
  1496. package/dist/esm/react/node_modules/viem/_esm/utils/encoding/toHex.js +0 -168
  1497. package/dist/esm/react/node_modules/viem/_esm/utils/hash/keccak256.js +0 -15
  1498. package/dist/esm/react/node_modules/viem/_esm/utils/lru.js +0 -38
  1499. package/dist/esm/react/node_modules/viem/_esm/utils/regex.js +0 -7
  1500. package/dist/esm/react/node_modules/viem/_esm/utils/signature/hashTypedData.js +0 -113
  1501. package/dist/esm/react/node_modules/viem/_esm/utils/stringify.js +0 -9
  1502. package/dist/esm/react/node_modules/viem/_esm/utils/typedData.js +0 -80
  1503. package/dist/esm/react/shared-ts/src/authorization/capabilityKinds.js +0 -111
  1504. package/dist/esm/react/shared-ts/src/authorization/delegatedAuthority.js +0 -121
  1505. package/dist/esm/react/shared-ts/src/authorization/index.js +0 -6
  1506. package/dist/esm/react/shared-ts/src/authorization/operationFingerprint.js +0 -57
  1507. package/dist/esm/react/shared-ts/src/authorization/walletAuthority.js +0 -719
  1508. package/dist/esm/react/shared-ts/src/authorization/walletCustodyOperation.js +0 -16
  1509. package/dist/esm/react/shared-ts/src/authorization/walletSessionIssuance.js +0 -118
  1510. package/dist/esm/react/shared-ts/src/device-linking/activeWalletSession.js +0 -104
  1511. package/dist/esm/react/shared-ts/src/device-linking/authorityActivation.js +0 -142
  1512. package/dist/esm/react/shared-ts/src/device-linking/committedSignerPackages.js +0 -273
  1513. package/dist/esm/react/shared-ts/src/device-linking/contracts.js +0 -8
  1514. package/dist/esm/react/shared-ts/src/device-linking/delegatedActivationPlan.js +0 -134
  1515. package/dist/esm/react/shared-ts/src/device-linking/deviceManagement.js +0 -120
  1516. package/dist/esm/react/shared-ts/src/device-linking/digests.js +0 -115
  1517. package/dist/esm/react/shared-ts/src/device-linking/ed25519ExportRoot.js +0 -171
  1518. package/dist/esm/react/shared-ts/src/device-linking/index.js +0 -12
  1519. package/dist/esm/react/shared-ts/src/device-linking/parsers.js +0 -1029
  1520. package/dist/esm/react/shared-ts/src/device-linking/requestProof.js +0 -25
  1521. package/dist/esm/react/shared-ts/src/device-linking/sourceContribution.js +0 -545
  1522. package/dist/esm/react/shared-ts/src/device-linking/walletSessionCredentialDelivery.js +0 -173
  1523. package/dist/esm/react/shared-ts/src/device-linking/wireFields.js +0 -59
  1524. package/dist/esm/react/shared-ts/src/near/actions.js +0 -236
  1525. package/dist/esm/react/shared-ts/src/near/nearClient.js +0 -252
  1526. package/dist/esm/react/shared-ts/src/passkey-custody/ceremonyCommitPayload.js +0 -43
  1527. package/dist/esm/react/shared-ts/src/passkey-custody/custodyEnvelope.js +0 -278
  1528. package/dist/esm/react/shared-ts/src/passkey-custody/custodySecretBinding.js +0 -181
  1529. package/dist/esm/react/shared-ts/src/passkey-custody/index.js +0 -4
  1530. package/dist/esm/react/shared-ts/src/passkey-custody/primitives.js +0 -58
  1531. package/dist/esm/react/shared-ts/src/signing-lanes/evmFamilySigningKeySlotId.js +0 -49
  1532. package/dist/esm/react/shared-ts/src/signing-lanes/index.js +0 -8
  1533. package/dist/esm/react/shared-ts/src/signing-lanes/ownerContinuity.js +0 -66
  1534. package/dist/esm/react/shared-ts/src/signing-lanes/participantDigest.js +0 -2
  1535. package/dist/esm/react/shared-ts/src/signing-lanes/participants.js +0 -256
  1536. package/dist/esm/react/shared-ts/src/signing-lanes/recordParsers.js +0 -483
  1537. package/dist/esm/react/shared-ts/src/signing-lanes/rotationDigests.js +0 -6
  1538. package/dist/esm/react/shared-ts/src/signing-lanes/rotationParsers.js +0 -3
  1539. package/dist/esm/react/shared-ts/src/signing-lanes/rotationProtocolParsers.js +0 -8
  1540. package/dist/esm/react/shared-ts/src/signing-lanes/rotationWireFields.js +0 -3
  1541. package/dist/esm/react/shared-ts/src/threshold/ecdsaDerivationRoleLocalBootstrap.js +0 -39
  1542. package/dist/esm/react/shared-ts/src/threshold/ed25519OperationFingerprint.js +0 -222
  1543. package/dist/esm/react/shared-ts/src/threshold/keyMaterialBrands.js +0 -25
  1544. package/dist/esm/react/shared-ts/src/threshold/participants.js +0 -67
  1545. package/dist/esm/react/shared-ts/src/threshold/secp256k1.js +0 -6
  1546. package/dist/esm/react/shared-ts/src/threshold/sessionPolicy.js +0 -8
  1547. package/dist/esm/react/shared-ts/src/threshold/signingRootScope.js +0 -40
  1548. package/dist/esm/react/shared-ts/src/utils/addAuthMethodRegistration.js +0 -103
  1549. package/dist/esm/react/shared-ts/src/utils/addWalletAuthMethod.js +0 -1
  1550. package/dist/esm/react/shared-ts/src/utils/authenticatorOptions.js +0 -22
  1551. package/dist/esm/react/shared-ts/src/utils/base58.js +0 -28
  1552. package/dist/esm/react/shared-ts/src/utils/base64.js +0 -70
  1553. package/dist/esm/react/shared-ts/src/utils/canonicalPrimitives.js +0 -38
  1554. package/dist/esm/react/shared-ts/src/utils/digestEncoding.js +0 -63
  1555. package/dist/esm/react/shared-ts/src/utils/digests.js +0 -33
  1556. package/dist/esm/react/shared-ts/src/utils/domainIds.js +0 -257
  1557. package/dist/esm/react/shared-ts/src/utils/ecdsaCapabilityActivation.js +0 -67
  1558. package/dist/esm/react/shared-ts/src/utils/ecdsaKeyFactsInventory.js +0 -46
  1559. package/dist/esm/react/shared-ts/src/utils/ecdsaServerTiming.js +0 -39
  1560. package/dist/esm/react/shared-ts/src/utils/emailOtpDomain.js +0 -28
  1561. package/dist/esm/react/shared-ts/src/utils/emailOtpRecoveryKey.js +0 -65
  1562. package/dist/esm/react/shared-ts/src/utils/encoders.js +0 -2
  1563. package/dist/esm/react/shared-ts/src/utils/errors.js +0 -95
  1564. package/dist/esm/react/shared-ts/src/utils/evmRpcResults.js +0 -101
  1565. package/dist/esm/react/shared-ts/src/utils/exactRecord.js +0 -44
  1566. package/dist/esm/react/shared-ts/src/utils/index.js +0 -38
  1567. package/dist/esm/react/shared-ts/src/utils/jsonRpc.js +0 -64
  1568. package/dist/esm/react/shared-ts/src/utils/keccak.js +0 -150
  1569. package/dist/esm/react/shared-ts/src/utils/near.js +0 -205
  1570. package/dist/esm/react/shared-ts/src/utils/nearRpcResults.js +0 -205
  1571. package/dist/esm/react/shared-ts/src/utils/normalize.js +0 -86
  1572. package/dist/esm/react/shared-ts/src/utils/registrationAuthMethodInput.js +0 -84
  1573. package/dist/esm/react/shared-ts/src/utils/registrationEstablishedSession.js +0 -275
  1574. package/dist/esm/react/shared-ts/src/utils/registrationIds.js +0 -226
  1575. package/dist/esm/react/shared-ts/src/utils/registrationIntent.js +0 -396
  1576. package/dist/esm/react/shared-ts/src/utils/registrationSignerPlan.js +0 -442
  1577. package/dist/esm/react/shared-ts/src/utils/routerAbEcdsaDerivation.js +0 -1334
  1578. package/dist/esm/react/shared-ts/src/utils/routerAbEd25519Yao.js +0 -747
  1579. package/dist/esm/react/shared-ts/src/utils/routerAbEd25519YaoDigests.js +0 -76
  1580. package/dist/esm/react/shared-ts/src/utils/routerAbNormalSigningIdentity.js +0 -115
  1581. package/dist/esm/react/shared-ts/src/utils/routerAbPublicKeyset.js +0 -11
  1582. package/dist/esm/react/shared-ts/src/utils/routerAbTraceContext.js +0 -36
  1583. package/dist/esm/react/shared-ts/src/utils/secureRandomId.js +0 -35
  1584. package/dist/esm/react/shared-ts/src/utils/signerDomain.js +0 -37
  1585. package/dist/esm/react/shared-ts/src/utils/signerSlot.js +0 -12
  1586. package/dist/esm/react/shared-ts/src/utils/signingSessionSeal.js +0 -98
  1587. package/dist/esm/react/shared-ts/src/utils/theme.js +0 -8
  1588. package/dist/esm/react/shared-ts/src/utils/thresholdEcdsaKeyHandle.js +0 -28
  1589. package/dist/esm/react/shared-ts/src/utils/validation.js +0 -92
  1590. package/dist/esm/react/shared-ts/src/utils/walletAddSignerActivation.js +0 -32
  1591. package/dist/esm/react/shared-ts/src/utils/walletAuthAuthority.js +0 -224
  1592. package/dist/esm/react/shared-ts/src/utils/walletAuthMethodRecord.js +0 -357
  1593. package/dist/esm/react/shared-ts/src/utils/walletCapabilityBindings.js +0 -277
  1594. package/dist/esm/react/shared-ts/src/utils/walletSessionFailure.js +0 -28
  1595. package/dist/esm/react/shared-ts/src/utils/webauthnDeviceInfo.js +0 -50
  1596. package/dist/esm/react/shared-ts/src/utils/wireSchema.js +0 -66
  1597. package/dist/esm/react/shared-ts/src/wallet-recovery/index.js +0 -10
  1598. package/dist/esm/react/shared-ts/src/wallet-recovery/recoveryCodeIssuance.js +0 -35
  1599. package/dist/esm/react/shared-ts/src/wallet-recovery/recoveryCodeLocator.js +0 -34
  1600. package/dist/esm/react/shared-ts/src/wallet-recovery/recoveryCodeReservation.js +0 -24
  1601. package/dist/esm/react/shared-ts/src/wallet-recovery/recoveryCodes.js +0 -3
  1602. package/dist/esm/react/shared-ts/src/wallet-recovery/recoveryKeyId.js +0 -14
  1603. package/dist/esm/react/shared-ts/src/wallet-recovery/walletRecoveryCommittedProjection.js +0 -254
  1604. package/dist/esm/react/shared-ts/src/wallet-recovery/walletRecoveryEcdsaPossession.js +0 -153
  1605. package/dist/esm/react/shared-ts/src/wallet-recovery/walletRecoveryEnvelopeSet.js +0 -84
  1606. package/dist/esm/react/shared-ts/src/wallet-recovery/walletRecoveryRotation.js +0 -64
  1607. package/dist/esm/react/theme/base-styles.js +0 -117
  1608. package/dist/esm/react/theme/palette.js +0 -170
  1609. package/dist/esm/react/utils/deviceDetection.js +0 -95
  1610. package/dist/esm/react/utils/intentDigest.js +0 -77
  1611. package/dist/esm/react/utils/qrScanner.js +0 -297
  1612. package/dist/esm/sdk/ConfirmationDrawer-MgFTBwwK.js +0 -425
  1613. package/dist/esm/sdk/EvmClient-f3gUhS2L.js +0 -644
  1614. package/dist/esm/sdk/NearClient-DY4NfHeD.js +0 -402
  1615. package/dist/esm/sdk/NonceCoordinator-4XWPhYww.js +0 -2253
  1616. package/dist/esm/sdk/accountIds-DhIPGOSN.js +0 -23
  1617. package/dist/esm/sdk/accountLifecycle-BAGG_rbk.js +0 -1341
  1618. package/dist/esm/sdk/actions-CCvThiKe.js +0 -225
  1619. package/dist/esm/sdk/adapters-B4JeK1nJ.js +0 -4864
  1620. package/dist/esm/sdk/base-D1B5mGin.js +0 -64
  1621. package/dist/esm/sdk/base64-Clm8C-e9.js +0 -68
  1622. package/dist/esm/sdk/browser-D6eZGhzE.js +0 -2393
  1623. package/dist/esm/sdk/bytes-qKxKn4gg.js +0 -40
  1624. package/dist/esm/sdk/canonicalPrimitives-BTHWz80v.js +0 -36
  1625. package/dist/esm/sdk/canonicalSignerErrorCode-CRoJMVpp.js +0 -153
  1626. package/dist/esm/sdk/capabilityKinds-hvYqa6S_.js +0 -109
  1627. package/dist/esm/sdk/chains-BMh3btVo.js +0 -124
  1628. package/dist/esm/sdk/challengeDelivery-Dd0586fo.js +0 -74
  1629. package/dist/esm/sdk/chunk-BtrIJ4_z.js +0 -33
  1630. package/dist/esm/sdk/configHelpers-vAQCzUD0.js +0 -179
  1631. package/dist/esm/sdk/csp-stylesheet-btENhsNp.js +0 -215
  1632. package/dist/esm/sdk/defaultConfigs-B3c16M_8.js +0 -355
  1633. package/dist/esm/sdk/display-KdIL0ff7.js +0 -126
  1634. package/dist/esm/sdk/domainIds-lcrFg6Sa.js +0 -338
  1635. package/dist/esm/sdk/ecdsaCapabilityManifest-kzO_fW09.js +0 -817
  1636. package/dist/esm/sdk/ecdsaChainTarget-Bl-JWyuw.js +0 -121
  1637. package/dist/esm/sdk/ecdsaPresignLifecycle-BFOTNYCK.js +0 -1983
  1638. package/dist/esm/sdk/ecdsaPresignPoolIdentity-BjxZVIqn.js +0 -47
  1639. package/dist/esm/sdk/ecdsaWalletRecords-Cz4m6bIz.js +0 -18
  1640. package/dist/esm/sdk/encoders-D8d07vpx.js +0 -0
  1641. package/dist/esm/sdk/enrichDisplayModelWithAbi-CWggsykc.js +0 -395
  1642. package/dist/esm/sdk/enrichDisplayModelWithAbi-SDRwTd_M.js +0 -579
  1643. package/dist/esm/sdk/errors-93h9uAW9.js +0 -92
  1644. package/dist/esm/sdk/events-DYoBL2HO.js +0 -8
  1645. package/dist/esm/sdk/evmCryptoWasm-DWklhEEb.js +0 -196
  1646. package/dist/esm/sdk/evmFamilyEcdsaIdentity-Co5XDcEA.js +0 -4288
  1647. package/dist/esm/sdk/exactSessionState-CiD5fBEs.js +0 -2612
  1648. package/dist/esm/sdk/exactSigningLaneIdentity-DQeqPMST.js +0 -335
  1649. package/dist/esm/sdk/executeWorkerOperation-Cl9whMK7.js +0 -10
  1650. package/dist/esm/sdk/export-viewer-host-ZqA2Yz3H.js +0 -204
  1651. package/dist/esm/sdk/helpers-ZrowMnev.js +0 -302
  1652. package/dist/esm/sdk/host-BWBbCAMu.js +0 -533
  1653. package/dist/esm/sdk/intentDigest-CvOSNlCH.js +0 -75
  1654. package/dist/esm/sdk/jsonRpc-VVkaQkFD.js +0 -62
  1655. package/dist/esm/sdk/jsxRuntime.module-CuH5ZEIA.js +0 -298
  1656. package/dist/esm/sdk/keccak-DUL3d8SF.js +0 -148
  1657. package/dist/esm/sdk/keyMaterialBrands-CX41hur6.js +0 -94
  1658. package/dist/esm/sdk/localOnly-Bg8UuLZ5.js +0 -146
  1659. package/dist/esm/sdk/messages-C7Dbx9iN.js +0 -594
  1660. package/dist/esm/sdk/mountExportPrivateKeySurface-DgX-IBG_.js +0 -542
  1661. package/dist/esm/sdk/mountRecoveryCodeBackupSurface-DXrExiJ7.js +0 -590
  1662. package/dist/esm/sdk/nearEd25519YaoMaterialActivation-DPb0s3hQ.js +0 -4008
  1663. package/dist/esm/sdk/nearEd25519YaoSigningPreparation-BeD-SmbK.js +0 -405
  1664. package/dist/esm/sdk/nearRpcResults-DoUgDATm.js +0 -216
  1665. package/dist/esm/sdk/nonceLaneKeys-C3c9lG6u.js +0 -164
  1666. package/dist/esm/sdk/normalization-CBt413-z.js +0 -22
  1667. package/dist/esm/sdk/operationFingerprint-C8Trar4R.js +0 -929
  1668. package/dist/esm/sdk/operationFingerprint-CGZui5dR.js +0 -55
  1669. package/dist/esm/sdk/passkey-custody-Bk1jAknm.js +0 -487
  1670. package/dist/esm/sdk/pendingWalletRecoveryCodeBackup-DLzBb3WQ.js +0 -237
  1671. package/dist/esm/sdk/prfCache-wqQSjYLn.js +0 -58
  1672. package/dist/esm/sdk/profileAccountProjection-uZVJuBvS.js +0 -86
  1673. package/dist/esm/sdk/promptText-CuRa_ivd.js +0 -32
  1674. package/dist/esm/sdk/recovery-entrypoint-DW2tGyMs.js +0 -779
  1675. package/dist/esm/sdk/registration-BZDzDv91.js +0 -14414
  1676. package/dist/esm/sdk/registration-BzVHODuD.js +0 -233
  1677. package/dist/esm/sdk/registrationAccounts-CKku_Sgy.js +0 -33
  1678. package/dist/esm/sdk/registrationIds-DLSdEKSv.js +0 -310
  1679. package/dist/esm/sdk/registrationIntent-D0PxwEY4.js +0 -393
  1680. package/dist/esm/sdk/registrationPreparationPreload-CIAuRlxI.js +0 -13
  1681. package/dist/esm/sdk/registrationSignerPlan-CAikVZZQ.js +0 -440
  1682. package/dist/esm/sdk/relayerHttp-VC8Holz1.js +0 -24
  1683. package/dist/esm/sdk/routePlan-D59x5xzQ.js +0 -83
  1684. package/dist/esm/sdk/router-C5lF_J_u.js +0 -4721
  1685. package/dist/esm/sdk/routerAbNormalSigning-fhvpDtmY.js +0 -992
  1686. package/dist/esm/sdk/runtime-auth-DFTqwj3u.js +0 -5540
  1687. package/dist/esm/sdk/runtime-device-link-C1Oub8Lw.js +0 -259
  1688. package/dist/esm/sdk/runtime-ecdsa-tempo-rkWwolw1.js +0 -177
  1689. package/dist/esm/sdk/runtime-email-otp-vuUG5LYl.js +0 -320
  1690. package/dist/esm/sdk/runtime-export-FZWj0HxJ.js +0 -112
  1691. package/dist/esm/sdk/runtime-near-B9cjurVD.js +0 -278
  1692. package/dist/esm/sdk/runtime-preferences-Dq0bfyS5.js +0 -67
  1693. package/dist/esm/sdk/runtime-recovery-C-vfFKF3.js +0 -45
  1694. package/dist/esm/sdk/runtime-recovery-codes-bTm3fLV4.js +0 -95
  1695. package/dist/esm/sdk/runtimeContext-iLXnxVlZ.js +0 -44443
  1696. package/dist/esm/sdk/runtimeLoader-hod6T2-m.js +0 -44
  1697. package/dist/esm/sdk/sdkSentEvents-MqDkbQg1.js +0 -599
  1698. package/dist/esm/sdk/secp256k1-el9aE4Sv.js +0 -2504
  1699. package/dist/esm/sdk/secureRandomId-BORsmdS4.js +0 -33
  1700. package/dist/esm/sdk/sessionPolicy-CHiilOAB.js +0 -453
  1701. package/dist/esm/sdk/shared-DkbeLCI3.js +0 -33
  1702. package/dist/esm/sdk/signEvmFamily-e4IWWsZs.js +0 -4666
  1703. package/dist/esm/sdk/signEvmFamilyWithUiConfirmForTempo-Cu9qdk8M.js +0 -226
  1704. package/dist/esm/sdk/signEvmWithUiConfirm-C61TCBnh.js +0 -27
  1705. package/dist/esm/sdk/signNear-Bblwn2kT.js +0 -5929
  1706. package/dist/esm/sdk/signatureUses-BkGyYt8F.js +0 -51
  1707. package/dist/esm/sdk/signerDomain-IEAVrOrc.js +0 -59
  1708. package/dist/esm/sdk/signerLoader-D7Aey0FD.js +0 -23
  1709. package/dist/esm/sdk/signerSlot-_ovonwVX.js +0 -10
  1710. package/dist/esm/sdk/signingFlow-rZfPegH9.js +0 -1320
  1711. package/dist/esm/sdk/signingSessionSeal-Cu-GHm6y.js +0 -96
  1712. package/dist/esm/sdk/surface-measurement-reporter-CSTyRsMa.js +0 -156
  1713. package/dist/esm/sdk/trace-rHe0wz7q.js +0 -127
  1714. package/dist/esm/sdk/transaction-activity-CSMCveBn.js +0 -218
  1715. package/dist/esm/sdk/transactionReview-DpHLTznU.js +0 -100
  1716. package/dist/esm/sdk/transactionReviewAdmission-BCPvl8OZ.js +0 -172
  1717. package/dist/esm/sdk/transactionState-DP9O8F6f.js +0 -1885
  1718. package/dist/esm/sdk/types-Dx9fczU7.js +0 -111
  1719. package/dist/esm/sdk/validation-gat4LEKm.js +0 -409
  1720. package/dist/esm/sdk/wallet-recovery-Bz9qKgaL.js +0 -1905
  1721. package/dist/esm/sdk/walletAuthority-BQBxgUBn.js +0 -1251
  1722. package/dist/esm/sdk/walletCustodyEcdsaContinuity-Hn4ORIbf.js +0 -11130
  1723. package/dist/esm/sdk/walletIframeIdentity-DB6Z2EC9.js +0 -13
  1724. package/dist/esm/sdk/walletRecoveryCommit-sjGNTHUj.js +0 -2159
  1725. package/dist/esm/sdk/walletRecoveryRotate-BgLlW5ih.js +0 -309
  1726. package/dist/esm/sdk/warmSessionHydration-Os8niEm7.js +0 -7
  1727. package/dist/esm/sdk/webauthnP256-DC5EIbKN.js +0 -82
  1728. package/dist/esm/sdk/webauthnPromptCoordinator-L96oVvLz.js +0 -168
  1729. package/dist/esm/shared-ts/src/signing-lanes/rotationDigests.js +0 -6
  1730. package/dist/esm/shared-ts/src/signing-lanes/rotationParsers.js +0 -3
  1731. package/dist/esm/shared-ts/src/signing-lanes/rotationProtocolParsers.js +0 -8
  1732. package/dist/esm/shared-ts/src/signing-lanes/rotationWireFields.js +0 -3
  1733. package/dist/esm/shared-ts/src/utils/addWalletAuthMethod.js +0 -1
  1734. package/dist/esm/styles.css +0 -43
  1735. package/dist/public/sdk/ConfirmationDrawer-MgFTBwwK.js +0 -425
  1736. package/dist/public/sdk/EvmClient-f3gUhS2L.js +0 -644
  1737. package/dist/public/sdk/NearClient-DY4NfHeD.js +0 -402
  1738. package/dist/public/sdk/NonceCoordinator-4XWPhYww.js +0 -2253
  1739. package/dist/public/sdk/accountIds-DhIPGOSN.js +0 -23
  1740. package/dist/public/sdk/accountLifecycle-BAGG_rbk.js +0 -1341
  1741. package/dist/public/sdk/actions-CCvThiKe.js +0 -225
  1742. package/dist/public/sdk/adapters-B4JeK1nJ.js +0 -4864
  1743. package/dist/public/sdk/base-D1B5mGin.js +0 -64
  1744. package/dist/public/sdk/base64-Clm8C-e9.js +0 -68
  1745. package/dist/public/sdk/browser-D6eZGhzE.js +0 -2393
  1746. package/dist/public/sdk/bytes-qKxKn4gg.js +0 -40
  1747. package/dist/public/sdk/canonicalPrimitives-BTHWz80v.js +0 -36
  1748. package/dist/public/sdk/canonicalSignerErrorCode-CRoJMVpp.js +0 -153
  1749. package/dist/public/sdk/capabilityKinds-hvYqa6S_.js +0 -109
  1750. package/dist/public/sdk/chains-BMh3btVo.js +0 -124
  1751. package/dist/public/sdk/challengeDelivery-Dd0586fo.js +0 -74
  1752. package/dist/public/sdk/chunk-BtrIJ4_z.js +0 -33
  1753. package/dist/public/sdk/configHelpers-vAQCzUD0.js +0 -179
  1754. package/dist/public/sdk/csp-stylesheet-btENhsNp.js +0 -215
  1755. package/dist/public/sdk/defaultConfigs-B3c16M_8.js +0 -355
  1756. package/dist/public/sdk/display-KdIL0ff7.js +0 -126
  1757. package/dist/public/sdk/domainIds-lcrFg6Sa.js +0 -338
  1758. package/dist/public/sdk/ecdsaCapabilityManifest-kzO_fW09.js +0 -817
  1759. package/dist/public/sdk/ecdsaChainTarget-Bl-JWyuw.js +0 -121
  1760. package/dist/public/sdk/ecdsaPresignLifecycle-BFOTNYCK.js +0 -1983
  1761. package/dist/public/sdk/ecdsaPresignPoolIdentity-BjxZVIqn.js +0 -47
  1762. package/dist/public/sdk/ecdsaWalletRecords-Cz4m6bIz.js +0 -18
  1763. package/dist/public/sdk/encoders-D8d07vpx.js +0 -0
  1764. package/dist/public/sdk/enrichDisplayModelWithAbi-CWggsykc.js +0 -395
  1765. package/dist/public/sdk/enrichDisplayModelWithAbi-SDRwTd_M.js +0 -579
  1766. package/dist/public/sdk/errors-93h9uAW9.js +0 -92
  1767. package/dist/public/sdk/events-DYoBL2HO.js +0 -8
  1768. package/dist/public/sdk/evmCryptoWasm-DWklhEEb.js +0 -196
  1769. package/dist/public/sdk/evmFamilyEcdsaIdentity-Co5XDcEA.js +0 -4288
  1770. package/dist/public/sdk/exactSessionState-CiD5fBEs.js +0 -2612
  1771. package/dist/public/sdk/exactSigningLaneIdentity-DQeqPMST.js +0 -335
  1772. package/dist/public/sdk/executeWorkerOperation-Cl9whMK7.js +0 -10
  1773. package/dist/public/sdk/export-viewer-host-ZqA2Yz3H.js +0 -204
  1774. package/dist/public/sdk/helpers-ZrowMnev.js +0 -302
  1775. package/dist/public/sdk/host-BWBbCAMu.js +0 -533
  1776. package/dist/public/sdk/intentDigest-CvOSNlCH.js +0 -75
  1777. package/dist/public/sdk/jsonRpc-VVkaQkFD.js +0 -62
  1778. package/dist/public/sdk/jsxRuntime.module-CuH5ZEIA.js +0 -298
  1779. package/dist/public/sdk/keccak-DUL3d8SF.js +0 -148
  1780. package/dist/public/sdk/keyMaterialBrands-CX41hur6.js +0 -94
  1781. package/dist/public/sdk/localOnly-Bg8UuLZ5.js +0 -146
  1782. package/dist/public/sdk/messages-C7Dbx9iN.js +0 -594
  1783. package/dist/public/sdk/mountExportPrivateKeySurface-DgX-IBG_.js +0 -542
  1784. package/dist/public/sdk/mountRecoveryCodeBackupSurface-DXrExiJ7.js +0 -590
  1785. package/dist/public/sdk/nearEd25519YaoMaterialActivation-DPb0s3hQ.js +0 -4008
  1786. package/dist/public/sdk/nearEd25519YaoSigningPreparation-BeD-SmbK.js +0 -405
  1787. package/dist/public/sdk/nearRpcResults-DoUgDATm.js +0 -216
  1788. package/dist/public/sdk/nonceLaneKeys-C3c9lG6u.js +0 -164
  1789. package/dist/public/sdk/normalization-CBt413-z.js +0 -22
  1790. package/dist/public/sdk/operationFingerprint-C8Trar4R.js +0 -929
  1791. package/dist/public/sdk/operationFingerprint-CGZui5dR.js +0 -55
  1792. package/dist/public/sdk/passkey-custody-Bk1jAknm.js +0 -487
  1793. package/dist/public/sdk/pendingWalletRecoveryCodeBackup-DLzBb3WQ.js +0 -237
  1794. package/dist/public/sdk/prfCache-wqQSjYLn.js +0 -58
  1795. package/dist/public/sdk/profileAccountProjection-uZVJuBvS.js +0 -86
  1796. package/dist/public/sdk/promptText-CuRa_ivd.js +0 -32
  1797. package/dist/public/sdk/recovery-entrypoint-DW2tGyMs.js +0 -779
  1798. package/dist/public/sdk/registration-BZDzDv91.js +0 -14414
  1799. package/dist/public/sdk/registration-BzVHODuD.js +0 -233
  1800. package/dist/public/sdk/registrationAccounts-CKku_Sgy.js +0 -33
  1801. package/dist/public/sdk/registrationIds-DLSdEKSv.js +0 -310
  1802. package/dist/public/sdk/registrationIntent-D0PxwEY4.js +0 -393
  1803. package/dist/public/sdk/registrationPreparationPreload-CIAuRlxI.js +0 -13
  1804. package/dist/public/sdk/registrationSignerPlan-CAikVZZQ.js +0 -440
  1805. package/dist/public/sdk/relayerHttp-VC8Holz1.js +0 -24
  1806. package/dist/public/sdk/routePlan-D59x5xzQ.js +0 -83
  1807. package/dist/public/sdk/router-C5lF_J_u.js +0 -4721
  1808. package/dist/public/sdk/routerAbNormalSigning-fhvpDtmY.js +0 -992
  1809. package/dist/public/sdk/runtime-auth-DFTqwj3u.js +0 -5540
  1810. package/dist/public/sdk/runtime-device-link-C1Oub8Lw.js +0 -259
  1811. package/dist/public/sdk/runtime-ecdsa-tempo-rkWwolw1.js +0 -177
  1812. package/dist/public/sdk/runtime-email-otp-vuUG5LYl.js +0 -320
  1813. package/dist/public/sdk/runtime-export-FZWj0HxJ.js +0 -112
  1814. package/dist/public/sdk/runtime-near-B9cjurVD.js +0 -278
  1815. package/dist/public/sdk/runtime-preferences-Dq0bfyS5.js +0 -67
  1816. package/dist/public/sdk/runtime-recovery-C-vfFKF3.js +0 -45
  1817. package/dist/public/sdk/runtime-recovery-codes-bTm3fLV4.js +0 -95
  1818. package/dist/public/sdk/runtimeContext-iLXnxVlZ.js +0 -44443
  1819. package/dist/public/sdk/runtimeLoader-hod6T2-m.js +0 -44
  1820. package/dist/public/sdk/sdkSentEvents-MqDkbQg1.js +0 -599
  1821. package/dist/public/sdk/secp256k1-el9aE4Sv.js +0 -2504
  1822. package/dist/public/sdk/secureRandomId-BORsmdS4.js +0 -33
  1823. package/dist/public/sdk/sessionPolicy-CHiilOAB.js +0 -453
  1824. package/dist/public/sdk/shared-DkbeLCI3.js +0 -33
  1825. package/dist/public/sdk/signEvmFamily-e4IWWsZs.js +0 -4666
  1826. package/dist/public/sdk/signEvmFamilyWithUiConfirmForTempo-Cu9qdk8M.js +0 -226
  1827. package/dist/public/sdk/signEvmWithUiConfirm-C61TCBnh.js +0 -27
  1828. package/dist/public/sdk/signNear-Bblwn2kT.js +0 -5929
  1829. package/dist/public/sdk/signatureUses-BkGyYt8F.js +0 -51
  1830. package/dist/public/sdk/signerDomain-IEAVrOrc.js +0 -59
  1831. package/dist/public/sdk/signerLoader-D7Aey0FD.js +0 -23
  1832. package/dist/public/sdk/signerSlot-_ovonwVX.js +0 -10
  1833. package/dist/public/sdk/signingFlow-rZfPegH9.js +0 -1320
  1834. package/dist/public/sdk/signingSessionSeal-Cu-GHm6y.js +0 -96
  1835. package/dist/public/sdk/surface-measurement-reporter-CSTyRsMa.js +0 -156
  1836. package/dist/public/sdk/trace-rHe0wz7q.js +0 -127
  1837. package/dist/public/sdk/transaction-activity-CSMCveBn.js +0 -218
  1838. package/dist/public/sdk/transactionReview-DpHLTznU.js +0 -100
  1839. package/dist/public/sdk/transactionReviewAdmission-BCPvl8OZ.js +0 -172
  1840. package/dist/public/sdk/transactionState-DP9O8F6f.js +0 -1885
  1841. package/dist/public/sdk/types-Dx9fczU7.js +0 -111
  1842. package/dist/public/sdk/validation-gat4LEKm.js +0 -409
  1843. package/dist/public/sdk/wallet-recovery-Bz9qKgaL.js +0 -1905
  1844. package/dist/public/sdk/walletAuthority-BQBxgUBn.js +0 -1251
  1845. package/dist/public/sdk/walletCustodyEcdsaContinuity-Hn4ORIbf.js +0 -11130
  1846. package/dist/public/sdk/walletIframeIdentity-DB6Z2EC9.js +0 -13
  1847. package/dist/public/sdk/walletRecoveryCommit-sjGNTHUj.js +0 -2159
  1848. package/dist/public/sdk/walletRecoveryRotate-BgLlW5ih.js +0 -309
  1849. package/dist/public/sdk/warmSessionHydration-Os8niEm7.js +0 -7
  1850. package/dist/public/sdk/webauthnP256-DC5EIbKN.js +0 -82
  1851. package/dist/public/sdk/webauthnPromptCoordinator-L96oVvLz.js +0 -168
  1852. package/dist/types/shared-ts/src/signing-lanes/participantDigest.typecheck.d.ts +0 -2
  1853. package/dist/types/shared-ts/src/signing-lanes/rotation.typecheck.d.ts +0 -2
  1854. package/dist/types/shared-ts/src/signing-lanes/rotationDigests.d.ts +0 -13
  1855. package/dist/types/shared-ts/src/signing-lanes/rotationLifecycle.d.ts +0 -78
  1856. package/dist/types/shared-ts/src/signing-lanes/rotationParsers.d.ts +0 -27
  1857. package/dist/types/shared-ts/src/signing-lanes/rotationProtocolParsers.d.ts +0 -6
  1858. package/dist/types/shared-ts/src/signing-lanes/rotationWireFields.d.ts +0 -20
  1859. package/dist/types/shared-ts/src/wallet-recovery/recoveryCodeAttempt.d.ts +0 -59
  1860. package/dist/types/wallet/src/SeamsWeb/walletIframe/client/transport/webauthn-bridge.d.ts +0 -3
  1861. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/laneHolderMaterialStore.d.ts +0 -52
  1862. package/dist/types/wallet/src/core/signingEngine/interfaces/nearKeyOps.d.ts +0 -15
  1863. package/dist/types/wallet/src/core/signingEngine/session/emailOtp/coordinatorRuntime.d.ts +0 -43
  1864. package/dist/types/wallet/src/core/signingEngine/session/holderShares/forbiddenHolderSharePayloads.typecheck.d.ts +0 -2
  1865. package/dist/types/wallet/src/core/signingEngine/session/holderShares/holderShareHandle.d.ts +0 -6
  1866. package/dist/types/wallet/src/core/signingEngine/session/identity/emailOtpEcdsaDerivationIdentity.typecheck.d.ts +0 -2
  1867. package/dist/types/wallet/src/core/signingEngine/session/lanes/operations/activationCoordinator.d.ts +0 -37
  1868. package/dist/types/wallet/src/core/signingEngine/session/lanes/operations/laneMaterialInvalidation.d.ts +0 -23
  1869. package/dist/types/wallet/src/core/signingEngine/session/lanes/operations/operations.typecheck.d.ts +0 -2
  1870. package/dist/types/wallet/src/core/signingEngine/session/lanes/operations/recipientPreparation.d.ts +0 -55
  1871. package/dist/types/wallet/src/core/signingEngine/session/warmCapabilities/ecdsaProvisionPlan.typecheck.d.ts +0 -6
  1872. package/dist/types/wallet/src/core/signingEngine/threshold/crypto/ecdsaLaneWasm.d.ts +0 -4
  1873. package/dist/types/wallet/src/core/signingEngine/uiConfirm/ui/transaction-display/renderers/evm.d.ts +0 -5
  1874. package/dist/types/wallet/src/core/signingEngine/uiConfirm/ui/transaction-display/renderers/near.d.ts +0 -5
  1875. package/dist/types/wallet/src/core/signingEngine/uiConfirm/ui/transaction-display/renderers/tempo.d.ts +0 -5
  1876. package/dist/types/wallet/src/core/signingEngine/webauthnAuth/fallbacks/safari-fallbacks.d.ts +0 -44
  1877. package/dist/types/wallet/src/core/signingEngine/workerManager/nearKeyOps/createNearKeyOps.d.ts +0 -4
  1878. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/ecdsaLaneHolderWorkerRuntime.d.ts +0 -20
  1879. package/dist/types/wallet/src/core/signingEngine/workerManager/workers/email-otp/passkeyCustodyLink.d.ts +0 -18
  1880. /package/dist/esm/{react/SeamsWeb → SeamsWeb}/assembly/preconnectWalletAssets.js +0 -0
@@ -1,4747 +0,0 @@
1
- import { base64UrlDecode, base64UrlEncode } from "../../../shared-ts/src/utils/base64.js";
2
- import { normalizeTrimmedString } from "../../../shared-ts/src/utils/normalize.js";
3
- import "../../../shared-ts/src/utils/validation.js";
4
- import { sha256HexUtf8 } from "../../../shared-ts/src/utils/digests.js";
5
- import { mpcMaterialActivationRefsEqual, parseMpcMaterialActivationRef, parseVerifiedEmailAddress, parseWalletAuthMethodId, parseWalletAuthorityId, parseWalletId, parseWalletKeyId, parseWalletRecoveryOperationId, parseWebAuthnCredentialIdB64u, parseWebAuthnRpId } from "../../../shared-ts/src/utils/domainIds.js";
6
- import { parseDigestB64u } from "../../../shared-ts/src/utils/canonicalPrimitives.js";
7
- import { sameDelegatedWalletAuthorityV1 } from "../../../shared-ts/src/authorization/delegatedAuthority.js";
8
- import { parseEd25519PublicKeyB64u } from "../../../shared-ts/src/passkey-custody/primitives.js";
9
- import { walletSessionPreservesCapabilities } from "../../../shared-ts/src/device-linking/activeWalletSession.js";
10
- import { isEmailOtpWalletAuthAuthority, isPasskeyWalletAuthAuthority, parseEmailOtpWalletAuthAuthority, parseWalletAuthAuthority, walletAuthAuthoritiesMatch } from "../../../shared-ts/src/utils/walletAuthAuthority.js";
11
- import { SIGNER_KINDS } from "../../../shared-ts/src/utils/signerDomain.js";
12
- import { walletIdFromString } from "../../../shared-ts/src/utils/registrationIds.js";
13
- import { thresholdEcdsaChainTargetFromRequest } from "../../signingEngine/interfaces/ecdsaChainTarget.js";
14
- import { toAccountId } from "../../types/accountIds.js";
15
- import { SEAMS_WALLET_INDEXES, SEAMS_WALLET_STORES } from "../schemaNames.js";
16
- import { parseEcdsaThresholdKeyId } from "../../signingEngine/session/keyMaterialBrands.js";
17
- import { parseWalletAuthMethodRecordV2 } from "../../../shared-ts/src/utils/walletAuthMethodRecord.js";
18
- import { parsePasskeyCustodyEnvelopeRecord, sameWalletCustodyEnvelopeOwnership } from "../../../shared-ts/src/passkey-custody/custodyEnvelope.js";
19
- import "../../../shared-ts/src/passkey-custody/index.js";
20
- import { encodeWalletSignerActivationSetV1, extendEcdsaWalletAuthorityWithEd25519, isActiveEcdsaWalletAuthorityV1, isActiveRecoveredWalletAuthorityV1, isEcdsaExtensionOfEd25519WalletAuthority, parseWalletAuthorityV1, walletAuthorityDigestsMatchV1 } from "../../../shared-ts/src/authorization/walletAuthority.js";
21
- import { parseLocalAuthorityInstallationReceiptV1 } from "../../../shared-ts/src/device-linking/authorityActivation.js";
22
- import "../../../shared-ts/src/device-linking/index.js";
23
- import { parseNearProvisioningState } from "../../types/sdkSentEvents.js";
24
- import { upsertEd25519YaoPublicCapabilityReferenceInTransaction } from "../../signingEngine/threshold/ed25519/yaoPublicCapabilityReferences.js";
25
- import { buildEnvelopeAAD, normalizePayloadEnvelope, sanitizePayload } from "../keyMaterialEnvelope.js";
26
- import { normalizeIndexedDbAccountAddress, normalizeIndexedDbAccountModel, normalizeIndexedDbChainIdKey, normalizeLastUserScope, toIndexedDbChainTargetKey } from "../normalization.js";
27
- import { buildNearProfileId } from "../../accountData/near/profileId.js";
28
- import { parseWalletAuthorityLinkedSignerMaterialRecordV1 } from "../linkedAuthoritySignerMaterial.js";
29
- import { planAccountSignerActivation } from "../accountSignerLifecycle.js";
30
- import { parseLastProfileState } from "../lastProfileState.js";
31
- import { assertPendingWalletRegistrationIdentity, buildPendingWalletRegistrationCommitV1, parsePendingWalletRegistrationCommitAppStateRow, pendingWalletRegistrationCommitAppStateKey, splitPersistedMixedRegistrationRow, toPendingWalletRegistrationCommitAppStateRow } from "../pendingWalletRegistrationCommit.js";
32
- import { buildPendingWalletRecoveryCommitV1, parsePendingWalletRecoveryCommitAppStateRow, pendingWalletRecoveryCommitAppStateKey, pendingWalletRecoveryCommitAppStateRowsMatch, pendingWalletRecoveryCommitIdentityMatches, toPendingWalletRecoveryCommitAppStateRow } from "../pendingWalletRecoveryCommit.js";
33
- import { parseStoredExactWalletSessionAuthorizationRowV6, readExactActiveWalletSessionForScopeInTransaction, replaceExactActiveWalletSessionAuthorizationInTransaction, toStoredExactWalletSessionAuthorizationRowV6 } from "./walletSessionAuthorizationStore.js";
34
- import { persistPreparedImportedWalletCustodyEcdsaContinuityInTransaction } from "./ecdsaCapabilityManifestStore.js";
35
- //#region src/core/indexedDB/seamsWalletDB/repositories.ts
36
- function assertNever(value) {
37
- throw new Error(`Unhandled wallet auth method branch: ${String(value)}`);
38
- }
39
- function exportRootEnvelopeMatchesAuthMethod(authMethod, envelope) {
40
- if (envelope.binding.kind !== "ed25519_yao_client_root_v1") return false;
41
- switch (authMethod.kind) {
42
- case "passkey": return envelope.factor.kind === "passkey" && envelope.factor.rpId === authMethod.rpId && envelope.factor.credentialIdB64u === authMethod.credentialIdB64u && envelope.binding.targetFactor.kind === "passkey_prf";
43
- case "email_otp": return envelope.factor.kind === "email_otp" && envelope.binding.targetFactor.kind === "email_otp";
44
- default: return assertNever(authMethod);
45
- }
46
- }
47
- function parseAppStateRow(value) {
48
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
49
- const key = Reflect.get(value, "key");
50
- if (typeof key !== "string" || key.length === 0) return null;
51
- return {
52
- key,
53
- value: Reflect.get(value, "value")
54
- };
55
- }
56
- const LOCAL_AUTHORITY_PENDING_PROFILE_PROJECTION_APP_STATE_PREFIX_V1 = "local-authority/pending-profile-projection/v1/";
57
- function localAuthorityPendingProfileProjectionAppStateKeyV1(authorityId) {
58
- return `${LOCAL_AUTHORITY_PENDING_PROFILE_PROJECTION_APP_STATE_PREFIX_V1}${authorityId}`;
59
- }
60
- function walletSelectionForInstalledAuthority(input, selection) {
61
- return {
62
- kind: "wallet_selection_v1",
63
- walletId: input.authority.walletId,
64
- walletAuthMethodId: input.authMethod.walletAuthMethodId,
65
- lockGeneration: selection?.record.lockGeneration ?? 0,
66
- lockState: selection?.record.lockState ?? "unlocked",
67
- updatedAtMs: input.receipt.installedAtMs
68
- };
69
- }
70
- function assertPendingWalletRegistrationRequestIdentity(pending, request) {
71
- if (pending.operation !== request.operation || pending.registrationCeremonyId !== request.registrationCeremonyId || pending.idempotencyKey !== request.idempotencyKey || pending.walletId !== request.walletId || pending.walletAuthMethodId !== request.walletAuthMethodId) throw new Error("pending wallet registration commit does not match the request");
72
- }
73
- function validateFoundingWalletAuthorityInput(input) {
74
- const authority = parseWalletAuthorityV1(input.authority);
75
- const authMethod = parseWalletAuthMethodRecordV2(input.authMethod);
76
- if (!authority.ok || authority.value.state !== "active" || !authMethod || authMethod.status !== "active" || authority.value.provenance.kind !== "wallet_registration" || authMethod.walletId !== authority.value.walletId || authMethod.walletAuthorityId !== authority.value.authorityId) throw new Error("founding wallet authority records are invalid");
77
- return {
78
- authority: authority.value,
79
- authMethod
80
- };
81
- }
82
- async function assertRegistrationFinalizeMatchesPending(input) {
83
- const pending = input.pending;
84
- const foundingMethod = input.foundingAuthority.authMethod;
85
- const initialMethod = input.registration.initialAuthMethod;
86
- assertPendingWalletRegistrationRequestIdentity(pending, input.request);
87
- assertPendingWalletRegistrationIdentity(pending, {
88
- operation: input.request.operation,
89
- walletId: input.request.walletId,
90
- walletAuthMethodId: input.request.walletAuthMethodId,
91
- authority: input.authority
92
- });
93
- if (foundingMethod.walletId !== pending.walletId || foundingMethod.walletAuthMethodId !== pending.walletAuthMethodId || initialMethod.walletId !== pending.walletId || initialMethod.status !== "active" || initialMethod.localStatus !== "synced" || initialMethod.kind !== pending.auth.kind || foundingMethod.kind !== pending.auth.kind || !input.registration.profiles.some((profile) => profile.profileId === pending.walletId) || input.registration.lastProfileState.profileId !== pending.walletId) throw new Error("registration finalize batch does not match the pending wallet");
94
- const profileIds = new Set(input.registration.profiles.map((profile) => profile.profileId));
95
- for (const profile of input.registration.profiles) if (profile.passkeyCredential && (pending.auth.kind !== "passkey" || profile.passkeyCredential.rawId !== pending.auth.credentialIdB64u)) throw new Error("registration profile credential does not match the pending commit");
96
- for (const activation of input.registration.signerActivations) if (!profileIds.has(activation.account.profileId)) throw new Error("registration signer account is outside the publication profiles");
97
- for (const keyMaterial of input.registration.keyMaterials) if (!profileIds.has(keyMaterial.profileId)) throw new Error("registration key material is outside the publication profiles");
98
- switch (pending.auth.kind) {
99
- case "passkey":
100
- if (!isPasskeyWalletAuthAuthority(input.authority) || initialMethod.kind !== "passkey" || foundingMethod.kind !== "passkey" || initialMethod.rpId !== pending.auth.rpId || initialMethod.credentialIdB64u !== pending.auth.credentialIdB64u || foundingMethod.rpId !== pending.auth.rpId || foundingMethod.credentialIdB64u !== pending.auth.credentialIdB64u || initialMethod.credentialPublicKeyB64u !== foundingMethod.credentialPublicKeyB64u) throw new Error("registration passkey records do not match the pending commit");
101
- for (const authenticator of input.registration.authenticators) if (!profileIds.has(authenticator.profileId) || authenticator.credentialId !== pending.auth.credentialIdB64u || base64UrlEncode(authenticator.credentialPublicKey) !== initialMethod.credentialPublicKeyB64u) throw new Error("registration passkey authenticator does not match the pending commit");
102
- return;
103
- case "email_otp": {
104
- if (initialMethod.kind !== "email_otp" || foundingMethod.kind !== "email_otp") throw new Error("registration Email OTP method records are invalid");
105
- const emailAuthority = parseEmailOtpWalletAuthAuthority(initialMethod.authority);
106
- if (!emailAuthority || !isEmailOtpWalletAuthAuthority(input.authority)) throw new Error("registration Email OTP authority records are invalid");
107
- const expectedEmailHashHex = await sha256HexUtf8(pending.auth.email);
108
- if (initialMethod.registrationAuthorityId !== pending.auth.registrationAuthorityId || foundingMethod.registrationAuthorityId !== pending.auth.registrationAuthorityId || initialMethod.emailHashHex !== expectedEmailHashHex || foundingMethod.emailHashHex !== expectedEmailHashHex || input.authority.verifier.emailHashHex !== expectedEmailHashHex || emailAuthority.factor.providerUserId !== pending.auth.providerSubject || emailAuthority.factor.provider !== input.authority.factor.provider || !walletAuthAuthoritiesMatch(emailAuthority, input.authority) || input.registration.authenticators.length !== 0) throw new Error("registration Email OTP records do not match the pending commit");
109
- return;
110
- }
111
- }
112
- }
113
- function assertPendingWalletRecoveryPublicationMatchesProjection(input) {
114
- const projection = input.pending.projection;
115
- if (!walletAuthorityRecordsMatch(input.authority, projection.authority) || !walletAuthMethodRecordsMatch(input.authMethod, projection.authMethod)) throw new Error("recovery publication records do not match the committed projection");
116
- const initialMethod = input.registration.initialAuthMethod;
117
- const profiles = input.registration.profiles;
118
- if (initialMethod.status !== "active" || initialMethod.localStatus !== "synced" || initialMethod.walletId !== projection.walletId || !profiles.some((profile) => profile.profileId === projection.walletId) || input.registration.lastProfileState.profileId !== projection.walletId || !Number.isSafeInteger(input.registration.lastProfileState.activeSignerSlot) || input.registration.lastProfileState.activeSignerSlot < 1) throw new Error("recovery profile publication does not match the committed projection");
119
- const profileIds = new Set(profiles.map((profile) => profile.profileId));
120
- for (const profile of profiles) if (profile.passkeyCredential && (projection.kind !== "passkey" || profile.passkeyCredential.rawId !== projection.target.credentialIdB64u)) throw new Error("recovery profile credential does not match the committed projection");
121
- for (const activation of input.registration.signerActivations) if (!profileIds.has(activation.account.profileId)) throw new Error("recovery signer account is outside the publication profiles");
122
- for (const keyMaterial of input.registration.keyMaterials) if (!profileIds.has(keyMaterial.profileId)) throw new Error("recovery key material is outside the publication profiles");
123
- if (projection.kind === "passkey") {
124
- if (initialMethod.kind !== "passkey") throw new Error("recovery passkey publication method branch is invalid");
125
- if (initialMethod.rpId !== projection.target.rpId || initialMethod.credentialIdB64u !== projection.target.credentialIdB64u || initialMethod.credentialPublicKeyB64u !== projection.authMethod.credentialPublicKeyB64u || !input.registration.authenticators.some((authenticator) => authenticator.profileId === projection.walletId && authenticator.credentialId === projection.target.credentialIdB64u && base64UrlEncode(authenticator.credentialPublicKey) === projection.authMethod.credentialPublicKeyB64u)) throw new Error("recovery passkey publication does not match the committed projection");
126
- return;
127
- }
128
- if (initialMethod.kind !== "email_otp") throw new Error("recovery Email OTP publication method branch is invalid");
129
- if (initialMethod.emailHashHex !== projection.target.emailHashHex || initialMethod.registrationAuthorityId !== projection.target.registrationAuthorityId || input.registration.authenticators.length !== 0 || profiles.some((profile) => profile.passkeyCredential !== void 0)) throw new Error("recovery Email OTP publication does not match the committed projection");
130
- const localAuthority = parseEmailOtpWalletAuthAuthority(initialMethod.authority);
131
- if (!localAuthority || localAuthority.walletId !== projection.walletId || localAuthority.factor.provider !== "google" || localAuthority.factor.providerUserId !== projection.target.providerSubject || localAuthority.verifier.emailHashHex !== projection.target.emailHashHex) throw new Error("recovery Email OTP factor does not match the committed projection");
132
- }
133
- function shouldDeletePublishedPendingWalletRegistrationCommit(pending) {
134
- switch (pending.operation) {
135
- case "near_provisioning": return true;
136
- case "registration_activate": return pending.signerPlanKind !== "near_ed25519";
137
- }
138
- }
139
- function assertCredentialFreeRegistrationSessionProjectionMatchesExisting(input) {
140
- if (input.incoming.walletId !== input.existing.walletId || input.incoming.authorityId !== input.existing.authorityId || input.incoming.authMethodId !== input.existing.authMethodId || input.incoming.authorizationId !== input.existing.authorizationId || input.incoming.quotaId !== input.existing.quotaId || input.incoming.issuedAtMs !== input.existing.issuedAtMs || input.incoming.expiresAtMs !== input.existing.expiresAtMs || input.incoming.expiresAtMs <= Date.now() || input.incoming.authorityRevocationEpoch !== input.existing.authorityRevocationEpoch || !walletSessionPreservesCapabilities(input.existing, input.incoming)) throw new Error("Credential-free registration projection changed immutable session identity");
141
- }
142
- const DEFAULT_NONCE_LANE_LOCK_TTL_MS = 5e3;
143
- const DEFAULT_NONCE_LANE_LOCK_WAIT_TIMEOUT_MS = 3e3;
144
- const DEFAULT_NONCE_LANE_LOCK_POLL_MS = 25;
145
- const LAST_PROFILE_STATE_APP_STATE_KEY = "lastProfileState";
146
- const WALLET_REGISTRATION_FINALIZE_STORES = [
147
- SEAMS_WALLET_STORES.appState,
148
- SEAMS_WALLET_STORES.wallets,
149
- SEAMS_WALLET_STORES.walletAuthMethods,
150
- SEAMS_WALLET_STORES.walletSigners,
151
- SEAMS_WALLET_STORES.nearAccountProjections,
152
- SEAMS_WALLET_STORES.signerOpsOutbox,
153
- SEAMS_WALLET_STORES.keyMaterial
154
- ];
155
- const WALLET_REGISTRATION_PUBLICATION_STORES = [
156
- SEAMS_WALLET_STORES.appState,
157
- SEAMS_WALLET_STORES.wallets,
158
- SEAMS_WALLET_STORES.walletAuthMethods,
159
- SEAMS_WALLET_STORES.walletAuthorities,
160
- SEAMS_WALLET_STORES.walletSelections,
161
- SEAMS_WALLET_STORES.walletSigners,
162
- SEAMS_WALLET_STORES.nearAccountProjections,
163
- SEAMS_WALLET_STORES.signerOpsOutbox,
164
- SEAMS_WALLET_STORES.keyMaterial,
165
- SEAMS_WALLET_STORES.walletSessionAuthorizations,
166
- SEAMS_WALLET_STORES.ecdsaCapabilityManifests,
167
- SEAMS_WALLET_STORES.ecdsaCurrentCapabilityManifests,
168
- SEAMS_WALLET_STORES.ecdsaRoleLocalMaterial,
169
- SEAMS_WALLET_STORES.ecdsaMaterialSealingKeys
170
- ];
171
- const WALLET_RECOVERY_PUBLICATION_STORES = [
172
- SEAMS_WALLET_STORES.appState,
173
- SEAMS_WALLET_STORES.wallets,
174
- SEAMS_WALLET_STORES.walletAuthMethods,
175
- SEAMS_WALLET_STORES.walletAuthorities,
176
- SEAMS_WALLET_STORES.walletSelections,
177
- SEAMS_WALLET_STORES.walletSigners,
178
- SEAMS_WALLET_STORES.nearAccountProjections,
179
- SEAMS_WALLET_STORES.signerOpsOutbox,
180
- SEAMS_WALLET_STORES.keyMaterial,
181
- SEAMS_WALLET_STORES.ecdsaCapabilityManifests,
182
- SEAMS_WALLET_STORES.ecdsaCurrentCapabilityManifests,
183
- SEAMS_WALLET_STORES.ecdsaRoleLocalMaterial,
184
- SEAMS_WALLET_STORES.ecdsaMaterialSealingKeys,
185
- SEAMS_WALLET_STORES.ecdsaClientPresignatures
186
- ];
187
- const DEFAULT_WALLET_RP_ID = "local";
188
- function requireWebAuthnRpId(value) {
189
- const parsed = parseWebAuthnRpId(value);
190
- if (!parsed.ok) throw new Error(parsed.error.message);
191
- return parsed.value;
192
- }
193
- const CHAIN_ACCOUNT_PROJECTION_SIGNER_SLOT = 0;
194
- var SeamsWalletDBConstraintError = class extends Error {
195
- constructor(code, message, details) {
196
- super(message);
197
- this.name = "SeamsWalletDBConstraintError";
198
- this.code = code;
199
- this.details = details;
200
- }
201
- };
202
- function sleep(ms) {
203
- return new Promise((resolve) => setTimeout(resolve, ms));
204
- }
205
- function createRandomToken(prefix) {
206
- const bytes = new Uint8Array(16);
207
- crypto.getRandomValues(bytes);
208
- return `${prefix}-${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
209
- }
210
- function nonceLeaseWalletId(record) {
211
- if (record.family === "near") return record.walletId;
212
- return record.accountId;
213
- }
214
- function nonceLeaseNearAccountId(record) {
215
- return record.family === "near" ? record.nearAccountId : "";
216
- }
217
- function nonceLeaseRow(record) {
218
- const leaseId = normalizeTrimmedString(record.leaseId || "");
219
- const laneKey = normalizeTrimmedString(record.laneKey || "");
220
- const walletId = normalizeTrimmedString(nonceLeaseWalletId(record) || "");
221
- const nearAccountId = normalizeTrimmedString(nonceLeaseNearAccountId(record) || "");
222
- if (!leaseId || !laneKey || !walletId) throw new Error("[SeamsWalletDB] nonce lease requires leaseId, laneKey, and wallet identity");
223
- return {
224
- lease_id: leaseId,
225
- lane_key: laneKey,
226
- wallet_id: walletId,
227
- ...nearAccountId ? { near_account_id: nearAccountId } : {},
228
- state: record.state,
229
- expires_at_ms: Math.floor(Number(record.expiresAtMs)),
230
- record
231
- };
232
- }
233
- function parseStoredNonEmptyString(value) {
234
- return typeof value === "string" && value.length > 0 && value.trim() === value ? value : null;
235
- }
236
- function parseNonceLaneLockRow(value) {
237
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
238
- const lockKey = parseStoredNonEmptyString(Reflect.get(value, "lock_key"));
239
- const ownerId = parseStoredNonEmptyString(Reflect.get(value, "owner_id"));
240
- const fencingToken = parseStoredNonEmptyString(Reflect.get(value, "fencing_token"));
241
- const acquiredAtMs = Reflect.get(value, "acquired_at_ms");
242
- const expiresAtMs = Reflect.get(value, "expires_at_ms");
243
- const updatedAtMs = Reflect.get(value, "updated_at_ms");
244
- if (!lockKey || !ownerId || !fencingToken || !Number.isSafeInteger(acquiredAtMs) || acquiredAtMs < 0 || !Number.isSafeInteger(expiresAtMs) || expiresAtMs < 0 || !Number.isSafeInteger(updatedAtMs) || updatedAtMs < 0) return null;
245
- return {
246
- lock_key: lockKey,
247
- owner_id: ownerId,
248
- fencing_token: fencingToken,
249
- acquired_at_ms: acquiredAtMs,
250
- expires_at_ms: expiresAtMs,
251
- updated_at_ms: updatedAtMs
252
- };
253
- }
254
- function parseStoredThresholdEcdsaChainTarget(value) {
255
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
256
- try {
257
- return thresholdEcdsaChainTargetFromRequest({
258
- kind: Reflect.get(value, "kind"),
259
- namespace: Reflect.get(value, "namespace"),
260
- chainId: Reflect.get(value, "chainId"),
261
- networkSlug: Reflect.get(value, "networkSlug")
262
- });
263
- } catch {
264
- return null;
265
- }
266
- }
267
- function parseNonceLeaseRecord(value) {
268
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
269
- const version = Reflect.get(value, "v");
270
- const leaseId = parseStoredNonEmptyString(Reflect.get(value, "leaseId"));
271
- const laneKey = parseStoredNonEmptyString(Reflect.get(value, "laneKey"));
272
- const networkKey = parseStoredNonEmptyString(Reflect.get(value, "networkKey"));
273
- const nonce = parseStoredNonEmptyString(Reflect.get(value, "nonce"));
274
- const operationId = parseStoredNonEmptyString(Reflect.get(value, "operationId"));
275
- const operationFingerprint = parseStoredNonEmptyString(Reflect.get(value, "operationFingerprint"));
276
- const reservedAtMs = Reflect.get(value, "reservedAtMs");
277
- const expiresAtMs = Reflect.get(value, "expiresAtMs");
278
- const updatedAtMs = Reflect.get(value, "updatedAtMs");
279
- const state = Reflect.get(value, "state");
280
- if (version !== 1 || !leaseId || !laneKey || !networkKey || !nonce || !operationId || !operationFingerprint || !Number.isSafeInteger(reservedAtMs) || !Number.isSafeInteger(expiresAtMs) || !Number.isSafeInteger(updatedAtMs) || state !== "reserved" && state !== "signed" && state !== "broadcast_accepted") return null;
281
- const txHash = Reflect.get(value, "txHash");
282
- if (state === "broadcast_accepted" && !parseStoredNonEmptyString(txHash)) return null;
283
- if (state !== "broadcast_accepted" && txHash !== void 0) return null;
284
- const runtimeId = Reflect.get(value, "runtimeId");
285
- const fencingToken = Reflect.get(value, "fencingToken");
286
- const batchId = Reflect.get(value, "batchId");
287
- const txIndex = Reflect.get(value, "txIndex");
288
- if (runtimeId !== void 0 && !parseStoredNonEmptyString(runtimeId) || fencingToken !== void 0 && !parseStoredNonEmptyString(fencingToken) || batchId !== void 0 && !parseStoredNonEmptyString(batchId) || txIndex !== void 0 && !Number.isSafeInteger(txIndex)) return null;
289
- const family = Reflect.get(value, "family");
290
- if (family === "near") {
291
- const walletId = parseStoredNonEmptyString(Reflect.get(value, "walletId"));
292
- const nearAccountId = parseStoredNonEmptyString(Reflect.get(value, "nearAccountId"));
293
- const publicKey = parseStoredNonEmptyString(Reflect.get(value, "publicKey"));
294
- if (!walletId || !nearAccountId || !publicKey) return null;
295
- return {
296
- v: 1,
297
- leaseId,
298
- laneKey,
299
- networkKey,
300
- nonce,
301
- operationId,
302
- operationFingerprint,
303
- reservedAtMs,
304
- expiresAtMs,
305
- updatedAtMs,
306
- family: "near",
307
- walletId,
308
- nearAccountId,
309
- publicKey,
310
- state,
311
- ...runtimeId === void 0 ? {} : { runtimeId },
312
- ...fencingToken === void 0 ? {} : { fencingToken },
313
- ...batchId === void 0 ? {} : { batchId },
314
- ...txIndex === void 0 ? {} : { txIndex },
315
- ...state === "broadcast_accepted" ? { txHash } : {}
316
- };
317
- }
318
- if (family !== "evm") return null;
319
- const chainTarget = parseStoredThresholdEcdsaChainTarget(Reflect.get(value, "chainTarget"));
320
- const sender = parseStoredNonEmptyString(Reflect.get(value, "sender"));
321
- const accountId = parseStoredNonEmptyString(Reflect.get(value, "accountId"));
322
- if (!chainTarget || !sender || !accountId) return null;
323
- const nonceKey = Reflect.get(value, "nonceKey");
324
- if (nonceKey !== void 0 && !parseStoredNonEmptyString(nonceKey)) return null;
325
- return {
326
- v: 1,
327
- leaseId,
328
- laneKey,
329
- networkKey,
330
- nonce,
331
- operationId,
332
- operationFingerprint,
333
- reservedAtMs,
334
- expiresAtMs,
335
- updatedAtMs,
336
- family: "evm",
337
- chainTarget,
338
- sender,
339
- accountId,
340
- state,
341
- ...runtimeId === void 0 ? {} : { runtimeId },
342
- ...fencingToken === void 0 ? {} : { fencingToken },
343
- ...batchId === void 0 ? {} : { batchId },
344
- ...txIndex === void 0 ? {} : { txIndex },
345
- ...nonceKey === void 0 ? {} : { nonceKey },
346
- ...state === "broadcast_accepted" ? { txHash } : {}
347
- };
348
- }
349
- function parseNonceLeaseRow(value) {
350
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
351
- const record = parseNonceLeaseRecord(Reflect.get(value, "record"));
352
- if (!record) return null;
353
- if (Reflect.get(value, "lease_id") !== record.leaseId) return null;
354
- if (Reflect.get(value, "lane_key") !== record.laneKey) return null;
355
- if (Reflect.get(value, "wallet_id") !== nonceLeaseWalletId(record)) return null;
356
- if ((Reflect.get(value, "near_account_id") || "") !== nonceLeaseNearAccountId(record)) return null;
357
- if (Reflect.get(value, "state") !== record.state) return null;
358
- if (Reflect.get(value, "expires_at_ms") !== Math.floor(Number(record.expiresAtMs))) return null;
359
- return record;
360
- }
361
- function keyRangeUpperBound(value) {
362
- return IDBKeyRange.upperBound(value);
363
- }
364
- async function deleteRowsByIndex(args) {
365
- let cursor = await args.store.index(args.indexName).openCursor(args.key);
366
- while (cursor) {
367
- await cursor.delete();
368
- cursor = await cursor.continue();
369
- }
370
- }
371
- function scopedLastProfileStateAppStateKey(scope) {
372
- const normalized = normalizeLastUserScope(scope);
373
- return normalized ? `${LAST_PROFILE_STATE_APP_STATE_KEY}::${normalized}` : LAST_PROFILE_STATE_APP_STATE_KEY;
374
- }
375
- function chainAccountProjectionId(args) {
376
- return `${args.chainIdKey}\0${args.accountAddress}`;
377
- }
378
- function walletSignerId(args) {
379
- return [
380
- args.chainIdKey,
381
- args.accountAddress,
382
- args.signerId
383
- ].join("\0");
384
- }
385
- function signerChainTargetKey(args) {
386
- return [args.chainIdKey, args.accountAddress].join("\0");
387
- }
388
- function normalizeEcdsaChainTargetKey(value) {
389
- if (value === null || typeof value !== "object" || Array.isArray(value)) return "";
390
- const kind = normalizeTrimmedString(Reflect.get(value, "kind") || "");
391
- const chainId = Number(Reflect.get(value, "chainId"));
392
- if (!Number.isSafeInteger(chainId) || chainId <= 0) return "";
393
- if (kind === "evm") {
394
- if (normalizeTrimmedString(Reflect.get(value, "namespace") || "") !== "eip155") return "";
395
- return toIndexedDbChainTargetKey({
396
- kind: "evm",
397
- namespace: "eip155",
398
- chainId,
399
- networkSlug: normalizeTrimmedString(Reflect.get(value, "networkSlug") || "")
400
- });
401
- }
402
- if (kind === "tempo") return toIndexedDbChainTargetKey({
403
- kind: "tempo",
404
- chainId,
405
- networkSlug: normalizeTrimmedString(Reflect.get(value, "networkSlug") || "")
406
- });
407
- return "";
408
- }
409
- function walletSignerScalarMirrors(record) {
410
- if (record.signerKind === SIGNER_KINDS.thresholdEcdsa) {
411
- const metadata = record.metadata || {};
412
- const keyHandle = normalizeTrimmedString(metadata.keyHandle || "");
413
- const ecdsaThresholdKeyId = normalizeTrimmedString(metadata.ecdsaThresholdKeyId || "");
414
- const thresholdOwnerAddress = normalizeIndexedDbAccountAddress(metadata.thresholdOwnerAddress || "");
415
- const chainTargetKey = normalizeEcdsaChainTargetKey(metadata.chainTarget);
416
- if (!keyHandle || !ecdsaThresholdKeyId || !thresholdOwnerAddress || !chainTargetKey) throw new Error("[SeamsWalletDB] threshold ECDSA signer requires keyHandle, ecdsaThresholdKeyId, thresholdOwnerAddress, and chainTarget");
417
- return {
418
- chainTargetKey,
419
- keyHandle,
420
- ecdsaThresholdKeyId,
421
- thresholdOwnerAddress
422
- };
423
- }
424
- const signerSlot = Number(record.signerSlot);
425
- if (!Number.isSafeInteger(signerSlot) || signerSlot < 1) throw new Error("[SeamsWalletDB] Ed25519 signer requires a positive signerSlot");
426
- const nearEd25519SigningKeyId = normalizeTrimmedString(record.metadata?.nearEd25519SigningKeyId || "");
427
- if (!nearEd25519SigningKeyId) throw new Error("[SeamsWalletDB] Ed25519 signer requires nearEd25519SigningKeyId");
428
- return {
429
- chainTargetKey: signerChainTargetKey({
430
- chainIdKey: record.chainIdKey,
431
- accountAddress: record.accountAddress
432
- }),
433
- nearSignerSlot: signerSlot,
434
- nearEd25519SigningKeyId
435
- };
436
- }
437
- function shouldWriteNearAccountProjection(args) {
438
- return args.accountModel === "near-native" || args.chainIdKey.startsWith("near:");
439
- }
440
- function makeConstraintError(code, message, details) {
441
- return new SeamsWalletDBConstraintError(code, message, details);
442
- }
443
- function profileRow(input, existing) {
444
- const profileId = normalizeTrimmedString(input.profileId || "");
445
- if (!profileId) throw new Error("[SeamsWalletDB] profileId is required");
446
- const now = Date.now();
447
- const passkeyCredential = input.passkeyCredential?.rawId ? input.passkeyCredential : existing?.passkeyCredential;
448
- const nearProvisioning = existing?.nearProvisioning?.status === "near_ready" && input.nearProvisioning?.status !== "near_ready" ? existing.nearProvisioning : input.nearProvisioning ?? existing?.nearProvisioning;
449
- const record = {
450
- profileId,
451
- defaultSignerSlot: input.defaultSignerSlot ?? existing?.defaultSignerSlot ?? 1,
452
- ...passkeyCredential ? { passkeyCredential } : {},
453
- preferences: input.preferences ?? existing?.preferences,
454
- ...nearProvisioning ? { nearProvisioning } : {},
455
- createdAt: existing?.createdAt ?? now,
456
- updatedAt: now
457
- };
458
- return {
459
- wallet_id: profileId,
460
- rp_id: DEFAULT_WALLET_RP_ID,
461
- status: "active",
462
- created_at: record.createdAt,
463
- updated_at: record.updatedAt,
464
- record
465
- };
466
- }
467
- function profileRowFromRecord(record) {
468
- return {
469
- wallet_id: record.profileId,
470
- rp_id: DEFAULT_WALLET_RP_ID,
471
- status: "active",
472
- created_at: record.createdAt,
473
- updated_at: record.updatedAt,
474
- record
475
- };
476
- }
477
- function profilePasskeyCredentialsMatch(left, right) {
478
- if (left === void 0 || right === void 0) return left === right;
479
- return left.id === right.id && left.rawId === right.rawId;
480
- }
481
- function userPreferencesMatch(left, right) {
482
- if (left === void 0 || right === void 0) return left === right;
483
- return left.useRelayer === right.useRelayer && left.useNetwork === right.useNetwork && left.confirmationConfig.uiMode === right.confirmationConfig.uiMode && left.confirmationConfig.behavior === right.confirmationConfig.behavior && left.confirmationConfig.autoProceedDelay === right.confirmationConfig.autoProceedDelay;
484
- }
485
- function nearProvisioningStatesMatch(left, right) {
486
- if (left === void 0 || right === void 0) return left === right;
487
- if (left.status !== right.status || left.updatedAtMs !== right.updatedAtMs) return false;
488
- switch (left.status) {
489
- case "near_pending":
490
- case "near_provisioning": return true;
491
- case "near_ready": return right.status === "near_ready" && left.nearAccountId === right.nearAccountId;
492
- case "near_failed_retryable": return right.status === "near_failed_retryable" && left.error === right.error && left.errorCode === right.errorCode;
493
- default: return assertNever(left);
494
- }
495
- }
496
- function profileRecordsMatch(left, right) {
497
- return left.profileId === right.profileId && left.defaultSignerSlot === right.defaultSignerSlot && profilePasskeyCredentialsMatch(left.passkeyCredential, right.passkeyCredential) && userPreferencesMatch(left.preferences, right.preferences) && nearProvisioningStatesMatch(left.nearProvisioning, right.nearProvisioning) && left.createdAt === right.createdAt && left.updatedAt === right.updatedAt;
498
- }
499
- function profileRowsMatch(left, right) {
500
- return left.wallet_id === right.wallet_id && left.rp_id === right.rp_id && left.status === right.status && left.created_at === right.created_at && left.updated_at === right.updated_at && profileRecordsMatch(left.record, right.record);
501
- }
502
- function profileAuthenticatorTransportsMatch(left, right) {
503
- if (left === void 0 || right === void 0) return left === right;
504
- if (left.length !== right.length) return false;
505
- return left.every((value, index) => value === right[index]);
506
- }
507
- function profileAuthenticatorRecordsMatch(left, right) {
508
- return left.profileId === right.profileId && left.signerSlot === right.signerSlot && left.credentialId === right.credentialId && canonicalBytesMatch(left.credentialPublicKey, right.credentialPublicKey) && profileAuthenticatorTransportsMatch(left.transports, right.transports) && left.name === right.name && left.registered === right.registered && left.syncedAt === right.syncedAt;
509
- }
510
- function localWalletAuthMethodRecordsMatch(left, right) {
511
- if (left.version !== right.version || left.kind !== right.kind || left.status !== right.status || left.localStatus !== right.localStatus || left.walletId !== right.walletId || left.createdAtMs !== right.createdAtMs || left.updatedAtMs !== right.updatedAtMs) return false;
512
- switch (left.kind) {
513
- case "passkey": return right.kind === "passkey" && left.rpId === right.rpId && left.credentialIdB64u === right.credentialIdB64u && left.credentialPublicKeyB64u === right.credentialPublicKeyB64u && left.counter === right.counter;
514
- case "email_otp": return right.kind === "email_otp" && left.emailHashHex === right.emailHashHex && left.registrationAuthorityId === right.registrationAuthorityId && walletAuthAuthoritiesMatch(left.authority, right.authority);
515
- default: return assertNever(left);
516
- }
517
- }
518
- function localWalletAuthMethodRowsMatch(left, right) {
519
- if (left.wallet_auth_method_id !== right.wallet_auth_method_id || left.wallet_id !== right.wallet_id || left.kind !== right.kind || left.auth_method !== right.auth_method || left.rp_id !== right.rp_id || left.auth_identifier_key !== right.auth_identifier_key || left.status !== right.status || left.updated_at !== right.updated_at || !localWalletAuthMethodRecordsMatch(left.record, right.record)) return false;
520
- switch (left.kind) {
521
- case "passkey": return right.kind === "passkey" && left.credential_id_b64u === right.credential_id_b64u && left.credential_public_key_b64u === right.credential_public_key_b64u && left.signer_slot === right.signer_slot && profileAuthenticatorRecordsMatch(left.authenticator, right.authenticator);
522
- case "email_otp": return right.kind === "email_otp" && left.email_hash_hex === right.email_hash_hex && left.challenge_id === right.challenge_id;
523
- default: return assertNever(left);
524
- }
525
- }
526
- function accountSignerRollbackMetadataBaseline(metadata) {
527
- if (metadata === void 0) return { kind: "account_signer_rollback_metadata_absent_v1" };
528
- return {
529
- kind: "account_signer_rollback_metadata_json_v1",
530
- json: JSON.stringify(metadata)
531
- };
532
- }
533
- function accountSignerRollbackMetadataMatchesBaseline(metadata, baseline) {
534
- switch (baseline.kind) {
535
- case "account_signer_rollback_metadata_absent_v1": return metadata === void 0;
536
- case "account_signer_rollback_metadata_json_v1": return metadata !== void 0 && JSON.stringify(metadata) === baseline.json;
537
- default: return assertNever(baseline);
538
- }
539
- }
540
- function keyMaterialRollbackPayloadBaseline(payload) {
541
- if (payload === void 0) return { kind: "key_material_rollback_payload_absent_v1" };
542
- return {
543
- kind: "key_material_rollback_payload_json_v1",
544
- json: JSON.stringify(payload)
545
- };
546
- }
547
- function keyMaterialRollbackPayloadMatchesBaseline(payload, baseline) {
548
- switch (baseline.kind) {
549
- case "key_material_rollback_payload_absent_v1": return payload === void 0;
550
- case "key_material_rollback_payload_json_v1": return payload !== void 0 && JSON.stringify(payload) === baseline.json;
551
- default: return assertNever(baseline);
552
- }
553
- }
554
- function accountSignerRollbackRecordsMatch(current, committed, metadataBaseline) {
555
- return current.profileId === committed.profileId && current.chainIdKey === committed.chainIdKey && current.accountAddress === committed.accountAddress && current.signerId === committed.signerId && current.signerSlot === committed.signerSlot && current.signerType === committed.signerType && current.signerKind === committed.signerKind && current.signerAuthMethod === committed.signerAuthMethod && current.signerSource === committed.signerSource && current.status === committed.status && current.addedAt === committed.addedAt && current.updatedAt === committed.updatedAt && current.removedAt === committed.removedAt && current.revocationReason === committed.revocationReason && accountSignerRollbackMetadataMatchesBaseline(current.metadata, metadataBaseline);
556
- }
557
- function keyMaterialRollbackRecordsMatch(current, committed, payloadBaseline) {
558
- return current.profileId === committed.profileId && current.signerSlot === committed.signerSlot && current.chainIdKey === committed.chainIdKey && current.accountAddress === committed.accountAddress && current.keyKind === committed.keyKind && current.algorithm === committed.algorithm && current.publicKey === committed.publicKey && current.signerId === committed.signerId && current.wrapKeySalt === committed.wrapKeySalt && keyMaterialRollbackPayloadMatchesBaseline(current.payload, payloadBaseline) && keyMaterialPayloadEnvelopesMatch(current.payloadEnvelope, committed.payloadEnvelope) && current.timestamp === committed.timestamp && current.schemaVersion === committed.schemaVersion;
559
- }
560
- function keyMaterialPayloadEnvelopesMatch(left, right) {
561
- if (left === void 0 || right === void 0) return left === right;
562
- return left.encVersion === right.encVersion && left.alg === right.alg && left.nonce === right.nonce && left.ciphertext === right.ciphertext && left.tag === right.tag && left.aad.profileId === right.aad.profileId && left.aad.signerSlot === right.aad.signerSlot && left.aad.chainIdKey === right.aad.chainIdKey && left.aad.accountAddress === right.aad.accountAddress && left.aad.keyKind === right.aad.keyKind && left.aad.schemaVersion === right.aad.schemaVersion && left.aad.signerId === right.aad.signerId;
563
- }
564
- function lastProfileStatesMatch(left, right) {
565
- return left.profileId === right.profileId && left.activeSignerSlot === right.activeSignerSlot && left.scope === right.scope;
566
- }
567
- function parseStoredProfilePreferences(value) {
568
- if (value === void 0) return void 0;
569
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
570
- const useRelayer = Reflect.get(value, "useRelayer");
571
- const useNetwork = Reflect.get(value, "useNetwork");
572
- const confirmationConfig = Reflect.get(value, "confirmationConfig");
573
- if (typeof useRelayer !== "boolean" || useNetwork !== "testnet" && useNetwork !== "mainnet" || confirmationConfig === null || typeof confirmationConfig !== "object" || Array.isArray(confirmationConfig)) return null;
574
- const uiMode = Reflect.get(confirmationConfig, "uiMode");
575
- const behavior = Reflect.get(confirmationConfig, "behavior");
576
- const autoProceedDelay = Reflect.get(confirmationConfig, "autoProceedDelay");
577
- const parsedAutoProceedDelay = autoProceedDelay === void 0 ? void 0 : typeof autoProceedDelay === "number" && Number.isSafeInteger(autoProceedDelay) && autoProceedDelay >= 0 ? autoProceedDelay : null;
578
- if (uiMode !== "none" && uiMode !== "modal" && uiMode !== "drawer" || behavior !== "requireClick" && behavior !== "skipClick" || parsedAutoProceedDelay === null) return null;
579
- return {
580
- useRelayer,
581
- useNetwork,
582
- confirmationConfig: {
583
- uiMode,
584
- behavior,
585
- ...parsedAutoProceedDelay === void 0 ? {} : { autoProceedDelay: parsedAutoProceedDelay }
586
- }
587
- };
588
- }
589
- function parseStoredProfileRecord(value) {
590
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
591
- const profileIdRaw = Reflect.get(value, "profileId");
592
- const profileId = parseWalletId(profileIdRaw);
593
- const defaultSignerSlot = Reflect.get(value, "defaultSignerSlot");
594
- const createdAt = Reflect.get(value, "createdAt");
595
- const updatedAt = Reflect.get(value, "updatedAt");
596
- if (!profileId.ok || profileId.value !== profileIdRaw || !Number.isSafeInteger(defaultSignerSlot) || Number(defaultSignerSlot) < 1 || !Number.isSafeInteger(createdAt) || Number(createdAt) < 0 || !Number.isSafeInteger(updatedAt) || Number(updatedAt) < 0) return null;
597
- const passkeyCredentialRaw = Reflect.get(value, "passkeyCredential");
598
- let passkeyCredential;
599
- if (passkeyCredentialRaw !== void 0) {
600
- if (passkeyCredentialRaw === null || typeof passkeyCredentialRaw !== "object" || Array.isArray(passkeyCredentialRaw)) return null;
601
- const id = Reflect.get(passkeyCredentialRaw, "id");
602
- const rawId = Reflect.get(passkeyCredentialRaw, "rawId");
603
- if (typeof id !== "string" || typeof rawId !== "string" || !id || !rawId || id.trim() !== id || rawId.trim() !== rawId) return null;
604
- passkeyCredential = {
605
- id,
606
- rawId
607
- };
608
- }
609
- const preferences = parseStoredProfilePreferences(Reflect.get(value, "preferences"));
610
- if (preferences === null) return null;
611
- const nearProvisioningRaw = Reflect.get(value, "nearProvisioning");
612
- let nearProvisioning;
613
- if (nearProvisioningRaw !== void 0) {
614
- const parsedNearProvisioning = parseNearProvisioningState(nearProvisioningRaw);
615
- if (parsedNearProvisioning === null) return null;
616
- nearProvisioning = parsedNearProvisioning;
617
- }
618
- return {
619
- profileId: profileId.value,
620
- defaultSignerSlot: Number(defaultSignerSlot),
621
- ...passkeyCredential === void 0 ? {} : { passkeyCredential },
622
- ...preferences === void 0 ? {} : { preferences },
623
- ...nearProvisioning === void 0 ? {} : { nearProvisioning },
624
- createdAt: Number(createdAt),
625
- updatedAt: Number(updatedAt)
626
- };
627
- }
628
- function parseProfileRow(value) {
629
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
630
- const record = parseStoredProfileRecord(Reflect.get(value, "record"));
631
- if (!record) return null;
632
- if (Reflect.get(value, "wallet_id") !== record.profileId) return null;
633
- if (Reflect.get(value, "created_at") !== record.createdAt) return null;
634
- if (Reflect.get(value, "updated_at") !== record.updatedAt) return null;
635
- return record;
636
- }
637
- function parseLocalAuthorityPendingProfileProjectionV1(value) {
638
- if (value === null || typeof value !== "object" || Array.isArray(value) || Reflect.get(value, "kind") !== "local_authority_pending_profile_projection_v1") return null;
639
- const profile = parseProfileStorageRowV1(Reflect.get(value, "profile"));
640
- const authenticatorRaw = Reflect.get(value, "authenticator");
641
- const localAuthMethodRaw = Reflect.get(value, "localAuthMethod");
642
- const authenticator = authenticatorRaw === null ? null : parseWalletAuthMethodStorageRow(authenticatorRaw);
643
- const localAuthMethod = localAuthMethodRaw === null ? null : parseWalletAuthMethodStorageRow(localAuthMethodRaw);
644
- if (!profile || authenticatorRaw !== null && (!authenticator || authenticator.kind !== "passkey" || authenticator.status !== "active") || localAuthMethodRaw !== null && (!localAuthMethod || localAuthMethod.kind !== "email_otp" || localAuthMethod.status !== "active")) return null;
645
- const authorityId = Reflect.get(value, "authorityId");
646
- const walletId = Reflect.get(value, "walletId");
647
- const authMethodId = Reflect.get(value, "authMethodId");
648
- if (typeof authorityId !== "string" || typeof walletId !== "string" || typeof authMethodId !== "string" || !authorityId || !walletId || !authMethodId || authorityId.trim() !== authorityId || walletId.trim() !== walletId || authMethodId.trim() !== authMethodId || profile.wallet_id !== walletId || authenticator !== null && authenticator.wallet_id !== walletId || localAuthMethod !== null && localAuthMethod.wallet_id !== walletId) return null;
649
- return {
650
- kind: "local_authority_pending_profile_projection_v1",
651
- authorityId,
652
- walletId,
653
- authMethodId,
654
- profile,
655
- authenticator: authenticator?.kind === "passkey" ? authenticator : null,
656
- localAuthMethod: localAuthMethod?.kind === "email_otp" ? localAuthMethod : null
657
- };
658
- }
659
- function parseProfileStorageRowV1(value) {
660
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
661
- const status = Reflect.get(value, "status");
662
- const rpId = Reflect.get(value, "rp_id");
663
- if (status !== "active" || typeof rpId !== "string") return null;
664
- const record = parseProfileRow(value);
665
- if (!record || Reflect.get(value, "wallet_id") !== record.profileId) return null;
666
- return {
667
- wallet_id: record.profileId,
668
- rp_id: rpId,
669
- status: "active",
670
- created_at: record.createdAt,
671
- updated_at: record.updatedAt,
672
- record
673
- };
674
- }
675
- function walletAuthMethodIdentifier(record) {
676
- switch (record.kind) {
677
- case "passkey": return normalizeTrimmedString(record.credentialIdB64u || "");
678
- case "email_otp": return normalizeTrimmedString(record.emailHashHex || "");
679
- default: {
680
- const _exhaustive = record;
681
- throw new Error(`[SeamsWalletDB] Unsupported auth-method binding: ${String(_exhaustive)}`);
682
- }
683
- }
684
- }
685
- function walletAuthMethodId(record) {
686
- if (record.kind === "passkey") return [
687
- normalizeTrimmedString(record.walletId || ""),
688
- record.kind,
689
- normalizeTrimmedString(record.rpId || ""),
690
- walletAuthMethodIdentifier(record)
691
- ].join("\0");
692
- return [
693
- normalizeTrimmedString(record.walletId || ""),
694
- record.kind,
695
- walletAuthMethodIdentifier(record)
696
- ].join("\0");
697
- }
698
- function walletAuthMethodFields(record) {
699
- if (record.version !== "wallet_auth_method_v1") throw new Error("[SeamsWalletDB] auth-method binding version is invalid");
700
- const walletId = normalizeTrimmedString(record.walletId || "");
701
- const rpId = record.kind === "passkey" ? normalizeTrimmedString(record.rpId || "") : "";
702
- const authIdentifierKey = walletAuthMethodIdentifier(record);
703
- const createdAtMs = Math.floor(Number(record.createdAtMs));
704
- const updatedAtMs = Math.floor(Number(record.updatedAtMs));
705
- if (!walletId || !authIdentifierKey || record.kind === "passkey" && !rpId) throw new Error("[SeamsWalletDB] auth-method binding requires walletId and branch identity");
706
- if (record.status !== "active" && record.status !== "revoked") throw new Error("[SeamsWalletDB] auth-method binding status is invalid");
707
- if (record.localStatus !== "synced" && record.localStatus !== "pending") throw new Error("[SeamsWalletDB] auth-method binding localStatus is invalid");
708
- if (!Number.isSafeInteger(createdAtMs)) throw new Error("[SeamsWalletDB] auth-method binding createdAtMs is invalid");
709
- if (!Number.isSafeInteger(updatedAtMs)) throw new Error("[SeamsWalletDB] auth-method binding updatedAtMs is invalid");
710
- if (record.kind === "passkey") {
711
- if (record.emailHashHex != null) throw new Error("[SeamsWalletDB] passkey auth-method binding has Email OTP fields");
712
- if (!normalizeTrimmedString(record.credentialPublicKeyB64u || "")) throw new Error("[SeamsWalletDB] passkey auth-method binding requires credential public key");
713
- if (!Number.isSafeInteger(record.counter) || record.counter < 0) throw new Error("[SeamsWalletDB] passkey auth-method binding counter is invalid");
714
- }
715
- if (record.kind === "email_otp") {
716
- if (record.credentialIdB64u != null || record.credentialPublicKeyB64u != null || record.counter != null || record.rpId != null) throw new Error("[SeamsWalletDB] Email OTP auth-method binding has passkey fields");
717
- if (!normalizeTrimmedString(record.registrationAuthorityId || "")) throw new Error("[SeamsWalletDB] Email OTP auth-method binding requires registrationAuthorityId");
718
- if (!record.authority) throw new Error("[SeamsWalletDB] Email OTP auth-method binding requires authority");
719
- const authority = parseEmailOtpWalletAuthAuthority(record.authority);
720
- if (!authority || authority.walletId !== record.walletId || authority.verifier.emailHashHex !== record.emailHashHex || !walletAuthAuthoritiesMatch(authority, record.authority)) throw new Error("[SeamsWalletDB] Email OTP auth-method authority binding is invalid");
721
- }
722
- return {
723
- wallet_auth_method_id: walletAuthMethodId(record),
724
- wallet_id: walletId,
725
- kind: record.kind,
726
- auth_method: record.kind,
727
- rp_id: rpId,
728
- auth_identifier_key: authIdentifierKey,
729
- status: record.status,
730
- updated_at: updatedAtMs,
731
- record
732
- };
733
- }
734
- function isoTimestampFromMs(ms) {
735
- return new Date(ms).toISOString();
736
- }
737
- function timestampMsFromIso(value, fallbackMs) {
738
- const parsed = Date.parse(value);
739
- return Number.isSafeInteger(parsed) ? parsed : fallbackMs;
740
- }
741
- function normalizeAuthenticatorRecord(record) {
742
- const profileId = normalizeTrimmedString(record.profileId || "");
743
- const credentialId = normalizeTrimmedString(record.credentialId || "");
744
- const signerSlot = Number(record.signerSlot);
745
- if (!profileId || !credentialId) throw new Error("[SeamsWalletDB] profileId and credentialId are required for authenticators");
746
- if (!Number.isSafeInteger(signerSlot) || signerSlot < 1) throw new Error("[SeamsWalletDB] authenticator signerSlot must be an integer >= 1");
747
- const credentialPublicKey = record.credentialPublicKey;
748
- if (!(credentialPublicKey instanceof Uint8Array) || credentialPublicKey.byteLength === 0) throw new Error("[SeamsWalletDB] authenticator credentialPublicKey must be a non-empty Uint8Array");
749
- return {
750
- profileId,
751
- signerSlot,
752
- credentialId,
753
- credentialPublicKey,
754
- ...Array.isArray(record.transports) ? { transports: record.transports } : {},
755
- ...record.name ? { name: String(record.name) } : {},
756
- registered: normalizeTrimmedString(record.registered || ""),
757
- syncedAt: normalizeTrimmedString(record.syncedAt || "")
758
- };
759
- }
760
- function passkeyAuthenticatorFromBinding(record, signerSlot) {
761
- const normalizedSignerSlot = Number(signerSlot);
762
- if (!Number.isSafeInteger(normalizedSignerSlot) || normalizedSignerSlot < 1) throw new Error("[SeamsWalletDB] passkey auth-method signerSlot must be an integer >= 1");
763
- return normalizeAuthenticatorRecord({
764
- profileId: record.walletId,
765
- signerSlot: normalizedSignerSlot,
766
- credentialId: record.credentialIdB64u,
767
- credentialPublicKey: base64UrlDecode(record.credentialPublicKeyB64u),
768
- registered: isoTimestampFromMs(record.createdAtMs),
769
- syncedAt: isoTimestampFromMs(record.updatedAtMs)
770
- });
771
- }
772
- function passkeyBindingFromAuthenticator(authenticator, existing) {
773
- const normalized = normalizeAuthenticatorRecord(authenticator);
774
- const credentialPublicKeyB64u = base64UrlEncode(normalized.credentialPublicKey);
775
- if (existing) {
776
- if (existing.walletId !== normalized.profileId) throw new Error("[SeamsWalletDB] passkey auth-method walletId does not match authenticator profileId");
777
- if (existing.credentialIdB64u !== normalized.credentialId) throw new Error("[SeamsWalletDB] passkey auth-method credentialId does not match authenticator credentialId");
778
- if (existing.credentialPublicKeyB64u !== credentialPublicKeyB64u) throw new Error("[SeamsWalletDB] passkey auth-method public key does not match authenticator public key");
779
- return existing;
780
- }
781
- const nowMs = Date.now();
782
- return {
783
- version: "wallet_auth_method_v1",
784
- kind: "passkey",
785
- status: "active",
786
- localStatus: "synced",
787
- walletId: walletIdFromString(normalized.profileId),
788
- rpId: requireWebAuthnRpId(DEFAULT_WALLET_RP_ID),
789
- credentialIdB64u: normalized.credentialId,
790
- credentialPublicKeyB64u,
791
- counter: 0,
792
- createdAtMs: timestampMsFromIso(normalized.registered, nowMs),
793
- updatedAtMs: timestampMsFromIso(normalized.syncedAt, nowMs)
794
- };
795
- }
796
- function passkeyAuthMethodRow(input) {
797
- const base = walletAuthMethodFields(input.binding);
798
- const authenticator = normalizeAuthenticatorRecord(input.authenticator);
799
- const credentialPublicKeyB64u = base64UrlEncode(authenticator.credentialPublicKey);
800
- if (base.kind !== "passkey") throw new Error("[SeamsWalletDB] passkey auth-method row requires a passkey binding");
801
- if (authenticator.profileId !== base.wallet_id) throw new Error("[SeamsWalletDB] passkey auth-method authenticator profileId mismatch");
802
- if (authenticator.credentialId !== input.binding.credentialIdB64u) throw new Error("[SeamsWalletDB] passkey auth-method authenticator credentialId mismatch");
803
- if (credentialPublicKeyB64u !== input.binding.credentialPublicKeyB64u) throw new Error("[SeamsWalletDB] passkey auth-method authenticator public key mismatch");
804
- return {
805
- ...base,
806
- kind: "passkey",
807
- auth_method: "passkey",
808
- record: input.binding,
809
- credential_id_b64u: input.binding.credentialIdB64u,
810
- credential_public_key_b64u: input.binding.credentialPublicKeyB64u,
811
- signer_slot: authenticator.signerSlot,
812
- authenticator
813
- };
814
- }
815
- function emailOtpAuthMethodRow(record) {
816
- const base = walletAuthMethodFields(record);
817
- if (base.kind !== "email_otp") throw new Error("[SeamsWalletDB] Email OTP auth-method row requires an Email OTP binding");
818
- return {
819
- ...base,
820
- kind: "email_otp",
821
- auth_method: "email_otp",
822
- record,
823
- email_hash_hex: record.emailHashHex,
824
- challenge_id: record.registrationAuthorityId
825
- };
826
- }
827
- function walletAuthMethodRowFromBinding(record, signerSlot) {
828
- switch (record.kind) {
829
- case "passkey": return passkeyAuthMethodRow({
830
- binding: record,
831
- authenticator: passkeyAuthenticatorFromBinding(record, signerSlot)
832
- });
833
- case "email_otp": return emailOtpAuthMethodRow(record);
834
- default: {
835
- const _exhaustive = record;
836
- throw new Error(`[SeamsWalletDB] Unsupported auth-method row: ${String(_exhaustive)}`);
837
- }
838
- }
839
- }
840
- function walletAuthMethodRowFromAuthenticator(record, existing) {
841
- const authenticator = normalizeAuthenticatorRecord(record);
842
- return passkeyAuthMethodRow({
843
- binding: passkeyBindingFromAuthenticator(authenticator, existing?.record),
844
- authenticator
845
- });
846
- }
847
- function buildLocalAuthorityPendingProfileProjectionV1(input) {
848
- if (input.profile.wallet_id !== input.walletId || input.authenticator !== null && input.authenticator.wallet_id !== input.walletId || input.localAuthMethod !== null && input.localAuthMethod.wallet_id !== input.walletId) throw new Error("local authority profile projection identity does not match installation");
849
- if (input.authenticator?.wallet_auth_method_id === input.authMethodId || input.localAuthMethod?.wallet_auth_method_id === input.authMethodId) throw new Error("local authority profile projection collides with the V2 auth-method key");
850
- return {
851
- kind: "local_authority_pending_profile_projection_v1",
852
- authorityId: input.authorityId,
853
- walletId: input.walletId,
854
- authMethodId: input.authMethodId,
855
- profile: input.profile,
856
- authenticator: input.authenticator,
857
- localAuthMethod: input.localAuthMethod
858
- };
859
- }
860
- function localAuthorityPendingProfileProjectionsMatchV1(left, right) {
861
- return left.authorityId === right.authorityId && left.walletId === right.walletId && left.authMethodId === right.authMethodId && profileRowsMatch(left.profile, right.profile) && (left.authenticator === null ? right.authenticator === null : right.authenticator !== null && localWalletAuthMethodRowsMatch(left.authenticator, right.authenticator)) && (left.localAuthMethod === null ? right.localAuthMethod === null : right.localAuthMethod !== null && localWalletAuthMethodRowsMatch(left.localAuthMethod, right.localAuthMethod));
862
- }
863
- function localAuthorityPendingProfileProjectionMatchesInputV1(projection, input) {
864
- return projection.authorityId === input.authority.authorityId && projection.walletId === input.authority.walletId && projection.authMethodId === input.authMethod.walletAuthMethodId && projection.profile.record.profileId === input.profile.profileId && projection.profile.record.defaultSignerSlot === (input.profile.defaultSignerSlot ?? 1) && (input.profile.passkeyCredential === void 0 || projection.profile.record.passkeyCredential?.id === input.profile.passkeyCredential.id && projection.profile.record.passkeyCredential.rawId === input.profile.passkeyCredential.rawId) && (input.profile.preferences === void 0 || userPreferencesMatch(projection.profile.record.preferences, input.profile.preferences)) && (input.authenticator === null ? projection.authenticator === null : projection.authenticator !== null && profileAuthenticatorRecordsMatch(projection.authenticator.authenticator, input.authenticator)) && (input.localAuthMethod === null ? projection.localAuthMethod === null : projection.localAuthMethod !== null && localWalletAuthMethodRecordsMatch(projection.localAuthMethod.record, input.localAuthMethod));
865
- }
866
- function parseStoredProfileAuthenticator(value) {
867
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
868
- const profileId = parseStoredNonEmptyString(Reflect.get(value, "profileId"));
869
- const signerSlot = Reflect.get(value, "signerSlot");
870
- const credentialId = parseStoredNonEmptyString(Reflect.get(value, "credentialId"));
871
- const credentialPublicKey = Reflect.get(value, "credentialPublicKey");
872
- const registered = parseStoredNonEmptyString(Reflect.get(value, "registered"));
873
- const syncedAt = parseStoredNonEmptyString(Reflect.get(value, "syncedAt"));
874
- if (!profileId || !Number.isSafeInteger(signerSlot) || signerSlot < 1 || !credentialId || !(credentialPublicKey instanceof Uint8Array) || credentialPublicKey.byteLength === 0 || !registered || !syncedAt) return null;
875
- const transportsRaw = Reflect.get(value, "transports");
876
- const nameRaw = Reflect.get(value, "name");
877
- if (transportsRaw !== void 0 && (!Array.isArray(transportsRaw) || transportsRaw.some((transport) => typeof transport !== "string")) || nameRaw !== void 0 && typeof nameRaw !== "string") return null;
878
- return {
879
- profileId,
880
- signerSlot: Number(signerSlot),
881
- credentialId,
882
- credentialPublicKey: new Uint8Array(credentialPublicKey),
883
- ...transportsRaw === void 0 ? {} : { transports: [...transportsRaw] },
884
- ...nameRaw === void 0 ? {} : { name: nameRaw },
885
- registered,
886
- syncedAt
887
- };
888
- }
889
- function parseStoredLocalWalletAuthMethodRecord(value) {
890
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
891
- const version = Reflect.get(value, "version");
892
- const kind = Reflect.get(value, "kind");
893
- const status = Reflect.get(value, "status");
894
- const localStatus = Reflect.get(value, "localStatus");
895
- const walletIdRaw = Reflect.get(value, "walletId");
896
- const walletId = parseWalletId(walletIdRaw);
897
- const createdAtMs = Reflect.get(value, "createdAtMs");
898
- const updatedAtMs = Reflect.get(value, "updatedAtMs");
899
- if (version !== "wallet_auth_method_v1" || kind !== "passkey" && kind !== "email_otp" || status !== "active" && status !== "revoked" || localStatus !== "synced" && localStatus !== "pending" || !walletId.ok || walletId.value !== walletIdRaw || !Number.isSafeInteger(createdAtMs) || Number(createdAtMs) < 0 || !Number.isSafeInteger(updatedAtMs) || Number(updatedAtMs) < 0) return null;
900
- if (kind === "passkey") {
901
- const rpIdRaw = Reflect.get(value, "rpId");
902
- const rpId = parseWebAuthnRpId(rpIdRaw);
903
- const credentialIdRaw = Reflect.get(value, "credentialIdB64u");
904
- const credentialIdB64u = parseWebAuthnCredentialIdB64u(credentialIdRaw);
905
- const credentialPublicKeyB64u = Reflect.get(value, "credentialPublicKeyB64u");
906
- const counter = Reflect.get(value, "counter");
907
- if (!rpId.ok || rpId.value !== rpIdRaw || !credentialIdB64u.ok || credentialIdB64u.value !== credentialIdRaw || typeof credentialPublicKeyB64u !== "string" || !credentialPublicKeyB64u || !Number.isSafeInteger(counter) || Number(counter) < 0) return null;
908
- return {
909
- version: "wallet_auth_method_v1",
910
- kind: "passkey",
911
- status,
912
- localStatus,
913
- walletId: walletId.value,
914
- rpId: rpId.value,
915
- credentialIdB64u: credentialIdB64u.value,
916
- credentialPublicKeyB64u,
917
- counter: Number(counter),
918
- createdAtMs: Number(createdAtMs),
919
- updatedAtMs: Number(updatedAtMs)
920
- };
921
- }
922
- const emailHashHex = parseStoredNonEmptyString(Reflect.get(value, "emailHashHex"));
923
- const registrationAuthorityId = parseStoredNonEmptyString(Reflect.get(value, "registrationAuthorityId"));
924
- const authority = parseEmailOtpWalletAuthAuthority(Reflect.get(value, "authority"));
925
- if (!emailHashHex || !registrationAuthorityId || !authority || authority.walletId !== walletId.value || authority.verifier.emailHashHex !== emailHashHex) return null;
926
- return {
927
- version: "wallet_auth_method_v1",
928
- kind: "email_otp",
929
- status,
930
- localStatus,
931
- walletId: walletId.value,
932
- emailHashHex,
933
- registrationAuthorityId,
934
- authority,
935
- createdAtMs: Number(createdAtMs),
936
- updatedAtMs: Number(updatedAtMs)
937
- };
938
- }
939
- function parseWalletAuthMethodStorageRow(value) {
940
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
941
- const record = parseStoredLocalWalletAuthMethodRecord(Reflect.get(value, "record"));
942
- if (!record) return null;
943
- let normalized;
944
- try {
945
- if (record.kind === "passkey") {
946
- const authenticator = parseStoredProfileAuthenticator(Reflect.get(value, "authenticator"));
947
- if (!authenticator) return null;
948
- normalized = passkeyAuthMethodRow({
949
- binding: record,
950
- authenticator
951
- });
952
- } else if (record.kind === "email_otp") normalized = emailOtpAuthMethodRow(record);
953
- else return null;
954
- } catch {
955
- return null;
956
- }
957
- if (Reflect.get(value, "wallet_auth_method_id") !== normalized.wallet_auth_method_id) return null;
958
- if (Reflect.get(value, "wallet_id") !== normalized.wallet_id) return null;
959
- if (Reflect.get(value, "kind") !== normalized.kind) return null;
960
- if (Reflect.get(value, "auth_method") !== normalized.auth_method) return null;
961
- if (normalized.kind === "passkey" && Reflect.get(value, "rp_id") !== normalized.rp_id) return null;
962
- if (Reflect.get(value, "auth_identifier_key") !== normalized.auth_identifier_key) return null;
963
- if (Reflect.get(value, "status") !== normalized.status) return null;
964
- if (Reflect.get(value, "updated_at") !== normalized.updated_at) return null;
965
- if (normalized.kind === "passkey") {
966
- if (Reflect.get(value, "credential_id_b64u") !== normalized.credential_id_b64u) return null;
967
- if (Reflect.get(value, "credential_public_key_b64u") !== normalized.credential_public_key_b64u) return null;
968
- if (Reflect.get(value, "signer_slot") !== normalized.signer_slot) return null;
969
- } else {
970
- if (Reflect.get(value, "email_hash_hex") !== normalized.email_hash_hex) return null;
971
- if (Reflect.get(value, "challenge_id") !== normalized.challenge_id) return null;
972
- }
973
- return normalized;
974
- }
975
- function parseWalletAuthMethodRow(value) {
976
- const row = parseWalletAuthMethodStorageRow(value);
977
- if (!row) return null;
978
- return row.record;
979
- }
980
- function parseAuthenticatorRow(value) {
981
- const row = parseWalletAuthMethodStorageRow(value);
982
- if (!row || row.kind !== "passkey" || row.status !== "active") return null;
983
- return row.authenticator;
984
- }
985
- function hasExactKeys(record, keys) {
986
- if (Object.keys(record).length !== keys.length) return false;
987
- for (const key of keys) if (!Object.prototype.hasOwnProperty.call(record, key)) return false;
988
- return true;
989
- }
990
- function requireBoundaryParsed(result, label) {
991
- if (!result.ok) throw new Error(`${label}: ${result.error.message}`);
992
- return result.value;
993
- }
994
- function parseNonEmptyBoundaryString(raw, label) {
995
- if (typeof raw !== "string" || raw.length === 0 || raw.trim() !== raw) throw new Error(`${label} must be a non-empty canonical string`);
996
- return raw;
997
- }
998
- function parseNonNegativeSafeInteger(raw, label) {
999
- if (!Number.isSafeInteger(raw) || Number(raw) < 0) throw new Error(`${label} must be a non-negative safe integer`);
1000
- return Number(raw);
1001
- }
1002
- function rawValueIsPresent(value) {
1003
- return value !== void 0;
1004
- }
1005
- function parseWalletAuthorityStorageRow(value) {
1006
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1007
- const parsed = parseWalletAuthorityV1(Reflect.get(value, "record"));
1008
- if (!parsed.ok) return null;
1009
- const record = parsed.value;
1010
- if (Reflect.get(value, "authority_id") !== record.authorityId || Reflect.get(value, "wallet_id") !== record.walletId || Reflect.get(value, "state") !== record.state || Reflect.get(value, "device_id") !== record.principal.deviceId || Reflect.get(value, "updated_at") !== record.updatedAtMs) return null;
1011
- return {
1012
- authority_id: record.authorityId,
1013
- wallet_id: record.walletId,
1014
- state: record.state,
1015
- device_id: record.principal.deviceId,
1016
- updated_at: record.updatedAtMs,
1017
- record
1018
- };
1019
- }
1020
- function walletAuthorityStorageRow(record) {
1021
- return {
1022
- authority_id: record.authorityId,
1023
- wallet_id: record.walletId,
1024
- state: record.state,
1025
- device_id: record.principal.deviceId,
1026
- updated_at: record.updatedAtMs,
1027
- record
1028
- };
1029
- }
1030
- function unavailableWalletAuthMethodPresentation(record) {
1031
- switch (record.kind) {
1032
- case "passkey": return {
1033
- version: "wallet_auth_method_local_presentation_v1",
1034
- kind: "passkey"
1035
- };
1036
- case "email_otp": return {
1037
- version: "wallet_auth_method_local_presentation_v1",
1038
- kind: "email_otp",
1039
- email: { kind: "unavailable" }
1040
- };
1041
- default: throw new Error("Wallet auth-method presentation kind is invalid");
1042
- }
1043
- }
1044
- function parseWalletAuthMethodLocalPresentationV1(value, record) {
1045
- if (value === void 0) return unavailableWalletAuthMethodPresentation(record);
1046
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1047
- if (Reflect.get(value, "version") !== "wallet_auth_method_local_presentation_v1" || Reflect.get(value, "kind") !== record.kind) return null;
1048
- switch (record.kind) {
1049
- case "passkey":
1050
- if (!hasExactKeys(value, ["version", "kind"])) return null;
1051
- return {
1052
- version: "wallet_auth_method_local_presentation_v1",
1053
- kind: "passkey"
1054
- };
1055
- case "email_otp": {
1056
- if (!hasExactKeys(value, [
1057
- "version",
1058
- "kind",
1059
- "email"
1060
- ])) return null;
1061
- const email = Reflect.get(value, "email");
1062
- if (email === null || typeof email !== "object" || Array.isArray(email)) return null;
1063
- switch (Reflect.get(email, "kind")) {
1064
- case "unavailable":
1065
- if (!hasExactKeys(email, ["kind"])) return null;
1066
- return {
1067
- version: "wallet_auth_method_local_presentation_v1",
1068
- kind: "email_otp",
1069
- email: { kind: "unavailable" }
1070
- };
1071
- case "verified": {
1072
- if (!hasExactKeys(email, ["kind", "address"])) return null;
1073
- const address = parseVerifiedEmailAddress(Reflect.get(email, "address"));
1074
- if (!address.ok) return null;
1075
- return {
1076
- version: "wallet_auth_method_local_presentation_v1",
1077
- kind: "email_otp",
1078
- email: {
1079
- kind: "verified",
1080
- address: address.value
1081
- }
1082
- };
1083
- }
1084
- default: return null;
1085
- }
1086
- }
1087
- default: return null;
1088
- }
1089
- }
1090
- function parseWalletAuthMethodV2StorageRow(value) {
1091
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1092
- const record = parseWalletAuthMethodRecordV2(Reflect.get(value, "record"));
1093
- if (!record) return null;
1094
- const presentation = parseWalletAuthMethodLocalPresentationV1(Reflect.get(value, "presentation"), record);
1095
- if (!presentation) return null;
1096
- if (Reflect.get(value, "wallet_auth_method_id") !== record.walletAuthMethodId || Reflect.get(value, "wallet_id") !== record.walletId || Reflect.get(value, "wallet_authority_id") !== record.walletAuthorityId || Reflect.get(value, "kind") !== record.kind || Reflect.get(value, "status") !== record.status || Reflect.get(value, "updated_at") !== record.updatedAtMs) return null;
1097
- return walletAuthMethodV2StorageRow(localWalletAuthMethodProjectionV2(record, presentation));
1098
- }
1099
- function walletAuthMethodV2StorageRow(projection) {
1100
- switch (projection.kind) {
1101
- case "passkey": return {
1102
- wallet_auth_method_id: projection.record.walletAuthMethodId,
1103
- wallet_id: projection.record.walletId,
1104
- wallet_authority_id: projection.record.walletAuthorityId,
1105
- kind: "passkey",
1106
- status: projection.record.status,
1107
- updated_at: projection.record.updatedAtMs,
1108
- presentation: projection.presentation,
1109
- record: projection.record
1110
- };
1111
- case "email_otp": return {
1112
- wallet_auth_method_id: projection.record.walletAuthMethodId,
1113
- wallet_id: projection.record.walletId,
1114
- wallet_authority_id: projection.record.walletAuthorityId,
1115
- kind: "email_otp",
1116
- status: projection.record.status,
1117
- updated_at: projection.record.updatedAtMs,
1118
- presentation: projection.presentation,
1119
- record: projection.record
1120
- };
1121
- default: throw new Error("Wallet auth-method projection kind is invalid");
1122
- }
1123
- }
1124
- function verifiedEmailPresentationFromLocalRecords(record, rows) {
1125
- const addresses = /* @__PURE__ */ new Set();
1126
- for (const row of rows) {
1127
- const local = parseWalletAuthMethodStorageRow(row)?.record;
1128
- if (!local || local.kind !== "email_otp" || local.emailHashHex !== record.emailHashHex || local.authority.bindingId !== record.walletAuthMethodId) continue;
1129
- const address = parseVerifiedEmailAddress(local.authority.factor.providerUserId);
1130
- if (address.ok) addresses.add(String(address.value));
1131
- }
1132
- if (addresses.size !== 1) return null;
1133
- const address = parseVerifiedEmailAddress([...addresses][0]);
1134
- if (!address.ok) return null;
1135
- return {
1136
- version: "wallet_auth_method_local_presentation_v1",
1137
- kind: "email_otp",
1138
- email: {
1139
- kind: "verified",
1140
- address: address.value
1141
- }
1142
- };
1143
- }
1144
- function walletAuthMethodLocalPresentation(record, rows, current) {
1145
- switch (record.kind) {
1146
- case "passkey": return unavailableWalletAuthMethodPresentation(record);
1147
- case "email_otp": return verifiedEmailPresentationFromLocalRecords(record, rows) ?? (current?.kind === "email_otp" && current.email.kind === "verified" ? current : unavailableWalletAuthMethodPresentation(record));
1148
- default: throw new Error("Wallet auth-method presentation kind is invalid");
1149
- }
1150
- }
1151
- function walletAuthMethodLocalPresentationsMatch(left, right) {
1152
- if (left.kind !== right.kind) return false;
1153
- if (left.kind === "passkey" && right.kind === "passkey") return true;
1154
- if (left.kind !== "email_otp" || right.kind !== "email_otp") return false;
1155
- if (left.email.kind !== right.email.kind) return false;
1156
- if (left.email.kind === "unavailable" && right.email.kind === "unavailable") return true;
1157
- return left.email.kind === "verified" && right.email.kind === "verified" && left.email.address === right.email.address;
1158
- }
1159
- function rawWalletAuthMethodRowHasPresentation(value) {
1160
- return value !== null && typeof value === "object" && !Array.isArray(value) && Reflect.get(value, "presentation") !== void 0;
1161
- }
1162
- function localWalletAuthMethodProjectionV2(record, presentation) {
1163
- switch (record.kind) {
1164
- case "passkey":
1165
- if (presentation.kind !== "passkey") throw new Error("Passkey auth method has non-passkey local presentation");
1166
- return {
1167
- kind: "passkey",
1168
- record,
1169
- presentation
1170
- };
1171
- case "email_otp":
1172
- if (presentation.kind !== "email_otp") throw new Error("Email OTP auth method has non-email local presentation");
1173
- return {
1174
- kind: "email_otp",
1175
- record,
1176
- presentation
1177
- };
1178
- default: throw new Error("Wallet auth-method projection kind is invalid");
1179
- }
1180
- }
1181
- async function walletAuthMethodV2StorageRowForStore(store, record) {
1182
- const existing = parseWalletAuthMethodV2StorageRow(await store.get(record.walletAuthMethodId));
1183
- return walletAuthMethodV2StorageRow(localWalletAuthMethodProjectionV2(record, walletAuthMethodLocalPresentation(record, await store.index(SEAMS_WALLET_INDEXES.walletId).getAll(record.walletId), existing?.presentation ?? null)));
1184
- }
1185
- function parseWalletAuthoritySignerMaterialRecord(value) {
1186
- if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("signer material record must be an object");
1187
- const kind = Reflect.get(value, "kind");
1188
- const keyFamily = Reflect.get(value, "keyFamily");
1189
- if (kind === "wallet_authority_linked_signer_material_v1") return parseWalletAuthorityLinkedSignerMaterialRecordV1(value);
1190
- if (kind !== "wallet_authority_signer_material_v1") throw new Error("signer material record kind is invalid");
1191
- if (keyFamily !== "ed25519" && keyFamily !== "ecdsa_secp256k1") throw new Error("signer material keyFamily is invalid");
1192
- const commonKeys = [
1193
- "kind",
1194
- "authorityId",
1195
- "walletAuthMethodId",
1196
- "activationId",
1197
- "keyFamily",
1198
- "materialActivation",
1199
- "sealedMaterialB64u",
1200
- "sealedMaterialDigestB64u"
1201
- ];
1202
- if (!hasExactKeys(value, keyFamily === "ecdsa_secp256k1" ? [...commonKeys, "ecdsaThresholdKeyId"] : commonKeys)) throw new Error("signer material record fields are invalid");
1203
- const authorityId = requireBoundaryParsed(parseWalletAuthorityId(Reflect.get(value, "authorityId")), "authorityId");
1204
- const walletAuthMethodId = requireBoundaryParsed(parseWalletAuthMethodId(Reflect.get(value, "walletAuthMethodId")), "walletAuthMethodId");
1205
- const materialActivation = requireBoundaryParsed(parseMpcMaterialActivationRef(Reflect.get(value, "materialActivation")), "materialActivation");
1206
- const activationId = parseNonEmptyBoundaryString(Reflect.get(value, "activationId"), "activationId");
1207
- const sealedMaterialB64u = parseNonEmptyBoundaryString(Reflect.get(value, "sealedMaterialB64u"), "sealedMaterialB64u");
1208
- const sealedMaterialDigestB64u = parseDigestB64u(Reflect.get(value, "sealedMaterialDigestB64u"));
1209
- if (materialActivation.activationId !== activationId) throw new Error("signer material activationId does not match materialActivation");
1210
- if (keyFamily === "ed25519") return {
1211
- kind: "wallet_authority_signer_material_v1",
1212
- authorityId,
1213
- walletAuthMethodId,
1214
- activationId: materialActivation.activationId,
1215
- keyFamily: "ed25519",
1216
- materialActivation,
1217
- sealedMaterialB64u,
1218
- sealedMaterialDigestB64u
1219
- };
1220
- return {
1221
- kind: "wallet_authority_signer_material_v1",
1222
- authorityId,
1223
- walletAuthMethodId,
1224
- activationId: materialActivation.activationId,
1225
- keyFamily: "ecdsa_secp256k1",
1226
- ecdsaThresholdKeyId: parseEcdsaThresholdKeyId(Reflect.get(value, "ecdsaThresholdKeyId")),
1227
- materialActivation,
1228
- sealedMaterialB64u,
1229
- sealedMaterialDigestB64u
1230
- };
1231
- }
1232
- function parseWalletAuthoritySignerMaterialStorageRow(value) {
1233
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1234
- try {
1235
- const record = parseWalletAuthoritySignerMaterialRecord(Reflect.get(value, "record"));
1236
- if (Reflect.get(value, "wallet_authority_id") !== record.authorityId || Reflect.get(value, "wallet_auth_method_id") !== record.walletAuthMethodId || Reflect.get(value, "activation_id") !== record.activationId || Reflect.get(value, "key_family") !== record.keyFamily || Reflect.get(value, "ecdsa_threshold_key_id") !== (record.keyFamily === "ecdsa_secp256k1" ? record.ecdsaThresholdKeyId : void 0) || Reflect.get(value, "sealed_material_b64u") !== record.sealedMaterialB64u || Reflect.get(value, "sealed_material_digest_b64u") !== record.sealedMaterialDigestB64u) return null;
1237
- return {
1238
- wallet_authority_id: record.authorityId,
1239
- wallet_auth_method_id: record.walletAuthMethodId,
1240
- activation_id: record.activationId,
1241
- key_family: record.keyFamily,
1242
- ecdsa_threshold_key_id: record.keyFamily === "ecdsa_secp256k1" ? record.ecdsaThresholdKeyId : void 0,
1243
- sealed_material_b64u: record.sealedMaterialB64u,
1244
- sealed_material_digest_b64u: record.sealedMaterialDigestB64u,
1245
- record
1246
- };
1247
- } catch {
1248
- return null;
1249
- }
1250
- }
1251
- function walletAuthoritySignerMaterialStorageRow(record) {
1252
- return {
1253
- wallet_authority_id: record.authorityId,
1254
- wallet_auth_method_id: record.walletAuthMethodId,
1255
- activation_id: record.activationId,
1256
- key_family: record.keyFamily,
1257
- ecdsa_threshold_key_id: record.keyFamily === "ecdsa_secp256k1" ? record.ecdsaThresholdKeyId : void 0,
1258
- sealed_material_b64u: record.sealedMaterialB64u,
1259
- sealed_material_digest_b64u: record.sealedMaterialDigestB64u,
1260
- record
1261
- };
1262
- }
1263
- function parseWalletAuthorityExportRootRecord(value) {
1264
- if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("export root record must be an object");
1265
- if (!hasExactKeys(value, [
1266
- "kind",
1267
- "authorityId",
1268
- "walletAuthMethodId",
1269
- "walletKeyId",
1270
- "envelope"
1271
- ])) throw new Error("export root record fields are invalid");
1272
- if (Reflect.get(value, "kind") !== "wallet_authority_export_root_v1") throw new Error("export root record kind is invalid");
1273
- const walletKeyId = requireBoundaryParsed(parseWalletKeyId(Reflect.get(value, "walletKeyId")), "walletKeyId");
1274
- const envelope = parsePasskeyCustodyEnvelopeRecord(Reflect.get(value, "envelope"));
1275
- if (envelope.binding.kind !== "ed25519_yao_client_root_v1" || envelope.binding.walletKeyId !== walletKeyId) throw new Error("export root envelope does not match walletKeyId");
1276
- return {
1277
- kind: "wallet_authority_export_root_v1",
1278
- authorityId: requireBoundaryParsed(parseWalletAuthorityId(Reflect.get(value, "authorityId")), "authorityId"),
1279
- walletAuthMethodId: requireBoundaryParsed(parseWalletAuthMethodId(Reflect.get(value, "walletAuthMethodId")), "walletAuthMethodId"),
1280
- walletKeyId,
1281
- envelope
1282
- };
1283
- }
1284
- function parseWalletAuthorityExportRootStorageRow(value) {
1285
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1286
- try {
1287
- const record = parseWalletAuthorityExportRootRecord(Reflect.get(value, "record"));
1288
- if (Reflect.get(value, "wallet_authority_id") !== record.authorityId || Reflect.get(value, "wallet_auth_method_id") !== record.walletAuthMethodId || Reflect.get(value, "wallet_key_id") !== record.walletKeyId || Reflect.get(value, "sealed_root_b64u") !== record.envelope.sealedCustodySecretB64u || Reflect.get(value, "sealed_root_digest_b64u") !== record.envelope.ciphertextDigestB64u) return null;
1289
- return {
1290
- wallet_authority_id: record.authorityId,
1291
- wallet_auth_method_id: record.walletAuthMethodId,
1292
- wallet_key_id: record.walletKeyId,
1293
- sealed_root_b64u: record.envelope.sealedCustodySecretB64u,
1294
- sealed_root_digest_b64u: record.envelope.ciphertextDigestB64u,
1295
- record
1296
- };
1297
- } catch {
1298
- return null;
1299
- }
1300
- }
1301
- function walletAuthorityExportRootStorageRow(record) {
1302
- return {
1303
- wallet_authority_id: record.authorityId,
1304
- wallet_auth_method_id: record.walletAuthMethodId,
1305
- wallet_key_id: record.walletKeyId,
1306
- sealed_root_b64u: record.envelope.sealedCustodySecretB64u,
1307
- sealed_root_digest_b64u: record.envelope.ciphertextDigestB64u,
1308
- record
1309
- };
1310
- }
1311
- function parseLocalAuthorityInstallationReceiptStorageRow(value) {
1312
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1313
- try {
1314
- const record = parseLocalAuthorityInstallationReceiptV1(Reflect.get(value, "record"));
1315
- if (Reflect.get(value, "authority_id") !== record.authorityId || Reflect.get(value, "wallet_id") !== record.walletId || Reflect.get(value, "wallet_auth_method_id") !== record.authMethodId || Reflect.get(value, "device_id") !== record.deviceId || Reflect.get(value, "package_set_digest_b64u") !== record.packageSetDigestB64u || Reflect.get(value, "installed_at_ms") !== record.installedAtMs) return null;
1316
- return {
1317
- authority_id: record.authorityId,
1318
- wallet_id: record.walletId,
1319
- wallet_auth_method_id: record.authMethodId,
1320
- device_id: record.deviceId,
1321
- package_set_digest_b64u: record.packageSetDigestB64u,
1322
- installed_at_ms: record.installedAtMs,
1323
- record
1324
- };
1325
- } catch {
1326
- return null;
1327
- }
1328
- }
1329
- function localAuthorityInstallationReceiptStorageRow(record) {
1330
- return {
1331
- authority_id: record.authorityId,
1332
- wallet_id: record.walletId,
1333
- wallet_auth_method_id: record.authMethodId,
1334
- device_id: record.deviceId,
1335
- package_set_digest_b64u: record.packageSetDigestB64u,
1336
- installed_at_ms: record.installedAtMs,
1337
- record
1338
- };
1339
- }
1340
- function parseWalletSelectionRecord(value) {
1341
- if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("wallet selection record must be an object");
1342
- if (!hasExactKeys(value, [
1343
- "kind",
1344
- "walletId",
1345
- "walletAuthMethodId",
1346
- "lockGeneration",
1347
- "lockState",
1348
- "updatedAtMs"
1349
- ])) throw new Error("wallet selection record fields are invalid");
1350
- if (Reflect.get(value, "kind") !== "wallet_selection_v1") throw new Error("wallet selection record kind is invalid");
1351
- const lockState = Reflect.get(value, "lockState");
1352
- if (lockState !== "locked" && lockState !== "unlocked") throw new Error("wallet selection lockState is invalid");
1353
- return {
1354
- kind: "wallet_selection_v1",
1355
- walletId: requireBoundaryParsed(parseWalletId(Reflect.get(value, "walletId")), "walletId"),
1356
- walletAuthMethodId: requireBoundaryParsed(parseWalletAuthMethodId(Reflect.get(value, "walletAuthMethodId")), "walletAuthMethodId"),
1357
- lockGeneration: parseNonNegativeSafeInteger(Reflect.get(value, "lockGeneration"), "lockGeneration"),
1358
- lockState,
1359
- updatedAtMs: parseNonNegativeSafeInteger(Reflect.get(value, "updatedAtMs"), "updatedAtMs")
1360
- };
1361
- }
1362
- function parseWalletSelectionStorageRow(value) {
1363
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1364
- try {
1365
- const record = parseWalletSelectionRecord(Reflect.get(value, "record"));
1366
- if (Reflect.get(value, "wallet_id") !== record.walletId || Reflect.get(value, "wallet_auth_method_id") !== record.walletAuthMethodId || Reflect.get(value, "lock_generation") !== record.lockGeneration || Reflect.get(value, "lock_state") !== record.lockState || Reflect.get(value, "updated_at_ms") !== record.updatedAtMs) return null;
1367
- return {
1368
- wallet_id: record.walletId,
1369
- wallet_auth_method_id: record.walletAuthMethodId,
1370
- lock_generation: record.lockGeneration,
1371
- lock_state: record.lockState,
1372
- updated_at_ms: record.updatedAtMs,
1373
- record
1374
- };
1375
- } catch {
1376
- return null;
1377
- }
1378
- }
1379
- function walletSelectionStorageRow(record) {
1380
- return {
1381
- wallet_id: record.walletId,
1382
- wallet_auth_method_id: record.walletAuthMethodId,
1383
- lock_generation: record.lockGeneration,
1384
- lock_state: record.lockState,
1385
- updated_at_ms: record.updatedAtMs,
1386
- record
1387
- };
1388
- }
1389
- function signerMaterialExpectations(value) {
1390
- if (value.keyFamilies.length === 1 && value.keyFamilies[0] === "ed25519") {
1391
- if (value.ed25519) return [{
1392
- keyFamily: "ed25519",
1393
- materialActivation: value.ed25519.materialActivation
1394
- }];
1395
- }
1396
- if (value.keyFamilies.length === 1 && value.keyFamilies[0] === "ecdsa_secp256k1") {
1397
- if (value.ecdsa) return [{
1398
- keyFamily: "ecdsa_secp256k1",
1399
- materialActivation: value.ecdsa.materialActivation
1400
- }];
1401
- }
1402
- if (value.keyFamilies.length === 2) {
1403
- if (value.ed25519 && value.ecdsa) return [{
1404
- keyFamily: "ed25519",
1405
- materialActivation: value.ed25519.materialActivation
1406
- }, {
1407
- keyFamily: "ecdsa_secp256k1",
1408
- materialActivation: value.ecdsa.materialActivation
1409
- }];
1410
- }
1411
- throw new Error("wallet signer activation families are invalid");
1412
- }
1413
- function ed25519WalletKeyId(value) {
1414
- if (value.keyFamilies.length === 1 && value.keyFamilies[0] === "ed25519") return value.ed25519 ? value.ed25519.signer.walletKeyId : null;
1415
- if (value.keyFamilies.length === 2) return value.ed25519 ? value.ed25519.signer.walletKeyId : null;
1416
- throw new Error("wallet signer activation families are invalid");
1417
- }
1418
- function hasEd25519SignerFamily(value) {
1419
- return value.keyFamilies.length === 2 || value.keyFamilies[0] === "ed25519";
1420
- }
1421
- function canonicalBytesMatch(left, right) {
1422
- if (left.byteLength !== right.byteLength) return false;
1423
- for (let index = 0; index < left.byteLength; index += 1) if (left[index] !== right[index]) return false;
1424
- return true;
1425
- }
1426
- function walletAuthorityLinkedMaterialTargetFactorsMatch(left, right) {
1427
- if (left.kind !== right.kind || left.walletAuthMethodId !== right.walletAuthMethodId || left.verificationDigestB64u !== right.verificationDigestB64u) return false;
1428
- switch (left.kind) {
1429
- case "passkey": return right.kind === "passkey" && left.rpId === right.rpId && left.credentialIdB64u === right.credentialIdB64u;
1430
- case "email_otp": return right.kind === "email_otp" && left.emailHashHex === right.emailHashHex && left.registrationAuthorityId === right.registrationAuthorityId;
1431
- default: return assertNever(left);
1432
- }
1433
- }
1434
- function walletAuthorityLinkedSignerMaterialRecordsMatch(left, right) {
1435
- if (right.kind !== left.kind || left.authorityId !== right.authorityId || left.walletAuthMethodId !== right.walletAuthMethodId || left.activationId !== right.activationId || !mpcMaterialActivationRefsEqual(left.materialActivation, right.materialActivation) || left.sealedMaterialB64u !== right.sealedMaterialB64u || left.sealedMaterialDigestB64u !== right.sealedMaterialDigestB64u || left.packageSetDigestB64u !== right.packageSetDigestB64u || !walletAuthorityLinkedMaterialTargetFactorsMatch(left.targetFactor, right.targetFactor)) return false;
1436
- switch (left.keyFamily) {
1437
- case "ed25519": return right.keyFamily === "ed25519";
1438
- case "ecdsa_secp256k1": return right.keyFamily === "ecdsa_secp256k1" && left.ecdsaThresholdKeyId === right.ecdsaThresholdKeyId;
1439
- default: return assertNever(left);
1440
- }
1441
- }
1442
- function walletCustodyEnvelopeLifecyclesMatch(left, right) {
1443
- if (left.state !== right.state) return false;
1444
- switch (left.state) {
1445
- case "active": return right.state === "active" && left.activatedAtMs === right.activatedAtMs;
1446
- case "retired": return right.state === "retired" && left.activatedAtMs === right.activatedAtMs && left.retiredAtMs === right.retiredAtMs;
1447
- case "revoked": return right.state === "revoked" && left.activatedAtMs === right.activatedAtMs && left.revokedAtMs === right.revokedAtMs;
1448
- default: return assertNever(left);
1449
- }
1450
- }
1451
- function walletCustodyEnvelopeFactorsMatch(left, right) {
1452
- if (left.kind !== right.kind) return false;
1453
- switch (left.kind) {
1454
- case "passkey": return right.kind === "passkey" && left.rpId === right.rpId && left.credentialIdB64u === right.credentialIdB64u && left.kekVersion === right.kekVersion;
1455
- case "email_otp": return right.kind === "email_otp" && left.enrollmentId === right.enrollmentId && left.enrollmentSealKeyVersion === right.enrollmentSealKeyVersion && left.kekVersion === right.kekVersion;
1456
- default: return assertNever(left);
1457
- }
1458
- }
1459
- function walletAuthorityExportRootEnvelopesMatch(left, right) {
1460
- if (left.kind !== right.kind || left.envelopeId !== right.envelopeId || left.walletId !== right.walletId || !sameWalletCustodyEnvelopeOwnership(left.ownership, right.ownership) || left.envelopeVersion !== right.envelopeVersion || left.envelopeRevision !== right.envelopeRevision || left.nonceB64u !== right.nonceB64u || left.sealedCustodySecretB64u !== right.sealedCustodySecretB64u || left.ciphertextDigestB64u !== right.ciphertextDigestB64u || left.aadHashB64u !== right.aadHashB64u || !walletCustodyEnvelopeLifecyclesMatch(left.lifecycle, right.lifecycle) || left.createdAtMs !== right.createdAtMs || left.updatedAtMs !== right.updatedAtMs) return false;
1461
- return left.binding.kind === "ed25519_yao_client_root_v1" && right.binding.kind === "ed25519_yao_client_root_v1" && left.binding.linkSessionId === right.binding.linkSessionId && left.binding.walletKeyId === right.binding.walletKeyId && left.binding.targetFactor.kind === right.binding.targetFactor.kind && left.binding.applicationBindingDigestB64u === right.binding.applicationBindingDigestB64u && left.binding.registeredPublicKeyB64u === right.binding.registeredPublicKeyB64u && left.binding.enrollmentId === right.binding.enrollmentId && left.binding.deviceId === right.binding.deviceId && left.binding.revocationEpoch === right.binding.revocationEpoch && walletCustodyEnvelopeFactorsMatch(left.factor, right.factor);
1462
- }
1463
- function walletSignerActivationSetsMatch(left, right) {
1464
- return canonicalBytesMatch(encodeWalletSignerActivationSetV1(left), encodeWalletSignerActivationSetV1(right));
1465
- }
1466
- function walletAuthorityPermissionsMatch(left, right) {
1467
- return sameDelegatedWalletAuthorityV1({
1468
- kind: "delegated_wallet_authority_v1",
1469
- permissions: left.permissions
1470
- }, {
1471
- kind: "delegated_wallet_authority_v1",
1472
- permissions: right.permissions
1473
- });
1474
- }
1475
- function walletAuthorityProvenancesMatch(left, right) {
1476
- if (left.kind !== right.kind) return false;
1477
- switch (left.kind) {
1478
- case "wallet_registration": return true;
1479
- case "device_link": return right.kind === "device_link" && left.enrollmentId === right.enrollmentId && left.sourceAuthorityId === right.sourceAuthorityId && left.linkSessionId === right.linkSessionId;
1480
- case "wallet_recovery": return right.kind === "wallet_recovery" && left.recoveryOperationId === right.recoveryOperationId && left.continuityAuthorityId === right.continuityAuthorityId;
1481
- default: return assertNever(left);
1482
- }
1483
- }
1484
- function walletAuthorityLifecycleFieldsMatch(left, right) {
1485
- if (left.state !== right.state) return false;
1486
- switch (left.state) {
1487
- case "pending_local_install": return right.state === "pending_local_install" && left.localInstallPackageSetDigestB64u === right.localInstallPackageSetDigestB64u;
1488
- case "active": return right.state === "active" && left.activatedAtMs === right.activatedAtMs;
1489
- case "revoked": return right.state === "revoked" && left.activatedAtMs === right.activatedAtMs && left.revokedAtMs === right.revokedAtMs;
1490
- }
1491
- return assertNever(left);
1492
- }
1493
- function walletAuthorityRecordsMatch(left, right) {
1494
- return left.kind === right.kind && left.authorityId === right.authorityId && left.walletId === right.walletId && left.principal.kind === right.principal.kind && left.principal.deviceId === right.principal.deviceId && walletAuthorityProvenancesMatch(left.provenance, right.provenance) && walletAuthorityPermissionsMatch(left, right) && walletAuthorityLifecycleFieldsMatch(left, right) && left.revocationEpoch === right.revocationEpoch && left.createdAtMs === right.createdAtMs && left.updatedAtMs === right.updatedAtMs && left.signerActivationSetDigestB64u === right.signerActivationSetDigestB64u && left.authorityDigestB64u === right.authorityDigestB64u && walletSignerActivationSetsMatch(left.signerActivations, right.signerActivations);
1495
- }
1496
- function walletAuthorityPendingMatchesActive(pending, active) {
1497
- return pending.kind === active.kind && pending.authorityId === active.authorityId && pending.walletId === active.walletId && pending.principal.kind === active.principal.kind && pending.principal.deviceId === active.principal.deviceId && walletAuthorityProvenancesMatch(pending.provenance, active.provenance) && walletAuthorityPermissionsMatch(pending, active) && walletSignerActivationSetsMatch(pending.signerActivations, active.signerActivations) && pending.signerActivationSetDigestB64u === active.signerActivationSetDigestB64u && pending.revocationEpoch === active.revocationEpoch && pending.createdAtMs === active.createdAtMs;
1498
- }
1499
- function walletAuthMethodRecordsMatch(left, right) {
1500
- if (left.version !== right.version || left.walletAuthMethodId !== right.walletAuthMethodId || left.walletId !== right.walletId || left.walletAuthorityId !== right.walletAuthorityId || left.createdAtMs !== right.createdAtMs || left.updatedAtMs !== right.updatedAtMs || left.kind !== right.kind || left.status !== right.status) return false;
1501
- switch (left.kind) {
1502
- case "passkey": return right.kind === "passkey" && left.rpId === right.rpId && left.credentialIdB64u === right.credentialIdB64u && left.credentialPublicKeyB64u === right.credentialPublicKeyB64u && left.counter === right.counter && (left.status === "pending_local_install" || left.activatedAtMs === right.activatedAtMs) && (left.status !== "revoked" || left.revokedAtMs === right.revokedAtMs);
1503
- case "email_otp": return right.kind === "email_otp" && left.emailHashHex === right.emailHashHex && left.registrationAuthorityId === right.registrationAuthorityId && (left.status === "pending_local_install" || left.activatedAtMs === right.activatedAtMs) && (left.status !== "revoked" || left.revokedAtMs === right.revokedAtMs);
1504
- }
1505
- return assertNever(left);
1506
- }
1507
- function walletAuthMethodPendingMatchesActive(pending, active) {
1508
- if (pending.version !== active.version || pending.walletAuthMethodId !== active.walletAuthMethodId || pending.walletId !== active.walletId || pending.walletAuthorityId !== active.walletAuthorityId || pending.kind !== active.kind || pending.createdAtMs !== active.createdAtMs) return false;
1509
- switch (pending.kind) {
1510
- case "passkey": return active.kind === "passkey" && pending.rpId === active.rpId && pending.credentialIdB64u === active.credentialIdB64u && pending.credentialPublicKeyB64u === active.credentialPublicKeyB64u && pending.counter === active.counter;
1511
- case "email_otp": return active.kind === "email_otp" && pending.emailHashHex === active.emailHashHex && pending.registrationAuthorityId === active.registrationAuthorityId;
1512
- }
1513
- return assertNever(pending);
1514
- }
1515
- function walletAuthoritySignerMaterialRecordsMatch(left, right) {
1516
- switch (left.kind) {
1517
- case "wallet_authority_signer_material_v1":
1518
- if (right.kind !== left.kind) return false;
1519
- if (left.authorityId !== right.authorityId || left.walletAuthMethodId !== right.walletAuthMethodId || left.activationId !== right.activationId || !mpcMaterialActivationRefsEqual(left.materialActivation, right.materialActivation) || left.sealedMaterialB64u !== right.sealedMaterialB64u || left.sealedMaterialDigestB64u !== right.sealedMaterialDigestB64u) return false;
1520
- switch (left.keyFamily) {
1521
- case "ed25519": return right.keyFamily === "ed25519";
1522
- case "ecdsa_secp256k1": return right.keyFamily === "ecdsa_secp256k1" && left.ecdsaThresholdKeyId === right.ecdsaThresholdKeyId;
1523
- default: return assertNever(left);
1524
- }
1525
- case "wallet_authority_linked_signer_material_v1": return right.kind === "wallet_authority_linked_signer_material_v1" && walletAuthorityLinkedSignerMaterialRecordsMatch(left, right);
1526
- default: return assertNever(left);
1527
- }
1528
- }
1529
- function walletAuthorityExportRootsMatch(left, right) {
1530
- return left.kind === right.kind && left.authorityId === right.authorityId && left.walletAuthMethodId === right.walletAuthMethodId && left.walletKeyId === right.walletKeyId && walletAuthorityExportRootEnvelopesMatch(left.envelope, right.envelope);
1531
- }
1532
- function localAuthorityInstallationReceiptsMatch(left, right) {
1533
- return left.kind === right.kind && left.authorityId === right.authorityId && left.walletId === right.walletId && left.authMethodId === right.authMethodId && left.deviceId === right.deviceId && left.packageSetDigestB64u === right.packageSetDigestB64u && walletSignerActivationSetsMatch(left.installedActivationRefs, right.installedActivationRefs) && left.installedRecordSetDigestB64u === right.installedRecordSetDigestB64u && left.targetFactorVerificationDigestB64u === right.targetFactorVerificationDigestB64u && left.installedAtMs === right.installedAtMs;
1534
- }
1535
- function walletSessionRecordsMatch(left, right) {
1536
- if (left.kind !== right.kind || left.walletId !== right.walletId || left.authorityId !== right.authorityId || left.authMethodId !== right.authMethodId || left.authorizationId !== right.authorizationId || left.quotaId !== right.quotaId || left.authorityDigestB64u !== right.authorityDigestB64u || left.authorityRevocationEpoch !== right.authorityRevocationEpoch || left.issuedAtMs !== right.issuedAtMs || left.expiresAtMs !== right.expiresAtMs || left.capabilitySubjects.length !== right.capabilitySubjects.length) return false;
1537
- for (let index = 0; index < left.capabilitySubjects.length; index += 1) {
1538
- const leftSubject = left.capabilitySubjects[index];
1539
- const rightSubject = right.capabilitySubjects[index];
1540
- if (leftSubject.kind !== rightSubject.kind) return false;
1541
- if (leftSubject.kind === "link_devices" || leftSubject.kind === "revoke_devices") {
1542
- if (rightSubject.kind !== leftSubject.kind) return false;
1543
- continue;
1544
- }
1545
- if (rightSubject.kind !== leftSubject.kind || leftSubject.keyFamily !== rightSubject.keyFamily || !mpcMaterialActivationRefsEqual(leftSubject.materialActivation, rightSubject.materialActivation)) return false;
1546
- }
1547
- return true;
1548
- }
1549
- function localAuthorityInstallationError(error) {
1550
- return error instanceof Error ? error.message : "local authority installation input is invalid";
1551
- }
1552
- function parseLocalEmailOtpAuthMethodForInstallation(input) {
1553
- const row = emailOtpAuthMethodRow(input.localAuthMethod);
1554
- if (row.status !== "active" || row.record.localStatus !== "synced") throw new Error("local Email OTP auth method must be active and synced");
1555
- if (row.record.walletId !== input.authority.walletId || row.record.emailHashHex !== input.authMethod.emailHashHex || row.record.registrationAuthorityId !== input.authMethod.registrationAuthorityId || row.record.authority.walletId !== input.authority.walletId || row.record.authority.bindingId !== input.authMethod.walletAuthMethodId) throw new Error("local Email OTP auth method does not match authMethod");
1556
- return row.record;
1557
- }
1558
- function parseLocalAuthorityInstallationInput(input) {
1559
- try {
1560
- const authority = requireBoundaryParsed(parseWalletAuthorityV1(input.authority), "authority");
1561
- if (authority.state !== "pending_local_install") throw new Error("authority must be pending_local_install");
1562
- const authMethod = parseWalletAuthMethodRecordV2(input.authMethod);
1563
- if (!authMethod || authMethod.status !== "pending_local_install") throw new Error("authMethod must be a pending_local_install V2 record");
1564
- const profileId = normalizeTrimmedString(input.profile.profileId || "");
1565
- if (!profileId || profileId !== String(authority.walletId)) throw new Error("profile identity does not match authority");
1566
- const defaultSignerSlot = input.profile.defaultSignerSlot === void 0 ? 1 : parseNonNegativeSafeInteger(input.profile.defaultSignerSlot, "profile.defaultSignerSlot");
1567
- if (defaultSignerSlot < 1) throw new Error("profile.defaultSignerSlot must be a positive safe integer");
1568
- const profile = {
1569
- profileId,
1570
- defaultSignerSlot,
1571
- ...input.profile.passkeyCredential ? { passkeyCredential: input.profile.passkeyCredential } : {},
1572
- ...input.profile.preferences ? { preferences: input.profile.preferences } : {},
1573
- ...input.profile.nearProvisioning ? { nearProvisioning: input.profile.nearProvisioning } : {}
1574
- };
1575
- const authenticator = input.authenticator === null ? null : normalizeAuthenticatorRecord(input.authenticator);
1576
- let localAuthMethod = null;
1577
- if (authMethod.kind === "passkey") {
1578
- if (input.localAuthMethod !== null) throw new Error("Passkey installation cannot include a local Email OTP auth method");
1579
- const passkeyCredential = profile.passkeyCredential;
1580
- if (!passkeyCredential || passkeyCredential.id !== authMethod.credentialIdB64u || passkeyCredential.rawId !== authMethod.credentialIdB64u) throw new Error("profile passkey credential does not match authMethod");
1581
- if (!authenticator || authenticator.profileId !== profileId || authenticator.signerSlot !== defaultSignerSlot || authenticator.credentialId !== authMethod.credentialIdB64u || base64UrlEncode(authenticator.credentialPublicKey) !== authMethod.credentialPublicKeyB64u) throw new Error("profile authenticator does not match authMethod");
1582
- } else {
1583
- if (authenticator !== null || profile.passkeyCredential !== void 0) throw new Error("Email OTP installation cannot include passkey profile records");
1584
- if (input.localAuthMethod === null) throw new Error("Email OTP installation requires a local auth method");
1585
- localAuthMethod = parseLocalEmailOtpAuthMethodForInstallation({
1586
- localAuthMethod: input.localAuthMethod,
1587
- authority,
1588
- authMethod
1589
- });
1590
- }
1591
- if (!Array.isArray(input.signerMaterials)) throw new Error("signerMaterials must be an array");
1592
- const signerMaterials = [];
1593
- for (const rawMaterial of input.signerMaterials) signerMaterials.push(parseWalletAuthoritySignerMaterialRecord(rawMaterial));
1594
- const exportRoot = input.exportRoot === null ? null : parseWalletAuthorityExportRootRecord(input.exportRoot);
1595
- const receipt = parseLocalAuthorityInstallationReceiptV1(input.receipt);
1596
- const expectedLockGeneration = parseNonNegativeSafeInteger(input.expectedLockGeneration, "expectedLockGeneration");
1597
- if (authMethod.walletId !== authority.walletId || authMethod.walletAuthorityId !== authority.authorityId || receipt.walletId !== authority.walletId || receipt.authorityId !== authority.authorityId || receipt.authMethodId !== authMethod.walletAuthMethodId || receipt.deviceId !== authority.principal.deviceId || receipt.packageSetDigestB64u !== authority.localInstallPackageSetDigestB64u) throw new Error("authority, authMethod, and receipt identities do not match");
1598
- if (!walletSignerActivationSetsMatch(receipt.installedActivationRefs, authority.signerActivations)) throw new Error("receipt signer activations do not match authority");
1599
- const expectations = signerMaterialExpectations(authority.signerActivations);
1600
- if (signerMaterials.length !== expectations.length) throw new Error("signer material records do not match authority signer families");
1601
- for (let index = 0; index < expectations.length; index += 1) {
1602
- const material = signerMaterials[index];
1603
- const expected = expectations[index];
1604
- if (material.authorityId !== authority.authorityId || material.walletAuthMethodId !== authMethod.walletAuthMethodId || material.keyFamily !== expected.keyFamily || !mpcMaterialActivationRefsEqual(material.materialActivation, expected.materialActivation)) throw new Error("signer material record does not match authority activation");
1605
- }
1606
- if ((hasEd25519SignerFamily(authority.signerActivations) && authority.permissions.includes("export_keys")) !== (exportRoot !== null)) throw new Error("Ed25519 export root presence does not match authority permissions");
1607
- if (exportRoot) {
1608
- const expectedWalletKeyId = ed25519WalletKeyId(authority.signerActivations);
1609
- if (expectedWalletKeyId === null || exportRoot.authorityId !== authority.authorityId || exportRoot.walletAuthMethodId !== authMethod.walletAuthMethodId || exportRoot.walletKeyId !== expectedWalletKeyId || exportRoot.envelope.walletId !== authority.walletId || exportRoot.envelope.binding.kind !== "ed25519_yao_client_root_v1" || exportRoot.envelope.binding.walletKeyId !== expectedWalletKeyId || exportRoot.envelope.binding.registeredPublicKeyB64u !== authority.signerActivations.ed25519?.signer.registeredPublicKeyB64u || authority.principal.kind !== "owner_device" || String(exportRoot.envelope.binding.deviceId) !== String(authority.principal.deviceId) || exportRoot.envelope.lifecycle.state !== "active" || !exportRootEnvelopeMatchesAuthMethod(authMethod, exportRoot.envelope)) throw new Error("export root does not match the Ed25519 authority activation");
1610
- }
1611
- return {
1612
- ok: true,
1613
- value: {
1614
- authority,
1615
- authMethod,
1616
- profile,
1617
- authenticator,
1618
- localAuthMethod,
1619
- signerMaterials,
1620
- exportRoot,
1621
- receipt,
1622
- expectedLockGeneration
1623
- }
1624
- };
1625
- } catch (error) {
1626
- return {
1627
- ok: false,
1628
- error: localAuthorityInstallationError(error)
1629
- };
1630
- }
1631
- }
1632
- function passkeyCredentialIndexKey(row) {
1633
- return [
1634
- "passkey",
1635
- row.rp_id,
1636
- row.credential_id_b64u
1637
- ].join("\0");
1638
- }
1639
- function walletAuthMethodRowsForRegistrationFinalize(input) {
1640
- const authenticators = input.authenticators.map((authenticator) => normalizeAuthenticatorRecord(authenticator));
1641
- const rows = /* @__PURE__ */ new Map();
1642
- const credentialRows = /* @__PURE__ */ new Map();
1643
- if (input.initialAuthMethod.kind === "passkey") {
1644
- const matchingAuthenticator = authenticators.find((authenticator) => authenticator.profileId === input.initialAuthMethod.walletId && authenticator.credentialId === input.initialAuthMethod.credentialIdB64u);
1645
- if (!matchingAuthenticator) throw new Error("[SeamsWalletDB] passkey registration finalize requires matching authenticator material");
1646
- const row = passkeyAuthMethodRow({
1647
- binding: input.initialAuthMethod,
1648
- authenticator: matchingAuthenticator
1649
- });
1650
- rows.set(row.wallet_auth_method_id, row);
1651
- credentialRows.set(passkeyCredentialIndexKey(row), row);
1652
- } else {
1653
- const row = emailOtpAuthMethodRow(input.initialAuthMethod);
1654
- rows.set(row.wallet_auth_method_id, row);
1655
- }
1656
- for (const authenticator of authenticators) {
1657
- if (input.initialAuthMethod.kind === "passkey" && authenticator.profileId === input.initialAuthMethod.walletId && authenticator.credentialId === input.initialAuthMethod.credentialIdB64u) {
1658
- const row = passkeyAuthMethodRow({
1659
- binding: input.initialAuthMethod,
1660
- authenticator
1661
- });
1662
- rows.set(row.wallet_auth_method_id, row);
1663
- credentialRows.set(passkeyCredentialIndexKey(row), row);
1664
- continue;
1665
- }
1666
- const row = walletAuthMethodRowFromAuthenticator(authenticator);
1667
- const credentialKey = passkeyCredentialIndexKey(row);
1668
- const existingCredentialRow = credentialRows.get(credentialKey);
1669
- if (existingCredentialRow) {
1670
- if (existingCredentialRow.credential_public_key_b64u !== row.credential_public_key_b64u) throw new Error("[SeamsWalletDB] duplicate passkey credential has conflicting public key");
1671
- if (existingCredentialRow.wallet_auth_method_id === row.wallet_auth_method_id) {
1672
- rows.set(row.wallet_auth_method_id, row);
1673
- credentialRows.set(credentialKey, row);
1674
- }
1675
- continue;
1676
- }
1677
- rows.set(row.wallet_auth_method_id, row);
1678
- credentialRows.set(credentialKey, row);
1679
- }
1680
- return [...rows.values()];
1681
- }
1682
- function chainAccountProjectionRow(input, existing) {
1683
- const profileId = normalizeTrimmedString(input.profileId || "");
1684
- const chainIdKey = normalizeIndexedDbChainIdKey(input.chainIdKey);
1685
- const accountAddress = normalizeIndexedDbAccountAddress(input.accountAddress);
1686
- const accountModel = normalizeIndexedDbAccountModel(input.accountModel);
1687
- if (!profileId || !chainIdKey || !accountAddress) throw new Error("[SeamsWalletDB] profileId, chainIdKey, and accountAddress are required");
1688
- if (!accountModel) throw new Error("[SeamsWalletDB] accountModel is required");
1689
- const now = Date.now();
1690
- const record = {
1691
- profileId,
1692
- chainIdKey,
1693
- accountAddress,
1694
- accountModel,
1695
- isPrimary: input.isPrimary ?? existing?.isPrimary ?? false,
1696
- createdAt: existing?.createdAt ?? now,
1697
- updatedAt: now
1698
- };
1699
- return {
1700
- wallet_id: profileId,
1701
- near_account_id: chainAccountProjectionId({
1702
- chainIdKey,
1703
- accountAddress
1704
- }),
1705
- signer_slot: CHAIN_ACCOUNT_PROJECTION_SIGNER_SLOT,
1706
- profile_id: profileId,
1707
- chain_id_key: chainIdKey,
1708
- account_address: accountAddress,
1709
- account_model: accountModel,
1710
- is_primary: !!record.isPrimary,
1711
- updated_at: record.updatedAt,
1712
- record
1713
- };
1714
- }
1715
- function parseStoredChainAccountRecord(value) {
1716
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1717
- const profileId = parseStoredNonEmptyString(Reflect.get(value, "profileId"));
1718
- const chainIdKey = normalizeIndexedDbChainIdKey(Reflect.get(value, "chainIdKey"));
1719
- const accountAddress = normalizeIndexedDbAccountAddress(Reflect.get(value, "accountAddress"));
1720
- const accountModel = normalizeIndexedDbAccountModel(Reflect.get(value, "accountModel"));
1721
- const createdAt = Reflect.get(value, "createdAt");
1722
- const updatedAt = Reflect.get(value, "updatedAt");
1723
- const isPrimary = Reflect.get(value, "isPrimary");
1724
- if (!profileId || !chainIdKey || !accountAddress || !accountModel || !Number.isSafeInteger(createdAt) || Number(createdAt) < 0 || !Number.isSafeInteger(updatedAt) || Number(updatedAt) < 0 || isPrimary !== void 0 && typeof isPrimary !== "boolean") return null;
1725
- return {
1726
- profileId,
1727
- chainIdKey,
1728
- accountAddress,
1729
- accountModel,
1730
- ...isPrimary === void 0 ? {} : { isPrimary },
1731
- createdAt: Number(createdAt),
1732
- updatedAt: Number(updatedAt)
1733
- };
1734
- }
1735
- function parseChainAccountProjectionRow(value) {
1736
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1737
- const record = parseStoredChainAccountRecord(Reflect.get(value, "record"));
1738
- if (!record) return null;
1739
- if (Reflect.get(value, "wallet_id") !== record.profileId) return null;
1740
- if (Reflect.get(value, "profile_id") !== record.profileId) return null;
1741
- if (Reflect.get(value, "chain_id_key") !== record.chainIdKey) return null;
1742
- if (Reflect.get(value, "account_address") !== record.accountAddress) return null;
1743
- if (Reflect.get(value, "account_model") !== record.accountModel) return null;
1744
- if (Reflect.get(value, "is_primary") !== !!record.isPrimary) return null;
1745
- if (Reflect.get(value, "updated_at") !== record.updatedAt) return null;
1746
- if (Reflect.get(value, "near_account_id") !== chainAccountProjectionId({
1747
- chainIdKey: record.chainIdKey,
1748
- accountAddress: record.accountAddress
1749
- })) return null;
1750
- return record;
1751
- }
1752
- function accountSignerRow(record) {
1753
- const profileId = normalizeTrimmedString(record.profileId || "");
1754
- const chainIdKey = normalizeIndexedDbChainIdKey(record.chainIdKey);
1755
- const accountAddress = normalizeIndexedDbAccountAddress(record.accountAddress);
1756
- const signerId = normalizeTrimmedString(record.signerId || "");
1757
- const signerKind = normalizeTrimmedString(record.signerKind || "");
1758
- if (!profileId || !chainIdKey || !accountAddress || !signerId || !signerKind) throw new Error("[SeamsWalletDB] signer requires profileId, chainIdKey, accountAddress, signerId, and signerKind");
1759
- const mirrors = walletSignerScalarMirrors({
1760
- ...record,
1761
- profileId,
1762
- chainIdKey,
1763
- accountAddress,
1764
- signerId
1765
- });
1766
- const isActive = record.status === "active";
1767
- return {
1768
- wallet_signer_id: walletSignerId({
1769
- chainIdKey,
1770
- accountAddress,
1771
- signerId
1772
- }),
1773
- wallet_id: profileId,
1774
- kind: signerKind,
1775
- chain_target_key: mirrors.chainTargetKey,
1776
- ...isActive && mirrors.nearSignerSlot != null ? { near_signer_slot: mirrors.nearSignerSlot } : {},
1777
- ...isActive && mirrors.nearEd25519SigningKeyId ? { near_ed25519_signing_key_id: mirrors.nearEd25519SigningKeyId } : {},
1778
- ...isActive && mirrors.keyHandle ? { key_handle: mirrors.keyHandle } : {},
1779
- ...isActive && mirrors.ecdsaThresholdKeyId ? { ecdsa_threshold_key_id: mirrors.ecdsaThresholdKeyId } : {},
1780
- ...isActive && mirrors.thresholdOwnerAddress ? { threshold_owner_address: mirrors.thresholdOwnerAddress } : {},
1781
- status: record.status,
1782
- updated_at: record.updatedAt,
1783
- record: {
1784
- ...record,
1785
- profileId,
1786
- chainIdKey,
1787
- accountAddress,
1788
- signerId
1789
- }
1790
- };
1791
- }
1792
- function parseStoredAccountSignerRecord(value) {
1793
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1794
- const profileId = parseStoredNonEmptyString(Reflect.get(value, "profileId"));
1795
- const chainIdKey = normalizeIndexedDbChainIdKey(Reflect.get(value, "chainIdKey"));
1796
- const accountAddress = normalizeIndexedDbAccountAddress(Reflect.get(value, "accountAddress"));
1797
- const signerId = parseStoredNonEmptyString(Reflect.get(value, "signerId"));
1798
- const signerSlot = Reflect.get(value, "signerSlot");
1799
- const signerType = parseStoredNonEmptyString(Reflect.get(value, "signerType"));
1800
- const signerKind = Reflect.get(value, "signerKind");
1801
- const signerAuthMethod = Reflect.get(value, "signerAuthMethod");
1802
- const signerSource = Reflect.get(value, "signerSource");
1803
- const status = Reflect.get(value, "status");
1804
- const addedAt = Reflect.get(value, "addedAt");
1805
- const updatedAt = Reflect.get(value, "updatedAt");
1806
- if (!profileId || !chainIdKey || !accountAddress || !signerId || !Number.isSafeInteger(signerSlot) || Number(signerSlot) < 1 || !signerType || signerKind !== SIGNER_KINDS.thresholdEd25519 && signerKind !== SIGNER_KINDS.thresholdEcdsa || signerAuthMethod !== "passkey" && signerAuthMethod !== "email_otp" || signerSource !== "passkey_registration" && signerSource !== "email_otp_registration" && signerSource !== "self_hosted_import" || status !== "active" && status !== "pending" && status !== "revoked" || !Number.isSafeInteger(addedAt) || Number(addedAt) < 0 || !Number.isSafeInteger(updatedAt) || Number(updatedAt) < 0) return null;
1807
- const metadataRaw = Reflect.get(value, "metadata");
1808
- let metadata;
1809
- if (metadataRaw !== void 0) {
1810
- if (metadataRaw === null || typeof metadataRaw !== "object" || Array.isArray(metadataRaw)) return null;
1811
- metadata = {};
1812
- for (const key of Object.keys(metadataRaw)) metadata[key] = Reflect.get(metadataRaw, key);
1813
- }
1814
- const removedAt = Reflect.get(value, "removedAt");
1815
- const revocationReason = Reflect.get(value, "revocationReason");
1816
- if (removedAt !== void 0 && (!Number.isSafeInteger(removedAt) || Number(removedAt) < 0) || revocationReason !== void 0 && typeof revocationReason !== "string") return null;
1817
- return {
1818
- profileId,
1819
- chainIdKey,
1820
- accountAddress,
1821
- signerId,
1822
- signerSlot: Number(signerSlot),
1823
- signerType,
1824
- signerKind,
1825
- signerAuthMethod,
1826
- signerSource,
1827
- status,
1828
- addedAt: Number(addedAt),
1829
- updatedAt: Number(updatedAt),
1830
- ...removedAt === void 0 ? {} : { removedAt: Number(removedAt) },
1831
- ...revocationReason === void 0 ? {} : { revocationReason },
1832
- ...metadata === void 0 ? {} : { metadata }
1833
- };
1834
- }
1835
- function parseAccountSignerRow(value) {
1836
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1837
- const record = parseStoredAccountSignerRecord(Reflect.get(value, "record"));
1838
- if (!record) return null;
1839
- if (Reflect.get(value, "wallet_signer_id") !== walletSignerId({
1840
- chainIdKey: record.chainIdKey,
1841
- accountAddress: record.accountAddress,
1842
- signerId: record.signerId
1843
- })) return null;
1844
- if (Reflect.get(value, "wallet_id") !== record.profileId) return null;
1845
- if (Reflect.get(value, "kind") !== record.signerKind) return null;
1846
- let mirrors;
1847
- try {
1848
- mirrors = walletSignerScalarMirrors(record);
1849
- } catch {
1850
- return null;
1851
- }
1852
- const requiresActiveMirrors = record.status === "active";
1853
- if (record.signerKind === SIGNER_KINDS.thresholdEd25519) {
1854
- const chainTargetKey = Reflect.get(value, "chain_target_key");
1855
- const nearSignerSlot = Reflect.get(value, "near_signer_slot");
1856
- const nearEd25519SigningKeyId = Reflect.get(value, "near_ed25519_signing_key_id");
1857
- if (chainTargetKey !== void 0 && chainTargetKey !== mirrors.chainTargetKey) return null;
1858
- if (requiresActiveMirrors && nearSignerSlot !== mirrors.nearSignerSlot) return null;
1859
- if (!requiresActiveMirrors && nearSignerSlot !== void 0 && nearSignerSlot !== mirrors.nearSignerSlot) return null;
1860
- if (requiresActiveMirrors && nearEd25519SigningKeyId !== mirrors.nearEd25519SigningKeyId) return null;
1861
- if (!requiresActiveMirrors && nearEd25519SigningKeyId !== void 0 && nearEd25519SigningKeyId !== mirrors.nearEd25519SigningKeyId) return null;
1862
- } else if (requiresActiveMirrors && Reflect.get(value, "chain_target_key") !== mirrors.chainTargetKey) return null;
1863
- else if (!requiresActiveMirrors && Reflect.get(value, "chain_target_key") !== void 0 && Reflect.get(value, "chain_target_key") !== mirrors.chainTargetKey) return null;
1864
- const keyHandle = Reflect.get(value, "key_handle");
1865
- const ecdsaThresholdKeyId = Reflect.get(value, "ecdsa_threshold_key_id");
1866
- const thresholdOwnerAddress = Reflect.get(value, "threshold_owner_address");
1867
- if (requiresActiveMirrors && keyHandle !== mirrors.keyHandle) return null;
1868
- if (!requiresActiveMirrors && keyHandle !== void 0 && keyHandle !== mirrors.keyHandle) return null;
1869
- if (requiresActiveMirrors && ecdsaThresholdKeyId !== mirrors.ecdsaThresholdKeyId) return null;
1870
- if (!requiresActiveMirrors && ecdsaThresholdKeyId !== void 0 && ecdsaThresholdKeyId !== mirrors.ecdsaThresholdKeyId) return null;
1871
- if (requiresActiveMirrors && thresholdOwnerAddress !== mirrors.thresholdOwnerAddress) return null;
1872
- if (!requiresActiveMirrors && thresholdOwnerAddress !== void 0 && thresholdOwnerAddress !== mirrors.thresholdOwnerAddress) return null;
1873
- if (Reflect.get(value, "status") !== record.status) return null;
1874
- if (Reflect.get(value, "updated_at") !== record.updatedAt) return null;
1875
- return record;
1876
- }
1877
- async function deleteConflictingThresholdEcdsaSignerRows(args) {
1878
- const row = args.nextRow;
1879
- if (row.kind !== SIGNER_KINDS.thresholdEcdsa || row.status === "revoked") return;
1880
- if (!row.key_handle || !row.ecdsa_threshold_key_id) return;
1881
- const walletRows = await args.store.index(SEAMS_WALLET_INDEXES.walletId).getAll(row.wallet_id);
1882
- const conflictingRowIds = /* @__PURE__ */ new Set();
1883
- for (const rawExisting of walletRows) {
1884
- if (rawExisting === null || typeof rawExisting !== "object" || Array.isArray(rawExisting)) continue;
1885
- if (!parseAccountSignerRow(rawExisting)) continue;
1886
- const existingRowId = normalizeTrimmedString(Reflect.get(rawExisting, "wallet_signer_id") || "");
1887
- if (!existingRowId || existingRowId === row.wallet_signer_id) continue;
1888
- if (Reflect.get(rawExisting, "kind") !== row.kind || Reflect.get(rawExisting, "chain_target_key") !== row.chain_target_key) continue;
1889
- if (Reflect.get(rawExisting, "key_handle") === row.key_handle || Reflect.get(rawExisting, "ecdsa_threshold_key_id") === row.ecdsa_threshold_key_id) conflictingRowIds.add(existingRowId);
1890
- }
1891
- for (const rowId of conflictingRowIds) await args.store.delete(rowId);
1892
- }
1893
- function signerOutboxRow(record) {
1894
- const opId = normalizeTrimmedString(record.opId || "");
1895
- const idempotencyKey = normalizeTrimmedString(record.idempotencyKey || "");
1896
- const chainIdKey = normalizeIndexedDbChainIdKey(record.chainIdKey);
1897
- const accountAddress = normalizeIndexedDbAccountAddress(record.accountAddress);
1898
- const signerId = normalizeTrimmedString(record.signerId || "");
1899
- if (!opId || !idempotencyKey || !chainIdKey || !accountAddress || !signerId) throw new Error("[SeamsWalletDB] signer op requires opId, idempotencyKey, chainIdKey, accountAddress, and signerId");
1900
- return {
1901
- op_id: opId,
1902
- idempotency_key: idempotencyKey,
1903
- status: record.status,
1904
- next_attempt_at: record.nextAttemptAt,
1905
- wallet_id: normalizeTrimmedString(String(record.payload?.profileId || "")),
1906
- chain_target_key: signerChainTargetKey({
1907
- chainIdKey,
1908
- accountAddress
1909
- }),
1910
- updated_at: record.updatedAt,
1911
- record: {
1912
- ...record,
1913
- opId,
1914
- idempotencyKey,
1915
- chainIdKey,
1916
- accountAddress,
1917
- signerId
1918
- }
1919
- };
1920
- }
1921
- function parseStoredSignerOutboxRecord(value) {
1922
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1923
- const opId = parseStoredNonEmptyString(Reflect.get(value, "opId"));
1924
- const idempotencyKey = parseStoredNonEmptyString(Reflect.get(value, "idempotencyKey"));
1925
- const opType = parseStoredNonEmptyString(Reflect.get(value, "opType"));
1926
- const chainIdKey = normalizeIndexedDbChainIdKey(Reflect.get(value, "chainIdKey"));
1927
- const accountAddress = normalizeIndexedDbAccountAddress(Reflect.get(value, "accountAddress"));
1928
- const signerId = parseStoredNonEmptyString(Reflect.get(value, "signerId"));
1929
- const status = Reflect.get(value, "status");
1930
- const attemptCount = Reflect.get(value, "attemptCount");
1931
- const nextAttemptAt = Reflect.get(value, "nextAttemptAt");
1932
- const createdAt = Reflect.get(value, "createdAt");
1933
- const updatedAt = Reflect.get(value, "updatedAt");
1934
- if (!opId || !idempotencyKey || !opType || !chainIdKey || !accountAddress || !signerId || status !== "queued" && status !== "submitted" && status !== "confirmed" && status !== "failed" && status !== "dead-letter" || !Number.isSafeInteger(attemptCount) || Number(attemptCount) < 0 || !Number.isSafeInteger(nextAttemptAt) || Number(nextAttemptAt) < 0 || !Number.isSafeInteger(createdAt) || Number(createdAt) < 0 || !Number.isSafeInteger(updatedAt) || Number(updatedAt) < 0) return null;
1935
- const payloadRaw = Reflect.get(value, "payload");
1936
- const payload = sanitizePayload(payloadRaw);
1937
- if (payloadRaw !== void 0 && (payloadRaw === null || typeof payloadRaw !== "object" || Array.isArray(payloadRaw))) return null;
1938
- const lastError = Reflect.get(value, "lastError");
1939
- const txHash = Reflect.get(value, "txHash");
1940
- if (lastError !== void 0 && typeof lastError !== "string" || txHash !== void 0 && typeof txHash !== "string") return null;
1941
- return {
1942
- opId,
1943
- idempotencyKey,
1944
- opType,
1945
- chainIdKey,
1946
- accountAddress,
1947
- signerId,
1948
- status,
1949
- attemptCount: Number(attemptCount),
1950
- nextAttemptAt: Number(nextAttemptAt),
1951
- createdAt: Number(createdAt),
1952
- updatedAt: Number(updatedAt),
1953
- ...payload === void 0 ? {} : { payload },
1954
- ...lastError === void 0 ? {} : { lastError },
1955
- ...txHash === void 0 ? {} : { txHash }
1956
- };
1957
- }
1958
- function parseSignerOutboxRow(value) {
1959
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1960
- const record = parseStoredSignerOutboxRecord(Reflect.get(value, "record"));
1961
- if (!record) return null;
1962
- if (Reflect.get(value, "op_id") !== record.opId) return null;
1963
- if (Reflect.get(value, "idempotency_key") !== record.idempotencyKey) return null;
1964
- if (Reflect.get(value, "status") !== record.status) return null;
1965
- if (Reflect.get(value, "next_attempt_at") !== record.nextAttemptAt) return null;
1966
- if (Reflect.get(value, "chain_target_key") !== signerChainTargetKey({
1967
- chainIdKey: record.chainIdKey,
1968
- accountAddress: record.accountAddress
1969
- })) return null;
1970
- const payloadProfileId = normalizeTrimmedString(String(record.payload && Reflect.get(record.payload, "profileId") ? Reflect.get(record.payload, "profileId") : ""));
1971
- if (Reflect.get(value, "wallet_id") !== payloadProfileId) return null;
1972
- if (Reflect.get(value, "updated_at") !== record.updatedAt) return null;
1973
- return record;
1974
- }
1975
- function keyMaterialId(args) {
1976
- return [args.walletSignerId, args.keyKind].join("\0");
1977
- }
1978
- function walletSignerIdForKeyMaterial(record) {
1979
- return walletSignerId({
1980
- chainIdKey: record.chainIdKey,
1981
- accountAddress: record.accountAddress,
1982
- signerId: record.signerId
1983
- });
1984
- }
1985
- function keyMaterialRow(data) {
1986
- const profileId = normalizeTrimmedString(data.profileId || "");
1987
- const signerId = normalizeTrimmedString(data.signerId || "");
1988
- const wrapKeySalt = normalizeTrimmedString(data.wrapKeySalt || "");
1989
- const chainIdKey = normalizeTrimmedString(data.chainIdKey || "").toLowerCase();
1990
- const accountAddress = normalizeIndexedDbAccountAddress(data.accountAddress);
1991
- const keyKind = normalizeTrimmedString(data.keyKind || "");
1992
- const algorithm = normalizeTrimmedString(data.algorithm || "");
1993
- const publicKey = normalizeTrimmedString(data.publicKey || "");
1994
- if (!profileId) throw new Error("[SeamsWalletDB] Missing profileId for key material record");
1995
- if (!Number.isSafeInteger(data.signerSlot) || data.signerSlot < 1) throw new Error("[SeamsWalletDB] Invalid signerSlot for key material record");
1996
- if (!chainIdKey) throw new Error("[SeamsWalletDB] Missing chainIdKey for key material record");
1997
- if (!accountAddress) throw new Error("[SeamsWalletDB] Missing accountAddress for key material record");
1998
- if (!signerId) throw new Error("[SeamsWalletDB] Missing signerId for key material record");
1999
- if (!keyKind) throw new Error("[SeamsWalletDB] Missing keyKind for key material record");
2000
- if (!algorithm) throw new Error("[SeamsWalletDB] Missing algorithm for key material record");
2001
- if (!publicKey) throw new Error("[SeamsWalletDB] Missing publicKey for key material record");
2002
- if (typeof data.timestamp !== "number") throw new Error("[SeamsWalletDB] Missing timestamp for key material record");
2003
- if (!Number.isSafeInteger(data.schemaVersion) || data.schemaVersion < 1) throw new Error("[SeamsWalletDB] Invalid schemaVersion for key material record");
2004
- const expectedAAD = buildEnvelopeAAD({
2005
- profileId,
2006
- signerSlot: data.signerSlot,
2007
- chainIdKey,
2008
- accountAddress,
2009
- keyKind,
2010
- schemaVersion: data.schemaVersion,
2011
- signerId
2012
- });
2013
- const payloadEnvelope = normalizePayloadEnvelope(data.payloadEnvelope, expectedAAD, `${profileId}/${data.signerSlot}/${chainIdKey}/${keyKind}`);
2014
- const payload = sanitizePayload(data.payload);
2015
- const record = {
2016
- profileId,
2017
- signerSlot: data.signerSlot,
2018
- chainIdKey,
2019
- accountAddress,
2020
- keyKind,
2021
- algorithm,
2022
- publicKey,
2023
- signerId,
2024
- ...wrapKeySalt ? { wrapKeySalt } : {},
2025
- ...payload ? { payload } : {},
2026
- ...payloadEnvelope ? { payloadEnvelope } : {},
2027
- timestamp: data.timestamp,
2028
- schemaVersion: data.schemaVersion
2029
- };
2030
- const walletSignerId = walletSignerIdForKeyMaterial(record);
2031
- const chainTargetKey = signerChainTargetKey({
2032
- chainIdKey,
2033
- accountAddress
2034
- });
2035
- return {
2036
- key_material_id: keyMaterialId({
2037
- walletSignerId,
2038
- keyKind
2039
- }),
2040
- wallet_id: profileId,
2041
- wallet_signer_id: walletSignerId,
2042
- chain_target_key: chainTargetKey,
2043
- key_handle: signerId,
2044
- public_key: publicKey,
2045
- updated_at: data.timestamp,
2046
- record
2047
- };
2048
- }
2049
- function signerKeyMaterialPairKey(args) {
2050
- return [
2051
- normalizeTrimmedString(args.profileId || ""),
2052
- normalizeIndexedDbChainIdKey(args.chainIdKey),
2053
- normalizeIndexedDbAccountAddress(args.accountAddress),
2054
- normalizeTrimmedString(args.signerId || ""),
2055
- String(Number(args.signerSlot))
2056
- ].join("\0");
2057
- }
2058
- function assertSignerKeyMaterialPairs(args) {
2059
- const signerKeys = new Set(args.signers.map((signer) => signerKeyMaterialPairKey({
2060
- profileId: signer.profileId,
2061
- chainIdKey: signer.chainIdKey,
2062
- accountAddress: signer.accountAddress,
2063
- signerId: signer.signerId,
2064
- signerSlot: signer.signerSlot
2065
- })));
2066
- const keyMaterialKeys = new Set(args.keyMaterials.filter((keyMaterial) => keyMaterial.keyKind === "threshold_share_v1").map((keyMaterial) => signerKeyMaterialPairKey({
2067
- profileId: keyMaterial.profileId,
2068
- chainIdKey: keyMaterial.chainIdKey,
2069
- accountAddress: keyMaterial.accountAddress,
2070
- signerId: keyMaterial.signerId,
2071
- signerSlot: keyMaterial.signerSlot
2072
- })));
2073
- const missingSigner = args.signers.find((signer) => signer.status === "active" && !keyMaterialKeys.has(signerKeyMaterialPairKey({
2074
- profileId: signer.profileId,
2075
- chainIdKey: signer.chainIdKey,
2076
- accountAddress: signer.accountAddress,
2077
- signerId: signer.signerId,
2078
- signerSlot: signer.signerSlot
2079
- })));
2080
- if (missingSigner) throw new Error(`[SeamsWalletDB] active signer ${missingSigner.signerId} requires matching threshold key material`);
2081
- const orphanedKeyMaterial = args.keyMaterials.find((keyMaterial) => keyMaterial.keyKind === "threshold_share_v1" && !signerKeys.has(signerKeyMaterialPairKey({
2082
- profileId: keyMaterial.profileId,
2083
- chainIdKey: keyMaterial.chainIdKey,
2084
- accountAddress: keyMaterial.accountAddress,
2085
- signerId: keyMaterial.signerId,
2086
- signerSlot: keyMaterial.signerSlot
2087
- })));
2088
- if (orphanedKeyMaterial) throw new Error(`[SeamsWalletDB] threshold key material for signer ${orphanedKeyMaterial.signerId} has no matching signer activation`);
2089
- }
2090
- function parseStoredKeyMaterialRecord(value) {
2091
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
2092
- const profileId = parseStoredNonEmptyString(Reflect.get(value, "profileId"));
2093
- const signerSlot = Reflect.get(value, "signerSlot");
2094
- const chainIdKey = normalizeIndexedDbChainIdKey(Reflect.get(value, "chainIdKey"));
2095
- const accountAddress = normalizeIndexedDbAccountAddress(Reflect.get(value, "accountAddress"));
2096
- const keyKind = parseStoredNonEmptyString(Reflect.get(value, "keyKind"));
2097
- const algorithm = parseStoredNonEmptyString(Reflect.get(value, "algorithm"));
2098
- const publicKey = parseStoredNonEmptyString(Reflect.get(value, "publicKey"));
2099
- const signerId = parseStoredNonEmptyString(Reflect.get(value, "signerId"));
2100
- const timestamp = Reflect.get(value, "timestamp");
2101
- const schemaVersion = Reflect.get(value, "schemaVersion");
2102
- if (!profileId || !Number.isSafeInteger(signerSlot) || Number(signerSlot) < 1 || !chainIdKey || !accountAddress || !keyKind || !algorithm || !publicKey || !signerId || typeof timestamp !== "number" || !Number.isSafeInteger(schemaVersion) || Number(schemaVersion) < 1) return null;
2103
- const wrapKeySaltRaw = Reflect.get(value, "wrapKeySalt");
2104
- if (wrapKeySaltRaw !== void 0 && typeof wrapKeySaltRaw !== "string") return null;
2105
- const payloadRaw = Reflect.get(value, "payload");
2106
- const payload = sanitizePayload(payloadRaw);
2107
- if (payloadRaw !== void 0 && (payloadRaw === null || typeof payloadRaw !== "object" || Array.isArray(payloadRaw))) return null;
2108
- const expectedAAD = buildEnvelopeAAD({
2109
- profileId,
2110
- signerSlot: Number(signerSlot),
2111
- chainIdKey,
2112
- accountAddress,
2113
- keyKind,
2114
- schemaVersion: Number(schemaVersion),
2115
- signerId
2116
- });
2117
- let payloadEnvelope;
2118
- try {
2119
- payloadEnvelope = normalizePayloadEnvelope(Reflect.get(value, "payloadEnvelope"), expectedAAD, `${profileId}/${signerSlot}/${chainIdKey}/${keyKind}`);
2120
- } catch {
2121
- return null;
2122
- }
2123
- return {
2124
- profileId,
2125
- signerSlot: Number(signerSlot),
2126
- chainIdKey,
2127
- accountAddress,
2128
- keyKind,
2129
- algorithm,
2130
- publicKey,
2131
- signerId,
2132
- ...wrapKeySaltRaw === void 0 ? {} : { wrapKeySalt: wrapKeySaltRaw },
2133
- ...payload === void 0 ? {} : { payload },
2134
- ...payloadEnvelope === void 0 ? {} : { payloadEnvelope },
2135
- timestamp,
2136
- schemaVersion: Number(schemaVersion)
2137
- };
2138
- }
2139
- function parseKeyMaterialRow(value) {
2140
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
2141
- const record = parseStoredKeyMaterialRecord(Reflect.get(value, "record"));
2142
- if (!record) return null;
2143
- if (Reflect.get(value, "key_material_id") !== keyMaterialId({
2144
- walletSignerId: walletSignerIdForKeyMaterial(record),
2145
- keyKind: record.keyKind
2146
- })) return null;
2147
- if (Reflect.get(value, "wallet_id") !== record.profileId) return null;
2148
- if (Reflect.get(value, "wallet_signer_id") !== walletSignerIdForKeyMaterial(record)) return null;
2149
- if (Reflect.get(value, "chain_target_key") !== signerChainTargetKey({
2150
- chainIdKey: record.chainIdKey,
2151
- accountAddress: record.accountAddress
2152
- })) return null;
2153
- if (Reflect.get(value, "key_handle") !== normalizeTrimmedString(record.signerId || "")) return null;
2154
- if (Reflect.get(value, "public_key") !== record.publicKey) return null;
2155
- if (Reflect.get(value, "updated_at") !== record.timestamp) return null;
2156
- return record;
2157
- }
2158
- function signerKeyMaterialPairKeyForSigner(signer) {
2159
- return signerKeyMaterialPairKey({
2160
- profileId: signer.profileId,
2161
- chainIdKey: signer.chainIdKey,
2162
- accountAddress: signer.accountAddress,
2163
- signerId: signer.signerId,
2164
- signerSlot: signer.signerSlot
2165
- });
2166
- }
2167
- function signerKeyMaterialPairKeyForMaterial(keyMaterial) {
2168
- return signerKeyMaterialPairKey({
2169
- profileId: keyMaterial.profileId,
2170
- chainIdKey: keyMaterial.chainIdKey,
2171
- accountAddress: keyMaterial.accountAddress,
2172
- signerId: keyMaterial.signerId,
2173
- signerSlot: keyMaterial.signerSlot
2174
- });
2175
- }
2176
- function collectSignerKeyMaterialProfileIds(args) {
2177
- const profileIds = /* @__PURE__ */ new Set();
2178
- for (const signer of args.signers) {
2179
- const profileId = normalizeTrimmedString(signer.profileId || "");
2180
- if (profileId) profileIds.add(profileId);
2181
- }
2182
- for (const keyMaterial of args.keyMaterials) {
2183
- const profileId = normalizeTrimmedString(keyMaterial.profileId || "");
2184
- if (profileId) profileIds.add(profileId);
2185
- }
2186
- return [...profileIds];
2187
- }
2188
- async function readActiveSignersForProfilesInTransaction(ctx, profileIds) {
2189
- const store = ctx.store(SEAMS_WALLET_STORES.walletSigners);
2190
- const signers = [];
2191
- for (const profileId of profileIds) {
2192
- const rows = await store.index(SEAMS_WALLET_INDEXES.walletId).getAll(profileId);
2193
- for (const row of rows) {
2194
- const parsed = parseAccountSignerRow(row);
2195
- if (parsed?.status === "active") signers.push(parsed);
2196
- }
2197
- }
2198
- return signers;
2199
- }
2200
- async function readThresholdKeyMaterialsForProfilesInTransaction(ctx, profileIds) {
2201
- const store = ctx.store(SEAMS_WALLET_STORES.keyMaterial);
2202
- const keyMaterials = [];
2203
- for (const profileId of profileIds) {
2204
- const rows = await store.index(SEAMS_WALLET_INDEXES.walletId).getAll(profileId);
2205
- for (const row of rows) {
2206
- const parsed = parseKeyMaterialRow(row);
2207
- if (parsed?.keyKind === "threshold_share_v1") keyMaterials.push(parsed);
2208
- }
2209
- }
2210
- return keyMaterials;
2211
- }
2212
- function mergeKeyMaterialsById(args) {
2213
- const merged = /* @__PURE__ */ new Map();
2214
- for (const keyMaterial of args.existing) merged.set(keyMaterialId({
2215
- walletSignerId: walletSignerIdForKeyMaterial(keyMaterial),
2216
- keyKind: keyMaterial.keyKind
2217
- }), keyMaterial);
2218
- for (const keyMaterial of args.incoming) merged.set(keyMaterialId({
2219
- walletSignerId: walletSignerIdForKeyMaterial(keyMaterial),
2220
- keyKind: keyMaterial.keyKind
2221
- }), keyMaterial);
2222
- return [...merged.values()];
2223
- }
2224
- async function assertSignerKeyMaterialPairsInTransaction(args) {
2225
- const profileIds = collectSignerKeyMaterialProfileIds({
2226
- signers: args.signers,
2227
- keyMaterials: args.keyMaterials
2228
- });
2229
- if (profileIds.length === 0) return;
2230
- const activeSigners = await readActiveSignersForProfilesInTransaction(args.ctx, profileIds);
2231
- const activeSignerKeys = new Set(activeSigners.map(signerKeyMaterialPairKeyForSigner));
2232
- assertSignerKeyMaterialPairs({
2233
- signers: activeSigners,
2234
- keyMaterials: mergeKeyMaterialsById({
2235
- existing: (await readThresholdKeyMaterialsForProfilesInTransaction(args.ctx, profileIds)).filter((keyMaterial) => activeSignerKeys.has(signerKeyMaterialPairKeyForMaterial(keyMaterial))),
2236
- incoming: args.keyMaterials
2237
- })
2238
- });
2239
- }
2240
- function isUsableKeyMaterialForRead(record) {
2241
- if (record.keyKind !== "threshold_share_v1" || record.algorithm !== "ed25519") return true;
2242
- const payload = record.payload || {};
2243
- return !!normalizeTrimmedString(payload.relayerKeyId || "") && !!normalizeTrimmedString(payload.keyVersion || "");
2244
- }
2245
- function selectKeyMaterialForRead(args) {
2246
- const activeSignerKeys = new Set(args.activeSigners.map(signerKeyMaterialPairKeyForSigner));
2247
- const usableActive = args.matches.filter((record) => activeSignerKeys.has(signerKeyMaterialPairKeyForMaterial(record))).find(isUsableKeyMaterialForRead);
2248
- if (usableActive) return usableActive;
2249
- const usable = args.matches.find(isUsableKeyMaterialForRead);
2250
- if (usable) return usable;
2251
- return [...args.matches].sort((a, b) => b.timestamp - a.timestamp)[0] || null;
2252
- }
2253
- var SeamsWalletRepositories = class {
2254
- constructor(manager) {
2255
- this.manager = manager;
2256
- }
2257
- async installLocalAuthority(input) {
2258
- const parsed = parseLocalAuthorityInstallationInput(input);
2259
- if (!parsed.ok) return {
2260
- kind: "integrity_error",
2261
- reason: parsed.error
2262
- };
2263
- if (!await walletAuthorityDigestsMatchV1(parsed.value.authority)) return {
2264
- kind: "integrity_error",
2265
- reason: "authority digest does not match canonical encoding"
2266
- };
2267
- return this.manager.runTransaction([
2268
- SEAMS_WALLET_STORES.appState,
2269
- SEAMS_WALLET_STORES.wallets,
2270
- SEAMS_WALLET_STORES.walletAuthMethods,
2271
- SEAMS_WALLET_STORES.walletAuthorities,
2272
- SEAMS_WALLET_STORES.walletAuthoritySignerMaterials,
2273
- SEAMS_WALLET_STORES.walletAuthorityExportRoots,
2274
- SEAMS_WALLET_STORES.walletAuthorityInstallationReceipts,
2275
- SEAMS_WALLET_STORES.walletSelections
2276
- ], "readwrite", this.installLocalAuthorityInTransaction.bind(this, parsed.value));
2277
- }
2278
- async finalizeLocalAuthorityActivation(input) {
2279
- const authorityResult = parseWalletAuthorityV1(input.authority);
2280
- if (!authorityResult.ok || authorityResult.value.state !== "active") throw new Error("active WalletAuthorityV1 is invalid");
2281
- const authMethod = parseWalletAuthMethodRecordV2(input.authMethod);
2282
- if (!authMethod || authMethod.status !== "active") throw new Error("active WalletAuthMethodRecordV2 is invalid");
2283
- const walletSession = parseStoredExactWalletSessionAuthorizationRowV6(toStoredExactWalletSessionAuthorizationRowV6(input.walletSession, input.operationCredential))?.record ?? null;
2284
- if (!walletSession) throw new Error("active Wallet Session is invalid");
2285
- const expectedLockGeneration = parseNonNegativeSafeInteger(input.expectedLockGeneration, "expectedLockGeneration");
2286
- if (authMethod.walletId !== authorityResult.value.walletId || authMethod.walletAuthorityId !== authorityResult.value.authorityId || walletSession.walletId !== authorityResult.value.walletId || walletSession.authorityId !== authorityResult.value.authorityId || walletSession.authMethodId !== authMethod.walletAuthMethodId || walletSession.authorityDigestB64u !== authorityResult.value.authorityDigestB64u || walletSession.authorityRevocationEpoch !== authorityResult.value.revocationEpoch) throw new Error("active authority, auth method, and Wallet Session identities differ");
2287
- return await this.manager.runTransaction([
2288
- SEAMS_WALLET_STORES.appState,
2289
- SEAMS_WALLET_STORES.wallets,
2290
- SEAMS_WALLET_STORES.walletAuthorities,
2291
- SEAMS_WALLET_STORES.walletAuthMethods,
2292
- SEAMS_WALLET_STORES.walletAuthorityInstallationReceipts,
2293
- SEAMS_WALLET_STORES.walletSelections,
2294
- SEAMS_WALLET_STORES.walletSessionAuthorizations
2295
- ], "readwrite", this.finalizeLocalAuthorityActivationInTransaction.bind(this, {
2296
- authority: authorityResult.value,
2297
- authMethod,
2298
- walletSession,
2299
- operationCredential: input.operationCredential,
2300
- expectedLockGeneration
2301
- }));
2302
- }
2303
- async publishLocalAuthorityActivation(input) {
2304
- const authorityResult = parseWalletAuthorityV1(input.authority);
2305
- if (!authorityResult.ok || authorityResult.value.state !== "active") throw new Error("active WalletAuthorityV1 is invalid");
2306
- const authMethod = parseWalletAuthMethodRecordV2(input.authMethod);
2307
- if (!authMethod || authMethod.status !== "active") throw new Error("active WalletAuthMethodRecordV2 is invalid");
2308
- const expectedLockGeneration = parseNonNegativeSafeInteger(input.expectedLockGeneration, "expectedLockGeneration");
2309
- if (authMethod.walletId !== authorityResult.value.walletId || authMethod.walletAuthorityId !== authorityResult.value.authorityId) throw new Error("active authority and auth method identities differ");
2310
- if (!await walletAuthorityDigestsMatchV1(authorityResult.value)) throw new Error("active WalletAuthorityV1 digest is invalid");
2311
- return await this.manager.runTransaction([
2312
- SEAMS_WALLET_STORES.appState,
2313
- SEAMS_WALLET_STORES.wallets,
2314
- SEAMS_WALLET_STORES.walletAuthorities,
2315
- SEAMS_WALLET_STORES.walletAuthMethods,
2316
- SEAMS_WALLET_STORES.walletAuthorityInstallationReceipts,
2317
- SEAMS_WALLET_STORES.walletSelections
2318
- ], "readwrite", this.publishLocalAuthorityActivationInTransaction.bind(this, {
2319
- authority: authorityResult.value,
2320
- authMethod,
2321
- expectedLockGeneration
2322
- }));
2323
- }
2324
- async advanceWalletLockGeneration(input) {
2325
- const walletId = requireBoundaryParsed(parseWalletId(input.walletId), "walletId");
2326
- const lockedAtMs = parseNonNegativeSafeInteger(input.lockedAtMs, "lockedAtMs");
2327
- return this.manager.runTransaction([SEAMS_WALLET_STORES.walletSelections], "readwrite", this.advanceWalletLockGenerationInTransaction.bind(this, {
2328
- walletId,
2329
- lockedAtMs
2330
- }));
2331
- }
2332
- async markWalletSelectionUnlocked(input) {
2333
- const walletId = requireBoundaryParsed(parseWalletId(input.walletId), "walletId");
2334
- const walletAuthMethodId = requireBoundaryParsed(parseWalletAuthMethodId(input.walletAuthMethodId), "walletAuthMethodId");
2335
- const unlockedAtMs = parseNonNegativeSafeInteger(input.unlockedAtMs, "unlockedAtMs");
2336
- await this.manager.runTransaction([SEAMS_WALLET_STORES.walletSelections, SEAMS_WALLET_STORES.walletAuthMethods], "readwrite", this.markWalletSelectionUnlockedInTransaction.bind(this, {
2337
- walletId,
2338
- walletAuthMethodId,
2339
- unlockedAtMs
2340
- }));
2341
- }
2342
- async persistRecoveredWalletAuthority(input) {
2343
- const authority = requireBoundaryParsed(parseWalletAuthorityV1(input.authority), "authority");
2344
- const authMethod = parseWalletAuthMethodRecordV2(input.authMethod);
2345
- const recoveredAtMs = parseNonNegativeSafeInteger(input.recoveredAtMs, "recoveredAtMs");
2346
- if (authority.state !== "active" || !isActiveRecoveredWalletAuthorityV1(authority) || !authMethod || authMethod.status !== "active" || authMethod.walletId !== authority.walletId || authMethod.walletAuthorityId !== authority.authorityId) throw new Error("recovered Wallet Authority projection is invalid");
2347
- if (!await walletAuthorityDigestsMatchV1(authority)) throw new Error("recovered Wallet Authority digest is invalid");
2348
- await this.manager.runTransaction([
2349
- SEAMS_WALLET_STORES.walletAuthorities,
2350
- SEAMS_WALLET_STORES.walletSelections,
2351
- SEAMS_WALLET_STORES.walletAuthMethods
2352
- ], "readwrite", this.persistRecoveredWalletAuthorityInTransaction.bind(this, {
2353
- authority,
2354
- authMethod,
2355
- recoveredAtMs
2356
- }));
2357
- }
2358
- async getLocalAuthorityInstallationReceipt(authorityId) {
2359
- const parsedAuthorityId = parseWalletAuthorityId(authorityId);
2360
- if (!parsedAuthorityId.ok) return null;
2361
- return parseLocalAuthorityInstallationReceiptStorageRow(await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.walletAuthorityInstallationReceipts, parsedAuthorityId.value))?.record || null;
2362
- }
2363
- async finalizeLocalAuthorityActivationInTransaction(input, ctx) {
2364
- const appStateStore = ctx.store(SEAMS_WALLET_STORES.appState);
2365
- const authorityStore = ctx.store(SEAMS_WALLET_STORES.walletAuthorities);
2366
- const authMethodStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2367
- const receiptStore = ctx.store(SEAMS_WALLET_STORES.walletAuthorityInstallationReceipts);
2368
- const selectionStore = ctx.store(SEAMS_WALLET_STORES.walletSelections);
2369
- const sessionStore = ctx.store(SEAMS_WALLET_STORES.walletSessionAuthorizations);
2370
- const authorityRaw = await authorityStore.get(input.authority.authorityId);
2371
- const authMethodRaw = await authMethodStore.get(input.authMethod.walletAuthMethodId);
2372
- const receiptRaw = await receiptStore.get(input.authority.authorityId);
2373
- const sessionRaw = await sessionStore.get(input.operationCredential.walletSessionId);
2374
- const profileProjectionRaw = await appStateStore.get(localAuthorityPendingProfileProjectionAppStateKeyV1(input.authority.authorityId));
2375
- const profileProjection = profileProjectionRaw === void 0 ? null : parseLocalAuthorityPendingProfileProjectionV1(profileProjectionRaw.value);
2376
- if (profileProjectionRaw !== void 0 && !profileProjection) throw new Error("local authority profile projection is missing or corrupt");
2377
- const existingAuthority = authorityRaw === void 0 ? null : parseWalletAuthorityStorageRow(authorityRaw);
2378
- const existingAuthMethod = authMethodRaw === void 0 ? null : parseWalletAuthMethodV2StorageRow(authMethodRaw);
2379
- const receipt = receiptRaw === void 0 ? null : parseLocalAuthorityInstallationReceiptStorageRow(receiptRaw);
2380
- const existingSessionWithCredential = sessionRaw === void 0 ? null : parseStoredExactWalletSessionAuthorizationRowV6(sessionRaw);
2381
- const existingSession = existingSessionWithCredential?.record ?? null;
2382
- if (!receipt) throw new Error("local authority installation receipt is missing or corrupt");
2383
- if (receipt.record.authorityId !== input.authority.authorityId || receipt.record.walletId !== input.authority.walletId || receipt.record.authMethodId !== input.authMethod.walletAuthMethodId || !walletSignerActivationSetsMatch(receipt.record.installedActivationRefs, input.authority.signerActivations)) throw new Error("local authority installation receipt does not match active authority");
2384
- if (!existingAuthority || !existingAuthMethod) throw new Error("pending local authority records are missing");
2385
- if (existingAuthority.record.state === "active") {
2386
- if (!walletAuthorityRecordsMatch(existingAuthority.record, input.authority) || existingAuthMethod.record.status !== "active" || !walletAuthMethodRecordsMatch(existingAuthMethod.record, input.authMethod)) throw new Error("active local authority replay conflicts with supplied records");
2387
- if (profileProjection) await this.publishPendingLocalAuthorityProfileProjectionInTransaction(input.authority, input.authMethod, profileProjection, ctx);
2388
- if (!existingSession) {
2389
- const selectionRaw = await selectionStore.get(input.authority.walletId);
2390
- if (selectionRaw === void 0) throw new Error("wallet selection is missing");
2391
- const selection = parseWalletSelectionStorageRow(selectionRaw);
2392
- if (!selection || selection.wallet_id !== input.authority.walletId) throw new Error("wallet selection is corrupt");
2393
- if (selection.lock_generation !== input.expectedLockGeneration) return {
2394
- kind: "stale_lock_generation",
2395
- expectedLockGeneration: input.expectedLockGeneration,
2396
- actualLockGeneration: selection.lock_generation
2397
- };
2398
- if (selection.record.lockState === "locked") return {
2399
- kind: "wallet_locked",
2400
- lockGeneration: selection.lock_generation
2401
- };
2402
- await sessionStore.put(toStoredExactWalletSessionAuthorizationRowV6(input.walletSession, input.operationCredential));
2403
- await selectionStore.put(walletSelectionStorageRow({
2404
- kind: "wallet_selection_v1",
2405
- walletId: selection.record.walletId,
2406
- walletAuthMethodId: input.authMethod.walletAuthMethodId,
2407
- lockGeneration: selection.record.lockGeneration,
2408
- lockState: "unlocked",
2409
- updatedAtMs: input.walletSession.issuedAtMs
2410
- }));
2411
- return { kind: "finalized" };
2412
- }
2413
- if (existingSession.kind !== "active_wallet_session_v1" || !walletSessionRecordsMatch(existingSession, input.walletSession) || existingSessionWithCredential?.operationCredential.token !== input.operationCredential.token) throw new Error("active local authority replay conflicts with supplied Wallet Session");
2414
- await sessionStore.put(toStoredExactWalletSessionAuthorizationRowV6(input.walletSession, input.operationCredential));
2415
- return { kind: "finalized" };
2416
- }
2417
- if (existingAuthority.record.state !== "pending_local_install" || existingAuthMethod.record.status !== "pending_local_install" || !walletAuthorityPendingMatchesActive(existingAuthority.record, input.authority) || !walletAuthMethodPendingMatchesActive(existingAuthMethod.record, input.authMethod)) throw new Error("local authority records are not the expected pending installation");
2418
- if (existingSession && existingSession.kind !== "active_wallet_session_v1") throw new Error("Wallet Session authorization is not active");
2419
- if (existingSession?.kind === "active_wallet_session_v1" && (!walletSessionRecordsMatch(existingSession, input.walletSession) || existingSessionWithCredential?.operationCredential.token !== input.operationCredential.token)) throw new Error("Wallet Session authorization conflicts with finalization");
2420
- const selectionRaw = await selectionStore.get(input.authority.walletId);
2421
- if (selectionRaw === void 0) throw new Error("wallet selection is missing");
2422
- const selection = parseWalletSelectionStorageRow(selectionRaw);
2423
- if (!selection || selection.wallet_id !== input.authority.walletId) throw new Error("wallet selection is corrupt");
2424
- if (selection.lock_generation !== input.expectedLockGeneration) return {
2425
- kind: "stale_lock_generation",
2426
- expectedLockGeneration: input.expectedLockGeneration,
2427
- actualLockGeneration: selection.lock_generation
2428
- };
2429
- if (selection.record.lockState === "locked") return {
2430
- kind: "wallet_locked",
2431
- lockGeneration: selection.lock_generation
2432
- };
2433
- if (!profileProjection) throw new Error("local authority profile projection is missing or corrupt");
2434
- await this.publishPendingLocalAuthorityProfileProjectionInTransaction(input.authority, input.authMethod, profileProjection, ctx);
2435
- await authorityStore.put(walletAuthorityStorageRow(input.authority));
2436
- await authMethodStore.put(await walletAuthMethodV2StorageRowForStore(authMethodStore, input.authMethod));
2437
- await sessionStore.put(toStoredExactWalletSessionAuthorizationRowV6(input.walletSession, input.operationCredential));
2438
- await selectionStore.put(walletSelectionStorageRow({
2439
- kind: "wallet_selection_v1",
2440
- walletId: selection.record.walletId,
2441
- walletAuthMethodId: input.authMethod.walletAuthMethodId,
2442
- lockGeneration: selection.record.lockGeneration,
2443
- lockState: "unlocked",
2444
- updatedAtMs: input.walletSession.issuedAtMs
2445
- }));
2446
- return { kind: "finalized" };
2447
- }
2448
- async publishPendingLocalAuthorityProfileProjectionInTransaction(authority, authMethod, projection, ctx) {
2449
- if (projection.authorityId !== authority.authorityId || projection.walletId !== authority.walletId || projection.authMethodId !== authMethod.walletAuthMethodId) throw new Error("local authority profile projection identity does not match activation");
2450
- if (projection.authenticator?.wallet_auth_method_id === authMethod.walletAuthMethodId || projection.localAuthMethod?.wallet_auth_method_id === authMethod.walletAuthMethodId) throw new Error("local authority profile projection collides with the V2 auth-method key");
2451
- const profileStore = ctx.store(SEAMS_WALLET_STORES.wallets);
2452
- const authMethodStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2453
- const existingProfileRaw = await profileStore.get(projection.profile.wallet_id);
2454
- const existingProfile = existingProfileRaw === void 0 ? null : parseProfileStorageRowV1(existingProfileRaw);
2455
- if (existingProfileRaw !== void 0 && !existingProfile) throw new Error("stored wallet profile is corrupt during authority publication");
2456
- if (existingProfile && !profileRowsMatch(existingProfile, projection.profile)) throw new Error("stored wallet profile changed during authority publication");
2457
- await profileStore.put(projection.profile);
2458
- for (const row of [projection.authenticator, projection.localAuthMethod]) {
2459
- if (!row) continue;
2460
- const existingRaw = await authMethodStore.get(row.wallet_auth_method_id);
2461
- if (existingRaw !== void 0) {
2462
- const existing = parseWalletAuthMethodStorageRow(existingRaw);
2463
- if (!existing || !localWalletAuthMethodRowsMatch(existing, row)) throw new Error("stored local auth method changed during authority publication");
2464
- }
2465
- await authMethodStore.put(row);
2466
- }
2467
- await authMethodStore.put(await walletAuthMethodV2StorageRowForStore(authMethodStore, authMethod));
2468
- await ctx.store(SEAMS_WALLET_STORES.appState).delete(localAuthorityPendingProfileProjectionAppStateKeyV1(authority.authorityId));
2469
- }
2470
- async publishLocalAuthorityActivationInTransaction(input, ctx) {
2471
- const profileProjectionRaw = await ctx.store(SEAMS_WALLET_STORES.appState).get(localAuthorityPendingProfileProjectionAppStateKeyV1(input.authority.authorityId));
2472
- const profileProjection = profileProjectionRaw === void 0 ? null : parseLocalAuthorityPendingProfileProjectionV1(profileProjectionRaw.value);
2473
- if (profileProjectionRaw !== void 0 && !profileProjection) throw new Error("local authority profile projection is missing or corrupt");
2474
- const authorityRaw = await ctx.store(SEAMS_WALLET_STORES.walletAuthorities).get(input.authority.authorityId);
2475
- const authMethodRaw = await ctx.store(SEAMS_WALLET_STORES.walletAuthMethods).get(input.authMethod.walletAuthMethodId);
2476
- const receiptRaw = await ctx.store(SEAMS_WALLET_STORES.walletAuthorityInstallationReceipts).get(input.authority.authorityId);
2477
- const authority = authorityRaw === void 0 ? null : parseWalletAuthorityStorageRow(authorityRaw);
2478
- const authMethod = authMethodRaw === void 0 ? null : parseWalletAuthMethodV2StorageRow(authMethodRaw);
2479
- const receipt = receiptRaw === void 0 ? null : parseLocalAuthorityInstallationReceiptStorageRow(receiptRaw);
2480
- if (!authority || !authMethod || !receipt) throw new Error("local authority publication prerequisites are missing");
2481
- if (receipt.record.authorityId !== input.authority.authorityId || receipt.record.walletId !== input.authority.walletId || receipt.record.authMethodId !== input.authMethod.walletAuthMethodId || !walletSignerActivationSetsMatch(receipt.record.installedActivationRefs, input.authority.signerActivations)) throw new Error("local authority installation receipt does not match publication");
2482
- if (authority.record.state === "active") {
2483
- if (!walletAuthorityRecordsMatch(authority.record, input.authority) || authMethod.record.status !== "active" || !walletAuthMethodRecordsMatch(authMethod.record, input.authMethod)) throw new Error("active local authority publication conflicts with stored records");
2484
- if (profileProjection) await this.publishPendingLocalAuthorityProfileProjectionInTransaction(input.authority, input.authMethod, profileProjection, ctx);
2485
- return { kind: "published" };
2486
- }
2487
- if (authority.record.state !== "pending_local_install" || authMethod.record.status !== "pending_local_install" || !walletAuthorityPendingMatchesActive(authority.record, input.authority) || !walletAuthMethodPendingMatchesActive(authMethod.record, input.authMethod)) throw new Error("local authority records are not the expected pending installation");
2488
- const selectionRaw = await ctx.store(SEAMS_WALLET_STORES.walletSelections).get(input.authority.walletId);
2489
- if (selectionRaw === void 0) throw new Error("wallet selection is missing");
2490
- const selection = parseWalletSelectionStorageRow(selectionRaw);
2491
- if (!selection || selection.wallet_id !== input.authority.walletId) throw new Error("wallet selection is corrupt");
2492
- if (selection.lock_generation !== input.expectedLockGeneration) return {
2493
- kind: "stale_lock_generation",
2494
- expectedLockGeneration: input.expectedLockGeneration,
2495
- actualLockGeneration: selection.lock_generation
2496
- };
2497
- if (selection.record.lockState === "locked") return {
2498
- kind: "wallet_locked",
2499
- lockGeneration: selection.lock_generation
2500
- };
2501
- if (!profileProjection) throw new Error("local authority profile projection is missing or corrupt");
2502
- await this.publishPendingLocalAuthorityProfileProjectionInTransaction(input.authority, input.authMethod, profileProjection, ctx);
2503
- await ctx.store(SEAMS_WALLET_STORES.walletAuthorities).put(walletAuthorityStorageRow(input.authority));
2504
- return { kind: "published" };
2505
- }
2506
- async advanceWalletLockGenerationInTransaction(input, ctx) {
2507
- const selectionStore = ctx.store(SEAMS_WALLET_STORES.walletSelections);
2508
- const selectionRaw = await selectionStore.get(input.walletId);
2509
- if (selectionRaw === void 0) throw new Error("wallet selection is missing");
2510
- const selection = parseWalletSelectionStorageRow(selectionRaw);
2511
- if (!selection || selection.wallet_id !== input.walletId) throw new Error("wallet selection is corrupt");
2512
- if (selection.record.lockGeneration >= Number.MAX_SAFE_INTEGER) throw new Error("wallet lock generation cannot advance");
2513
- const lockGeneration = selection.record.lockGeneration + 1;
2514
- await selectionStore.put(walletSelectionStorageRow({
2515
- kind: "wallet_selection_v1",
2516
- walletId: selection.record.walletId,
2517
- walletAuthMethodId: selection.record.walletAuthMethodId,
2518
- lockGeneration,
2519
- lockState: "locked",
2520
- updatedAtMs: input.lockedAtMs
2521
- }));
2522
- return lockGeneration;
2523
- }
2524
- async assertSelectionMoveBetweenAuthorityMembers(input, ctx) {
2525
- const authMethodStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2526
- const fromRaw = await authMethodStore.get(input.fromWalletAuthMethodId);
2527
- const toRaw = await authMethodStore.get(input.toWalletAuthMethodId);
2528
- const from = fromRaw === void 0 ? null : parseWalletAuthMethodV2StorageRow(fromRaw);
2529
- const to = toRaw === void 0 ? null : parseWalletAuthMethodV2StorageRow(toRaw);
2530
- if (!from || !to || to.record.status !== "active" || to.record.walletId !== input.walletId || from.record.walletId !== input.walletId || from.record.walletAuthorityId !== to.record.walletAuthorityId) throw new Error("wallet selection is missing or corrupt");
2531
- }
2532
- async markWalletSelectionUnlockedInTransaction(input, ctx) {
2533
- const selectionStore = ctx.store(SEAMS_WALLET_STORES.walletSelections);
2534
- const selectionRaw = await selectionStore.get(input.walletId);
2535
- const selection = selectionRaw === void 0 ? null : parseWalletSelectionStorageRow(selectionRaw);
2536
- if (!selection || selection.wallet_id !== input.walletId) throw new Error("wallet selection is missing or corrupt");
2537
- if (selection.record.walletAuthMethodId !== input.walletAuthMethodId) await this.assertSelectionMoveBetweenAuthorityMembers({
2538
- walletId: input.walletId,
2539
- fromWalletAuthMethodId: selection.record.walletAuthMethodId,
2540
- toWalletAuthMethodId: input.walletAuthMethodId
2541
- }, ctx);
2542
- await selectionStore.put(walletSelectionStorageRow({
2543
- kind: "wallet_selection_v1",
2544
- walletId: selection.record.walletId,
2545
- walletAuthMethodId: input.walletAuthMethodId,
2546
- lockGeneration: selection.record.lockGeneration,
2547
- lockState: "unlocked",
2548
- updatedAtMs: input.unlockedAtMs
2549
- }));
2550
- }
2551
- async persistRecoveredWalletAuthorityInTransaction(input, ctx) {
2552
- const authorityStore = ctx.store(SEAMS_WALLET_STORES.walletAuthorities);
2553
- const existingAuthorityRaw = await authorityStore.get(input.authority.authorityId);
2554
- const existingAuthority = existingAuthorityRaw === void 0 ? null : parseWalletAuthorityStorageRow(existingAuthorityRaw)?.record;
2555
- if (existingAuthorityRaw !== void 0 && !existingAuthority) throw new Error("local Wallet Authority is corrupt");
2556
- if (existingAuthority && !walletAuthorityRecordsMatch(existingAuthority, input.authority)) throw new Error("recovered Wallet Authority conflicts with local authority");
2557
- await authorityStore.put(walletAuthorityStorageRow(input.authority));
2558
- const authMethodStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2559
- await authMethodStore.put(await walletAuthMethodV2StorageRowForStore(authMethodStore, input.authMethod));
2560
- const selectionStore = ctx.store(SEAMS_WALLET_STORES.walletSelections);
2561
- const selectionRaw = await selectionStore.get(input.authority.walletId);
2562
- const selection = selectionRaw === void 0 ? null : parseWalletSelectionStorageRow(selectionRaw);
2563
- if (selectionRaw !== void 0 && !selection) throw new Error("recovered wallet selection is corrupt");
2564
- await selectionStore.put(walletSelectionStorageRow({
2565
- kind: "wallet_selection_v1",
2566
- walletId: input.authority.walletId,
2567
- walletAuthMethodId: input.authMethod.walletAuthMethodId,
2568
- lockGeneration: selection?.record.lockGeneration ?? 0,
2569
- lockState: "locked",
2570
- updatedAtMs: input.recoveredAtMs
2571
- }));
2572
- }
2573
- async installLocalAuthorityInTransaction(input, ctx) {
2574
- const appStateStore = ctx.store(SEAMS_WALLET_STORES.appState);
2575
- const profileRaw = await ctx.store(SEAMS_WALLET_STORES.wallets).get(input.profile.profileId);
2576
- const existingProfile = profileRaw === void 0 ? null : parseProfileRow(profileRaw);
2577
- if (profileRaw !== void 0 && !existingProfile) return {
2578
- kind: "integrity_error",
2579
- reason: "wallet profile row is invalid"
2580
- };
2581
- const authenticatorStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2582
- const authenticatorLookupRow = input.authenticator ? walletAuthMethodRowFromAuthenticator(input.authenticator) : null;
2583
- const localAuthMethodRow = input.localAuthMethod ? walletAuthMethodRowFromBinding(input.localAuthMethod, input.profile.defaultSignerSlot ?? 1) : null;
2584
- const authenticatorRaw = authenticatorLookupRow ? await authenticatorStore.get(authenticatorLookupRow.wallet_auth_method_id) : void 0;
2585
- const existingAuthenticatorRow = authenticatorRaw === void 0 ? null : parseWalletAuthMethodStorageRow(authenticatorRaw);
2586
- const authenticatorRow = input.authenticator ? walletAuthMethodRowFromAuthenticator(input.authenticator, existingAuthenticatorRow?.kind === "passkey" ? existingAuthenticatorRow : void 0) : null;
2587
- const localAuthMethodRaw = localAuthMethodRow ? await authenticatorStore.get(localAuthMethodRow.wallet_auth_method_id) : void 0;
2588
- const existingLocalAuthMethodRow = localAuthMethodRaw === void 0 ? null : parseWalletAuthMethodStorageRow(localAuthMethodRaw);
2589
- const selectionStore = ctx.store(SEAMS_WALLET_STORES.walletSelections);
2590
- const selectionRaw = await selectionStore.get(input.authority.walletId);
2591
- const selection = selectionRaw === void 0 ? null : parseWalletSelectionStorageRow(selectionRaw);
2592
- if (selectionRaw !== void 0 && (!selection || selection.wallet_id !== input.authority.walletId)) return {
2593
- kind: "integrity_error",
2594
- reason: "wallet selection row is invalid"
2595
- };
2596
- if (selection && selection.lock_generation !== input.expectedLockGeneration) return {
2597
- kind: "stale_lock_generation",
2598
- expectedLockGeneration: input.expectedLockGeneration,
2599
- actualLockGeneration: selection.lock_generation
2600
- };
2601
- if (!selection && input.expectedLockGeneration !== 0) return {
2602
- kind: "integrity_error",
2603
- reason: "initial wallet selection requires lock generation zero"
2604
- };
2605
- const authorityStore = ctx.store(SEAMS_WALLET_STORES.walletAuthorities);
2606
- const authMethodStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2607
- const signerMaterialStore = ctx.store(SEAMS_WALLET_STORES.walletAuthoritySignerMaterials);
2608
- const exportRootStore = ctx.store(SEAMS_WALLET_STORES.walletAuthorityExportRoots);
2609
- const receiptStore = ctx.store(SEAMS_WALLET_STORES.walletAuthorityInstallationReceipts);
2610
- const profileProjectionKey = localAuthorityPendingProfileProjectionAppStateKeyV1(input.authority.authorityId);
2611
- const profileProjectionRaw = await appStateStore.get(profileProjectionKey);
2612
- const profileProjection = profileProjectionRaw === void 0 ? null : parseLocalAuthorityPendingProfileProjectionV1(profileProjectionRaw.value);
2613
- if (profileProjectionRaw !== void 0 && !profileProjection) return {
2614
- kind: "integrity_error",
2615
- reason: "local authority profile projection is missing or corrupt"
2616
- };
2617
- const profileProjectionRecord = profileProjection ?? buildLocalAuthorityPendingProfileProjectionV1({
2618
- authorityId: input.authority.authorityId,
2619
- walletId: input.authority.walletId,
2620
- authMethodId: input.authMethod.walletAuthMethodId,
2621
- profile: profileRow(input.profile, existingProfile || void 0),
2622
- authenticator: authenticatorRow,
2623
- localAuthMethod: localAuthMethodRow?.kind === "email_otp" ? localAuthMethodRow : null
2624
- });
2625
- const authorityRaw = await authorityStore.get(input.authority.authorityId);
2626
- const authMethodRaw = await authMethodStore.get(input.authMethod.walletAuthMethodId);
2627
- const signerMaterialRaws = [];
2628
- for (const material of input.signerMaterials) signerMaterialRaws.push(await signerMaterialStore.get([
2629
- material.authorityId,
2630
- material.walletAuthMethodId,
2631
- material.activationId
2632
- ]));
2633
- const exportRootRaw = input.exportRoot ? await exportRootStore.get([
2634
- input.exportRoot.authorityId,
2635
- input.exportRoot.walletAuthMethodId,
2636
- input.exportRoot.walletKeyId
2637
- ]) : void 0;
2638
- const receiptRaw = await receiptStore.get(input.receipt.authorityId);
2639
- const existingAuthority = authorityRaw === void 0 ? null : parseWalletAuthorityStorageRow(authorityRaw);
2640
- const existingAuthMethod = authMethodRaw === void 0 ? null : parseWalletAuthMethodV2StorageRow(authMethodRaw);
2641
- const existingSignerMaterials = [];
2642
- for (let index = 0; index < signerMaterialRaws.length; index += 1) {
2643
- const raw = signerMaterialRaws[index];
2644
- existingSignerMaterials.push(raw === void 0 ? null : parseWalletAuthoritySignerMaterialStorageRow(raw)?.record || null);
2645
- }
2646
- const existingExportRoot = exportRootRaw === void 0 ? null : parseWalletAuthorityExportRootStorageRow(exportRootRaw)?.record || null;
2647
- const existingReceipt = receiptRaw === void 0 ? null : parseLocalAuthorityInstallationReceiptStorageRow(receiptRaw)?.record || null;
2648
- if (profileProjection && !localAuthorityPendingProfileProjectionMatchesInputV1(profileProjection, input)) return {
2649
- kind: "integrity_error",
2650
- reason: "local authority profile projection conflicts with replay"
2651
- };
2652
- const installationStateExists = authorityRaw !== void 0 || authMethodRaw !== void 0 || signerMaterialRaws.some(rawValueIsPresent) || exportRootRaw !== void 0 || receiptRaw !== void 0 || profileProjectionRaw !== void 0;
2653
- const allInstallationRecords = authorityRaw !== void 0 && authMethodRaw !== void 0 && signerMaterialRaws.every(rawValueIsPresent) && (input.exportRoot === null ? exportRootRaw === void 0 : exportRootRaw !== void 0) && receiptRaw !== void 0;
2654
- if (installationStateExists) {
2655
- if (!selection || !allInstallationRecords || !existingAuthority || !existingAuthMethod || !existingReceipt || !profileProjection || !localAuthorityPendingProfileProjectionsMatchV1(profileProjection, profileProjectionRecord)) return {
2656
- kind: "integrity_error",
2657
- reason: "local authority replay is incomplete or malformed"
2658
- };
2659
- if (!walletAuthorityRecordsMatch(existingAuthority.record, input.authority) || !walletAuthMethodRecordsMatch(existingAuthMethod.record, input.authMethod) || !localAuthorityInstallationReceiptsMatch(existingReceipt, input.receipt)) return {
2660
- kind: "integrity_error",
2661
- reason: "local authority replay conflicts with stored records"
2662
- };
2663
- if (existingProfile && !profileRecordsMatch(existingProfile, profileProjection.profile.record) || profileProjection.authenticator && existingAuthenticatorRow !== null && !localWalletAuthMethodRowsMatch(existingAuthenticatorRow, profileProjection.authenticator) || profileProjection.localAuthMethod && existingLocalAuthMethodRow !== null && !localWalletAuthMethodRowsMatch(existingLocalAuthMethodRow, profileProjection.localAuthMethod)) return {
2664
- kind: "integrity_error",
2665
- reason: "stored local profile projection conflicts with replay"
2666
- };
2667
- for (let index = 0; index < input.signerMaterials.length; index += 1) {
2668
- const existingMaterial = existingSignerMaterials[index];
2669
- if (!existingMaterial || !walletAuthoritySignerMaterialRecordsMatch(existingMaterial, input.signerMaterials[index])) return {
2670
- kind: "integrity_error",
2671
- reason: "stored signer material conflicts with replay"
2672
- };
2673
- }
2674
- if (input.exportRoot) {
2675
- if (!existingExportRoot || !walletAuthorityExportRootsMatch(existingExportRoot, input.exportRoot)) return {
2676
- kind: "integrity_error",
2677
- reason: "stored export root conflicts with replay"
2678
- };
2679
- }
2680
- await selectionStore.put(walletSelectionStorageRow(walletSelectionForInstalledAuthority(input, selection)));
2681
- return {
2682
- kind: "idempotent_replay",
2683
- receipt: existingReceipt
2684
- };
2685
- }
2686
- await appStateStore.put({
2687
- key: profileProjectionKey,
2688
- value: profileProjectionRecord
2689
- });
2690
- await authorityStore.put(walletAuthorityStorageRow(input.authority));
2691
- await authMethodStore.put(await walletAuthMethodV2StorageRowForStore(authMethodStore, input.authMethod));
2692
- for (const material of input.signerMaterials) await signerMaterialStore.put(walletAuthoritySignerMaterialStorageRow(material));
2693
- if (input.exportRoot) await exportRootStore.put(walletAuthorityExportRootStorageRow(input.exportRoot));
2694
- await receiptStore.put(localAuthorityInstallationReceiptStorageRow(input.receipt));
2695
- await selectionStore.put(walletSelectionStorageRow(walletSelectionForInstalledAuthority(input, selection)));
2696
- return {
2697
- kind: "installed",
2698
- receipt: input.receipt
2699
- };
2700
- }
2701
- async getWalletAuthority(walletAuthorityId) {
2702
- const parsedId = parseWalletAuthorityId(walletAuthorityId);
2703
- if (!parsedId.ok) return null;
2704
- const row = parseWalletAuthorityStorageRow(await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.walletAuthorities, parsedId.value));
2705
- if (!row || !await walletAuthorityDigestsMatchV1(row.record)) return null;
2706
- return row.record;
2707
- }
2708
- async persistFoundingWalletAuthority(input) {
2709
- const validated = validateFoundingWalletAuthorityInput(input);
2710
- await this.manager.runTransaction([
2711
- SEAMS_WALLET_STORES.appState,
2712
- SEAMS_WALLET_STORES.walletAuthorities,
2713
- SEAMS_WALLET_STORES.walletAuthMethods,
2714
- SEAMS_WALLET_STORES.wallets,
2715
- SEAMS_WALLET_STORES.walletSelections
2716
- ], "readwrite", this.persistFoundingWalletAuthorityInTransaction.bind(this, validated, "activate"));
2717
- }
2718
- async persistFoundingWalletAuthorityInTransaction(input, selectionPolicy, ctx) {
2719
- if (selectionPolicy === "preserve") {
2720
- const selection = parseWalletSelectionStorageRow(await ctx.store(SEAMS_WALLET_STORES.walletSelections).get(input.authority.walletId));
2721
- if (!selection || selection.record.lockState !== "unlocked" || selection.record.walletAuthMethodId !== input.authMethod.walletAuthMethodId) throw new Error("Deferred registration publication was interrupted by wallet lock");
2722
- }
2723
- await ctx.store(SEAMS_WALLET_STORES.walletAuthorities).put(walletAuthorityStorageRow(input.authority));
2724
- const authMethodStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2725
- await authMethodStore.put(await walletAuthMethodV2StorageRowForStore(authMethodStore, input.authMethod));
2726
- if (selectionPolicy === "preserve") return;
2727
- await ctx.store(SEAMS_WALLET_STORES.walletSelections).put(walletSelectionStorageRow({
2728
- kind: "wallet_selection_v1",
2729
- walletId: input.authority.walletId,
2730
- walletAuthMethodId: input.authMethod.walletAuthMethodId,
2731
- lockGeneration: 0,
2732
- lockState: "unlocked",
2733
- updatedAtMs: input.authMethod.activatedAtMs
2734
- }));
2735
- }
2736
- async getWalletAuthMethodV2(walletAuthMethodId) {
2737
- const parsedId = parseWalletAuthMethodId(walletAuthMethodId);
2738
- if (!parsedId.ok) return null;
2739
- return parseWalletAuthMethodV2StorageRow(await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.walletAuthMethods, parsedId.value))?.record || null;
2740
- }
2741
- async listWalletSelections() {
2742
- return (await (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.walletSelections, "readonly").store.getAll()).flatMap((row) => {
2743
- const parsed = parseWalletSelectionStorageRow(row);
2744
- return parsed ? [parsed.record] : [];
2745
- });
2746
- }
2747
- async listWalletSelectionWalletIds() {
2748
- return (await (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.walletSelections, "readonly").store.getAllKeys()).flatMap((key) => {
2749
- const parsed = parseWalletId(key);
2750
- return parsed.ok ? [parsed.value] : [];
2751
- });
2752
- }
2753
- async listWalletAuthMethodsV2ForWallet(walletId) {
2754
- const normalizedWalletId = normalizeTrimmedString(walletId || "");
2755
- if (!normalizedWalletId) return [];
2756
- return (await (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.walletAuthMethods, "readonly").store.index(SEAMS_WALLET_INDEXES.walletId).getAll(normalizedWalletId)).flatMap((row) => {
2757
- const parsed = parseWalletAuthMethodV2StorageRow(row);
2758
- return parsed ? [parsed.record] : [];
2759
- });
2760
- }
2761
- async listLocalWalletAuthMethodProjectionsV2ForWallet(walletId) {
2762
- const normalizedWalletId = normalizeTrimmedString(walletId || "");
2763
- if (!normalizedWalletId) return [];
2764
- return await this.manager.runTransaction([SEAMS_WALLET_STORES.walletAuthMethods], "readwrite", async (ctx) => {
2765
- const store = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2766
- const rows = await store.index(SEAMS_WALLET_INDEXES.walletId).getAll(normalizedWalletId);
2767
- const projections = [];
2768
- for (const raw of rows) {
2769
- const parsed = parseWalletAuthMethodV2StorageRow(raw);
2770
- if (!parsed) continue;
2771
- const presentation = walletAuthMethodLocalPresentation(parsed.record, rows, parsed.presentation);
2772
- if (!rawWalletAuthMethodRowHasPresentation(raw) || !walletAuthMethodLocalPresentationsMatch(parsed.presentation, presentation)) await store.put(walletAuthMethodV2StorageRow(localWalletAuthMethodProjectionV2(parsed.record, presentation)));
2773
- projections.push(localWalletAuthMethodProjectionV2(parsed.record, presentation));
2774
- }
2775
- return projections;
2776
- });
2777
- }
2778
- async retainVerifiedEmailOtpLocalPresentation(input) {
2779
- const emailHashHex = await sha256HexUtf8(String(input.emailAddress));
2780
- return await this.manager.runTransaction([SEAMS_WALLET_STORES.walletAuthMethods], "readwrite", async (ctx) => {
2781
- const store = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
2782
- const row = parseWalletAuthMethodV2StorageRow(await store.get(input.walletAuthMethodId));
2783
- if (!row) return {
2784
- kind: "not_retained",
2785
- reason: "missing_auth_method"
2786
- };
2787
- if (row.record.walletId !== input.walletId) return {
2788
- kind: "not_retained",
2789
- reason: "wallet_mismatch"
2790
- };
2791
- if (row.record.kind !== "email_otp") return {
2792
- kind: "not_retained",
2793
- reason: "auth_method_not_email_otp"
2794
- };
2795
- if (row.record.emailHashHex !== emailHashHex) return {
2796
- kind: "not_retained",
2797
- reason: "email_hash_mismatch"
2798
- };
2799
- const presentation = {
2800
- version: "wallet_auth_method_local_presentation_v1",
2801
- kind: "email_otp",
2802
- email: {
2803
- kind: "verified",
2804
- address: input.emailAddress
2805
- }
2806
- };
2807
- await store.put(walletAuthMethodV2StorageRow({
2808
- kind: "email_otp",
2809
- record: row.record,
2810
- presentation
2811
- }));
2812
- return {
2813
- kind: "retained",
2814
- projection: {
2815
- kind: "email_otp",
2816
- record: row.record,
2817
- presentation
2818
- }
2819
- };
2820
- });
2821
- }
2822
- async resolveSelectedWalletAuthority(walletId) {
2823
- return await this.resolveWalletAuthorityForSelection(walletId, null);
2824
- }
2825
- /**
2826
- * Resolve the authority as a named method rather than as the selected one.
2827
- *
2828
- * Unlocking a sibling is how an added method comes into use - invariant 9
2829
- * makes lock and unlock the route - and the unlock moves the selection to it.
2830
- * Resolving through the selection first would make that impossible: the
2831
- * method cannot become selected until it unlocks, and it cannot unlock until
2832
- * it is selected. Naming the method breaks the circle; the move itself is
2833
- * still guarded, and still only between members of one authority.
2834
- */
2835
- async resolveWalletAuthorityForMethod(walletId, walletAuthMethodId) {
2836
- const parsed = parseWalletAuthMethodId(walletAuthMethodId);
2837
- if (!parsed.ok) return {
2838
- kind: "integrity_error",
2839
- reason: "walletAuthMethodId is invalid"
2840
- };
2841
- return await this.resolveWalletAuthorityForSelection(walletId, parsed.value);
2842
- }
2843
- async resolveWalletAuthorityForSelection(walletId, walletAuthMethodId) {
2844
- const parsedWalletId = parseWalletId(walletId);
2845
- if (!parsedWalletId.ok) return {
2846
- kind: "integrity_error",
2847
- reason: "walletId is invalid"
2848
- };
2849
- return this.manager.runTransaction([
2850
- SEAMS_WALLET_STORES.walletSelections,
2851
- SEAMS_WALLET_STORES.walletAuthMethods,
2852
- SEAMS_WALLET_STORES.walletAuthorities,
2853
- SEAMS_WALLET_STORES.walletAuthoritySignerMaterials,
2854
- SEAMS_WALLET_STORES.walletAuthorityExportRoots
2855
- ], "readonly", (ctx) => this.resolveSelectedWalletAuthorityInTransaction(parsedWalletId.value, ctx, walletAuthMethodId));
2856
- }
2857
- async resolveSelectedWalletAuthorityInTransaction(walletId, ctx, requestedWalletAuthMethodId = null) {
2858
- const selectionRaw = await ctx.store(SEAMS_WALLET_STORES.walletSelections).get(walletId);
2859
- if (selectionRaw === void 0) return { kind: "missing_selection" };
2860
- const selection = parseWalletSelectionStorageRow(selectionRaw);
2861
- if (!selection || selection.wallet_id !== walletId) return {
2862
- kind: "integrity_error",
2863
- reason: "wallet selection row is invalid"
2864
- };
2865
- const resolvedAuthMethodId = requestedWalletAuthMethodId ?? selection.record.walletAuthMethodId;
2866
- const authMethodRaw = await ctx.store(SEAMS_WALLET_STORES.walletAuthMethods).get(String(resolvedAuthMethodId));
2867
- if (authMethodRaw === void 0) return {
2868
- kind: "missing_auth_method",
2869
- walletAuthMethodId: resolvedAuthMethodId
2870
- };
2871
- const authMethod = parseWalletAuthMethodV2StorageRow(authMethodRaw);
2872
- if (!authMethod || authMethod.wallet_id !== walletId) return {
2873
- kind: "integrity_error",
2874
- reason: "selected V2 auth method row is invalid"
2875
- };
2876
- const authorityRaw = await ctx.store(SEAMS_WALLET_STORES.walletAuthorities).get(authMethod.wallet_authority_id);
2877
- if (authorityRaw === void 0) return {
2878
- kind: "missing_authority",
2879
- walletAuthorityId: authMethod.record.walletAuthorityId
2880
- };
2881
- const authority = parseWalletAuthorityStorageRow(authorityRaw);
2882
- if (!authority || authority.wallet_id !== walletId) return {
2883
- kind: "integrity_error",
2884
- reason: "selected wallet authority row is invalid"
2885
- };
2886
- if (authority.authority_id !== authMethod.wallet_authority_id) return {
2887
- kind: "integrity_error",
2888
- reason: "auth method authority reference does not resolve exactly"
2889
- };
2890
- if (authority.record.provenance.kind === "wallet_registration" || authority.record.provenance.kind === "wallet_recovery") {
2891
- if (!await walletAuthorityDigestsMatchV1(authority.record)) return {
2892
- kind: "integrity_error",
2893
- reason: "selected wallet authority digest is invalid"
2894
- };
2895
- return {
2896
- kind: "resolved",
2897
- selection: selection.record,
2898
- authMethod: authMethod.record,
2899
- authority: authority.record,
2900
- signerMaterials: [],
2901
- exportRoot: null
2902
- };
2903
- }
2904
- const signerMaterialStore = ctx.store(SEAMS_WALLET_STORES.walletAuthoritySignerMaterials);
2905
- const signerMaterials = [];
2906
- let expectations;
2907
- try {
2908
- expectations = signerMaterialExpectations(authority.record.signerActivations);
2909
- } catch {
2910
- return {
2911
- kind: "integrity_error",
2912
- reason: "selected authority signer activations are invalid"
2913
- };
2914
- }
2915
- for (const expected of expectations) {
2916
- const rawMaterial = await signerMaterialStore.get([
2917
- authority.record.authorityId,
2918
- authMethod.record.walletAuthMethodId,
2919
- expected.materialActivation.activationId
2920
- ]);
2921
- if (rawMaterial === void 0) return {
2922
- kind: "integrity_error",
2923
- reason: "selected signer material row is missing"
2924
- };
2925
- const materialRow = parseWalletAuthoritySignerMaterialStorageRow(rawMaterial);
2926
- if (!materialRow || materialRow.wallet_authority_id !== authority.record.authorityId || materialRow.wallet_auth_method_id !== authMethod.record.walletAuthMethodId || materialRow.activation_id !== expected.materialActivation.activationId || materialRow.key_family !== expected.keyFamily || !mpcMaterialActivationRefsEqual(materialRow.record.materialActivation, expected.materialActivation)) return {
2927
- kind: "integrity_error",
2928
- reason: "selected signer material row is invalid"
2929
- };
2930
- signerMaterials.push(materialRow.record);
2931
- }
2932
- const exportRootRaws = await ctx.store(SEAMS_WALLET_STORES.walletAuthorityExportRoots).index(SEAMS_WALLET_INDEXES.walletAuthorityAuthMethodId).getAll([authority.record.authorityId, authMethod.record.walletAuthMethodId]);
2933
- const requiresExportRoot = hasEd25519SignerFamily(authority.record.signerActivations) && authority.record.permissions.includes("export_keys");
2934
- if (exportRootRaws.length !== (requiresExportRoot ? 1 : 0)) return {
2935
- kind: "integrity_error",
2936
- reason: "selected authority export-root cardinality is invalid"
2937
- };
2938
- let exportRoot = null;
2939
- if (requiresExportRoot) {
2940
- const row = parseWalletAuthorityExportRootStorageRow(exportRootRaws[0]);
2941
- const expectedWalletKeyId = ed25519WalletKeyId(authority.record.signerActivations);
2942
- if (!row || expectedWalletKeyId === null || row.wallet_authority_id !== authority.record.authorityId || row.wallet_auth_method_id !== authMethod.record.walletAuthMethodId || row.record.walletKeyId !== expectedWalletKeyId || row.record.envelope.walletId !== walletId || row.record.envelope.binding.kind !== "ed25519_yao_client_root_v1" || row.record.envelope.binding.walletKeyId !== expectedWalletKeyId || row.record.envelope.binding.registeredPublicKeyB64u !== authority.record.signerActivations.ed25519?.signer.registeredPublicKeyB64u || authority.record.principal.kind !== "owner_device" || String(row.record.envelope.binding.deviceId) !== String(authority.record.principal.deviceId) || row.record.envelope.lifecycle.state !== "active" || !exportRootEnvelopeMatchesAuthMethod(authMethod.record, row.record.envelope)) return {
2943
- kind: "integrity_error",
2944
- reason: "selected authority export root is invalid"
2945
- };
2946
- exportRoot = row.record;
2947
- }
2948
- if (!await walletAuthorityDigestsMatchV1(authority.record)) return {
2949
- kind: "integrity_error",
2950
- reason: "selected wallet authority digest is invalid"
2951
- };
2952
- return {
2953
- kind: "resolved",
2954
- selection: selection.record,
2955
- authMethod: authMethod.record,
2956
- authority: authority.record,
2957
- signerMaterials,
2958
- exportRoot
2959
- };
2960
- }
2961
- async getAppState(key) {
2962
- const normalizedKey = normalizeTrimmedString(key || "");
2963
- if (!normalizedKey) return void 0;
2964
- return (await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.appState, normalizedKey))?.value;
2965
- }
2966
- async listAppStateEntriesByPrefix(prefix) {
2967
- const normalizedPrefix = normalizeTrimmedString(prefix || "");
2968
- if (!normalizedPrefix) return [];
2969
- return (await (await this.manager.getDB()).getAll(SEAMS_WALLET_STORES.appState)).flatMap((raw) => {
2970
- const row = parseAppStateRow(raw);
2971
- return row && row.key.startsWith(normalizedPrefix) ? [row] : [];
2972
- });
2973
- }
2974
- async setAppState(key, value) {
2975
- const normalizedKey = normalizeTrimmedString(key || "");
2976
- if (!normalizedKey) return;
2977
- await this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
2978
- await ctx.store(SEAMS_WALLET_STORES.appState).put({
2979
- key: normalizedKey,
2980
- value
2981
- });
2982
- });
2983
- }
2984
- async putPendingWalletRegistrationCommits(records) {
2985
- const rows = records.map(toPendingWalletRegistrationCommitAppStateRow);
2986
- await this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
2987
- const store = ctx.store(SEAMS_WALLET_STORES.appState);
2988
- for (const row of rows) {
2989
- if (await store.get(row.key)) throw new Error("Registration checkpoint already exists");
2990
- await store.put(row);
2991
- }
2992
- });
2993
- }
2994
- async advancePendingNearRegistration(input) {
2995
- const current = input.expected;
2996
- const next = input.next;
2997
- if (current.registrationCeremonyId !== next.registrationCeremonyId || current.walletId !== next.walletId || current.walletAuthMethodId !== next.walletAuthMethodId || current.signedSetup !== next.signedSetup || current.signerPlanKind !== next.signerPlanKind || current.createdAtMs !== next.createdAtMs || next.updatedAtMs < current.updatedAtMs || JSON.stringify(current.auth) !== JSON.stringify(next.auth) || !(current.phase === "planned" && next.phase === "execution_prepared" || current.phase === "execution_prepared" && next.phase === "joined")) throw new Error("Invalid NEAR registration checkpoint transition");
2998
- if (current.phase === "planned" && next.phase === "execution_prepared" && (current.idempotencyKey !== next.idempotencyKey || JSON.stringify(current.admissionRequest) !== JSON.stringify(next.admissionRequest) || JSON.stringify(current.baseCustodyCommit) !== JSON.stringify(next.baseCustodyCommit))) throw new Error("NEAR preparation changed its immutable request");
2999
- if (current.phase === "execution_prepared" && next.phase === "joined" && (next.completion.kind !== "encrypted_checkpoint" || JSON.stringify(next.completion.prepared) !== JSON.stringify(current))) throw new Error("Joined NEAR must retain its exact encrypted completion checkpoint");
3000
- const row = toPendingWalletRegistrationCommitAppStateRow(current);
3001
- const nextRow = toPendingWalletRegistrationCommitAppStateRow(next);
3002
- await this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
3003
- const store = ctx.store(SEAMS_WALLET_STORES.appState);
3004
- const saved = parsePendingWalletRegistrationCommitAppStateRow(await store.get(row.key));
3005
- if (!saved || JSON.stringify(saved.record) !== JSON.stringify(current)) throw new Error("NEAR registration checkpoint changed concurrently");
3006
- await store.put(nextRow);
3007
- });
3008
- }
3009
- async putPendingWalletRegistrationCommit(record) {
3010
- const row = toPendingWalletRegistrationCommitAppStateRow(record);
3011
- await this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
3012
- await ctx.store(SEAMS_WALLET_STORES.appState).put(row);
3013
- });
3014
- }
3015
- async migratePendingMixedRegistrationRows() {
3016
- const rows = await (await this.manager.getDB()).getAll(SEAMS_WALLET_STORES.appState);
3017
- const candidates = await Promise.all(rows.map(splitPersistedMixedRegistrationRow));
3018
- await this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
3019
- const store = ctx.store(SEAMS_WALLET_STORES.appState);
3020
- for (const candidate of candidates) {
3021
- if (!candidate) continue;
3022
- const activation = toPendingWalletRegistrationCommitAppStateRow(candidate.activation);
3023
- if (JSON.stringify(await store.get(activation.key)) !== JSON.stringify(candidate.original)) continue;
3024
- const near = toPendingWalletRegistrationCommitAppStateRow(candidate.near);
3025
- const savedNear = await store.get(near.key);
3026
- if (savedNear && JSON.stringify(savedNear) !== JSON.stringify(near)) throw new Error("Conflicting NEAR continuation during registration migration");
3027
- await store.put(near);
3028
- await store.put(activation);
3029
- }
3030
- });
3031
- }
3032
- async getPendingWalletRegistrationCommit(input) {
3033
- await this.migratePendingMixedRegistrationRows();
3034
- const registrationCeremonyId = normalizeTrimmedString(input.registrationCeremonyId || "");
3035
- if (!registrationCeremonyId) return null;
3036
- return parsePendingWalletRegistrationCommitAppStateRow(await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.appState, pendingWalletRegistrationCommitAppStateKey({
3037
- registrationCeremonyId,
3038
- operation: input.operation
3039
- })))?.record || null;
3040
- }
3041
- async listPendingWalletRegistrationCommits() {
3042
- await this.migratePendingMixedRegistrationRows();
3043
- return (await (await this.manager.getDB()).getAll(SEAMS_WALLET_STORES.appState)).flatMap((raw) => {
3044
- const parsed = parsePendingWalletRegistrationCommitAppStateRow(raw);
3045
- return parsed ? [parsed.record] : [];
3046
- });
3047
- }
3048
- async deletePendingWalletRegistrationCommit(input) {
3049
- const registrationCeremonyId = normalizeTrimmedString(input.registrationCeremonyId || "");
3050
- if (!registrationCeremonyId) return;
3051
- await this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
3052
- await ctx.store(SEAMS_WALLET_STORES.appState).delete(pendingWalletRegistrationCommitAppStateKey({
3053
- registrationCeremonyId,
3054
- operation: input.operation
3055
- }));
3056
- });
3057
- }
3058
- /**
3059
- * Adopts the authority the Gateway returned after this wallet added an ECDSA
3060
- * signer: the local authority extended with exactly the activation this
3061
- * device made, nothing else changed. The Gateway promoted the wallet's live
3062
- * Wallet Sessions to it; the next exact status read carries that promotion
3063
- * into the local session, which keeps its operation credential.
3064
- */
3065
- async adoptAddedEcdsaSignerAuthority(input) {
3066
- const parsed = parseWalletAuthorityV1(input.authority);
3067
- if (!parsed.ok || parsed.value.state !== "active" || !await walletAuthorityDigestsMatchV1(parsed.value)) throw new Error("Added ECDSA signer authority is invalid");
3068
- const next = parsed.value;
3069
- const nextEcdsa = next.signerActivations.ecdsa;
3070
- if (!nextEcdsa || !mpcMaterialActivationRefsEqual(nextEcdsa.materialActivation, input.materialActivation)) throw new Error("Added ECDSA signer authority does not carry the activated signer");
3071
- await this.manager.runTransaction([SEAMS_WALLET_STORES.walletAuthorities], "readwrite", async (ctx) => {
3072
- const store = ctx.store(SEAMS_WALLET_STORES.walletAuthorities);
3073
- const current = parseWalletAuthorityStorageRow(await store.get(next.authorityId));
3074
- if (!current || current.record.state !== "active") throw new Error("Added ECDSA signer has no active local authority to extend");
3075
- if (current.record.authorityDigestB64u === next.authorityDigestB64u) return;
3076
- if (!isEcdsaExtensionOfEd25519WalletAuthority(current.record, next)) throw new Error("Added ECDSA signer authority is not an extension of the local authority");
3077
- await store.put(walletAuthorityStorageRow(next));
3078
- });
3079
- }
3080
- /**
3081
- * Replaces the exact active Wallet Session with the one a status read
3082
- * returned, only while it still binds the wallet's stored authority and its
3083
- * unlocked selection. The status crosses the network, and a publication
3084
- * can commit meanwhile: deferred NEAR provisioning extends the authority
3085
- * and rebinds the session in one transaction. Writing the older status
3086
- * after it would bind the session to an authority digest no longer stored,
3087
- * and every exact-session check would refuse it until another status read.
3088
- */
3089
- async replaceExactActiveWalletSessionFromStatus(input) {
3090
- return await this.manager.runTransaction([
3091
- SEAMS_WALLET_STORES.walletAuthorities,
3092
- SEAMS_WALLET_STORES.walletSessionAuthorizations,
3093
- SEAMS_WALLET_STORES.walletSelections
3094
- ], "readwrite", this.replaceExactActiveWalletSessionFromStatusInTransaction.bind(this, input));
3095
- }
3096
- async replaceExactActiveWalletSessionFromStatusInTransaction(input, ctx) {
3097
- const authority = parseWalletAuthorityStorageRow(await ctx.store(SEAMS_WALLET_STORES.walletAuthorities).get(input.active.authorityId));
3098
- const selection = parseWalletSelectionStorageRow(await ctx.store(SEAMS_WALLET_STORES.walletSelections).get(input.active.walletId));
3099
- if (!authority || authority.record.state !== "active" || authority.record.walletId !== input.active.walletId || authority.record.authorityDigestB64u !== input.active.authorityDigestB64u || authority.record.revocationEpoch !== input.active.authorityRevocationEpoch || !selection || selection.record.lockState !== "unlocked" || selection.record.walletAuthMethodId !== input.active.authMethodId) return { kind: "superseded" };
3100
- await replaceExactActiveWalletSessionAuthorizationInTransaction({
3101
- ctx,
3102
- active: input.active,
3103
- operationCredential: input.operationCredential
3104
- });
3105
- return { kind: "replaced" };
3106
- }
3107
- async reconcilePendingNearRegistrationAuthority(input) {
3108
- const authority = await this.getWalletAuthority(input.walletSession.authorityId);
3109
- if (!authority || authority.state !== "active" || !isActiveEcdsaWalletAuthorityV1(authority)) return;
3110
- const rows = await this.listPendingWalletRegistrationCommits();
3111
- for (const pending of rows) {
3112
- if (pending.operation !== "near_provisioning" || pending.phase !== "joined" || pending.signerPlanKind !== "near_ed25519_and_evm_family_ecdsa" || pending.walletId !== input.walletSession.walletId || pending.walletAuthMethodId !== input.walletSession.authMethodId) continue;
3113
- const metadata = pending.localMaterial.ed25519.metadata;
3114
- const extended = await extendEcdsaWalletAuthorityWithEd25519({
3115
- authority,
3116
- ed25519: {
3117
- kind: "wallet_ed25519_signer_activation_v1",
3118
- signer: {
3119
- kind: "exact_administered_ed25519_signer_v1",
3120
- keyFamily: "ed25519",
3121
- walletId: pending.walletId,
3122
- walletKeyId: requireBoundaryParsed(parseWalletKeyId(`wallet-key:ed25519:${pending.walletId}:${metadata.nearEd25519SigningKeyId}`), "NEAR wallet key"),
3123
- registeredPublicKeyB64u: parseEd25519PublicKeyB64u(metadata.registeredPublicKeyB64u)
3124
- },
3125
- materialActivation: metadata.materialActivation
3126
- },
3127
- now: Date.now()
3128
- });
3129
- if (extended.authorityDigestB64u !== input.walletSession.authorityDigestB64u || extended.revocationEpoch !== input.walletSession.authorityRevocationEpoch) continue;
3130
- await this.manager.runTransaction([
3131
- SEAMS_WALLET_STORES.appState,
3132
- SEAMS_WALLET_STORES.walletAuthorities,
3133
- SEAMS_WALLET_STORES.walletSessionAuthorizations,
3134
- SEAMS_WALLET_STORES.walletSelections
3135
- ], "readwrite", this.reconcilePendingNearRegistrationAuthorityInTransaction.bind(this, {
3136
- pending,
3137
- authority: extended,
3138
- previousDigest: authority.authorityDigestB64u,
3139
- walletSession: input.walletSession,
3140
- operationCredential: input.operationCredential
3141
- }));
3142
- return;
3143
- }
3144
- }
3145
- async reconcilePendingNearRegistrationAuthorityInTransaction(input, ctx) {
3146
- const current = await readExactActiveWalletSessionForScopeInTransaction({
3147
- ctx,
3148
- walletId: input.pending.walletId,
3149
- authorityId: input.authority.authorityId,
3150
- authMethodId: input.pending.walletAuthMethodId
3151
- });
3152
- const selection = parseWalletSelectionStorageRow(await ctx.store(SEAMS_WALLET_STORES.walletSelections).get(input.pending.walletId));
3153
- const authority = parseWalletAuthorityStorageRow(await ctx.store(SEAMS_WALLET_STORES.walletAuthorities).get(input.authority.authorityId));
3154
- const pending = parsePendingWalletRegistrationCommitAppStateRow(await ctx.store(SEAMS_WALLET_STORES.appState).get(pendingWalletRegistrationCommitAppStateKey(input.pending)));
3155
- if (current.kind !== "found" || current.operationCredential.token !== input.operationCredential.token || !selection || selection.record.lockState !== "unlocked" || selection.record.walletAuthMethodId !== input.pending.walletAuthMethodId || !authority || authority.record.state !== "active" || authority.record.authorityDigestB64u !== input.previousDigest && authority.record.authorityDigestB64u !== input.authority.authorityDigestB64u || !pending || JSON.stringify(pending.record) !== JSON.stringify(input.pending)) throw new Error("NEAR authority reconciliation was superseded");
3156
- assertCredentialFreeRegistrationSessionProjectionMatchesExisting({
3157
- incoming: input.walletSession,
3158
- existing: current.record
3159
- });
3160
- await ctx.store(SEAMS_WALLET_STORES.walletAuthorities).put(walletAuthorityStorageRow(input.authority));
3161
- await replaceExactActiveWalletSessionAuthorizationInTransaction({
3162
- ctx,
3163
- active: input.walletSession,
3164
- operationCredential: current.operationCredential
3165
- });
3166
- }
3167
- async completePendingNearRegistration(input) {
3168
- await this.manager.runTransaction([
3169
- SEAMS_WALLET_STORES.appState,
3170
- SEAMS_WALLET_STORES.wallets,
3171
- SEAMS_WALLET_STORES.walletSessionAuthorizations,
3172
- SEAMS_WALLET_STORES.walletSelections
3173
- ], "readwrite", this.completePendingNearRegistrationInTransaction.bind(this, input));
3174
- }
3175
- async completePendingNearRegistrationInTransaction(input, ctx) {
3176
- const current = await readExactActiveWalletSessionForScopeInTransaction({
3177
- ctx,
3178
- walletId: input.pending.walletId,
3179
- authorityId: input.walletSession.authorityId,
3180
- authMethodId: input.pending.walletAuthMethodId
3181
- });
3182
- if (current.kind !== "found" || current.operationCredential.token !== input.operationCredential.token || current.record.authorityDigestB64u !== input.walletSession.authorityDigestB64u) throw new Error("NEAR readiness requires the current Wallet Session");
3183
- assertCredentialFreeRegistrationSessionProjectionMatchesExisting({
3184
- incoming: input.walletSession,
3185
- existing: current.record
3186
- });
3187
- const selection = parseWalletSelectionStorageRow(await ctx.store(SEAMS_WALLET_STORES.walletSelections).get(input.pending.walletId));
3188
- if (!selection || selection.record.lockState !== "unlocked" || selection.record.walletAuthMethodId !== input.pending.walletAuthMethodId) throw new Error("NEAR readiness was interrupted by a wallet lock or selection change");
3189
- const pendingKey = pendingWalletRegistrationCommitAppStateKey(input.pending);
3190
- const stored = parsePendingWalletRegistrationCommitAppStateRow(await ctx.store(SEAMS_WALLET_STORES.appState).get(pendingKey));
3191
- if (!stored || JSON.stringify(stored.record) !== JSON.stringify(input.pending)) throw new Error("NEAR readiness journal changed concurrently");
3192
- const profile = parseProfileRow(await ctx.store(SEAMS_WALLET_STORES.wallets).get(input.pending.walletId));
3193
- if (!profile) throw new Error("NEAR readiness requires its committed wallet");
3194
- await ctx.store(SEAMS_WALLET_STORES.wallets).put(profileRow({
3195
- profileId: profile.profileId,
3196
- nearProvisioning: {
3197
- status: "near_ready",
3198
- nearAccountId: input.nearAccountId,
3199
- updatedAtMs: Date.now()
3200
- }
3201
- }, profile));
3202
- await ctx.store(SEAMS_WALLET_STORES.appState).delete(pendingKey);
3203
- }
3204
- async putPendingWalletRecoveryCommit(record) {
3205
- const row = await toPendingWalletRecoveryCommitAppStateRow(record);
3206
- await this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
3207
- await ctx.store(SEAMS_WALLET_STORES.appState).put(row);
3208
- });
3209
- }
3210
- async advancePendingWalletRecoveryCommit(input) {
3211
- const awaiting = await buildPendingWalletRecoveryCommitV1(input.awaiting);
3212
- const promoted = await buildPendingWalletRecoveryCommitV1(input.promoted);
3213
- if (awaiting.stage !== "awaiting_server_promotion" || promoted.stage !== "server_promoted" || !pendingWalletRecoveryCommitIdentityMatches(awaiting, promoted)) throw new Error("pending wallet recovery promotion changed its immutable identity");
3214
- const awaitingRow = await toPendingWalletRecoveryCommitAppStateRow(awaiting);
3215
- const promotedRow = await toPendingWalletRecoveryCommitAppStateRow(promoted);
3216
- return this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
3217
- const store = ctx.store(SEAMS_WALLET_STORES.appState);
3218
- const stored = await store.get(awaitingRow.key);
3219
- if (pendingWalletRecoveryCommitAppStateRowsMatch(stored, awaitingRow)) {
3220
- await store.put(promotedRow);
3221
- return promoted;
3222
- }
3223
- if (pendingWalletRecoveryCommitAppStateRowsMatch(stored, promotedRow)) return promoted;
3224
- throw new Error("stored pending wallet recovery commit does not match the expected stage");
3225
- });
3226
- }
3227
- async getPendingWalletRecoveryCommit(recoveryOperationId) {
3228
- const parsedRecoveryOperationId = requireBoundaryParsed(parseWalletRecoveryOperationId(recoveryOperationId), "recoveryOperationId");
3229
- return (await parsePendingWalletRecoveryCommitAppStateRow(await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.appState, pendingWalletRecoveryCommitAppStateKey(parsedRecoveryOperationId))))?.record ?? null;
3230
- }
3231
- async listPendingWalletRecoveryCommits() {
3232
- const db = await this.manager.getDB();
3233
- return (await Promise.all((await db.getAll(SEAMS_WALLET_STORES.appState)).map(parsePendingWalletRecoveryCommitAppStateRow))).flatMap((parsed) => parsed ? [parsed.record] : []);
3234
- }
3235
- async deletePendingWalletRecoveryCommit(recoveryOperationId) {
3236
- const parsedRecoveryOperationId = requireBoundaryParsed(parseWalletRecoveryOperationId(recoveryOperationId), "recoveryOperationId");
3237
- await this.manager.runTransaction([SEAMS_WALLET_STORES.appState], "readwrite", async (ctx) => {
3238
- await ctx.store(SEAMS_WALLET_STORES.appState).delete(pendingWalletRecoveryCommitAppStateKey(parsedRecoveryOperationId));
3239
- });
3240
- }
3241
- async getProfile(profileId) {
3242
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
3243
- if (!normalizedProfileId) return null;
3244
- return parseProfileRow(await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.wallets, normalizedProfileId));
3245
- }
3246
- async getWalletPreferences(walletId) {
3247
- return (await this.getProfile(walletId))?.preferences || {};
3248
- }
3249
- async listProfiles(args) {
3250
- const db = await this.manager.getDB();
3251
- const limit = Number.isSafeInteger(args?.limit) && Number(args?.limit) > 0 ? Number(args?.limit) : void 0;
3252
- return (limit ? await db.getAll(SEAMS_WALLET_STORES.wallets, void 0, limit) : await db.getAll(SEAMS_WALLET_STORES.wallets)).flatMap((row) => {
3253
- const parsed = parseProfileRow(row);
3254
- return parsed ? [parsed] : [];
3255
- });
3256
- }
3257
- async upsertProfile(input) {
3258
- const profileId = normalizeTrimmedString(input.profileId || "");
3259
- if (!profileId) throw new Error("[SeamsWalletDB] profileId is required");
3260
- let written = null;
3261
- await this.manager.runTransaction([SEAMS_WALLET_STORES.wallets], "readwrite", async (ctx) => {
3262
- const store = ctx.store(SEAMS_WALLET_STORES.wallets);
3263
- const next = profileRow(input, parseProfileRow(await store.get(profileId)) || void 0);
3264
- written = next.record;
3265
- await store.put(next);
3266
- });
3267
- if (!written) throw new Error("[SeamsWalletDB] profile write did not complete");
3268
- return written;
3269
- }
3270
- async upsertWalletAuthMethod(record) {
3271
- const fields = walletAuthMethodFields(record);
3272
- let written = null;
3273
- await this.manager.runTransaction([SEAMS_WALLET_STORES.wallets, SEAMS_WALLET_STORES.walletAuthMethods], "readwrite", async (ctx) => {
3274
- const profile = parseProfileRow(await ctx.store(SEAMS_WALLET_STORES.wallets).get(fields.wallet_id));
3275
- if (!profile) throw makeConstraintError("MISSING_PROFILE", `Cannot upsert auth-method binding for unknown wallet: ${fields.wallet_id}`, {
3276
- profileId: fields.wallet_id,
3277
- authIdentifierKey: fields.auth_identifier_key
3278
- });
3279
- const store = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
3280
- const existing = parseWalletAuthMethodStorageRow(await store.get(fields.wallet_auth_method_id));
3281
- const row = record.kind === "passkey" && existing?.kind === "passkey" ? passkeyAuthMethodRow({
3282
- binding: record,
3283
- authenticator: existing.authenticator
3284
- }) : walletAuthMethodRowFromBinding(record, profile.defaultSignerSlot);
3285
- await store.put(row);
3286
- written = row.record;
3287
- });
3288
- if (!written) throw new Error("[SeamsWalletDB] auth-method write did not complete");
3289
- return written;
3290
- }
3291
- async upsertWalletAuthMethodV2(record) {
3292
- const parsed = parseWalletAuthMethodRecordV2(record);
3293
- if (!parsed) throw new Error("[SeamsWalletDB] auth-method V2 record is invalid");
3294
- await this.manager.runTransaction([SEAMS_WALLET_STORES.wallets, SEAMS_WALLET_STORES.walletAuthMethods], "readwrite", async (ctx) => {
3295
- if (!parseProfileRow(await ctx.store(SEAMS_WALLET_STORES.wallets).get(parsed.walletId))) throw makeConstraintError("MISSING_PROFILE", `Cannot upsert auth-method V2 binding for unknown wallet: ${String(parsed.walletId)}`, { profileId: String(parsed.walletId) });
3296
- const authMethodStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
3297
- await authMethodStore.put(await walletAuthMethodV2StorageRowForStore(authMethodStore, parsed));
3298
- });
3299
- }
3300
- async getWalletAuthMethod(args) {
3301
- const kind = args.kind;
3302
- const rpId = normalizeTrimmedString(args.rpId || "");
3303
- const authIdentifierKey = normalizeTrimmedString(args.authIdentifierKey || "");
3304
- if (!rpId || !authIdentifierKey) return null;
3305
- const parsed = (await (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.walletAuthMethods, "readonly").store.index(SEAMS_WALLET_INDEXES.kindRpIdAuthIdentifier).getAll([
3306
- kind,
3307
- rpId,
3308
- authIdentifierKey
3309
- ])).flatMap((row) => {
3310
- const record = parseWalletAuthMethodRow(row);
3311
- return record ? [record] : [];
3312
- });
3313
- return parsed.length === 1 ? parsed[0] : null;
3314
- }
3315
- async listWalletAuthMethodsForWallet(walletId) {
3316
- const normalizedWalletId = normalizeTrimmedString(walletId || "");
3317
- if (!normalizedWalletId) return [];
3318
- return (await (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.walletAuthMethods, "readonly").store.index(SEAMS_WALLET_INDEXES.walletId).getAll(normalizedWalletId)).flatMap((row) => {
3319
- const parsed = parseWalletAuthMethodRow(row);
3320
- return parsed ? [parsed] : [];
3321
- });
3322
- }
3323
- async upsertChainAccount(input) {
3324
- const profileId = normalizeTrimmedString(input.profileId || "");
3325
- const chainIdKey = normalizeIndexedDbChainIdKey(input.chainIdKey);
3326
- const accountAddress = normalizeIndexedDbAccountAddress(input.accountAddress);
3327
- if (!profileId || !chainIdKey || !accountAddress) throw new Error("[SeamsWalletDB] profileId, chainIdKey, and accountAddress are required");
3328
- let written = null;
3329
- await this.manager.runTransaction([SEAMS_WALLET_STORES.wallets, SEAMS_WALLET_STORES.nearAccountProjections], "readwrite", async (ctx) => {
3330
- if (!parseProfileRow(await ctx.store(SEAMS_WALLET_STORES.wallets).get(profileId))) throw new Error(`[SeamsWalletDB] Cannot upsert chain account for unknown profile: ${profileId}`);
3331
- const store = ctx.store(SEAMS_WALLET_STORES.nearAccountProjections);
3332
- const projectionId = chainAccountProjectionId({
3333
- chainIdKey,
3334
- accountAddress
3335
- });
3336
- const next = chainAccountProjectionRow(input, parseChainAccountProjectionRow(await store.get([
3337
- profileId,
3338
- projectionId,
3339
- CHAIN_ACCOUNT_PROJECTION_SIGNER_SLOT
3340
- ])) || void 0);
3341
- written = next.record;
3342
- if (next.record.isPrimary) {
3343
- const rows = await store.index(SEAMS_WALLET_INDEXES.profileId).getAll(profileId);
3344
- for (const row of rows || []) {
3345
- const parsed = parseChainAccountProjectionRow(row);
3346
- if (!parsed || parsed.chainIdKey !== chainIdKey || !parsed.isPrimary) continue;
3347
- if (parsed.accountAddress === accountAddress) continue;
3348
- await store.put(chainAccountProjectionRow({
3349
- profileId: parsed.profileId,
3350
- chainIdKey: parsed.chainIdKey,
3351
- accountAddress: parsed.accountAddress,
3352
- accountModel: parsed.accountModel,
3353
- isPrimary: false
3354
- }, parsed));
3355
- }
3356
- }
3357
- await store.put(next);
3358
- });
3359
- if (!written) throw new Error("[SeamsWalletDB] chain-account write did not complete");
3360
- return written;
3361
- }
3362
- async listChainAccountsByProfile(profileId) {
3363
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
3364
- if (!normalizedProfileId) return [];
3365
- const tx = (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.nearAccountProjections, "readonly");
3366
- const rows = await tx.store.index(SEAMS_WALLET_INDEXES.profileId).getAll(normalizedProfileId);
3367
- await tx.done;
3368
- return rows.flatMap((row) => {
3369
- const parsed = parseChainAccountProjectionRow(row);
3370
- return parsed ? [parsed] : [];
3371
- });
3372
- }
3373
- async listChainAccountsByProfileAndChain(profileId, chainIdKey) {
3374
- const normalizedChainIdKey = normalizeIndexedDbChainIdKey(chainIdKey);
3375
- if (!normalizedChainIdKey) return [];
3376
- return (await this.listChainAccountsByProfile(profileId)).filter((row) => row.chainIdKey === normalizedChainIdKey);
3377
- }
3378
- async getChainAccount(input) {
3379
- const profileId = normalizeTrimmedString(input.profileId || "");
3380
- const chainIdKey = normalizeIndexedDbChainIdKey(input.chainIdKey);
3381
- const accountAddress = normalizeIndexedDbAccountAddress(input.accountAddress);
3382
- if (!profileId || !chainIdKey || !accountAddress) return null;
3383
- return parseChainAccountProjectionRow(await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.nearAccountProjections, [
3384
- profileId,
3385
- chainAccountProjectionId({
3386
- chainIdKey,
3387
- accountAddress
3388
- }),
3389
- CHAIN_ACCOUNT_PROJECTION_SIGNER_SLOT
3390
- ]));
3391
- }
3392
- async resolveProfileAccountContext(accountRef) {
3393
- const chainIdKey = normalizeIndexedDbChainIdKey(accountRef.chainIdKey);
3394
- const accountAddress = normalizeIndexedDbAccountAddress(accountRef.accountAddress);
3395
- if (!chainIdKey || !accountAddress) return null;
3396
- const match = (await (await this.manager.getDB()).getAll(SEAMS_WALLET_STORES.nearAccountProjections)).flatMap((row) => {
3397
- const parsed = parseChainAccountProjectionRow(row);
3398
- return parsed ? [parsed] : [];
3399
- }).find((row) => row.chainIdKey === chainIdKey && row.accountAddress === accountAddress);
3400
- if (!match?.profileId) return null;
3401
- return {
3402
- profileId: match.profileId,
3403
- accountRef: {
3404
- chainIdKey,
3405
- accountAddress
3406
- }
3407
- };
3408
- }
3409
- async listChainAccountsByChain(chainIdKey) {
3410
- const normalizedChainIdKey = normalizeIndexedDbChainIdKey(chainIdKey);
3411
- if (!normalizedChainIdKey) return [];
3412
- return (await (await this.manager.getDB()).getAll(SEAMS_WALLET_STORES.nearAccountProjections)).flatMap((row) => {
3413
- const parsed = parseChainAccountProjectionRow(row);
3414
- return parsed && parsed.chainIdKey === normalizedChainIdKey ? [parsed] : [];
3415
- });
3416
- }
3417
- buildAccountSignerRecord(args) {
3418
- const removedAt = args.status === "revoked" ? args.removedAt ?? args.existing?.removedAt ?? args.now : void 0;
3419
- return {
3420
- profileId: args.profileId,
3421
- chainIdKey: args.chainIdKey,
3422
- accountAddress: args.accountAddress,
3423
- signerId: args.signerId,
3424
- signerSlot: args.signerSlot,
3425
- signerType: args.signerType,
3426
- signerKind: args.signerKind,
3427
- signerAuthMethod: args.signerAuthMethod,
3428
- signerSource: args.signerSource,
3429
- status: args.status,
3430
- addedAt: args.existing?.addedAt ?? args.now,
3431
- updatedAt: args.now,
3432
- ...removedAt != null ? { removedAt } : {},
3433
- ...args.revocationReason ? { revocationReason: normalizeTrimmedString(args.revocationReason) } : args.existing?.revocationReason ? { revocationReason: args.existing.revocationReason } : {},
3434
- ...args.metadata != null ? { metadata: args.metadata } : args.existing?.metadata != null ? { metadata: args.existing.metadata } : {}
3435
- };
3436
- }
3437
- assertSignerWriteInvariants(args) {
3438
- const { next } = args;
3439
- if (next.status !== "revoked") {
3440
- if (!next.signerKind || !next.signerAuthMethod || !next.signerSource) throw makeConstraintError("MISSING_SIGNER_KIND", "Active and pending account signers require signerKind, signerAuthMethod, and signerSource", {
3441
- chainIdKey: next.chainIdKey,
3442
- accountAddress: next.accountAddress,
3443
- signerId: next.signerId,
3444
- status: next.status
3445
- });
3446
- }
3447
- if (next.status === "revoked" && next.removedAt == null) throw makeConstraintError("REVOKED_SIGNER_REQUIRES_REMOVED_AT", `Revoked signer ${next.signerId} must include removedAt`, {
3448
- chainIdKey: next.chainIdKey,
3449
- accountAddress: next.accountAddress,
3450
- signerId: next.signerId
3451
- });
3452
- if (next.status === "active") {
3453
- const conflictingSlot = args.activeSigners.find((row) => row.signerId !== next.signerId && row.signerSlot === next.signerSlot);
3454
- if (conflictingSlot) throw makeConstraintError("DUPLICATE_ACTIVE_SIGNER_SLOT", `Active signer slot ${next.signerSlot} is already used for ${next.chainIdKey}/${next.accountAddress}`, {
3455
- chainIdKey: next.chainIdKey,
3456
- accountAddress: next.accountAddress,
3457
- signerId: next.signerId,
3458
- signerSlot: next.signerSlot,
3459
- conflictingSignerId: conflictingSlot.signerId
3460
- });
3461
- }
3462
- if (args.existingStatus && args.existingStatus !== next.status) {
3463
- if (!{
3464
- pending: new Set([
3465
- "pending",
3466
- "active",
3467
- "revoked"
3468
- ]),
3469
- active: new Set(["active", "revoked"]),
3470
- revoked: new Set(["revoked"])
3471
- }[args.existingStatus]?.has(next.status)) throw makeConstraintError("INVALID_SIGNER_STATUS_TRANSITION", `Invalid signer status transition ${args.existingStatus} -> ${next.status}`, {
3472
- chainIdKey: next.chainIdKey,
3473
- accountAddress: next.accountAddress,
3474
- signerId: next.signerId,
3475
- previousStatus: args.existingStatus,
3476
- nextStatus: next.status
3477
- });
3478
- }
3479
- if (next.status === "active" && String(next.signerKind || "") === "threshold-ecdsa") {
3480
- const metadata = next.metadata || {};
3481
- if (!normalizeTrimmedString(metadata.keyHandle)) throw makeConstraintError("INVALID_SIGNER_METADATA", "Active threshold ECDSA signer requires metadata.keyHandle", {
3482
- chainIdKey: next.chainIdKey,
3483
- accountAddress: next.accountAddress,
3484
- signerId: next.signerId
3485
- });
3486
- if (!normalizeTrimmedString(metadata.ecdsaThresholdKeyId)) throw makeConstraintError("INVALID_SIGNER_METADATA", "Active threshold ECDSA signer requires metadata.ecdsaThresholdKeyId", {
3487
- chainIdKey: next.chainIdKey,
3488
- accountAddress: next.accountAddress,
3489
- signerId: next.signerId
3490
- });
3491
- const thresholdOwnerAddress = normalizeIndexedDbAccountAddress(metadata.thresholdOwnerAddress);
3492
- if (!thresholdOwnerAddress || thresholdOwnerAddress !== next.accountAddress) throw makeConstraintError("INVALID_SIGNER_METADATA", "Active threshold ECDSA signer requires metadata.thresholdOwnerAddress matching accountAddress", {
3493
- chainIdKey: next.chainIdKey,
3494
- accountAddress: next.accountAddress,
3495
- signerId: next.signerId
3496
- });
3497
- const chainTargetKey = normalizeEcdsaChainTargetKey(metadata.chainTarget);
3498
- if (!chainTargetKey) throw makeConstraintError("INVALID_SIGNER_METADATA", "Active threshold ECDSA signer requires metadata.chainTarget", {
3499
- chainIdKey: next.chainIdKey,
3500
- accountAddress: next.accountAddress,
3501
- signerId: next.signerId
3502
- });
3503
- if (chainTargetKey !== next.chainIdKey) throw makeConstraintError("INVALID_SIGNER_METADATA", "Active threshold ECDSA signer metadata.chainTarget must match chainIdKey", {
3504
- chainIdKey: next.chainIdKey,
3505
- chainTargetKey,
3506
- accountAddress: next.accountAddress,
3507
- signerId: next.signerId
3508
- });
3509
- }
3510
- }
3511
- async enqueueSignerOperationInTransaction(store, input) {
3512
- const opId = normalizeTrimmedString(input.opId || "");
3513
- const idempotencyKey = normalizeTrimmedString(input.idempotencyKey || "");
3514
- const chainIdKey = normalizeIndexedDbChainIdKey(input.chainIdKey);
3515
- const accountAddress = normalizeIndexedDbAccountAddress(input.accountAddress);
3516
- const signerId = normalizeTrimmedString(input.signerId || "");
3517
- if (!opId || !idempotencyKey || !chainIdKey || !accountAddress || !signerId) throw new Error("[SeamsWalletDB] opId, idempotencyKey, chainIdKey, accountAddress, and signerId are required");
3518
- const existing = parseSignerOutboxRow(await store.get(opId));
3519
- if (!existing) {
3520
- const byIdempotency = parseSignerOutboxRow(await store.index(SEAMS_WALLET_INDEXES.idempotencyKey).get(idempotencyKey));
3521
- if (byIdempotency) return byIdempotency;
3522
- }
3523
- const now = Date.now();
3524
- const next = {
3525
- opId,
3526
- idempotencyKey,
3527
- opType: input.opType,
3528
- chainIdKey,
3529
- accountAddress,
3530
- signerId,
3531
- payload: input.payload ?? existing?.payload,
3532
- status: input.status ?? existing?.status ?? "queued",
3533
- attemptCount: input.attemptCount ?? existing?.attemptCount ?? 0,
3534
- nextAttemptAt: input.nextAttemptAt ?? existing?.nextAttemptAt ?? now,
3535
- lastError: input.lastError ?? existing?.lastError,
3536
- txHash: input.txHash ?? existing?.txHash,
3537
- createdAt: existing?.createdAt ?? now,
3538
- updatedAt: now
3539
- };
3540
- await store.put(signerOutboxRow(next));
3541
- return next;
3542
- }
3543
- async activateAccountSignerInTransaction(ctx, input) {
3544
- const profileId = normalizeTrimmedString(input.account.profileId || "");
3545
- const chainIdKey = normalizeIndexedDbChainIdKey(input.account.chainIdKey);
3546
- const accountAddress = normalizeIndexedDbAccountAddress(input.account.accountAddress);
3547
- const accountModel = normalizeIndexedDbAccountModel(input.account.accountModel);
3548
- const signerId = normalizeTrimmedString(input.signer.signerId || "");
3549
- const signerKind = input.signer.signerKind;
3550
- const signerAuthMethod = input.signer.signerAuthMethod;
3551
- const signerSource = input.signer.signerSource;
3552
- if (!profileId || !chainIdKey || !accountAddress || !accountModel || !signerId || !signerKind || !signerAuthMethod || !signerSource) throw new Error("[SeamsWalletDB] profileId, chainIdKey, accountAddress, accountModel, signerId, signerKind, signerAuthMethod, and signerSource are required");
3553
- const signerStore = ctx.store(SEAMS_WALLET_STORES.walletSigners);
3554
- if (!parseProfileRow(await ctx.store(SEAMS_WALLET_STORES.wallets).get(profileId))) throw makeConstraintError("MISSING_PROFILE", `Cannot upsert signer without profile row: ${profileId}`, {
3555
- profileId,
3556
- chainIdKey,
3557
- accountAddress,
3558
- signerId
3559
- });
3560
- if (shouldWriteNearAccountProjection({
3561
- accountModel,
3562
- chainIdKey
3563
- })) {
3564
- const chainAccountStore = ctx.store(SEAMS_WALLET_STORES.nearAccountProjections);
3565
- const existingChainAccount = parseChainAccountProjectionRow(await chainAccountStore.get([
3566
- profileId,
3567
- chainAccountProjectionId({
3568
- chainIdKey,
3569
- accountAddress
3570
- }),
3571
- CHAIN_ACCOUNT_PROJECTION_SIGNER_SLOT
3572
- ]));
3573
- const chainAccount = chainAccountProjectionRow({
3574
- profileId,
3575
- chainIdKey,
3576
- accountAddress,
3577
- accountModel,
3578
- isPrimary: input.selectAsActive === true ? true : existingChainAccount?.isPrimary ?? true
3579
- }, existingChainAccount || void 0);
3580
- await chainAccountStore.put(chainAccount);
3581
- }
3582
- const allActiveSigners = (await signerStore.index(SEAMS_WALLET_INDEXES.status).getAll("active")).flatMap((row) => {
3583
- const parsed = parseAccountSignerRow(row);
3584
- return parsed ? [parsed] : [];
3585
- });
3586
- const activeSigners = allActiveSigners.flatMap((parsed) => {
3587
- return parsed.chainIdKey === chainIdKey && parsed.accountAddress === accountAddress ? [parsed] : [];
3588
- });
3589
- const plan = planAccountSignerActivation({
3590
- activeSigners,
3591
- signer: {
3592
- signerId,
3593
- signerKind,
3594
- signerAuthMethod,
3595
- signerSource
3596
- },
3597
- activationPolicy: input.activationPolicy,
3598
- ...input.preferredSlot != null ? { preferredSlot: input.preferredSlot } : {}
3599
- });
3600
- const now = Date.now();
3601
- await this.revokeSignersForReplacement({
3602
- signerStore,
3603
- allActiveSigners,
3604
- accountActiveSigners: activeSigners,
3605
- profileId,
3606
- chainIdKey,
3607
- accountModel,
3608
- signerId,
3609
- activationPolicy: input.activationPolicy,
3610
- now
3611
- });
3612
- const activeSignersForInvariant = this.activeSignersAfterReplacement({
3613
- allActiveSigners,
3614
- accountActiveSigners: activeSigners,
3615
- profileId,
3616
- chainIdKey,
3617
- signerId,
3618
- activationPolicy: input.activationPolicy
3619
- });
3620
- const existingSigner = parseAccountSignerRow(await signerStore.get(walletSignerId({
3621
- chainIdKey,
3622
- accountAddress,
3623
- signerId
3624
- })));
3625
- if (existingSigner && existingSigner.profileId !== profileId) throw makeConstraintError("CHAIN_ACCOUNT_PROFILE_MISMATCH", `Signer row belongs to a different profile for ${chainIdKey}/${accountAddress}/${signerId}`, {
3626
- expectedProfileId: profileId,
3627
- existingProfileId: existingSigner.profileId
3628
- });
3629
- const signer = this.buildAccountSignerRecord({
3630
- profileId,
3631
- chainIdKey,
3632
- accountAddress,
3633
- signerId,
3634
- signerSlot: plan.signerSlot,
3635
- signerType: input.signer.signerType,
3636
- signerKind,
3637
- signerAuthMethod,
3638
- signerSource,
3639
- status: "active",
3640
- existing: existingSigner || void 0,
3641
- now,
3642
- ...input.signer.metadata ? { metadata: input.signer.metadata } : {}
3643
- });
3644
- this.assertSignerWriteInvariants({
3645
- next: signer,
3646
- accountModel,
3647
- existingStatus: existingSigner?.status,
3648
- activeSigners: activeSignersForInvariant
3649
- });
3650
- const signerRow = accountSignerRow(signer);
3651
- await deleteConflictingThresholdEcdsaSignerRows({
3652
- store: signerStore,
3653
- nextRow: signerRow
3654
- });
3655
- await signerStore.put(signerRow);
3656
- if (input.selectAsActive ?? true) await ctx.store(SEAMS_WALLET_STORES.appState).put({
3657
- key: scopedLastProfileStateAppStateKey(),
3658
- value: {
3659
- profileId,
3660
- activeSignerSlot: plan.signerSlot
3661
- }
3662
- });
3663
- if (input.mutation?.routeThroughOutbox ?? false) {
3664
- const opId = normalizeTrimmedString(input.mutation?.opId || "") || createRandomToken("add-signer");
3665
- const idempotencyKey = normalizeTrimmedString(input.mutation?.idempotencyKey || "") || `add-signer:${signer.chainIdKey}:${signer.accountAddress}:${signer.signerId}:${signer.signerSlot}`;
3666
- await this.enqueueSignerOperationInTransaction(ctx.store(SEAMS_WALLET_STORES.signerOpsOutbox), {
3667
- opId,
3668
- idempotencyKey,
3669
- opType: "add-signer",
3670
- chainIdKey: signer.chainIdKey,
3671
- accountAddress: signer.accountAddress,
3672
- signerId: signer.signerId,
3673
- payload: this.signerOutboxPayload(signer, input.mutation),
3674
- status: input.mutation?.outboxStatus || "queued"
3675
- });
3676
- }
3677
- return {
3678
- signer,
3679
- signerSlot: plan.signerSlot
3680
- };
3681
- }
3682
- activeSignersAfterReplacement(args) {
3683
- const replacedSignerIds = /* @__PURE__ */ new Set();
3684
- for (const signer of this.signersRetiredByActivationPolicy(args)) replacedSignerIds.add(signer.signerId);
3685
- if (replacedSignerIds.size === 0) return args.accountActiveSigners;
3686
- const retained = [];
3687
- for (const signer of args.accountActiveSigners) if (!replacedSignerIds.has(signer.signerId)) retained.push(signer);
3688
- return retained;
3689
- }
3690
- signersRetiredByActivationPolicy(args) {
3691
- const retired = [];
3692
- switch (args.activationPolicy.mode) {
3693
- case "replace_slot":
3694
- for (const signer of args.accountActiveSigners) if (signer.signerSlot === args.activationPolicy.signerSlot && signer.signerId !== args.signerId) retired.push(signer);
3695
- return retired;
3696
- case "replace_profile_chain_kind":
3697
- for (const signer of args.allActiveSigners) if (signer.profileId === args.profileId && signer.chainIdKey === args.chainIdKey && signer.signerKind === args.activationPolicy.replacedSignerKind && signer.signerId !== args.signerId) retired.push(signer);
3698
- return retired;
3699
- default: return retired;
3700
- }
3701
- }
3702
- async revokeSignersForReplacement(args) {
3703
- const retired = this.signersRetiredByActivationPolicy(args);
3704
- if (retired.length === 0) return;
3705
- const revocationReason = normalizeTrimmedString(args.activationPolicy.mode === "replace_slot" || args.activationPolicy.mode === "replace_profile_chain_kind" ? args.activationPolicy.revocationReason : "");
3706
- for (const signer of retired) {
3707
- const revoked = this.buildAccountSignerRecord({
3708
- ...signer,
3709
- status: "revoked",
3710
- existing: signer,
3711
- now: args.now,
3712
- removedAt: args.now,
3713
- revocationReason
3714
- });
3715
- this.assertSignerWriteInvariants({
3716
- next: revoked,
3717
- accountModel: args.accountModel,
3718
- existingStatus: signer.status,
3719
- activeSigners: args.accountActiveSigners
3720
- });
3721
- await args.signerStore.put(accountSignerRow(revoked));
3722
- }
3723
- }
3724
- async activateAccountSigner(input) {
3725
- let result = null;
3726
- await this.manager.runTransaction([
3727
- SEAMS_WALLET_STORES.appState,
3728
- SEAMS_WALLET_STORES.wallets,
3729
- SEAMS_WALLET_STORES.wallets,
3730
- SEAMS_WALLET_STORES.nearAccountProjections,
3731
- SEAMS_WALLET_STORES.walletSigners,
3732
- SEAMS_WALLET_STORES.appState,
3733
- SEAMS_WALLET_STORES.signerOpsOutbox
3734
- ], "readwrite", async (ctx) => {
3735
- result = await this.activateAccountSignerInTransaction(ctx, input);
3736
- });
3737
- if (!result) throw new Error("[SeamsWalletDB] signer activation did not complete");
3738
- return result;
3739
- }
3740
- async stageAccountSigner(input) {
3741
- return this.writePreparedAccountSigner({
3742
- account: input.account,
3743
- signer: input.signer,
3744
- status: "pending",
3745
- signerSlot: input.signer.signerSlot,
3746
- mutation: input.mutation
3747
- });
3748
- }
3749
- async writePreparedAccountSigner(input) {
3750
- const profileId = normalizeTrimmedString(input.account.profileId || "");
3751
- const chainIdKey = normalizeIndexedDbChainIdKey(input.account.chainIdKey);
3752
- const accountAddress = normalizeIndexedDbAccountAddress(input.account.accountAddress);
3753
- const accountModel = normalizeIndexedDbAccountModel(input.account.accountModel);
3754
- const signerId = normalizeTrimmedString(input.signer.signerId || "");
3755
- const signerSlot = Number(input.signerSlot);
3756
- const signerKind = input.signer.signerKind;
3757
- const signerAuthMethod = input.signer.signerAuthMethod;
3758
- const signerSource = input.signer.signerSource;
3759
- if (!profileId || !chainIdKey || !accountAddress || !accountModel || !signerId || !signerKind || !signerAuthMethod || !signerSource) throw new Error("[SeamsWalletDB] profileId, chainIdKey, accountAddress, accountModel, signerId, signerKind, signerAuthMethod, and signerSource are required");
3760
- if (!Number.isSafeInteger(signerSlot) || signerSlot < 1) throw new Error("[SeamsWalletDB] signerSlot must be an integer >= 1");
3761
- let result = null;
3762
- await this.manager.runTransaction([
3763
- SEAMS_WALLET_STORES.wallets,
3764
- SEAMS_WALLET_STORES.nearAccountProjections,
3765
- SEAMS_WALLET_STORES.walletSigners,
3766
- SEAMS_WALLET_STORES.signerOpsOutbox
3767
- ], "readwrite", async (ctx) => {
3768
- if (!parseProfileRow(await ctx.store(SEAMS_WALLET_STORES.wallets).get(profileId))) throw makeConstraintError("MISSING_PROFILE", `Cannot upsert signer without profile row: ${profileId}`, {
3769
- profileId,
3770
- chainIdKey,
3771
- accountAddress,
3772
- signerId
3773
- });
3774
- const chainAccountStore = ctx.store(SEAMS_WALLET_STORES.nearAccountProjections);
3775
- const existingChainAccount = parseChainAccountProjectionRow(await chainAccountStore.get([
3776
- profileId,
3777
- chainAccountProjectionId({
3778
- chainIdKey,
3779
- accountAddress
3780
- }),
3781
- CHAIN_ACCOUNT_PROJECTION_SIGNER_SLOT
3782
- ]));
3783
- const chainAccount = chainAccountProjectionRow({
3784
- profileId,
3785
- chainIdKey,
3786
- accountAddress,
3787
- accountModel,
3788
- isPrimary: existingChainAccount?.isPrimary
3789
- }, existingChainAccount || void 0);
3790
- await chainAccountStore.put(chainAccount);
3791
- const signerStore = ctx.store(SEAMS_WALLET_STORES.walletSigners);
3792
- const existingSigner = parseAccountSignerRow(await signerStore.get(walletSignerId({
3793
- chainIdKey,
3794
- accountAddress,
3795
- signerId
3796
- })));
3797
- if (existingSigner && existingSigner.profileId !== profileId) throw makeConstraintError("CHAIN_ACCOUNT_PROFILE_MISMATCH", `Signer row belongs to a different profile for ${chainIdKey}/${accountAddress}/${signerId}`, {
3798
- expectedProfileId: profileId,
3799
- existingProfileId: existingSigner.profileId
3800
- });
3801
- const activeSigners = (await signerStore.index(SEAMS_WALLET_INDEXES.status).getAll("active")).flatMap((row) => {
3802
- const parsed = parseAccountSignerRow(row);
3803
- return parsed && parsed.chainIdKey === chainIdKey && parsed.accountAddress === accountAddress ? [parsed] : [];
3804
- });
3805
- const now = Date.now();
3806
- const signer = this.buildAccountSignerRecord({
3807
- profileId,
3808
- chainIdKey,
3809
- accountAddress,
3810
- signerId,
3811
- signerSlot,
3812
- signerType: input.signer.signerType,
3813
- signerKind,
3814
- signerAuthMethod,
3815
- signerSource,
3816
- status: input.status,
3817
- existing: existingSigner || void 0,
3818
- now,
3819
- ...input.signer.metadata ? { metadata: input.signer.metadata } : {}
3820
- });
3821
- this.assertSignerWriteInvariants({
3822
- next: signer,
3823
- accountModel,
3824
- existingStatus: existingSigner?.status,
3825
- activeSigners
3826
- });
3827
- const signerRow = accountSignerRow(signer);
3828
- await deleteConflictingThresholdEcdsaSignerRows({
3829
- store: signerStore,
3830
- nextRow: signerRow
3831
- });
3832
- await signerStore.put(signerRow);
3833
- if (input.mutation?.routeThroughOutbox ?? false) {
3834
- const opId = normalizeTrimmedString(input.mutation?.opId || "") || createRandomToken("add-signer");
3835
- const idempotencyKey = normalizeTrimmedString(input.mutation?.idempotencyKey || "") || `add-signer:${signer.chainIdKey}:${signer.accountAddress}:${signer.signerId}:${signer.signerSlot}`;
3836
- await this.enqueueSignerOperationInTransaction(ctx.store(SEAMS_WALLET_STORES.signerOpsOutbox), {
3837
- opId,
3838
- idempotencyKey,
3839
- opType: "add-signer",
3840
- chainIdKey: signer.chainIdKey,
3841
- accountAddress: signer.accountAddress,
3842
- signerId: signer.signerId,
3843
- payload: this.signerOutboxPayload(signer, input.mutation),
3844
- status: input.mutation?.outboxStatus || "queued"
3845
- });
3846
- }
3847
- result = {
3848
- signer,
3849
- signerSlot
3850
- };
3851
- });
3852
- if (!result) throw new Error("[SeamsWalletDB] signer write did not complete");
3853
- return result;
3854
- }
3855
- signerOutboxPayload(signer, mutation) {
3856
- return {
3857
- profileId: signer.profileId,
3858
- signerSlot: signer.signerSlot,
3859
- signerType: signer.signerType,
3860
- signerKind: signer.signerKind,
3861
- signerAuthMethod: signer.signerAuthMethod,
3862
- signerSource: signer.signerSource,
3863
- ...signer.metadata ? { signerMetadata: signer.metadata } : {},
3864
- ...mutation?.outboxPayload ? mutation.outboxPayload : {}
3865
- };
3866
- }
3867
- async listAccountSigners(args) {
3868
- const chainIdKey = normalizeIndexedDbChainIdKey(args.chainIdKey);
3869
- const accountAddress = normalizeIndexedDbAccountAddress(args.accountAddress);
3870
- if (!chainIdKey || !accountAddress) return [];
3871
- const db = await this.manager.getDB();
3872
- return (args.status ? await db.transaction(SEAMS_WALLET_STORES.walletSigners, "readonly").store.index(SEAMS_WALLET_INDEXES.status).getAll(args.status) : await db.getAll(SEAMS_WALLET_STORES.walletSigners)).flatMap((row) => {
3873
- const parsed = parseAccountSignerRow(row);
3874
- return parsed && parsed.chainIdKey === chainIdKey && parsed.accountAddress === accountAddress ? [parsed] : [];
3875
- });
3876
- }
3877
- async listAccountSignersByProfile(args) {
3878
- const profileId = normalizeTrimmedString(args.profileId || "");
3879
- if (!profileId) return [];
3880
- return (await (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.walletSigners, "readonly").store.index(SEAMS_WALLET_INDEXES.walletId).getAll(profileId)).flatMap((row) => {
3881
- const parsed = parseAccountSignerRow(row);
3882
- return parsed && (!args.status || parsed.status === args.status) ? [parsed] : [];
3883
- });
3884
- }
3885
- /**
3886
- * The wallet's active signers, resolved from its identity — not from a guess
3887
- * that the wallet id is a profile key.
3888
- *
3889
- * Two local profile identities exist: the canonical wallet profile, keyed by
3890
- * the wallet id and carrying NEAR provisioning, and the NEAR account profile
3891
- * (`buildNearProfileId`), which owns the signer rows. Reading signer rows
3892
- * with the wallet id as the profile key answered "none" for every registered
3893
- * wallet, which surfaced far away as an unresolvable session identity and as
3894
- * ECDSA material reporting `device_link_required` on a device that was never
3895
- * linked.
3896
- *
3897
- * The pivot goes through branded constructors on purpose: only a NEAR
3898
- * account id proven by the wallet's own provisioning record can become the
3899
- * profile key. Rows written directly under the wallet id are still read —
3900
- * that is the canonical wallet profile's own signer set.
3901
- */
3902
- async listActiveWalletSigners(args) {
3903
- const walletId = normalizeTrimmedString(args.walletId || "");
3904
- if (!walletId) return [];
3905
- const signerKind = args.signerFamily === "ecdsa" ? SIGNER_KINDS.thresholdEcdsa : SIGNER_KINDS.thresholdEd25519;
3906
- const profileIds = [walletId];
3907
- const provisioning = (await this.getProfile(walletId))?.nearProvisioning;
3908
- if (provisioning?.status === "near_ready" && provisioning.nearAccountId) profileIds.push(String(buildNearProfileId(toAccountId(provisioning.nearAccountId))));
3909
- const collected = [];
3910
- const seen = /* @__PURE__ */ new Set();
3911
- for (const profileId of profileIds) {
3912
- const signers = await this.listAccountSignersByProfile({
3913
- profileId,
3914
- status: "active"
3915
- });
3916
- for (const signer of signers) {
3917
- if (signer.signerKind !== signerKind) continue;
3918
- const metadataWalletId = normalizeTrimmedString(String(signer.metadata?.walletId ?? ""));
3919
- if (metadataWalletId && metadataWalletId !== walletId) continue;
3920
- const key = `${signer.chainIdKey}/${signer.accountAddress}/${signer.signerId}`;
3921
- if (seen.has(key)) continue;
3922
- seen.add(key);
3923
- collected.push(signer);
3924
- }
3925
- }
3926
- return collected;
3927
- }
3928
- async getActiveWalletSignerForChainTarget(args) {
3929
- const walletId = normalizeTrimmedString(args.walletId || "");
3930
- if (!walletId) return null;
3931
- const chainTargetKey = toIndexedDbChainTargetKey(args.chainTarget);
3932
- const matches = (await this.listActiveWalletSigners({
3933
- walletId,
3934
- signerFamily: "ecdsa"
3935
- })).filter((signer) => signer.chainIdKey === chainTargetKey);
3936
- if (matches.length > 1) throw new Error(`[SeamsWalletDB] ambiguous active ECDSA wallet signer for ${walletId}/${chainTargetKey}`);
3937
- return matches[0] || null;
3938
- }
3939
- async getAccountSigner(args) {
3940
- const chainIdKey = normalizeIndexedDbChainIdKey(args.chainIdKey);
3941
- const accountAddress = normalizeIndexedDbAccountAddress(args.accountAddress);
3942
- const signerId = normalizeTrimmedString(args.signerId || "");
3943
- if (!chainIdKey || !accountAddress || !signerId) return null;
3944
- return parseAccountSignerRow(await (await this.manager.getDB()).get(SEAMS_WALLET_STORES.walletSigners, walletSignerId({
3945
- chainIdKey,
3946
- accountAddress,
3947
- signerId
3948
- })));
3949
- }
3950
- async setAccountSignerStatus(args) {
3951
- const existing = await this.getAccountSigner(args);
3952
- if (!existing) return null;
3953
- const chainAccount = await this.getChainAccount({
3954
- profileId: existing.profileId,
3955
- chainIdKey: existing.chainIdKey,
3956
- accountAddress: existing.accountAddress
3957
- });
3958
- if (!chainAccount) throw makeConstraintError("MISSING_CHAIN_ACCOUNT", `Cannot update signer status without chain account row: ${existing.profileId}/${existing.chainIdKey}/${existing.accountAddress}`, {
3959
- profileId: existing.profileId,
3960
- chainIdKey: existing.chainIdKey,
3961
- accountAddress: existing.accountAddress,
3962
- signerId: existing.signerId
3963
- });
3964
- let updated = null;
3965
- await this.manager.runTransaction([SEAMS_WALLET_STORES.walletSigners, SEAMS_WALLET_STORES.signerOpsOutbox], "readwrite", async (ctx) => {
3966
- const signerStore = ctx.store(SEAMS_WALLET_STORES.walletSigners);
3967
- const activeSigners = (await signerStore.index(SEAMS_WALLET_INDEXES.status).getAll("active")).flatMap((row) => {
3968
- const parsed = parseAccountSignerRow(row);
3969
- return parsed && parsed.chainIdKey === existing.chainIdKey && parsed.accountAddress === existing.accountAddress ? [parsed] : [];
3970
- });
3971
- const next = this.buildAccountSignerRecord({
3972
- ...existing,
3973
- status: args.status,
3974
- existing,
3975
- now: Date.now(),
3976
- ...args.removedAt != null ? { removedAt: args.removedAt } : {},
3977
- ...args.revocationReason ? { revocationReason: args.revocationReason } : {}
3978
- });
3979
- this.assertSignerWriteInvariants({
3980
- next,
3981
- accountModel: chainAccount.accountModel,
3982
- existingStatus: existing.status,
3983
- activeSigners
3984
- });
3985
- await signerStore.put(accountSignerRow(next));
3986
- if (args.mutation?.routeThroughOutbox ?? true) {
3987
- const opType = args.status === "revoked" ? "revoke-signer" : "add-signer";
3988
- const opId = normalizeTrimmedString(args.mutation?.opId || "") || createRandomToken(opType);
3989
- const idempotencyKey = normalizeTrimmedString(args.mutation?.idempotencyKey || "") || `signer-status:${args.status}:${next.chainIdKey}:${next.accountAddress}:${next.signerId}`;
3990
- await this.enqueueSignerOperationInTransaction(ctx.store(SEAMS_WALLET_STORES.signerOpsOutbox), {
3991
- opId,
3992
- idempotencyKey,
3993
- opType,
3994
- chainIdKey: next.chainIdKey,
3995
- accountAddress: next.accountAddress,
3996
- signerId: next.signerId,
3997
- payload: {
3998
- profileId: next.profileId,
3999
- signerSlot: next.signerSlot,
4000
- status: next.status,
4001
- ...next.removedAt != null ? { removedAt: next.removedAt } : {},
4002
- ...next.revocationReason ? { revocationReason: next.revocationReason } : {},
4003
- ...args.mutation?.outboxPayload ? args.mutation.outboxPayload : {}
4004
- },
4005
- status: args.mutation?.outboxStatus || "queued"
4006
- });
4007
- }
4008
- updated = next;
4009
- });
4010
- return updated;
4011
- }
4012
- async enqueueSignerOperation(input) {
4013
- let record = null;
4014
- await this.manager.runTransaction([SEAMS_WALLET_STORES.signerOpsOutbox], "readwrite", async (ctx) => {
4015
- record = await this.enqueueSignerOperationInTransaction(ctx.store(SEAMS_WALLET_STORES.signerOpsOutbox), input);
4016
- });
4017
- if (!record) throw new Error("[SeamsWalletDB] signer op enqueue did not complete");
4018
- return record;
4019
- }
4020
- async listSignerOperations(args) {
4021
- const statuses = args?.statuses && args.statuses.length > 0 ? args.statuses : [
4022
- "queued",
4023
- "submitted",
4024
- "failed"
4025
- ];
4026
- const dueBeforeRaw = typeof args?.dueBefore === "number" ? args.dueBefore : Date.now();
4027
- const dueBefore = Number.isFinite(dueBeforeRaw) ? dueBeforeRaw : Number.MAX_SAFE_INTEGER;
4028
- const limit = Number.isSafeInteger(args?.limit) && Number(args?.limit) > 0 ? Number(args?.limit) : 100;
4029
- const db = await this.manager.getDB();
4030
- const collected = [];
4031
- for (const status of statuses) {
4032
- const tx = db.transaction(SEAMS_WALLET_STORES.signerOpsOutbox, "readonly");
4033
- const rows = await tx.store.index(SEAMS_WALLET_INDEXES.statusNextAttemptAt).getAll(IDBKeyRange.bound([status, Number.MIN_SAFE_INTEGER], [status, dueBefore]));
4034
- await tx.done;
4035
- collected.push(...(rows || []).flatMap((row) => {
4036
- const parsed = parseSignerOutboxRow(row);
4037
- return parsed ? [parsed] : [];
4038
- }));
4039
- }
4040
- collected.sort((a, b) => {
4041
- const timeDelta = (a.nextAttemptAt || 0) - (b.nextAttemptAt || 0);
4042
- if (timeDelta !== 0) return timeDelta;
4043
- return String(a.opId || "").localeCompare(String(b.opId || ""));
4044
- });
4045
- return collected.slice(0, limit);
4046
- }
4047
- async setSignerOperationStatus(args) {
4048
- const opId = normalizeTrimmedString(args.opId || "");
4049
- if (!opId) return null;
4050
- let updated = null;
4051
- await this.manager.runTransaction([SEAMS_WALLET_STORES.signerOpsOutbox], "readwrite", async (ctx) => {
4052
- const store = ctx.store(SEAMS_WALLET_STORES.signerOpsOutbox);
4053
- const existing = parseSignerOutboxRow(await store.get(opId));
4054
- if (!existing) return;
4055
- const attemptDelta = Number.isFinite(args.attemptDelta) ? Number(args.attemptDelta) : 0;
4056
- const attemptCount = Math.max(0, (existing.attemptCount || 0) + attemptDelta);
4057
- const next = {
4058
- ...existing,
4059
- status: args.status,
4060
- attemptCount,
4061
- nextAttemptAt: typeof args.nextAttemptAt === "number" ? args.nextAttemptAt : existing.nextAttemptAt,
4062
- ...args.lastError === null ? { lastError: void 0 } : typeof args.lastError === "string" ? { lastError: args.lastError } : { lastError: existing.lastError },
4063
- ...args.txHash === null ? { txHash: void 0 } : typeof args.txHash === "string" ? { txHash: args.txHash } : { txHash: existing.txHash },
4064
- updatedAt: Date.now()
4065
- };
4066
- await store.put(signerOutboxRow(next));
4067
- updated = next;
4068
- });
4069
- return updated;
4070
- }
4071
- async getProfileContinuitySnapshot(profileId) {
4072
- const profile = await this.getProfile(profileId);
4073
- if (!profile) return null;
4074
- return {
4075
- profile,
4076
- chainAccounts: await this.listChainAccountsByProfile(profile.profileId),
4077
- accountSigners: await this.listAccountSignersByProfile({ profileId: profile.profileId })
4078
- };
4079
- }
4080
- async listProfileAuthenticators(profileId) {
4081
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
4082
- if (!normalizedProfileId) return [];
4083
- const tx = (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.walletAuthMethods, "readonly");
4084
- const rows = await tx.store.index(SEAMS_WALLET_INDEXES.walletIdKind).getAll([normalizedProfileId, "passkey"]);
4085
- await tx.done;
4086
- return rows.flatMap((row) => {
4087
- const parsed = parseAuthenticatorRow(row);
4088
- return parsed ? [parsed] : [];
4089
- });
4090
- }
4091
- async listWalletPasskeyAuthenticators(walletId) {
4092
- const own = await this.listProfileAuthenticators(walletId);
4093
- const provisioning = (await this.getProfile(walletId))?.nearProvisioning;
4094
- if (provisioning?.status !== "near_ready" || !provisioning.nearAccountId) return own;
4095
- const nearProfileId = String(buildNearProfileId(toAccountId(provisioning.nearAccountId)));
4096
- if (nearProfileId === walletId) return own;
4097
- const nearRows = await this.listProfileAuthenticators(nearProfileId);
4098
- const seen = new Set(own.map((record) => record.credentialId));
4099
- return [...own, ...nearRows.filter((record) => !seen.has(record.credentialId))];
4100
- }
4101
- async getWalletPasskeyAuthenticator(args) {
4102
- const credentialId = normalizeTrimmedString(args.credentialId || "");
4103
- if (!credentialId) return null;
4104
- return (await this.listWalletPasskeyAuthenticators(args.walletId)).find((record) => record.credentialId === credentialId) ?? null;
4105
- }
4106
- async upsertProfileAuthenticator(record) {
4107
- const normalized = normalizeAuthenticatorRecord(record);
4108
- await this.manager.runTransaction([SEAMS_WALLET_STORES.wallets, SEAMS_WALLET_STORES.walletAuthMethods], "readwrite", async (ctx) => {
4109
- if (!parseProfileRow(await ctx.store(SEAMS_WALLET_STORES.wallets).get(normalized.profileId))) throw makeConstraintError("MISSING_PROFILE", `Cannot upsert authenticator for unknown profile: ${normalized.profileId}`, {
4110
- profileId: normalized.profileId,
4111
- credentialId: normalized.credentialId
4112
- });
4113
- const store = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
4114
- const existing = parseWalletAuthMethodStorageRow(await store.index(SEAMS_WALLET_INDEXES.passkeyRpIdCredentialId).get([
4115
- "passkey",
4116
- DEFAULT_WALLET_RP_ID,
4117
- normalized.credentialId
4118
- ]));
4119
- const row = walletAuthMethodRowFromAuthenticator(normalized, existing?.kind === "passkey" ? existing : void 0);
4120
- await store.put(row);
4121
- });
4122
- }
4123
- async getProfileAuthenticatorByCredentialId(profileId, credentialId) {
4124
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
4125
- const normalizedCredentialId = normalizeTrimmedString(credentialId || "");
4126
- if (!normalizedProfileId || !normalizedCredentialId) return null;
4127
- const row = parseAuthenticatorRow(await (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.walletAuthMethods, "readonly").store.index(SEAMS_WALLET_INDEXES.passkeyRpIdCredentialId).get([
4128
- "passkey",
4129
- DEFAULT_WALLET_RP_ID,
4130
- normalizedCredentialId
4131
- ]));
4132
- return row?.profileId === normalizedProfileId ? row : null;
4133
- }
4134
- async persistWalletRegistrationFinalize(input) {
4135
- return this.manager.runTransaction(WALLET_REGISTRATION_FINALIZE_STORES, "readwrite", this.persistWalletRegistrationFinalizeInTransaction.bind(this, input));
4136
- }
4137
- async publishPendingWalletRegistrationCommit(input) {
4138
- return await this.publishPendingWalletRegistrationCommitWithDisposition(input, true);
4139
- }
4140
- async publishPendingWalletRegistrationCommitAndRetain(input) {
4141
- return await this.publishPendingWalletRegistrationCommitWithDisposition(input, false);
4142
- }
4143
- async publishPendingWalletRegistrationCommitWithDisposition(input, deletePending) {
4144
- const pending = buildPendingWalletRegistrationCommitV1(input.pending);
4145
- const authority = parseWalletAuthAuthority(input.authority);
4146
- if (!authority) throw new Error("registration wallet auth authority is invalid");
4147
- const foundingAuthority = validateFoundingWalletAuthorityInput(input.foundingAuthority);
4148
- await assertRegistrationFinalizeMatchesPending({
4149
- request: input.request,
4150
- pending,
4151
- authority,
4152
- foundingAuthority,
4153
- registration: input.registration
4154
- });
4155
- const walletSession = input.walletSessionPublication.walletSession;
4156
- if (walletSession.walletId !== pending.walletId || walletSession.authorityId !== foundingAuthority.authority.authorityId || walletSession.authMethodId !== pending.walletAuthMethodId || walletSession.authorityDigestB64u !== foundingAuthority.authority.authorityDigestB64u || walletSession.authorityRevocationEpoch !== foundingAuthority.authority.revocationEpoch) throw new Error("registration Wallet Session identity does not match the pending wallet");
4157
- return this.manager.runTransaction(WALLET_REGISTRATION_PUBLICATION_STORES, "readwrite", this.publishPendingWalletRegistrationCommitInTransaction.bind(this, {
4158
- request: input.request,
4159
- pending,
4160
- authority,
4161
- foundingAuthority,
4162
- registration: input.registration,
4163
- ecdsaContinuity: input.ecdsaContinuity,
4164
- walletSessionPublication: input.walletSessionPublication,
4165
- deletePending
4166
- }));
4167
- }
4168
- async publishPendingWalletRecoveryCommit(input) {
4169
- const pending = await buildPendingWalletRecoveryCommitV1(input.pending);
4170
- if (pending.stage !== "server_promoted") throw new Error("pending wallet recovery commit is not server-promoted");
4171
- const authority = requireBoundaryParsed(parseWalletAuthorityV1(input.authority), "authority");
4172
- if (authority.state !== "active" || !isActiveRecoveredWalletAuthorityV1(authority)) throw new Error("recovered Wallet Authority projection is invalid");
4173
- const authMethod = parseWalletAuthMethodRecordV2(input.authMethod);
4174
- if (!authMethod || authMethod.status !== "active") throw new Error("recovered Wallet Auth Method projection is invalid");
4175
- if (!await walletAuthorityDigestsMatchV1(authority)) throw new Error("recovered Wallet Authority digest is invalid");
4176
- const normalizedInput = {
4177
- pending,
4178
- authority,
4179
- authMethod,
4180
- registration: input.registration,
4181
- ecdsaContinuity: input.ecdsaContinuity,
4182
- ed25519PublicCapabilityReferences: input.ed25519PublicCapabilityReferences
4183
- };
4184
- assertPendingWalletRecoveryPublicationMatchesProjection(normalizedInput);
4185
- const pendingRow = await toPendingWalletRecoveryCommitAppStateRow(pending);
4186
- return this.manager.runTransaction(WALLET_RECOVERY_PUBLICATION_STORES, "readwrite", this.publishPendingWalletRecoveryCommitInTransaction.bind(this, {
4187
- ...normalizedInput,
4188
- pendingRow
4189
- }));
4190
- }
4191
- async publishPendingWalletRegistrationCommitInTransaction(input, ctx) {
4192
- const pendingKey = pendingWalletRegistrationCommitAppStateKey({
4193
- registrationCeremonyId: input.request.registrationCeremonyId,
4194
- operation: input.request.operation
4195
- });
4196
- const storedPendingRow = parsePendingWalletRegistrationCommitAppStateRow(await ctx.store(SEAMS_WALLET_STORES.appState).get(pendingKey));
4197
- const storedPending = storedPendingRow?.record;
4198
- if (storedPending) assertPendingWalletRegistrationRequestIdentity(storedPending, input.request);
4199
- if (!storedPendingRow || !storedPending || storedPendingRow?.registration_ceremony_id !== input.request.registrationCeremonyId || storedPendingRow.operation !== input.request.operation || storedPendingRow.wallet_id !== input.request.walletId || storedPendingRow.wallet_auth_method_id !== input.request.walletAuthMethodId || storedPendingRow.updated_at_ms !== input.pending.updatedAtMs || storedPending.idempotencyKey !== input.pending.idempotencyKey || storedPending.signerPlanKind !== input.pending.signerPlanKind) throw new Error("stored pending wallet registration commit does not match the expected row");
4200
- let credentialFreeSessionReconciled = false;
4201
- if (input.walletSessionPublication.kind === "issued") await replaceExactActiveWalletSessionAuthorizationInTransaction({
4202
- ctx,
4203
- active: input.walletSessionPublication.walletSession,
4204
- operationCredential: input.walletSessionPublication.operationCredential
4205
- });
4206
- else {
4207
- const existingSession = await readExactActiveWalletSessionForScopeInTransaction({
4208
- ctx,
4209
- walletId: input.pending.walletId,
4210
- authorityId: input.foundingAuthority.authority.authorityId,
4211
- authMethodId: input.pending.walletAuthMethodId
4212
- });
4213
- if (existingSession.kind !== "found") throw new Error("Credential-free registration projection has no exact local Wallet Session");
4214
- assertCredentialFreeRegistrationSessionProjectionMatchesExisting({
4215
- incoming: input.walletSessionPublication.walletSession,
4216
- existing: existingSession.record
4217
- });
4218
- await replaceExactActiveWalletSessionAuthorizationInTransaction({
4219
- ctx,
4220
- active: input.walletSessionPublication.walletSession,
4221
- operationCredential: existingSession.operationCredential
4222
- });
4223
- credentialFreeSessionReconciled = true;
4224
- }
4225
- const result = await this.persistWalletRegistrationFinalizeInTransaction(input.registration, ctx);
4226
- await this.persistFoundingWalletAuthorityInTransaction(input.foundingAuthority, input.walletSessionPublication.kind === "credential_free_projection" ? "preserve" : "activate", ctx);
4227
- for (const continuity of input.ecdsaContinuity) await persistPreparedImportedWalletCustodyEcdsaContinuityInTransaction(ctx, continuity);
4228
- if (input.deletePending && (input.walletSessionPublication.kind === "issued" ? shouldDeletePublishedPendingWalletRegistrationCommit(input.pending) : credentialFreeSessionReconciled)) await ctx.store(SEAMS_WALLET_STORES.appState).delete(pendingKey);
4229
- return result;
4230
- }
4231
- async publishPendingWalletRecoveryCommitInTransaction(input, ctx) {
4232
- if (!pendingWalletRecoveryCommitAppStateRowsMatch(await ctx.store(SEAMS_WALLET_STORES.appState).get(input.pendingRow.key), input.pendingRow)) throw new Error("stored pending wallet recovery commit does not match the expected row");
4233
- const result = await this.persistWalletRegistrationFinalizeInTransaction(input.registration, ctx);
4234
- await this.persistRecoveredWalletAuthorityInTransaction({
4235
- authority: input.authority,
4236
- authMethod: input.authMethod,
4237
- recoveredAtMs: input.pending.updatedAtMs
4238
- }, ctx);
4239
- await deleteRowsByIndex({
4240
- store: ctx.store(SEAMS_WALLET_STORES.ecdsaClientPresignatures),
4241
- indexName: SEAMS_WALLET_INDEXES.walletId,
4242
- key: IDBKeyRange.only(String(input.authority.walletId))
4243
- });
4244
- for (const continuity of input.ecdsaContinuity) await persistPreparedImportedWalletCustodyEcdsaContinuityInTransaction(ctx, continuity);
4245
- const appStateStore = ctx.store(SEAMS_WALLET_STORES.appState);
4246
- for (const reference of input.ed25519PublicCapabilityReferences) await upsertEd25519YaoPublicCapabilityReferenceInTransaction(appStateStore, reference);
4247
- await ctx.store(SEAMS_WALLET_STORES.appState).delete(input.pendingRow.key);
4248
- return result;
4249
- }
4250
- async persistWalletRegistrationFinalizeInTransaction(input, ctx) {
4251
- const authMethodRows = walletAuthMethodRowsForRegistrationFinalize(input);
4252
- const keyMaterialRows = input.keyMaterials.map((keyMaterial) => keyMaterialRow(keyMaterial));
4253
- const signerActivations = [];
4254
- const profileStore = ctx.store(SEAMS_WALLET_STORES.wallets);
4255
- for (const profile of input.profiles) {
4256
- const profileId = normalizeTrimmedString(profile.profileId || "");
4257
- if (!profileId) throw new Error("[SeamsWalletDB] profileId is required");
4258
- const existing = parseProfileRow(await profileStore.get(profileId)) || void 0;
4259
- await profileStore.put(profileRow(profile, existing));
4260
- }
4261
- const authMethodStore = ctx.store(SEAMS_WALLET_STORES.walletAuthMethods);
4262
- for (const row of authMethodRows) {
4263
- if (!parseProfileRow(await profileStore.get(row.wallet_id))) throw makeConstraintError("MISSING_PROFILE", `Cannot upsert auth method for unknown wallet: ${row.wallet_id}`, {
4264
- profileId: row.wallet_id,
4265
- authIdentifierKey: row.auth_identifier_key
4266
- });
4267
- await authMethodStore.put(row);
4268
- }
4269
- for (const activation of input.signerActivations) signerActivations.push(await this.activateAccountSignerInTransaction(ctx, activation));
4270
- await assertSignerKeyMaterialPairsInTransaction({
4271
- ctx,
4272
- signers: signerActivations.map((activation) => activation.signer),
4273
- keyMaterials: input.keyMaterials
4274
- });
4275
- const keyMaterialStore = ctx.store(SEAMS_WALLET_STORES.keyMaterial);
4276
- for (const row of keyMaterialRows) await keyMaterialStore.put(row);
4277
- if (input.lastProfileState) await ctx.store(SEAMS_WALLET_STORES.appState).put({
4278
- key: scopedLastProfileStateAppStateKey(input.lastProfileState.scope),
4279
- value: {
4280
- profileId: input.lastProfileState.profileId,
4281
- activeSignerSlot: input.lastProfileState.activeSignerSlot,
4282
- ...input.lastProfileState.scope ? { scope: normalizeLastUserScope(input.lastProfileState.scope) } : {}
4283
- }
4284
- });
4285
- return { signerActivations };
4286
- }
4287
- async persistWalletSignerFinalize(input) {
4288
- const keyMaterialRows = input.keyMaterials.map((keyMaterial) => keyMaterialRow(keyMaterial));
4289
- const signerActivations = [];
4290
- const profiles = [];
4291
- let lastProfileState = null;
4292
- await this.manager.runTransaction([
4293
- SEAMS_WALLET_STORES.appState,
4294
- SEAMS_WALLET_STORES.wallets,
4295
- SEAMS_WALLET_STORES.walletSigners,
4296
- SEAMS_WALLET_STORES.nearAccountProjections,
4297
- SEAMS_WALLET_STORES.signerOpsOutbox,
4298
- SEAMS_WALLET_STORES.keyMaterial
4299
- ], "readwrite", async (ctx) => {
4300
- const profileStore = ctx.store(SEAMS_WALLET_STORES.wallets);
4301
- if (input.lastProfileState) {
4302
- const appStateStore = ctx.store(SEAMS_WALLET_STORES.appState);
4303
- const key = scopedLastProfileStateAppStateKey(input.lastProfileState.scope);
4304
- const previousRow = parseAppStateRow(await appStateStore.get(key));
4305
- lastProfileState = {
4306
- key,
4307
- committed: {
4308
- profileId: input.lastProfileState.profileId,
4309
- activeSignerSlot: input.lastProfileState.activeSignerSlot,
4310
- ...input.lastProfileState.scope ? { scope: normalizeLastUserScope(input.lastProfileState.scope) } : {}
4311
- },
4312
- previousPresent: previousRow !== null,
4313
- previousValue: previousRow?.value
4314
- };
4315
- }
4316
- for (const profile of input.profiles) {
4317
- const profileId = normalizeTrimmedString(profile.profileId || "");
4318
- if (!profileId) throw new Error("[SeamsWalletDB] profileId is required");
4319
- const existing = parseProfileRow(await profileStore.get(profileId));
4320
- const committedRow = profileRow(profile, existing || void 0);
4321
- await profileStore.put(committedRow);
4322
- profiles.push({
4323
- committed: committedRow.record,
4324
- previous: existing
4325
- });
4326
- }
4327
- for (const activation of input.signerActivations) signerActivations.push(await this.activateAccountSignerInTransaction(ctx, activation));
4328
- await assertSignerKeyMaterialPairsInTransaction({
4329
- ctx,
4330
- signers: signerActivations.map((activation) => activation.signer),
4331
- keyMaterials: input.keyMaterials
4332
- });
4333
- const keyMaterialStore = ctx.store(SEAMS_WALLET_STORES.keyMaterial);
4334
- for (const row of keyMaterialRows) await keyMaterialStore.put(row);
4335
- if (input.lastProfileState) {
4336
- const appStateStore = ctx.store(SEAMS_WALLET_STORES.appState);
4337
- if (!lastProfileState) throw new Error("[SeamsWalletDB] last profile rollback state was not captured");
4338
- await appStateStore.put({
4339
- key: lastProfileState.key,
4340
- value: lastProfileState.committed
4341
- });
4342
- }
4343
- });
4344
- return {
4345
- signerActivations,
4346
- rollbackReceipt: {
4347
- kind: "wallet_signer_finalize_rollback_v1",
4348
- profiles,
4349
- signers: signerActivations.map((activation) => ({
4350
- committed: activation.signer,
4351
- metadataBaseline: accountSignerRollbackMetadataBaseline(activation.signer.metadata)
4352
- })),
4353
- keyMaterials: keyMaterialRows.map((row) => ({
4354
- committed: row.record,
4355
- payloadBaseline: keyMaterialRollbackPayloadBaseline(row.record.payload)
4356
- })),
4357
- lastProfileState
4358
- }
4359
- };
4360
- }
4361
- async rollbackWalletSignerFinalize(receipt) {
4362
- if (receipt.kind !== "wallet_signer_finalize_rollback_v1") throw new Error("[SeamsWalletDB] invalid wallet signer rollback receipt");
4363
- await this.manager.runTransaction([
4364
- SEAMS_WALLET_STORES.appState,
4365
- SEAMS_WALLET_STORES.wallets,
4366
- SEAMS_WALLET_STORES.walletSigners,
4367
- SEAMS_WALLET_STORES.keyMaterial
4368
- ], "readwrite", async (ctx) => {
4369
- const profileStore = ctx.store(SEAMS_WALLET_STORES.wallets);
4370
- const signerStore = ctx.store(SEAMS_WALLET_STORES.walletSigners);
4371
- const keyMaterialStore = ctx.store(SEAMS_WALLET_STORES.keyMaterial);
4372
- const appStateStore = ctx.store(SEAMS_WALLET_STORES.appState);
4373
- for (const profile of receipt.profiles) {
4374
- const current = parseProfileRow(await profileStore.get(profile.committed.profileId));
4375
- if (current === null || !profileRecordsMatch(current, profile.committed)) throw new Error("[SeamsWalletDB] wallet signer rollback profile changed");
4376
- }
4377
- for (const signerEntry of receipt.signers) {
4378
- const signer = signerEntry.committed;
4379
- const id = walletSignerId({
4380
- chainIdKey: signer.chainIdKey,
4381
- accountAddress: signer.accountAddress,
4382
- signerId: signer.signerId
4383
- });
4384
- const current = parseAccountSignerRow(await signerStore.get(id));
4385
- if (current === null || !accountSignerRollbackRecordsMatch(current, signer, signerEntry.metadataBaseline)) throw new Error("[SeamsWalletDB] wallet signer rollback signer changed");
4386
- }
4387
- for (const keyMaterialEntry of receipt.keyMaterials) {
4388
- const keyMaterial = keyMaterialEntry.committed;
4389
- const id = keyMaterialId({
4390
- walletSignerId: walletSignerIdForKeyMaterial(keyMaterial),
4391
- keyKind: keyMaterial.keyKind
4392
- });
4393
- const current = parseKeyMaterialRow(await keyMaterialStore.get(id));
4394
- if (current === null || !keyMaterialRollbackRecordsMatch(current, keyMaterial, keyMaterialEntry.payloadBaseline)) throw new Error("[SeamsWalletDB] wallet signer rollback key material changed");
4395
- }
4396
- if (receipt.lastProfileState) {
4397
- const current = parseLastProfileState(parseAppStateRow(await appStateStore.get(receipt.lastProfileState.key))?.value);
4398
- if (current === null || !lastProfileStatesMatch(current, receipt.lastProfileState.committed)) throw new Error("[SeamsWalletDB] wallet signer rollback selection changed");
4399
- }
4400
- for (const signerEntry of receipt.signers) {
4401
- const signer = signerEntry.committed;
4402
- await signerStore.delete(walletSignerId({
4403
- chainIdKey: signer.chainIdKey,
4404
- accountAddress: signer.accountAddress,
4405
- signerId: signer.signerId
4406
- }));
4407
- }
4408
- for (const keyMaterialEntry of receipt.keyMaterials) {
4409
- const keyMaterial = keyMaterialEntry.committed;
4410
- await keyMaterialStore.delete(keyMaterialId({
4411
- walletSignerId: walletSignerIdForKeyMaterial(keyMaterial),
4412
- keyKind: keyMaterial.keyKind
4413
- }));
4414
- }
4415
- for (const profile of receipt.profiles) if (profile.previous) await profileStore.put(profileRowFromRecord(profile.previous));
4416
- else await profileStore.delete(profile.committed.profileId);
4417
- if (receipt.lastProfileState) if (receipt.lastProfileState.previousPresent) await appStateStore.put({
4418
- key: receipt.lastProfileState.key,
4419
- value: receipt.lastProfileState.previousValue
4420
- });
4421
- else await appStateStore.delete(receipt.lastProfileState.key);
4422
- });
4423
- }
4424
- async clearProfileAuthenticators(profileId) {
4425
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
4426
- if (!normalizedProfileId) return;
4427
- await this.manager.runTransaction([SEAMS_WALLET_STORES.walletAuthMethods], "readwrite", async (ctx) => {
4428
- let cursor = await ctx.store(SEAMS_WALLET_STORES.walletAuthMethods).index(SEAMS_WALLET_INDEXES.walletIdKind).openCursor(IDBKeyRange.only([normalizedProfileId, "passkey"]));
4429
- while (cursor) {
4430
- await cursor.delete();
4431
- cursor = await cursor.continue();
4432
- }
4433
- });
4434
- }
4435
- async selectProfileAuthenticatorsForPrompt(args) {
4436
- const profileId = normalizeTrimmedString(args.profileId || "");
4437
- const authenticators = Array.isArray(args.authenticators) ? args.authenticators : [];
4438
- if (!profileId || authenticators.length <= 1) return { authenticatorsForPrompt: authenticators };
4439
- const lastProfileState = await this.getLastProfileState().catch(() => null);
4440
- if (!lastProfileState) return { authenticatorsForPrompt: authenticators };
4441
- const expectedSignerSlot = Number(lastProfileState.activeSignerSlot);
4442
- const bySignerSlot = authenticators.filter((authenticator) => {
4443
- return authenticator.signerSlot === expectedSignerSlot;
4444
- });
4445
- const expectedCredentialId = normalizeTrimmedString(bySignerSlot[0]?.credentialId || authenticators[0]?.credentialId || "");
4446
- const byCredentialId = expectedCredentialId ? authenticators.filter((authenticator) => authenticator.credentialId === expectedCredentialId) : [];
4447
- const authenticatorsForPrompt = byCredentialId.length > 0 ? byCredentialId : bySignerSlot.length > 0 ? bySignerSlot : authenticators;
4448
- const selectedCredentialRawId = normalizeTrimmedString(args.selectedCredentialRawId || "");
4449
- const accountLabel = normalizeTrimmedString(args.accountLabel || profileId);
4450
- return {
4451
- authenticatorsForPrompt,
4452
- wrongPasskeyError: selectedCredentialRawId && expectedCredentialId && selectedCredentialRawId !== expectedCredentialId ? `You have multiple passkeys for account ${accountLabel}, but used a different passkey than the most recently logged-in one. Please use the passkey for the most recently active signer.` : void 0
4453
- };
4454
- }
4455
- async updatePreferences(args) {
4456
- const profileId = normalizeTrimmedString(args.profileId || "");
4457
- if (!profileId) return null;
4458
- let updatedPreferences = null;
4459
- await this.manager.runTransaction([SEAMS_WALLET_STORES.wallets], "readwrite", async (ctx) => {
4460
- const store = ctx.store(SEAMS_WALLET_STORES.wallets);
4461
- const profile = parseProfileRow(await store.get(profileId));
4462
- if (!profile) return;
4463
- updatedPreferences = {
4464
- ...profile.preferences || {},
4465
- ...args.preferences
4466
- };
4467
- const next = profileRow({
4468
- profileId: profile.profileId,
4469
- defaultSignerSlot: profile.defaultSignerSlot,
4470
- preferences: updatedPreferences,
4471
- ...profile.passkeyCredential ? { passkeyCredential: profile.passkeyCredential } : {}
4472
- }, profile);
4473
- await store.put(next);
4474
- });
4475
- return updatedPreferences;
4476
- }
4477
- async updateWalletPreferences(args) {
4478
- const walletId = normalizeTrimmedString(args.walletId || "");
4479
- if (!walletId) return null;
4480
- return await this.updatePreferences({
4481
- profileId: walletId,
4482
- preferences: args.preferences
4483
- });
4484
- }
4485
- async deleteProfileData(profileId, scope) {
4486
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
4487
- if (!normalizedProfileId) return;
4488
- await this.manager.runTransaction([
4489
- SEAMS_WALLET_STORES.appState,
4490
- SEAMS_WALLET_STORES.wallets,
4491
- SEAMS_WALLET_STORES.walletAuthMethods,
4492
- SEAMS_WALLET_STORES.walletSigners,
4493
- SEAMS_WALLET_STORES.nearAccountProjections,
4494
- SEAMS_WALLET_STORES.signerOpsOutbox,
4495
- SEAMS_WALLET_STORES.keyMaterial,
4496
- SEAMS_WALLET_STORES.ecdsaClientPresignatures
4497
- ], "readwrite", async (ctx) => {
4498
- const appStateStore = ctx.store(SEAMS_WALLET_STORES.appState);
4499
- if (parseLastProfileState((await appStateStore.get(scopedLastProfileStateAppStateKey()))?.value)?.profileId === normalizedProfileId) await appStateStore.put({
4500
- key: scopedLastProfileStateAppStateKey(),
4501
- value: null
4502
- });
4503
- const scopedKey = scopedLastProfileStateAppStateKey(scope);
4504
- if (scopedKey !== scopedLastProfileStateAppStateKey()) {
4505
- if (parseLastProfileState((await appStateStore.get(scopedKey))?.value)?.profileId === normalizedProfileId) await appStateStore.put({
4506
- key: scopedKey,
4507
- value: null
4508
- });
4509
- }
4510
- await ctx.store(SEAMS_WALLET_STORES.wallets).delete(normalizedProfileId);
4511
- await deleteRowsByIndex({
4512
- store: ctx.store(SEAMS_WALLET_STORES.walletAuthMethods),
4513
- indexName: SEAMS_WALLET_INDEXES.walletId,
4514
- key: IDBKeyRange.only(normalizedProfileId)
4515
- });
4516
- await deleteRowsByIndex({
4517
- store: ctx.store(SEAMS_WALLET_STORES.walletSigners),
4518
- indexName: SEAMS_WALLET_INDEXES.walletId,
4519
- key: IDBKeyRange.only(normalizedProfileId)
4520
- });
4521
- await deleteRowsByIndex({
4522
- store: ctx.store(SEAMS_WALLET_STORES.nearAccountProjections),
4523
- indexName: SEAMS_WALLET_INDEXES.profileId,
4524
- key: IDBKeyRange.only(normalizedProfileId)
4525
- });
4526
- await deleteRowsByIndex({
4527
- store: ctx.store(SEAMS_WALLET_STORES.signerOpsOutbox),
4528
- indexName: SEAMS_WALLET_INDEXES.walletId,
4529
- key: IDBKeyRange.only(normalizedProfileId)
4530
- });
4531
- await deleteRowsByIndex({
4532
- store: ctx.store(SEAMS_WALLET_STORES.keyMaterial),
4533
- indexName: SEAMS_WALLET_INDEXES.walletId,
4534
- key: IDBKeyRange.only(normalizedProfileId)
4535
- });
4536
- await deleteRowsByIndex({
4537
- store: ctx.store(SEAMS_WALLET_STORES.ecdsaClientPresignatures),
4538
- indexName: SEAMS_WALLET_INDEXES.walletId,
4539
- key: IDBKeyRange.only(normalizedProfileId)
4540
- });
4541
- });
4542
- }
4543
- async getLastProfileState(scope) {
4544
- const key = scopedLastProfileStateAppStateKey(scope);
4545
- return parseLastProfileState(await this.getAppState(key).catch(() => void 0));
4546
- }
4547
- async setLastProfileState(state, scope) {
4548
- const key = scopedLastProfileStateAppStateKey(scope);
4549
- const normalizedState = state ? parseLastProfileState(state) : null;
4550
- if (state && !normalizedState) throw new Error("[SeamsWalletDB] invalid last profile state");
4551
- await this.setAppState(key, normalizedState);
4552
- }
4553
- async setLastProfileStateForProfile(profileId, activeSignerSlot, scope) {
4554
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
4555
- const normalizedActiveSignerSlot = Number(activeSignerSlot);
4556
- if (!normalizedProfileId) throw new Error("[SeamsWalletDB] profileId is required");
4557
- if (!Number.isSafeInteger(normalizedActiveSignerSlot) || normalizedActiveSignerSlot < 1) throw new Error("[SeamsWalletDB] activeSignerSlot must be an integer >= 1");
4558
- const normalizedScope = normalizeLastUserScope(scope);
4559
- await this.setLastProfileState({
4560
- profileId: normalizedProfileId,
4561
- activeSignerSlot: normalizedActiveSignerSlot,
4562
- ...normalizedScope ? { scope: normalizedScope } : {}
4563
- }, normalizedScope);
4564
- }
4565
- async clearLastProfileSelection(scope) {
4566
- await this.setLastProfileState(null, scope);
4567
- }
4568
- async storeKeyMaterial(data) {
4569
- const row = keyMaterialRow(data);
4570
- await this.manager.runTransaction([SEAMS_WALLET_STORES.keyMaterial], "readwrite", async (ctx) => {
4571
- await ctx.store(SEAMS_WALLET_STORES.keyMaterial).put(row);
4572
- });
4573
- }
4574
- async getKeyMaterial(profileId, signerSlot, chainIdKey, keyKind) {
4575
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
4576
- const normalizedChainIdKey = normalizeTrimmedString(chainIdKey || "").toLowerCase();
4577
- const normalizedKeyKind = normalizeTrimmedString(keyKind || "");
4578
- if (!normalizedProfileId || !normalizedChainIdKey || !normalizedKeyKind) return null;
4579
- let selected = null;
4580
- await this.manager.runTransaction([SEAMS_WALLET_STORES.keyMaterial, SEAMS_WALLET_STORES.walletSigners], "readonly", async (ctx) => {
4581
- const matches = (await ctx.store(SEAMS_WALLET_STORES.keyMaterial).index(SEAMS_WALLET_INDEXES.walletId).getAll(normalizedProfileId)).flatMap((row) => {
4582
- const parsed = parseKeyMaterialRow(row);
4583
- return parsed && parsed.signerSlot === signerSlot && parsed.chainIdKey === normalizedChainIdKey && parsed.keyKind === normalizedKeyKind ? [parsed] : [];
4584
- });
4585
- if (matches.length === 0) {
4586
- selected = null;
4587
- return;
4588
- }
4589
- selected = selectKeyMaterialForRead({
4590
- matches,
4591
- activeSigners: (await ctx.store(SEAMS_WALLET_STORES.walletSigners).index(SEAMS_WALLET_INDEXES.walletId).getAll(normalizedProfileId)).flatMap((row) => {
4592
- const parsed = parseAccountSignerRow(row);
4593
- return parsed?.status === "active" && parsed.signerSlot === signerSlot && parsed.chainIdKey === normalizedChainIdKey ? [parsed] : [];
4594
- })
4595
- });
4596
- });
4597
- return selected;
4598
- }
4599
- async listKeyMaterialByProfile(profileId, chainIdKey) {
4600
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
4601
- const normalizedChainIdKey = normalizeTrimmedString(chainIdKey || "").toLowerCase();
4602
- if (!normalizedProfileId) return [];
4603
- const tx = (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.keyMaterial, "readonly");
4604
- const rows = await tx.store.index(SEAMS_WALLET_INDEXES.walletId).getAll(normalizedProfileId);
4605
- await tx.done;
4606
- const records = rows.flatMap((row) => {
4607
- const parsed = parseKeyMaterialRow(row);
4608
- return parsed ? [parsed] : [];
4609
- });
4610
- if (!normalizedChainIdKey) return records;
4611
- return records.filter((record) => record.chainIdKey === normalizedChainIdKey);
4612
- }
4613
- async listKeyMaterialByProfileAndSignerSlot(profileId, signerSlot, chainIdKey) {
4614
- if (!Number.isSafeInteger(signerSlot) || signerSlot < 1) return [];
4615
- return (await this.listKeyMaterialByProfile(profileId, chainIdKey)).filter((record) => record.signerSlot === signerSlot);
4616
- }
4617
- async deleteKeyMaterial(profileId, signerSlot, chainIdKey, keyKind) {
4618
- const normalizedProfileId = normalizeTrimmedString(profileId || "");
4619
- const normalizedChainIdKey = normalizeTrimmedString(chainIdKey || "").toLowerCase();
4620
- const normalizedKeyKind = normalizeTrimmedString(keyKind || "");
4621
- if (!normalizedProfileId || !normalizedChainIdKey || !normalizedKeyKind) return;
4622
- if (!Number.isSafeInteger(signerSlot) || signerSlot < 1) return;
4623
- await this.manager.runTransaction([SEAMS_WALLET_STORES.keyMaterial], "readwrite", async (ctx) => {
4624
- const store = ctx.store(SEAMS_WALLET_STORES.keyMaterial);
4625
- const rows = await store.index(SEAMS_WALLET_INDEXES.walletId).getAll(normalizedProfileId);
4626
- for (const row of rows) {
4627
- const parsed = parseKeyMaterialRow(row);
4628
- if (parsed && parsed.signerSlot === signerSlot && parsed.chainIdKey === normalizedChainIdKey && parsed.keyKind === normalizedKeyKind) await store.delete(keyMaterialId({
4629
- walletSignerId: walletSignerIdForKeyMaterial(parsed),
4630
- keyKind: parsed.keyKind
4631
- }));
4632
- }
4633
- });
4634
- }
4635
- async readNonceLaneLeaseRecords(laneKey) {
4636
- const normalizedLaneKey = normalizeTrimmedString(laneKey || "");
4637
- if (!normalizedLaneKey) return [];
4638
- const tx = (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.nonceLaneLeases, "readonly");
4639
- const rows = await tx.store.index(SEAMS_WALLET_INDEXES.laneKey).getAll(normalizedLaneKey);
4640
- await tx.done;
4641
- return rows.flatMap((row) => {
4642
- const parsed = parseNonceLeaseRow(row);
4643
- return parsed ? [parsed] : [];
4644
- });
4645
- }
4646
- async listNonceLaneLeaseRecords(args) {
4647
- const walletId = normalizeTrimmedString(args?.walletId || "");
4648
- const tx = (await this.manager.getDB()).transaction(SEAMS_WALLET_STORES.nonceLaneLeases, "readonly");
4649
- const rows = walletId ? await tx.store.index(SEAMS_WALLET_INDEXES.walletId).getAll(walletId) : await tx.store.getAll();
4650
- await tx.done;
4651
- return rows.flatMap((row) => {
4652
- const parsed = parseNonceLeaseRow(row);
4653
- return parsed ? [parsed] : [];
4654
- });
4655
- }
4656
- async upsertNonceLaneLeaseRecord(record) {
4657
- const row = nonceLeaseRow(record);
4658
- await this.manager.runTransaction([SEAMS_WALLET_STORES.nonceLaneLeases], "readwrite", async (ctx) => {
4659
- await ctx.store(SEAMS_WALLET_STORES.nonceLaneLeases).put(row);
4660
- });
4661
- }
4662
- async removeNonceLaneLeaseRecord(input) {
4663
- const leaseId = normalizeTrimmedString(input.leaseId || "");
4664
- if (!leaseId) return;
4665
- await this.manager.runTransaction([SEAMS_WALLET_STORES.nonceLaneLeases], "readwrite", async (ctx) => {
4666
- await ctx.store(SEAMS_WALLET_STORES.nonceLaneLeases).delete(leaseId);
4667
- });
4668
- }
4669
- async clearNonceLaneLeaseRecordsForWallet(walletId) {
4670
- const normalizedWalletId = normalizeTrimmedString(walletId || "");
4671
- if (!normalizedWalletId) return;
4672
- await this.manager.runTransaction([SEAMS_WALLET_STORES.nonceLaneLeases], "readwrite", async (ctx) => {
4673
- const store = ctx.store(SEAMS_WALLET_STORES.nonceLaneLeases);
4674
- const rows = await store.index(SEAMS_WALLET_INDEXES.walletId).getAll(normalizedWalletId);
4675
- for (const row of rows) {
4676
- const parsed = parseNonceLeaseRow(row);
4677
- if (parsed && parsed.state !== "broadcast_accepted") await store.delete(parsed.leaseId);
4678
- }
4679
- });
4680
- }
4681
- async clearAllNonceLaneLeaseRecords() {
4682
- await this.manager.runTransaction([SEAMS_WALLET_STORES.nonceLaneLeases], "readwrite", async (ctx) => {
4683
- await ctx.store(SEAMS_WALLET_STORES.nonceLaneLeases).clear();
4684
- });
4685
- }
4686
- async pruneExpiredNonceLaneLeaseRecords(nowMs) {
4687
- const normalizedNow = Math.floor(Number(nowMs));
4688
- if (!Number.isSafeInteger(normalizedNow)) return;
4689
- await this.manager.runTransaction([SEAMS_WALLET_STORES.nonceLaneLeases], "readwrite", async (ctx) => {
4690
- const store = ctx.store(SEAMS_WALLET_STORES.nonceLaneLeases);
4691
- const rows = await store.index(SEAMS_WALLET_INDEXES.expiresAtMs).getAll(keyRangeUpperBound(normalizedNow));
4692
- for (const row of rows) {
4693
- const parsed = parseNonceLeaseRow(row);
4694
- if (parsed && parsed.state !== "broadcast_accepted") await store.delete(parsed.leaseId);
4695
- }
4696
- });
4697
- }
4698
- async withNonceLaneCoordinationLock(input, task) {
4699
- const lockKey = normalizeTrimmedString(input.lockKey || "");
4700
- const ownerId = normalizeTrimmedString(input.ownerId || "");
4701
- if (!lockKey || !ownerId) throw new Error("[SeamsWalletDB] nonce lane lock requires lockKey and ownerId");
4702
- const ttlMs = Math.max(1, Math.floor(Number(input.ttlMs) || DEFAULT_NONCE_LANE_LOCK_TTL_MS));
4703
- const waitTimeoutMs = Math.max(1, Math.floor(Number(input.waitTimeoutMs) || DEFAULT_NONCE_LANE_LOCK_WAIT_TIMEOUT_MS));
4704
- const fencingToken = createRandomToken("nonce-lane-lock");
4705
- const deadlineMs = Date.now() + waitTimeoutMs;
4706
- const tryAcquire = async () => {
4707
- let acquired = false;
4708
- await this.manager.runTransaction([SEAMS_WALLET_STORES.nonceLaneLocks], "readwrite", async (ctx) => {
4709
- const store = ctx.store(SEAMS_WALLET_STORES.nonceLaneLocks);
4710
- const nowMs = Date.now();
4711
- const existing = parseNonceLaneLockRow(await store.get(lockKey));
4712
- if (existing && existing.expires_at_ms > nowMs) return;
4713
- const next = {
4714
- lock_key: lockKey,
4715
- owner_id: ownerId,
4716
- fencing_token: fencingToken,
4717
- acquired_at_ms: nowMs,
4718
- expires_at_ms: nowMs + ttlMs,
4719
- updated_at_ms: nowMs
4720
- };
4721
- await store.put(next);
4722
- acquired = true;
4723
- });
4724
- return acquired;
4725
- };
4726
- while (!await tryAcquire()) {
4727
- if (Date.now() >= deadlineMs) {
4728
- const error = /* @__PURE__ */ new Error("[SeamsWalletDB] durable nonce lane lock timed out");
4729
- error.code = "durable_lock_timeout";
4730
- throw error;
4731
- }
4732
- await sleep(DEFAULT_NONCE_LANE_LOCK_POLL_MS);
4733
- }
4734
- try {
4735
- return await task();
4736
- } finally {
4737
- await this.manager.runTransaction([SEAMS_WALLET_STORES.nonceLaneLocks], "readwrite", async (ctx) => {
4738
- const store = ctx.store(SEAMS_WALLET_STORES.nonceLaneLocks);
4739
- if (parseNonceLaneLockRow(await store.get(lockKey))?.fencing_token === fencingToken) await store.delete(lockKey);
4740
- }).catch(() => void 0);
4741
- }
4742
- }
4743
- };
4744
- //#endregion
4745
- export { SeamsWalletRepositories };
4746
-
4747
- //# sourceMappingURL=repositories.js.map